LVS部署(转载)
来源:互联网 发布:淘宝开店考试考什么 编辑:程序博客网 时间:2024/04/29 16:55
转自:http://blog.chinaunix.net/space.php?uid=22600159&do=blog&id=2124185
LVS with DR mode
1、Servers environment
System: CentOS 5.2
lvs-m : 192.168.1.221lvs-s : 192.168.1.222web-1 : 192.168.1.2web-2 : 192.168.1.3VIP : 192.168.1.220
2、Install related softwares
lvs-m# yum install ipvsadmlvs-m# yum install heartbeat-ldirectordlvs-m# yum install heartbeat
- The above operations also need implement on lvs-s.
3、Configure LVS
lvs-m# cd /etc/ha.dlvs-m# cp /usr/share/doc/heartbeat-2.1.3/ha.cf .lvs-m# cp /usr/share/doc/heartbeat-2.1.3/authkeys .lvs-m# cp /usr/share/doc/heartbeat-2.1.3/haresources .lvs-m# cp /usr/share/doc/heartbeat-ldirectord-2.1.3/ldirectord.cf .
- The above operations also need implement on lvs-s.
4、Configure HA
lvs-m# vi ha.cfmodfiy:#logfile /var/log/ha-log#keepalive 2#deadtime 30#warntime 10#initdead 120#udpport 694#bcast eth0 # Linuxucast eth0 192.168.1.2#node ken3#node kathy#ping 10.10.10.254to:logfile /var/log/ha-logkeepalive 2deadtime 30warntime 10initdead 120udpport 694bcast eth0 # Linuxucast eth0 192.168.1.222 //lvs-s's IPnode lvs-m # the node name must same as the output of "uname -n"node lvs-s # the node name must same as the output of "uname -n"ping 192.168.1.222 //lvs-s's IP
- The above operations also need implement on lvs-s.
- Attention the ip address.
5、Configure auth mode
lvs-m# vi authkeysmodfiy:#auth 1#1 crcto:auth 11 crc
lvs-m# chomd 600 autkeys
- The above operations also need implement on lvs-s.
6、Configure virtual Service
lvs-m# vi haresourcesRemovin all then add following line:
lvs-m IPaddr::192.168.1.220/32/eth0:0 ldirectord //here, node lvs-m works as master
- the lvs-s server as follows:
lvs-m IPaddr::192.168.1.220/32/eth0:0 ldirectord //here, node lvs-m works as master
If we configure them work as master/master mode, and the vip on lvs-s is 192.168.1.230, the configuration in both haresources files as follows:lvs-m IPaddr::192.168.1.220/32/eth0:0 ldirectordlvs-s IPaddr::192.168.1.230/32/eth0:0 ldirectord
Add following lines to /etc/sysctl.conf
net.ipv4.conf.lo.arp_ignore = 0net.ipv4.conf.lo.arp_announce = 0net.ipv4.conf.eth0.arp_ignore = 0net.ipv4.conf.eth0.arp_announce = 0and change "net.ipv4.ip_forward = 0" to "net.ipv4.ip_forward = 1"
lvs-m# sysctl -p
- The above operations also need implement on lvs-s.
- On Web server
web-n# vi /root/vip.shAdd:################################################################################# Virtual IP Setup################################################################################ifconfig lo:0 192.168.1.220 broadcast 192.168.1.220 netmask 255.255.255.255 uproute add -host 192.168.1.220 dev lo:0################################################################################# The end################################################################################
web-n# chmod a+x /root/vip.shweb-n# echo "/root/vip.sh" >> /etc/rc.local
And add the following lines to /etc/sysctl.conf on web server
net.ipv4.conf.lo.arp_ignore = 0net.ipv4.conf.lo.arp_announce = 0
web-n# sysctl -p
7、Configure hosts
lvs-m# vi /etc/hosts192.168.1.221 lvs-m192.168.1.222 lvs-s
- The above operations also need implement on lvs-s.
8、Configure ldirectord
lvs-m# vi ldirectord.cf
Add:
checktimeout=3checkinterval=1autoreload=yesquiescent=novirtual=192.168.1.220:80 real=192.168.1.2:80 gate 1 ".healthcheck.html", "OKAY" real=192.168.1.3:80 gate 1 ".healthcheck.html", "OKAY" fallback=127.0.0.1:80 gate 1 ".healthcheck.html", "OKAY" service=http request=".healthcheck.html" receive="Test Page" scheduler=rr protocol=tcp persistent = 600
- The above operations also need implement on lvs-s.
Create healthcheck page in web server
web-n# echo "OKAY" > /var/www/html/.healthcheck.html
9、Start heartbeat
lvs-m# chkconfig heartbeat onlvs-m# service heartbeat start
lvs-s# chkconfig heartbeat onlvs-s# service heartbeat start
10、Check ipvsadm status
lvs-m# watch ipvsadm -L -n
LVS with NAT mode
1、Servers environment
lvs-m : eth0:192.168.1.221 eth1:172.16.1.1lvs-s : eth0:192.168.1.222 eht1:172.16.1.254web-1 : eth0:172.16.1.2 //gw:172.16.1.1web-2 : eth0:172.16.1.3 //gw:172.16.1.1VIP : 192.168.1.220
2、Install related softwares
lvs-m# yum install ipvsadmlvs-m# yum install heartbeat-ldirectordlvs-m# yum install heartbeat
- The above operations also need implement on lvs-s.
3、Configure LVS
lvs-m# cd /etc/ha.dlvs-m# cp /usr/share/doc/heartbeat-2.1.3/ha.cf .lvs-m# cp /usr/share/doc/heartbeat-2.1.3/authkeys .lvs-m# cp /usr/share/doc/heartbeat-2.1.3/haresources .lvs-m# cp /usr/share/doc/heartbeat-ldirectord-2.1.3/ldirectord.cf .
- The above operations also need implement on lvs-s.
4、Configure HA
lvs-m# vi ha.cfmodfiy:#logfile /var/log/ha-log#keepalive 2#deadtime 30#warntime 10#initdead 120#udpport 694#bcast eth0 # Linuxucast eth0 192.168.1.2#node ken3#node kathy#ping 10.10.10.254to:logfile /var/log/ha-logkeepalive 2deadtime 30warntime 10initdead 120udpport 694bcast eth0 # Linuxucast eth0 192.168.1.222 //lvs-s's IPnode lvs-m # uname -nnode lvs-s # uname -nping 192.168.1.222 //lvs-s's IP
- The above operations also need implement on lvs-s.
- Attention the ip address.
5、Configure auth mode
lvs-m# vi authkeysmodfiy:#auth 1#1 crcto:auth 11 crc
lvs-m# chomd 600 autkeys
- The above operations also need implement on lvs-s.
6、Configure virtual Service
lvs-m# vi haresourcesAdd:lvs-m IPaddr::192.168.1.220/32/eth0:0 ldirectord //lvs-m server
- the lvs-s server as follows:
lvs-m IPaddr::192.168.1.220/32/eth0:0 ldirectord
Add following lines to /etc/sysctl.conf
net.ipv4.conf.lo.arp_ignore = 0net.ipv4.conf.lo.arp_announce = 0net.ipv4.conf.eth0.arp_ignore = 0net.ipv4.conf.eth0.arp_announce = 0and change "net.ipv4.ip_forward = 0" to "net.ipv4.ip_forward = 1"
- The above operations also need implement on lvs-s.
7、Configure hosts
lvs-m# vi /etc/hosts192.168.1.221 lvs-m192.168.1.222 lvs-s
- The above operations also need implement on lvs-s.
8、Configure ldirectord
lvs-m# vi ldirectord.cf
Add:
checktimeout=3checkinterval=1autoreload=yesquiescent=novirtual=192.168.1.220:80 real=172.16.1.2:80 gate 1 ".healthcheck.html", "OKAY" real=172.16.1.3:80 gate 1 ".healthcheck.html", "OKAY" fallback=127.0.0.1:80 gate 1 ".healthcheck.html", "OKAY" service=http request=".healthcheck.html" receive="Test Page" scheduler=rr protocol=tcp persistent = 600
- The above operations also need implement on lvs-s.
Create healthcheck page in web server
web-n# echo "OKAY" > /var/www/html/.healthcheck.html
9、Start heartbeat
lvs-m# chkconfig heartbeat onlvs-m# service heartbeat start
lvs-s# chkconfig heartbeat onlvs-s# service heartbeat start
10、Check ipvsadm status
lvs-m# watch ipvsadm -L -n
Some useful notes
- LVS forwarding:
gate -g Route LVS-DR
ipip -i Tunnel LVS-TUN
masq -m Masq LVS-NAT
- Check the healthcheck page
web-n# lynx -dump 127.0.0.1/.healthcheck.html
- LVS部署(转载)
- lvs部署
- LVS+Keepalived 部署
- LVS + Keepalived + mycat部署
- LVS-DR部署
- 转载--CentOS 6.3下部署LVS(NAT)+keepalived实现高性能高可用负载均衡
- 突破LVS瓶颈,LVS Cluster部署(OSPF + LVS)
- 突破LVS瓶颈,LVS Cluster部署(OSPF + LVS)
- 突破LVS瓶颈,LVS Cluster部署(OSPF + LVS)
- 突破LVS瓶颈,LVS Cluster部署(OSPF + LVS)
- 突破LVS瓶颈,LVS Cluster部署(OSPF + LVS)
- 突破LVS瓶颈,LVS Cluster部署(OSPF + LVS)
- 突破LVS瓶颈,LVS Cluster部署(OSPF + LVS)
- keepalived + LVS 配置和部署
- lvs+nginx负载均衡部署
- Keepalived+LVS 安装部署文档
- LVS集群部署详细过程(LVS+OSPF)
- 一个公网地址部署LVS/DR模式
- Informix使用建议
- 利用dos命令初步杀毒--tasklist
- 12款精美的免费 CSS 网页模板下载
- ubuntu将打开终端添加到鼠标右键
- CSS浏览器兼容问题
- LVS部署(转载)
- 常用汉字的UTF-8编码
- OpenCV2.3在VS2010中的配置
- asp.net实现打包程序
- 正则表达式30分钟入门
- lucene学习笔记
- 奇怪的回车换行问题
- 计算灰度共生矩阵GLCM
- 802.1p 802.1q是什么协议