CentOS6.2下搭建LVS(DR)+Keepalived实现高性能高可用负(2)

4、在2台Director Server(LVS_Master与)上分别配置Keepalived
[root@host1 ~]# less /etc/keepalived/keepalived.conf   ! Configuration File for keepalived  global_defs {     router_id LVS_MASTER #网上资料说这个值也需要修改,具体不详,之前我们线上的主备就一直是一样的 ^ ^还是修改一下吧!  }  vrrp_instance VI_1 {      state MASTER #LVS_Backup上修改成BACKUP      interface eth0      virtual_router_id 51      priority 100 #LVS_Backup上修改成80     advert_int 1      authentication {          auth_type PASS          auth_pass 1111      }      virtual_ipaddress {          192.168.10.100      }  }  virtual_server 192.168.10.100 80 {      delay_loop 6      lb_algo rr      lb_kind DR      nat_mask 255.255.255.0      persistence_timeout 50      protocol TCP       real_server 192.168.10.3 80 {          weight 1          TCP_CHECK {          connect_timeout 10          nb_get_retry 3          connect_port 80          }      }      real_server 192.168.10.4 80 {          weight 1          TCP_CHECK {          connect_timeout 10          nb_get_retry 3          connect_port 80          }      }  

BACKUP服务器同上配置,先安装lvs再按装keepalived,然后配置/etc/keepalived/keepalived.conf,只需将红色标示的部分改一下即可。
 5、分别在2台Real Server上面编写脚本并启动

[root@host3 init.d]# cat /etc/init.d/realserver.sh      #!/bin/bash  SNS_VIP=192.168.10.100           . /etc/rc.d/init.d/functions           case "$1" in start)          ifconfig lo:0 $SNS_VIP netmask 255.255.255.255 broadcast $SNS_VIP          /sbin/route add -host $SNS_VIP dev lo:0          echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore          echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce          echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore          echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce          sysctl -p >/dev/null 2>&1          echo "RealServer Start OK"                  ;;  stop)          ifconfig lo:0 down          route del $SNS_VIP >/dev/null 2>&1          echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore          echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce          echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore          echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce          echo "RealServer Stoped"         ;;          *)          echo "Usage: $0 {start|stop}"         exit 1  esac           exit 0    

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/4fb5d2825083f70eb5ccde27729b0785.html