热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Lvs_dr模式+Keepalived

LVS+keepalived实验环境:server2|server3:主备节点 配置 keepalivedserver4|server5:RS 开启w

LVS+keepalived

实验环境:

server2|server3:主备节点 配置 keepalived
server4|server5:RS 开启web服务|配置arptables
iptables off
selinux disabled
*都添加虚拟IP

server2

#安装keepaalived
[root@server2 ~]# ls
keepalived-1.2.24.tar.gz
[root@server2 ~]# tar zxf keepalived-1.2.24.tar.gz
[root@server2 ~]# cd keepalived-1.2.24
[root@server2 keepalived-1.2.24]# ./configure --prefix=/usr/local/keepalived
.....
------------------------
Keepalived version : 1.2.24
Compiler : gcc
Preprocessor flags :
Compiler flags : -Wall -Wunused -Wstrict-prototypes
Linker flags :
Extra Lib : -ldl -lssl -lcrypto
Use IPVS Framework : Yes
IPVS use libnl : No
IPVS syncd attributes : No
IPVS 64 bit stats : No
fwmark socket support : Yes
Use VRRP Framework : Yes
Use VRRP VMAC : Yes
Use VRRP authentication : Yes
With ip rules/routes : Yes
SNMP keepalived support : No
SNMP checker support : No
SNMP RFCv2 support : No
SNMP RFCv3 support : No
SHA1 support : No
Use Debug flags : No
Stacktrace support : No
Memory alloc check : No
libnl version : None
Use IPv4 devconf : No
Use libiptc : No
Use libipset : No
Build genhash : Yes
Build documentation : No
.....
[root@server2 keepalived-1.2.24]# make
[root@server2 keepalived-1.2.24]# make install
[root@server2 keepalived-1.2.24]# yum search kernel-devel
[root@server2 keepalived-1.2.24]# rpm -q kernel-devel
kernel-devel-2.6.32-431.el6.x86_64
[root@server2 keepalived-1.2.24]# rpm -q ipvsadm
ipvsadm-1.26-2.el6.x86_64
[root@server2 keepalived-1.2.24]# rpm -q ipvsadm-devel
package ipvsadm-devel is not installed
[root@server2 keepalived-1.2.24]# cd /usr/local/keepalived/etc/
[root@server2 etc]# ll
total 12
drwxr-xr-x. 3 root root 4096 Jun 3 11:57 keepalived
drwxr-xr-x. 3 root root 4096 Jun 3 11:57 rc.d
drwxr-xr-x. 2 root root 4096 Jun 3 11:57 sysconfig
[root@server2 etc]# ln -s /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
[root@server2 etc]# ln -s /usr/local/keepalived/etc/keepalived/ /etc/
[root@server2 etc]# ln -s /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
[root@server2 etc]# ll /etc/init.d/keepalived
lrwxrwxrwx. 1 root root 48 Jun 3 12:55 /etc/init.d/keepalived -> /usr/local/keepalived/etc/rc.d/init.d/keepalived
[root@server2 etc]# ll
total 12
drwxr-xr-x. 3 root root 4096 Jun 3 11:57 keepalived
drwxr-xr-x. 3 root root 4096 Jun 3 11:57 rc.d
drwxr-xr-x. 2 root root 4096 Jun 3 11:57 sysconfig
[root@server2 etc]# cd rc.d/init.d/
[root@server2 init.d]# ls
keepalived
[root@server2 init.d]# ll
total 4
-rw-r--r--. 1 root root 1308 Jun 3 11:57 keepalived
[root@server2 init.d]# chmod +x keepalived
[root@server2 init.d]# ll
total 4
-rwxr-xr-x. 1 root root 1308 Jun 3 11:57 keepalived
[root@server2 init.d]# cd ../..
[root@server2 etc]# ls
keepalived rc.d sysconfig
[root@server2 etc]# ll /etc/sysconfig/keepalived
lrwxrwxrwx. 1 root root 47 Jun 3 12:54 /etc/sysconfig/keepalived -> /usr/local/keepalived//etc/sysconfig/keepalived
[root@server2 etc]# pwd
/usr
/local/keepalived/etc
[root@server2 etc]# cd /etc
/keepalived/
[root@server2 keepalived]# vim keepalived.conf
!! Configuration File for keepalivedglobal_defs {notification_email {root@localhost #}notification_email_from keepalived@server2smtp_server 172.25.30.2smtp_connect_timeout 30router_id LVS_DEVELvrrp_skip_check_adv_addrvrrp_strictvrrp_garp_interval 0vrrp_gna_interval 0
}vrrp_instance VI_1 {state MASTER #server3 里面改为 BACKUP(备)interface eth0 #发送心跳的节点virtual_router_id 130 #路由idpriority 100 #优先级,主备优先级要不一致advert_int 1authentication {auth_type PASSauth_pass 1111}virtual_ipaddress {172.25.30.100}
}virtual_server 172.25.30.100 80 {delay_loop 6lb_algo rrlb_kind DR
# persistence_timeout 50protocol TCPreal_server 172.25.30.4 80 {weight 1TCP_CHECK {}connect_timeout 3nb_get_retry 3delay_before_retry 3}real_server 172.25.30.5 80 {weight 1TCP_CHECK {connect_timeout 3nb_get_retry 3delay_before_retry 3}}[root@server2 keepalived]# ls
keepalived.conf samples
[root@server2 keepalived]# cd /usr/local/keepalived/
[root@server2 keepalived]# ls
bin etc lib sbin share
[root@server2 keepalived]# cd ..
[root@server2 local]# ls
bin etc games include keepalived lib lib64 libexec sbin share src
[root@server2 local]# scp -r keepalived/ root@172.25.30.3:/usr/local/
[root@server2 local]# cd /etc/keepalived/
[root@server2 keepalived]# ls
keepalived.conf samples
[root@server2 keepalived]# scp keepalived.conf 172.25.30.3:/etc/keepalived/
root@172.25.30.3's password:
keepalived.conf 100% 1056 1.0KB/s 00:00
[root@server2 keepalived]# /etc/init.d/keepalived start
Starting keepalived: /bin/bash: keepalived: command not found[FAILED]
[root@server2 keepalived]# ln -s /usr/local/keepalived/sbin/keepalived /sbin/
[root@server2 keepalived]# /etc/init.d/keepalived start
Starting keepalived: [ OK ][root@server2 etc]#
server3[root@server3 ~]# cd /usr/local/
[root@server3 local]# ls
bin etc games include keepalived lib lib64 libexec sbin share src
[root@server3 local]# ln -s /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
[root@server3 local]# ln -s /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
[root@server3 local]# chmod +x /etc/init.d/keepalived
[root@server3 local]# mkdir /etc/keepalived
[root@server3 local]# cd /etc/keepalived/
[root@server3 keepalived]# ls
keepalived.conf
[root@server3 keepalived]# vim keepalived.conf
[root@server3 keepalived]# /etc/init.d/keepalived start
Starting keepalived: /bin/bash: keepalived: command not found[FAILED]
[root@server3 keepalived]# ln -s /usr/local/keepalived/sbin/keepalived /sbin/
[root@server3 keepalived]# /etc/init.d/keepalived start
Starting keepalived: [ OK ]
*Server4和Server5
[root@server4 ~]# /etc/init.d/httpd start
Starting httpd: httpd: Could not reliably determine the server'
s fully qualified domain name, using 172.25.30.4 for ServerName[ OK ]
[root@server4 ~]#
[root@server5 ~]# /etc/init.d/httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 172.25.254.5 for ServerName[ OK ]
[root@server5 ~]#

测试:

[root@foundation30 Desktop]# curl 172.25.30.100
server4
[root@foundation30 Desktop]# curl 172.25.30.100
server5
[root@foundation30 Desktop]# curl 172.25.30.100
server4
[root@foundation30 Desktop]# curl 172.25.30.100
server5
[root@foundation30 Desktop]# [root@server2 keepalived]# ipvsadm -l
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 172.25.30.100:http rr-> 172.25.30.4:http Route 1 0 6 -> 172.25.30.5:http Route 1 0 7
[root@server2 keepalived]# 基于 Vsftpd 服务|开放 21 端口实验环境:
基于keepalived配置
server4|server5安装 vsftpd 服务并开启server4|server5同步
[root@server4 ~]# yum install vsftpd -y
[root@server4 ~]# /etc/init.d/vsftpd start
Starting vsftpd for vsftpd: [ OK ]
[root@server4 ~]# server2|server3中[root@server2 ~]# vim /etc/keepalived/keepalived.conf .....persistence_timeout 50 #必须有时间延迟
....
*Server 3中同步[root@server2 ~]# ipvsadm -l
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 172.25.30.100:ftp rr persistent 50 #ftp服务持续连接-> 172.25.30.4:ftp Route 1 0 0 -> 172.25.30.5:http Route 1 1 0
TCP 172.25.30.100:http rr-> 172.25.30.4:http Route 1 0 0 -> 172.25.30.5:http Route 1 0 0
[root@server2 ~]#
*测试[root@foundation30 pub]# lftp 172.25.30.100
lftp 172.25.30.100:~> ls
drwxr-xr-x 2 0 0 4096 Feb 12 2013 pub
lftp 172.25.30.100:/> exit
[root@foundation30 pub]#


推荐阅读
  • 解决Only fullscreen opaque activities can request orientation错误的方法
    本文介绍了在使用PictureSelectorLight第三方框架时遇到的Only fullscreen opaque activities can request orientation错误,并提供了一种有效的解决方案。 ... [详细]
  • 在CentOS 7环境中安装配置Redis及使用Redis Desktop Manager连接时的注意事项与技巧
    在 CentOS 7 环境中安装和配置 Redis 时,需要注意一些关键步骤和最佳实践。本文详细介绍了从安装 Redis 到配置其基本参数的全过程,并提供了使用 Redis Desktop Manager 连接 Redis 服务器的技巧和注意事项。此外,还探讨了如何优化性能和确保数据安全,帮助用户在生产环境中高效地管理和使用 Redis。 ... [详细]
  • 在Linux系统中避免安装MySQL的简易指南
    在Linux系统中避免安装MySQL的简易指南 ... [详细]
  • SecureCRT是一款功能强大的终端仿真软件,支持SSH1和SSH2协议,适用于在Windows环境下高效连接和管理Linux服务器。该工具不仅提供了稳定的连接性能,还具备丰富的配置选项,能够满足不同用户的需求。通过SecureCRT,用户可以轻松实现对远程Linux系统的安全访问和操作。 ... [详细]
  • 本文介绍了如何利用Shell脚本高效地部署MHA(MySQL High Availability)高可用集群。通过详细的脚本编写和配置示例,展示了自动化部署过程中的关键步骤和注意事项。该方法不仅简化了集群的部署流程,还提高了系统的稳定性和可用性。 ... [详细]
  • 为了在Hadoop 2.7.2中实现对Snappy压缩和解压功能的原生支持,本文详细介绍了如何重新编译Hadoop源代码,并优化其Native编译过程。通过这一优化,可以显著提升数据处理的效率和性能。此外,还探讨了编译过程中可能遇到的问题及其解决方案,为用户提供了一套完整的操作指南。 ... [详细]
  • 在Ubuntu上安装MySQL时解决缺少libaio.so.1错误及libaio在MySQL中的重要性分析
    在Ubuntu系统上安装MySQL时,遇到了缺少libaio.so.1的错误。本文详细介绍了如何解决这一问题,并深入探讨了libaio库在MySQL性能优化中的重要作用。对于初学者而言,理解这些依赖关系和配置步骤是成功安装和运行MySQL的关键。通过本文的指导,读者可以顺利解决相关问题,并更好地掌握MySQL在Linux环境下的部署与管理。 ... [详细]
  • 在 CentOS 6.5 系统上部署 VNC 服务器的详细步骤与配置指南
    在 CentOS 6.5 系统上部署 VNC 服务器时,首先需要确认 VNC 服务是否已安装。通常情况下,VNC 服务默认未安装。可以通过运行特定的查询命令来检查其安装状态。如果查询结果为空,则表明 VNC 服务尚未安装,需进行手动安装。此外,建议在安装前确保系统的软件包管理器已更新至最新版本,以避免兼容性问题。 ... [详细]
  • 在JavaWeb项目架构中,NFS(网络文件系统)的实现与优化是关键环节。NFS允许不同主机系统通过局域网共享文件和目录,提高资源利用率和数据访问效率。本文详细探讨了NFS在JavaWeb项目中的应用,包括配置、性能优化及常见问题的解决方案,旨在为开发者提供实用的技术参考。 ... [详细]
  • 本文提供了详细的 Filebeat 部署指南,涵盖了解压安装包、配置文件编辑以及启动服务等关键步骤。具体操作包括使用 `tar -zxvf filebeat-6.1.1-linux-x86_64.tar.gz` 解压安装包,并通过 `vi /home/elk/filebeat-6.4.2-linux/filebeat.yml` 编辑配置文件。此外,文章还介绍了最佳实践,帮助用户确保 Filebeat 的高效运行和数据传输的可靠性。 ... [详细]
  • 在 Ubuntu 中遇到 Samba 服务器故障时,尝试卸载并重新安装 Samba 发现配置文件未重新生成。本文介绍了解决该问题的方法。 ... [详细]
  • 基于Linux开源VOIP系统LinPhone[四]
    ****************************************************************************************** ... [详细]
  • 本文介绍了如何在 macOS 上安装 HL-340 USB 转串口驱动,并提供了详细的步骤和注意事项。包括下载驱动、关闭系统完整性保护、安装驱动以及验证安装的方法。 ... [详细]
  • 如何在Linux服务器上配置MySQL和Tomcat的开机自动启动
    在Linux服务器上部署Web项目时,通常需要确保MySQL和Tomcat服务能够随系统启动而自动运行。本文将详细介绍如何在Linux环境中配置MySQL和Tomcat的开机自启动,以确保服务的稳定性和可靠性。通过合理的配置,可以有效避免因服务未启动而导致的项目故障。 ... [详细]
  • 您的数据库配置是否安全?DBSAT工具助您一臂之力!
    本文探讨了Oracle提供的免费工具DBSAT,该工具能够有效协助用户检测和优化数据库配置的安全性。通过全面的分析和报告,DBSAT帮助用户识别潜在的安全漏洞,并提供针对性的改进建议,确保数据库系统的稳定性和安全性。 ... [详细]
author-avatar
醒来时t我尚年少你未老
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有