标签:
#cd /usr/local/src #wget http://www.keepalived.org/software/keepalived-1.2.22.tar.gz #./configure --prefix=/usr/local/keepalived #make & make install
! Configuration File for keepalived global_defs { router_id edu-proxy-01 } vrrp_script chk_nginx { script "/etc/keepalived/nginx_check.sh" interval 2 weight -20 } vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id 51 mcast_src_ip 10.0.4.249 priority 100 nopreempt advert_int 1 authentication { auth_type PASS auth_pass 1111 } track_script { chk_nginx } virtual_ipaddress { 10.0.4.248 } }
! Configuration File for keepalived global_defs { router_id edu-proxy-02 } vrrp_script chk_nginx { script "/etc/keepalived/nginx_check.sh" interval 2 weight -20 } vrrp_instance VI_1 { state BACKUP interface eth0 virtual_router_id 51 mcast_src_ip 10.0.4.250 priority 90 advert_int 1 authentication { auth_type PASS auth_pass 1111 } track_script { chk_nginx } virtual_ipaddress { 10.0.4.248 } }
#!/bin/bash A=`ps -C nginx –no-header |wc -l` if [ $A -eq 0 ];then /usr/local/openrestry/nginx/sbin/nginx //Nginx安装路径 sleep 2 if [ `ps -C nginx --no-header |wc -l` -eq 0 ];then killall keepalived fi fi
/usr/local/keepalived/sbin/keepalived [root@localhost sbin]# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:c6:9b:91 brd ff:ff:ff:ff:ff:ff inet 10.0.4.249/24 brd 10.0.4.255 scope global eth0 inet 10.0.4.248/32 scope global eth0 inet6 fe80::20c:29ff:fec6:9b91/64 scope link valid_lft forever preferred_lft forever
[root@localhost keepalived]# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:75:6c:82 brd ff:ff:ff:ff:ff:ff inet 10.0.4.250/24 brd 10.0.4.255 scope global eth0 inet 10.0.4.248/32 scope global eth0 inet6 fe80::20c:29ff:fe75:6c82/64 scope link valid_lft forever preferred_lft forever
标签:
原文地址:http://www.cnblogs.com/sagech/p/5664818.html