本文共 2099 字,大约阅读时间需要 6 分钟。
keepavlied起初专门为LVS设计的,专门用来监控LVS集群系统中各个服务节点的状态,后来加入VRRP功能,因此除了配合LVS服务外,也可以作为其他服务(nginx,haproxy)的高可用软件。
keepalived服务两大用途:healthcheck 健康检查(针对RS) 、failover 高可用故障转移(主备)
keepalived的安装,主和备都需要安装
和LVS安装一样,最好也先给内核路径做一个软连接到/usr/src/linux
1 2 3 4 5 | [root@localhost ~] # ln -s /usr/src/kernels/2.6.32-573.8.1.el6.i686/ /usr/src/linux [root@localhost ~] # cd /usr/local/src/ [root@localhost src] # wget [root@localhost src]# tar xf keepalived-1.1.19.tar.gz [root@localhost src] # cd keepalived-1.1.19 [root@localhost keepalived-1.1.19] # ./configure |
configure执行成功的结果:有3个Yes;支持IPVS框架,IPVS的同步支持,VRRP的框架支持;
Keepalived configuration
------------------------
Keepalived version : 1.1.19
Compiler : gcc
Compiler flags : -g -O2
Extra Lib : -lpopt -lssl -lcrypto
Use IPVS Framework : Yes
IPVS sync daemon support : Yes
Use VRRP Framework : Yes
Use Debug flags : No
1 2 | [root@localhost keepalived-1.1.19] # make [root@localhost keepalived-1.1.19] # make install |
配置keepalived
1 2 3 4 5 6 | [root@localhost keepalived-1.1.19] # cp /usr/local/etc/rc.d/init.d/keepalived /etc/init.d/ [root@localhost keepalived-1.1.19] # cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/ [root@localhost keepalived-1.1.19] # mkdir /etc/keepalived -p [root@localhost keepalived-1.1.19] # cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/ [root@localhost keepalived-1.1.19] # cp /usr/local/sbin/keepalived /usr/sbin/ [root@localhost keepalived-1.1.19] # /etc/init.d/keepalived start |
主MASTER、备backup上配置文件:/etc/keepalived/keepalived.conf
主master配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id 51 priority 150 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.20.100 /24 } } |
备 backup 的配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | vrrp_instance VI_1 { state BACKUP interface eth0 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.20.100 /24 } } |
主、备启动keepalived,主绑定VIP地址,主停止keepalived服务,备机马上接管VIP;
本文转自 模范生 51CTO博客,原文链接:http://blog.51cto.com/mofansheng/1715866,如需转载请自行联系原作者