标签:keepalived
一、环境说明
MASTER节点 192.168.89.100
BACKUP节点 192.168.89.101
VIP:192.168.89.102
二、MASTER节点的配置文件
1、主节点配置文件
! Configuration File for keepalived
global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id 1b01
}
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.89.102/24 dev eth0 label eth0:1
}
}
2、启动keepalived
[root@kep1 keepalived]# /etc/init.d/keepalived start
3、查看虚拟IP
[root@kep1 keepalived]# ip addr | grep 192.168.89.102
inet 192.168.89.102/24 scope global secondary eth0
三、BACKUP节点配置文件
1、配置文件
! Configuration File for keepalived
global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id 1b02
}
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.89.102/24 dev eth0 label eht0:1
}
}
2、启动keepalived
[root@kep2 keepalived]# /etc/init.d/keepalived start
3、检查虚拟IP
[root@kep2 keepalived]# ip addr | grep 192.168.89.102
注意:如果MASTER活着的神话,BACKUP不会接管虚拟IP,所以这里没有输出IP是正常的
如果备节点有出现虚拟IP,那么说明高可用脑裂了,脑裂是两台服务器争抢统一资源导致的,
如果发生脑裂,排除思路如下:
1、主备是否通信正常?防火墙是否阻挡?
2、主备两台的keepalived配置文件是否正确?virtual_router_id是否一样?
四、进行高可用主备服务器切换测试
1、停掉主节点上的keepalived服务,然后在BACKUP节点查看是否接管虚拟IP
2、重新启动主节点上的keepalived服务,看看这时候主节点会不会重新接管VIP,BACKUP节点会不会释放VIP
如果上面两个测试正常,说明配置没有问题。
注意,如果发生脑裂问题,需要注意一下启动顺序
本文出自 “运维杂谈Q群:223843163” 博客,请务必保留此出处http://freshair.blog.51cto.com/8272891/1880976
CentOS6.5环境 keepalived高可用服务单实例配置
标签:keepalived
原文地址:http://freshair.blog.51cto.com/8272891/1880976