資源描述:
《lvs負(fù)載均衡dr模式》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、LVS負(fù)載均衡群集DR模式環(huán)境架設(shè):調(diào)度器ip,eth0192.168.0.99虛擬ip,eth0:0192.168.0.200A服務(wù)器ip,eth0192.168.0.10回環(huán)口ip,lo:0192.168.0.200B服務(wù)器ip,eth0192.168.0.11回環(huán)口ip,lo:0192.168.0.200實驗1步驟:一、調(diào)度器配置1)配置調(diào)度器ip地址//setup192.168.0.992)安裝ipvsadm管理器[root@LVS-Master/]#mount/dev/cdrom/media/[
2、root@LVS-Master/]#cd/media/Cluster[root@LVS-MasterCluster]#rpm-ivhipvsadm-1.24-8.1.i386.rpm3)配置VIP設(shè)定腳本[root@LVS-Master~]#vi/opt/vip.sh#!/bin/bashifconfigeth0:0192.168.0.200broadcast192.168.0.200netmask255.255.255.255uprouteadd-host192.168.0.200deveth0:0ip
3、vsadm–Cipvsadm–A–t192.168.0.200:80–srr–p600ipvsadm–a–t192.168.0.200:80–r192.168.0.10-gipvsadm–a–t192.168.0.200:80–r192.168.0.11–gipvsadm4)設(shè)置腳本可執(zhí)行權(quán)限[root@LVS-Master~]#chmodu+x/opt/vip.sh5)執(zhí)行VIP腳本[root@LVS-Master~]#../opt/vip.sh6)查看ipvsadm列表[root@LVS-Master
4、~]#ipvsadm–l//查看ipvsadm列表IPVirtualServerversion1.2.1(size=4096)ProtLocalAddress:PortSchedulerFlags->RemoteAddress:PortForwardWeightActiveConnInActConnTCP192.168.0.200:httprr->192.168.0.10:httpRoute100->192.168.0.11:httpRoute100Vim/etc/sysctl.confNet.ipv4.
5、ip_forward=1//開啟中繼轉(zhuǎn)發(fā)Sysctl–p//執(zhí)行生效7)把腳本寫入到開機啟動項里二、A.B服務(wù)器上的配置提供服務(wù)的A和B不需要安裝任何IPVS軟件,只需要設(shè)置在開機后自動執(zhí)行以下腳本:1)在A服務(wù)器上的設(shè)置配置真實ip為192.168.0.10//setup[root@localhost~]#vi/opt/lvs.sh//編寫腳本#!/bin/bashifconfiglo:0192.168.0.200broadcast192.168.0.200netmask255.255.255.255u
6、prouteadd-host192.168.0.200devlo:0echo"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[root@localhost~]#chmodu+x/opt/lvs.
7、sh//添加腳本lvs.sh的執(zhí)行權(quán)限[root@localhost~]#../opt/lvs.sh//執(zhí)行腳本[root@localhost~]#echo"wosAfuwuqi">/var/www/html/index.html//在A添加測試頁[root@localhost~]#servciehttpdrestart//重啟web服務(wù)器7)把腳本寫入到開機啟動項里2)在B服務(wù)器上的設(shè)置配置真實ip為192.168.0.11//setup[root@localhost~]#vi/opt/lvs.dr//
8、編寫lvs.dr腳本#!/bin/bashifconfiglo:0192.168.0.200broadcast192.168.0.200netmask255.255.255.255uprouteadd-host192.168.0.200devlo:0echo"1">/proc/sys/net/ipv4/conf/lo/arp_ignoreecho"2">/proc/sys/net/ipv4/conf/lo/arp_announ