centos上配置lvs dr集群
3臺集群伺服器作業系統:centos 5.5 x86
1臺客戶端作業系統:windows 2008 x64
lvs集群使用dr模式,1個ds(director server),2個rs(real server)。路由只有乙個,routea=routeb。上圖中的gw為閘道器(gateway),vip為lvs中的虛擬ip。
· ds
修改/etc/sysctl.conf檔案:
net.ipv4.ip_forward = 1
通過命令sysctl –p使其生效。
修改/etc/sysconfig/network-scripts/ifcfg-eth0檔案:
device=eth0
bootproto=static
onboot=yes
netmask=255.255.255.0
ipaddr=192.168.137.101
broadcast=192.168.137.255
gateway=192.168.137.1
新建或修改/etc/sysconfig/network-scripts/ifcfg-eth0:0檔案:
device=eth0:0
bootproto=static
onboot=yes
netmask=255.255.255.0
ipaddr=192.168.137.137
broadcast=192.168.137.255
gateway=192.168.137.1
配置後ifconfig命令返回如下結果:
eth0 link encap:ethernet hwaddr 08:00:27:25:39:d9
inet addr:192.168.137.101 bcast:192.168.137.255 mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe25:39d9/64 scope:link
up broadcast running multicast mtu:1500 metric:1
rx packets:3757711 errors:0 dropped:0 overruns:0 frame:0
tx packets:2475767 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
rx bytes:250120448 (238.5 mib) tx bytes:159666117 (152.2 mib)
eth0:0 link encap:ethernet hwaddr 08:00:27:25:39:d9
inet addr:192.168.137.137 bcast:192.168.137.255 mask:255.255.255.0
up broadcast running multicast mtu:1500 metric:1
lo link encap:local loopback
inet addr:127.0.0.1 mask:255.0.0.0
inet6 addr: ::1/128 scope:host
up loopback running mtu:16436 metric:1
rx packets:25241 errors:0 dropped:0 overruns:0 frame:0
tx packets:25241 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
rx bytes:3785187 (3.6 mib) tx bytes:3785187 (3.6 mib)
使用命令新增rs主機:
ipvsadm –c
ipvsadm -a -t 192.168.137.137:80 -s rr
ipvsadm -a -t 192.168.137.137:80 -r 192.168.137.102 -g
ipvsadm -a -t 192.168.137.137:80 -r 192.168.137.103 -g
ipvsadm -ln
在 測試集群網路是否正確時,使用rr(round-robin)的集群模式容易檢視集群是否正常工作。如果正常,在rs1和rs2的/var/www /html下放置內容不同的index.html檔案,然後從客戶端client訪問vip(192.168.137.137),可以看到在瀏覽器中會交 替顯示rs1和rs2上不同的index.html內容。
· rs
修改/etc/sysctl.conf檔案:
net.ipv4.ip_forward = 1
# for lvs
net.ipv4.conf.lo.arp_ignore=1
net.ipv4.conf.lo.arp_announce=2
net.ipv4.conf.all.arp_ignore=1
net.ipv4.conf.all.arp_announce=2
通過命令sysctl –p使其生效。
修改/etc/sysconfig/network-scripts/ifcfg-eth0檔案:
device=eth0
bootproto=static
onboot=yes
netmask=255.255.255.0
ipaddr=192.168.137.102
broadcast=192.168.137.255
gateway=192.168.137.1
新建或修改/etc/sysconfig/network-scripts/ifcfg-lo:0檔案:
device=lo:0
ipaddr=192.168.137.137
netmask=255.255.255.255
onboot=yes
配置後ifconfig命令返回如下結果:
eth0 link encap:ethernet hwaddr 08:00:27:e4:df:02
inet addr:192.168.137.102 bcast:192.168.137.255 mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fee4:df02/64 scope:link
up broadcast running multicast mtu:1500 metric:1
rx packets:1670284 errors:0 dropped:0 overruns:0 frame:0
tx packets:871829 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
rx bytes:113130561 (107.8 mib) tx bytes:54181142 (51.6 mib)
lo link encap:local loopback
inet addr:127.0.0.1 mask:255.0.0.0
inet6 addr: ::1/128 scope:host
up loopback running mtu:16436 metric:1
rx packets:25523 errors:0 dropped:0 overruns:0 frame:0
tx packets:25523 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
rx bytes:3769820 (3.5 mib) tx bytes:3769820 (3.5 mib)
lo:0 link encap:local loopback
inet addr:192.168.137.137 mask:255.255.255.255
up loopback running mtu:16436 metric:1
CentOS6 4 配置LVS(DR模式)
dr模式中lvs主機與實際伺服器都有一塊網絡卡連在同一物理網段上。ip分配 vip 10.10.3.170 rip1 10.10.3.140 rip2 10.10.3.141 1 安裝所需的依賴包 yum install y wget make kernel devel gcc gcc c libn...
centOS7 LVS DR模式配置(指令碼)
dr模式 通過director將報文源和目標mac位址修改,傳送給rs,rs不經過ds將響應報文直接傳送給client。lvs伺服器 ds dip 172.22.5.10 vip 172.22.5.200 http伺服器rs1 rip 172.22.5.20 vip 172.22.5.200 htt...
LVS DR 配置步驟
與lvs nat配置 步驟一樣首先需要規劃ip位址 cip 192.168.56.1 dip 192.168.56.101 vip 192.168.56.110 rip 192.168.56.102 192.168.56.103 設定director 1 配置vip,ifconfig eth0 0 ...