keepalived的简单应用——管理VIP的飘动
时间:2010-12-31 来源:killkill
安装很简单:
tar zxvf keepalived-1.1.20.tar.gz cd keepalived-1.1.20 ./configure --prefix=/ make make install
修改一下 /etc/keepalived/keepalived.conf 这个配置文件就可以用了,以下是我的环境,192.168.10.141和192.168.10.142是两个VIP,可以在两台服务器之间飘动:
主机的配置:
global_defs { notification_email { [email protected] } notification_email_from [email protected] smtp_server 192.168.0.48 smtp_connect_timeout 10 router_id nginx } vrrp_instance VI_141 { state BACKUP interface eth0 virtual_router_id 141 priority 50 advert_int 1 authentication { auth_type PASS auth_pass 141 } virtual_ipaddress { 192.168.10.141/26 dev eth0 } } vrrp_instance VI_142 { state BACKUP interface eth0 virtual_router_id 142 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 142 } virtual_ipaddress { 192.168.10.142/26 dev eth0 } }
备机的配置:
global_defs { notification_email { [email protected] } notification_email_from [email protected] smtp_server 10.168.0.48 smtp_connect_timeout 10 router_id nginx } vrrp_instance VI_141 { state BACKUP interface eth0 virtual_router_id 141 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 141 } virtual_ipaddress { 192.168.10.141/26 dev eth0 } } vrrp_instance VI_142 { state BACKUP interface eth0 virtual_router_id 142 priority 50 advert_int 1 authentication { auth_type PASS auth_pass 142 } virtual_ipaddress { 192.168.10.142/26 dev eth0 } }
乍一看,主机和备机的配置文件是一样的,仔细看一下priority的值,使用以下命令即可将keepalived加入linux的服务中:
chkconfig --add keepalived ;
通过启、停keepalived这个服务即可观察到VIP的飘动,至于为什么VIP飘动后可以很快地生效,还有待研究。
相关阅读 更多 +