本文共 3563 字,大约阅读时间需要 11 分钟。
例 14.1. piranha master
[root@lvs1 ~]# cat /etc/sysconfig/ha/lvs.cfserial_no = 31primary = 172.16.0.2primary_private = 172.16.2.2service = lvsbackup_active = 1backup = 172.16.0.3backup_private = 172.16.2.3heartbeat = 1heartbeat_port = 539keepalive = 2deadtime = 6network = directdebug_level = NONEmonitor_links = 0syncdaemon = 0virtual LVS-HTTP { active = 1 address = 172.16.0.1 eth0:1 vip_nmask = 255.255.255.255 port = 80 send = "GET / HTTP/1.0\r\n\r\n" expect = "HTTP" use_regex = 0 load_monitor = none scheduler = wlc protocol = tcp timeout = 6 reentry = 15 quiesce_server = 0 server Web1 { address = 172.16.0.5 active = 1 port = 80 weight = 2 } server Web2 { address = 172.16.0.6 active = 1 port = 80 weight = 2 } server Web3 { address = 172.16.0.7 active = 1 port = 80 weight = 2 } server Web4 { address = 172.16.0.8 active = 0 port = 80 weight = 0 }}
例 14.2. piranha slave
serial_no = 30primary = 172.16.0.2primary_private = 172.16.2.2service = lvsbackup_active = 1backup = 172.16.0.3backup_private = 172.16.2.3heartbeat = 1heartbeat_port = 539keepalive = 2deadtime = 6network = directdebug_level = NONEmonitor_links = 0syncdaemon = 0virtual LVS-HTTP { active = 1 address = 172.16.0.1 eth0:1 vip_nmask = 255.255.255.255 port = 80 send = "GET / HTTP/1.0\r\n\r\n" expect = "HTTP" use_regex = 0 load_monitor = none scheduler = wlc protocol = tcp timeout = 6 reentry = 15 quiesce_server = 0 server Web1 { address = 172.16.0.5 active = 1 port = 80 weight = 2 } server Web2 { address = 172.16.0.6 active = 1 port = 80 weight = 2 } server Web3 { address = 172.16.0.7 active = 1 port = 80 weight = 2 } server Web4 { address = 172.16.0.8 active = 0 port = 80 weight = 3 }}
virtual SLB-MySQL { active = 1 address = 172.16.1.50 eth0:2 vip_nmask = 255.255.255.255 port = 3306 persistent = 30 send = "" expect = "" use_regex = 0 load_monitor = none scheduler = wlc protocol = tcp timeout = 5 reentry = 15 quiesce_server = 0 server MySQL1 { address = 172.16.1.46 active = 1 port = 3306 weight = 1 } server MySQL2 { address = 172.16.1.47 active = 1 port = 3306 weight = 1 } server MySQL3 { address = 172.16.1.48 active = 1 port = 3306 weight = 1 }}
# cat /srv/script/lvs-client-start#!/bin/bash### Disable IP_Forward in Linux Kernel ###echo 0 > /proc/sys/net/ipv4/ip_forward### Disable ARP Reponse on This RealServer ###echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignoreecho 2 > /proc/sys/net/ipv4/conf/lo/arp_announceecho 1 > /proc/sys/net/ipv4/conf/all/arp_ignoreecho 2 > /proc/sys/net/ipv4/conf/all/arp_announce### Add VIP Address and Route ###VIP=172.16.1.50/sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up/sbin/route add -host $VIP1 dev lo:0
我比较喜欢使用ip命令代替route命令
ip route add $VIP dev lo:0 src $VIP
Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a>comments powered by Disqus 原文出处:Netkiller 系列 手札 本文作者:陈景峯 转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。