15.2.3. lvs-nat安装配置
- Date:
2018-10
15.2.3.1. 环境
- 服务器列表
默认硬件、系统版本全部相同,只是主机名不同和网络配置不同
主机名 |
IP |
lvs_vip_01 |
192.168.1.166 |
lvs_rip_web01 |
192.168.1.187 |
lvs_rip_web02 |
192.168.1.163 |
系统版本 |
CentOS release 6.6 (Final) |
硬件环境 |
x86_64 |
lvsadm |
ipvsadm-1.26 |
15.2.3.2. 安装配置
15.2.3.2.1. 配置说明
本lvs实例是基于NAT的实例配置。且调度算法使用rr(官方叫做轮叫,本人习惯叫做轮询算法。权重使用默认都是1)
15.2.3.2.2. lvs_vip_01安装配置过程
安装配置过程:
1[root@lvs_vip_01 ~]# mkdir /home/tools -p
2[root@lvs_vip_01 ~]# ll /home
3total 4
4drwxr-xr-x. 2 root root 4096 Nov 2 02:51 tools
5[root@lvs_vip_01 ~]# lsmod|grep ip_vs
6[root@lvs_vip_01 ~]# cd /home/tools
7[root@lvs_vip_01 tools]# pwd
8/home/tools
9[root@lvs_vip_01 tools]# ls
10[root@lvs_vip_01 tools]# wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz
11--2018-11-02 02:55:23-- http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz
12Resolving www.linuxvirtualserver.org... 173.255.202.51, 2600:3c00::f03c:91ff:fe96:fcc2
13Connecting to www.linuxvirtualserver.org|173.255.202.51|:80... connected.
14HTTP request sent, awaiting response... 200 OK
15Length: 41700 (41K) [application/x-gzip]
16Saving to: “ipvsadm-1.26.tar.gz”
17
18100%[===================================================================================================================================>] 41,700 194K/s in 0.2s
19
202018-11-02 02:55:25 (194 KB/s) - “ipvsadm-1.26.tar.gz” saved [41700/41700]
21
22[root@lvs_vip_01 tools]# ls
23ipvsadm-1.26.tar.gz
24[root@lvs_vip_01 tools]# rpm -qa libnl* popt*
25popt-1.13-7.el6.x86_64
26libnl-1.1.4-2.el6.x86_64
27
28[root@lvs_vip_01 tools]#
29[root@lvs_vip_01 tools]# yum install libnl* popt* -y
30Loaded plugins: fastestmirror, security
31Setting up Install Process
32Determining fastest mirrors
33* base: ftp.sjtu.edu.cn
34* extras: mirrors.tuna.tsinghua.edu.cn
35* updates: mirrors.tuna.tsinghua.edu.cn
36base | 3.7 kB 00:00
37base/primary_db | 4.7 MB 00:00
38extras | 3.4 kB 00:00
39extras/primary_db | 26 kB 00:00
40updates | 3.4 kB 00:00
41updates/primary_db | 1.9 MB 00:00
42Package libnl-1.1.4-2.el6.x86_64 already installed and latest version
43Package popt-1.13-7.el6.x86_64 already installed and latest version
44Resolving Dependencies
45--> Running transaction check
46---> Package libnl-devel.x86_64 0:1.1.4-2.el6 will be installed
47---> Package libnl3.x86_64 0:3.2.21-8.el6 will be installed
48---> Package libnl3-cli.x86_64 0:3.2.21-8.el6 will be installed
49---> Package libnl3-devel.x86_64 0:3.2.21-8.el6 will be installed
50---> Package libnl3-doc.x86_64 0:3.2.21-8.el6 will be installed
51---> Package popt-devel.x86_64 0:1.13-7.el6 will be installed
52---> Package popt-static.x86_64 0:1.13-7.el6 will be installed
53--> Finished Dependency Resolution
54
55Dependencies Resolved
56
57=============================================================================================================================================================================
58Package Arch Version Repository Size
59=============================================================================================================================================================================
60Installing:
61libnl-devel x86_64 1.1.4-2.el6 base 707 k
62libnl3 x86_64 3.2.21-8.el6 base 183 k
63libnl3-cli x86_64 3.2.21-8.el6 base 58 k
64libnl3-devel x86_64 3.2.21-8.el6 base 56 k
65libnl3-doc x86_64 3.2.21-8.el6 base 10 M
66popt-devel x86_64 1.13-7.el6 base 21 k
67popt-static x86_64 1.13-7.el6 base 21 k
68
69Transaction Summary
70=============================================================================================================================================================================
71Install 7 Package(s)
72
73Total download size: 11 M
74Installed size: 30 M
75Downloading Packages:
76(1/7): libnl-devel-1.1.4-2.el6.x86_64.rpm | 707 kB 00:00
77(2/7): libnl3-3.2.21-8.el6.x86_64.rpm | 183 kB 00:00
78(3/7): libnl3-cli-3.2.21-8.el6.x86_64.rpm | 58 kB 00:00
79(4/7): libnl3-devel-3.2.21-8.el6.x86_64.rpm | 56 kB 00:00
80(5/7): libnl3-doc-3.2.21-8.el6.x86_64.rpm | 10 MB 00:02
81(6/7): popt-devel-1.13-7.el6.x86_64.rpm | 21 kB 00:00
82(7/7): popt-static-1.13-7.el6.x86_64.rpm | 21 kB 00:00
83-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
84Total 3.6 MB/s | 11 MB 00:03
85Running rpm_check_debug
86Running Transaction Test
87Transaction Test Succeeded
88Running Transaction
89Installing : libnl3-3.2.21-8.el6.x86_64 1/7
90Installing : libnl3-cli-3.2.21-8.el6.x86_64 2/7
91Installing : popt-devel-1.13-7.el6.x86_64 3/7
92Installing : popt-static-1.13-7.el6.x86_64 4/7
93Installing : libnl3-devel-3.2.21-8.el6.x86_64 5/7
94Installing : libnl3-doc-3.2.21-8.el6.x86_64 6/7
95Installing : libnl-devel-1.1.4-2.el6.x86_64 7/7
96Verifying : libnl3-devel-3.2.21-8.el6.x86_64 1/7
97Verifying : libnl-devel-1.1.4-2.el6.x86_64 2/7
98Verifying : popt-static-1.13-7.el6.x86_64 3/7
99Verifying : popt-devel-1.13-7.el6.x86_64 4/7
100Verifying : libnl3-cli-3.2.21-8.el6.x86_64 5/7
101Verifying : libnl3-3.2.21-8.el6.x86_64 6/7
102Verifying : libnl3-doc-3.2.21-8.el6.x86_64 7/7
103
104Installed:
105libnl-devel.x86_64 0:1.1.4-2.el6 libnl3.x86_64 0:3.2.21-8.el6 libnl3-cli.x86_64 0:3.2.21-8.el6 libnl3-devel.x86_64 0:3.2.21-8.el6 libnl3-doc.x86_64 0:3.2.21-8.el6
106popt-devel.x86_64 0:1.13-7.el6 popt-static.x86_64 0:1.13-7.el6
107
108Complete!
109[root@lvs_vip_01 tools]# rpm -qa libnl* popt*
110libnl3-3.2.21-8.el6.x86_64
111libnl3-devel-3.2.21-8.el6.x86_64
112popt-1.13-7.el6.x86_64
113libnl-1.1.4-2.el6.x86_64
114libnl3-cli-3.2.21-8.el6.x86_64
115popt-static-1.13-7.el6.x86_64
116libnl3-doc-3.2.21-8.el6.x86_64
117popt-devel-1.13-7.el6.x86_64
118libnl-devel-1.1.4-2.el6.x86_64
119[root@lvs_vip_01 tools]# ls
120ipvsadm-1.26.tar.gz
121[root@lvs_vip_01 tools]# tar -xf ipvsadm-1.26.tar.gz
122[root@lvs_vip_01 tools]# ls
123ipvsadm-1.26 ipvsadm-1.26.tar.gz
124[root@lvs_vip_01 tools]# cd ipvsadm-1.26
125[root@lvs_vip_01 ipvsadm-1.26]# ls
126config_stream.c contrib dynamic_array.c ipvsadm.8 ipvsadm-restore ipvsadm-save ipvsadm.sh ipvsadm.spec.in Makefile README VERSION
127config_stream.h debian dynamic_array.h ipvsadm.c ipvsadm-restore.8 ipvsadm-save.8 ipvsadm.spec libipvs PERSISTENCE_ENGINES SCHEDULERS
128[root@lvs_vip_01 ipvsadm-1.26]# make
129make -C libipvs
130make[1]: Entering directory `/home/tools/ipvsadm-1.26/libipvs'`
131gcc -Wall -Wunused -Wstrict-prototypes -g -fPIC -DLIBIPVS_USE_NL -DHAVE_NET_IP_VS_H -c -o libipvs.o libipvs.c
132gcc -Wall -Wunused -Wstrict-prototypes -g -fPIC -DLIBIPVS_USE_NL -DHAVE_NET_IP_VS_H -c -o ip_vs_nl_policy.o ip_vs_nl_policy.c
133ar rv libipvs.a libipvs.o ip_vs_nl_policy.o
134ar: creating libipvs.a
135a - libipvs.o
136a - ip_vs_nl_policy.o
137gcc -shared -Wl,-soname,libipvs.so -o libipvs.so libipvs.o ip_vs_nl_policy.o
138make[1]: Leaving directory `/home/tools/ipvsadm-1.26/libipvs'`
139gcc -Wall -Wunused -Wstrict-prototypes -g -DVERSION=\"1.26\" -DSCHEDULERS=\""rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq"\" -DPE_LIST=\""sip"\" -DHAVE_POPT -DHAVE_NET_IP_VS_H -c -o ipvsadm.o ipvsadm.c
140ipvsadm.c: In function ‘print_largenum’:
141ipvsadm.c:1383: warning: field width should have type ‘int’, but argument 2 has type ‘size_t’
142gcc -Wall -Wunused -Wstrict-prototypes -g -DVERSION=\"1.26\" -DSCHEDULERS=\""rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq"\" -DPE_LIST=\""sip"\" -DHAVE_POPT -DHAVE_NET_IP_VS_H -c -o config_stream.o config_stream.c
143gcc -Wall -Wunused -Wstrict-prototypes -g -DVERSION=\"1.26\" -DSCHEDULERS=\""rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq"\" -DPE_LIST=\""sip"\" -DHAVE_POPT -DHAVE_NET_IP_VS_H -c -o dynamic_array.o dynamic_array.c
144gcc -Wall -Wunused -Wstrict-prototypes -g -o ipvsadm ipvsadm.o config_stream.o dynamic_array.o libipvs/libipvs.a -lpopt -lnl
145[root@lvs_vip_01 ipvsadm-1.26]# echo $?
1460
147[root@lvs_vip_01 ipvsadm-1.26]# make install
148make -C libipvs
149make[1]: Entering directory `/home/tools/ipvsadm-1.26/libipvs'`
150make[1]: Nothing to be done for `all'.`
151make[1]: Leaving directory `/home/tools/ipvsadm-1.26/libipvs'`
152if [ ! -d /sbin ]; then mkdir -p /sbin; fi
153install -m 0755 ipvsadm /sbin
154install -m 0755 ipvsadm-save /sbin
155install -m 0755 ipvsadm-restore /sbin
156[ -d /usr/man/man8 ] || mkdir -p /usr/man/man8
157install -m 0644 ipvsadm.8 /usr/man/man8
158install -m 0644 ipvsadm-save.8 /usr/man/man8
159install -m 0644 ipvsadm-restore.8 /usr/man/man8
160[ -d /etc/rc.d/init.d ] || mkdir -p /etc/rc.d/init.d
161install -m 0755 ipvsadm.sh /etc/rc.d/init.d/ipvsadm
162[root@lvs_vip_01 ipvsadm-1.26]#
163[root@lvs_vip_01 ipvsadm-1.26]#
164[root@lvs_vip_01 ipvsadm-1.26]# lsmod|grep ip_vs
165[root@lvs_vip_01 ipvsadm-1.26]# /sbin/ipvsadm
166IP Virtual Server version 1.2.1 (size=4096)
167Prot LocalAddress:Port Scheduler Flags
168-> RemoteAddress:Port Forward Weight ActiveConn InActConn
169[root@lvs_vip_01 ipvsadm-1.26]#
170[root@lvs_vip_01 ipvsadm-1.26]# lsmod|grep ip_vs
171ip_vs 125694 0
172libcrc32c 1246 1 ip_vs
173ipv6 334932 270 ip_vs,ip6t_REJECT,nf_conntrack_ipv6,nf_defrag_ipv6
174[root@lvs_vip_01 ipvsadm-1.26]#
175[root@lvs_vip_01 ipvsadm-1.26]# ifconfig eth0:0 192.168.1.250/24
176[root@lvs_vip_01 ipvsadm-1.26]# ifconfig
177eth0 Link encap:Ethernet HWaddr 00:0C:29:12:76:B6
178 inet addr:192.168.1.166 Bcast:192.168.161.255 Mask:255.255.255.0
179 inet6 addr: fe80::20c:29ff:fe12:76b6/64 Scope:Link
180 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
181 RX packets:14142 errors:0 dropped:0 overruns:0 frame:0
182 TX packets:6611 errors:0 dropped:0 overruns:0 carrier:0
183 collisions:0 txqueuelen:1000
184 RX bytes:19317256 (18.4 MiB) TX bytes:501456 (489.7 KiB)
185
186eth0:0 Link encap:Ethernet HWaddr 00:0C:29:12:76:B6
187 inet addr:192.168.1.250 Bcast:192.168.161.255 Mask:255.255.255.0
188 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
189
190lo Link encap:Local Loopback
191 inet addr:127.0.0.1 Mask:255.0.0.0
192 inet6 addr: ::1/128 Scope:Host
193 UP LOOPBACK RUNNING MTU:65536 Metric:1
194 RX packets:0 errors:0 dropped:0 overruns:0 frame:0
195 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
196 collisions:0 txqueuelen:0
197 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
198
199[root@lvs_vip_01 ipvsadm-1.26]# ping 192.168.1.250
200PING 192.168.1.250 (192.168.1.250) 56(84) bytes of data.
20164 bytes from 192.168.1.250: icmp_seq=1 ttl=64 time=0.024 ms
202^C
203--- 192.168.1.250 ping statistics ---
2041 packets transmitted, 1 received, 0% packet loss, time 935ms
205rtt min/avg/max/mdev = 0.024/0.024/0.024/0.000 ms
206
207[root@lvs_vip_01 ~]# ipvsadm -L -n
208IP Virtual Server version 1.2.1 (size=4096)
209Prot LocalAddress:Port Scheduler Flags
210-> RemoteAddress:Port Forward Weight ActiveConn InActConn
211[root@lvs_vip_01 ~]# ipvsadm -A -t 192.168.1.250:80 -s rr
212[root@lvs_vip_01 ~]# ipvsadm -a -t 192.168.1.250:80 -r 192.168.1.187 -m
213[root@lvs_vip_01 ~]# ipvsadm -a -t 192.168.1.250:80 -r 192.168.1.163 -m
214[root@lvs_vip_01 ~]# ipvsadm -L -n
215IP Virtual Server version 1.2.1 (size=4096)
216Prot LocalAddress:Port Scheduler Flags
217-> RemoteAddress:Port Forward Weight ActiveConn InActConn
218TCP 192.168.1.250:80 rr
219-> 192.168.1.187:80 Masq 1 0 0
220-> 192.168.1.163:80 Masq 1 0 0
221
222[root@lvs_vip_01 ipvsadm-1.26]# ntpdate pool.ntp.org
223 sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
224 setenforce 0
225 /etc/init.d/iptables stop
226 chkconfig iptables off
2272 Nov 03:18:06 ntpdate[1837]: 87.120.166.8 rate limit response from server.
2282 Nov 03:18:06 ntpdate[1837]: 37.247.53.178 rate limit response from server.
2291 Nov 19:18:06 ntpdate[1837]: step time server 87.120.166.8 offset -28800.986290 sec
230[root@lvs_vip_01 ipvsadm-1.26]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
231[root@lvs_vip_01 ipvsadm-1.26]# setenforce 0
232[root@lvs_vip_01 ipvsadm-1.26]# /etc/init.d/iptables stop
233iptables: Setting chains to policy ACCEPT: filter [ OK ]
234iptables: Flushing firewall rules: [ OK ]
235iptables: Unloading modules: [ OK ]
236[root@lvs_vip_01 ipvsadm-1.26]# chkconfig iptables off
注意
有的资料说要开启路由转发。但是我测试没有开启路由转发也可以成功。如果需要开启路由转发,命令:
15.2.3.2.3. lvs_rip_web01安装配置过程
安装配置过程:
1[root@lvs_rip_web01 ~]# mkdir /home/tools -p
2[root@lvs_rip_web01 ~]# ll /home
3total 4
4drwxr-xr-x. 2 root root 4096 Nov 2 02:51 tools
5[root@lvs_rip_web01 ~]# lsmod|grep ip_vs
6[root@lvs_rip_web01 ~]# echo '1'>/proc/sys/net/ipv4/ip_forward
7[root@lvs_rip_web01 ~]# cd /home/tools
8[root@lvs_rip_web01 tools]# pwd
9/home/tools
10[root@lvs_rip_web01 tools]# ls
11[root@lvs_rip_web01 tools]# wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz
12--2018-11-02 02:55:23-- http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz
13Resolving www.linuxvirtualserver.org... 173.255.202.51, 2600:3c00::f03c:91ff:fe96:fcc2
14Connecting to www.linuxvirtualserver.org|173.255.202.51|:80... connected.
15HTTP request sent, awaiting response... 200 OK
16Length: 41700 (41K) [application/x-gzip]
17Saving to: “ipvsadm-1.26.tar.gz”
18
19100%[===================================================================================================================================>] 41,700 193K/s in 0.2s
20
212018-11-02 02:55:25 (193 KB/s) - “ipvsadm-1.26.tar.gz” saved [41700/41700]
22
23[root@lvs_rip_web01 tools]# ls
24ipvsadm-1.26.tar.gz
25[root@lvs_rip_web01 tools]# rpm -qa libnl* popt*
26popt-1.13-7.el6.x86_64
27libnl-1.1.4-2.el6.x86_64
28
29[root@lvs_rip_web01 tools]#
30[root@lvs_rip_web01 tools]# yum install libnl* popt* -y
31Loaded plugins: fastestmirror, security
32Setting up Install Process
33Determining fastest mirrors
34* base: mirrors.njupt.edu.cn
35* extras: mirrors.njupt.edu.cn
36* updates: ftp.sjtu.edu.cn
37base | 3.7 kB 00:00
38http://mirrors.njupt.edu.cn/centos/6.10/os/x86_64/repodata/1aa8754bde2f3921d67cca4bb70d9f587fb858a24cc3d1f66d3315292a89fc20-primary.sqlite.bz2: [Errno 14] PYCURL ERROR 7 - "couldn't connect to host"
39Trying other mirror.
40base/primary_db | 4.7 MB 00:00
41extras | 3.4 kB 00:00
42http://mirrors.njupt.edu.cn/centos/6.10/extras/x86_64/repodata/0eb1b6b805b166a5f14cd3ad42db731169281d059ffbcdb1ebc157c0e4f675cf-primary.sqlite.bz2: [Errno 14] PYCURL ERROR 7 - "couldn't connect to host"
43Trying other mirror.
44extras/primary_db | 26 kB 00:00
45updates | 3.4 kB 00:00
46updates/primary_db | 1.9 MB 00:00
47Package libnl-1.1.4-2.el6.x86_64 already installed and latest version
48Package popt-1.13-7.el6.x86_64 already installed and latest version
49Resolving Dependencies
50--> Running transaction check
51---> Package libnl-devel.x86_64 0:1.1.4-2.el6 will be installed
52---> Package libnl3.x86_64 0:3.2.21-8.el6 will be installed
53---> Package libnl3-cli.x86_64 0:3.2.21-8.el6 will be installed
54---> Package libnl3-devel.x86_64 0:3.2.21-8.el6 will be installed
55---> Package libnl3-doc.x86_64 0:3.2.21-8.el6 will be installed
56---> Package popt-devel.x86_64 0:1.13-7.el6 will be installed
57---> Package popt-static.x86_64 0:1.13-7.el6 will be installed
58--> Finished Dependency Resolution
59
60Dependencies Resolved
61
62=============================================================================================================================================================================
63Package Arch Version Repository Size
64=============================================================================================================================================================================
65Installing:
66libnl-devel x86_64 1.1.4-2.el6 base 707 k
67libnl3 x86_64 3.2.21-8.el6 base 183 k
68libnl3-cli x86_64 3.2.21-8.el6 base 58 k
69libnl3-devel x86_64 3.2.21-8.el6 base 56 k
70libnl3-doc x86_64 3.2.21-8.el6 base 10 M
71popt-devel x86_64 1.13-7.el6 base 21 k
72popt-static x86_64 1.13-7.el6 base 21 k
73
74Transaction Summary
75=============================================================================================================================================================================
76Install 7 Package(s)
77
78Total download size: 11 M
79Installed size: 30 M
80Downloading Packages:
81(1/7): libnl-devel-1.1.4-2.el6.x86_64.rpm | 707 kB 00:00
82(2/7): libnl3-3.2.21-8.el6.x86_64.rpm | 183 kB 00:00
83(3/7): libnl3-cli-3.2.21-8.el6.x86_64.rpm | 58 kB 00:00
84(4/7): libnl3-devel-3.2.21-8.el6.x86_64.rpm | 56 kB 00:00
85(5/7): libnl3-doc-3.2.21-8.el6.x86_64.rpm | 10 MB 00:02
86(6/7): popt-devel-1.13-7.el6.x86_64.rpm | 21 kB 00:00
87(7/7): popt-static-1.13-7.el6.x86_64.rpm | 21 kB 00:00
88-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
89Total 4.0 MB/s | 11 MB 00:02
90Running rpm_check_debug
91Running Transaction Test
92Transaction Test Succeeded
93Running Transaction
94Installing : libnl3-3.2.21-8.el6.x86_64 1/7
95Installing : libnl3-cli-3.2.21-8.el6.x86_64 2/7
96Installing : popt-devel-1.13-7.el6.x86_64 3/7
97Installing : popt-static-1.13-7.el6.x86_64 4/7
98Installing : libnl3-devel-3.2.21-8.el6.x86_64 5/7
99Installing : libnl3-doc-3.2.21-8.el6.x86_64 6/7
100Installing : libnl-devel-1.1.4-2.el6.x86_64 7/7
101Verifying : libnl3-devel-3.2.21-8.el6.x86_64 1/7
102Verifying : libnl-devel-1.1.4-2.el6.x86_64 2/7
103Verifying : popt-static-1.13-7.el6.x86_64 3/7
104Verifying : popt-devel-1.13-7.el6.x86_64 4/7
105Verifying : libnl3-cli-3.2.21-8.el6.x86_64 5/7
106Verifying : libnl3-3.2.21-8.el6.x86_64 6/7
107Verifying : libnl3-doc-3.2.21-8.el6.x86_64 7/7
108
109Installed:
110libnl-devel.x86_64 0:1.1.4-2.el6 libnl3.x86_64 0:3.2.21-8.el6 libnl3-cli.x86_64 0:3.2.21-8.el6 libnl3-devel.x86_64 0:3.2.21-8.el6 libnl3-doc.x86_64 0:3.2.21-8.el6
111popt-devel.x86_64 0:1.13-7.el6 popt-static.x86_64 0:1.13-7.el6
112
113Complete!
114[root@lvs_rip_web01 tools]# rpm -qa libnl* popt*
115libnl3-3.2.21-8.el6.x86_64
116libnl3-devel-3.2.21-8.el6.x86_64
117popt-1.13-7.el6.x86_64
118libnl-1.1.4-2.el6.x86_64
119libnl3-cli-3.2.21-8.el6.x86_64
120popt-static-1.13-7.el6.x86_64
121libnl3-doc-3.2.21-8.el6.x86_64
122popt-devel-1.13-7.el6.x86_64
123libnl-devel-1.1.4-2.el6.x86_64
124[root@lvs_rip_web01 tools]# ls
125ipvsadm-1.26.tar.gz
126[root@lvs_rip_web01 tools]# tar -xf ipvsadm-1.26.tar.gz
127[root@lvs_rip_web01 tools]# ls
128ipvsadm-1.26 ipvsadm-1.26.tar.gz
129[root@lvs_rip_web01 tools]# cd ipvsadm-1.26
130[root@lvs_rip_web01 ipvsadm-1.26]# ls
131config_stream.c contrib dynamic_array.c ipvsadm.8 ipvsadm-restore ipvsadm-save ipvsadm.sh ipvsadm.spec.in Makefile README VERSION
132config_stream.h debian dynamic_array.h ipvsadm.c ipvsadm-restore.8 ipvsadm-save.8 ipvsadm.spec libipvs PERSISTENCE_ENGINES SCHEDULERS
133[root@lvs_rip_web01 ipvsadm-1.26]# make
134make -C libipvs
135make[1]: Entering directory `/home/tools/ipvsadm-1.26/libipvs'`
136gcc -Wall -Wunused -Wstrict-prototypes -g -fPIC -DLIBIPVS_USE_NL -DHAVE_NET_IP_VS_H -c -o libipvs.o libipvs.c
137gcc -Wall -Wunused -Wstrict-prototypes -g -fPIC -DLIBIPVS_USE_NL -DHAVE_NET_IP_VS_H -c -o ip_vs_nl_policy.o ip_vs_nl_policy.c
138ar rv libipvs.a libipvs.o ip_vs_nl_policy.o
139ar: creating libipvs.a
140a - libipvs.o
141a - ip_vs_nl_policy.o
142gcc -shared -Wl,-soname,libipvs.so -o libipvs.so libipvs.o ip_vs_nl_policy.o
143make[1]: Leaving directory `/home/tools/ipvsadm-1.26/libipvs'`
144gcc -Wall -Wunused -Wstrict-prototypes -g -DVERSION=\"1.26\" -DSCHEDULERS=\""rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq"\" -DPE_LIST=\""sip"\" -DHAVE_POPT -DHAVE_NET_IP_VS_H -c -o ipvsadm.o ipvsadm.c
145ipvsadm.c: In function ‘print_largenum’:
146ipvsadm.c:1383: warning: field width should have type ‘int’, but argument 2 has type ‘size_t’
147gcc -Wall -Wunused -Wstrict-prototypes -g -DVERSION=\"1.26\" -DSCHEDULERS=\""rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq"\" -DPE_LIST=\""sip"\" -DHAVE_POPT -DHAVE_NET_IP_VS_H -c -o config_stream.o config_stream.c
148gcc -Wall -Wunused -Wstrict-prototypes -g -DVERSION=\"1.26\" -DSCHEDULERS=\""rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq"\" -DPE_LIST=\""sip"\" -DHAVE_POPT -DHAVE_NET_IP_VS_H -c -o dynamic_array.o dynamic_array.c
149gcc -Wall -Wunused -Wstrict-prototypes -g -o ipvsadm ipvsadm.o config_stream.o dynamic_array.o libipvs/libipvs.a -lpopt -lnl
150[root@lvs_rip_web01 ipvsadm-1.26]# echo $?
1510
152[root@lvs_rip_web01 ipvsadm-1.26]# make install
153make -C libipvs
154make[1]: Entering directory `/home/tools/ipvsadm-1.26/libipvs'`
155make[1]: Nothing to be done for `all'.`
156make[1]: Leaving directory `/home/tools/ipvsadm-1.26/libipvs'`
157if [ ! -d /sbin ]; then mkdir -p /sbin; fi
158install -m 0755 ipvsadm /sbin
159install -m 0755 ipvsadm-save /sbin
160install -m 0755 ipvsadm-restore /sbin
161[ -d /usr/man/man8 ] || mkdir -p /usr/man/man8
162install -m 0644 ipvsadm.8 /usr/man/man8
163install -m 0644 ipvsadm-save.8 /usr/man/man8
164install -m 0644 ipvsadm-restore.8 /usr/man/man8
165[ -d /etc/rc.d/init.d ] || mkdir -p /etc/rc.d/init.d
166install -m 0755 ipvsadm.sh /etc/rc.d/init.d/ipvsadm
167[root@lvs_rip_web01 ipvsadm-1.26]#
168[root@lvs_rip_web01 ipvsadm-1.26]#
169[root@lvs_rip_web01 ipvsadm-1.26]# lsmod|grep ip_vs
170[root@lvs_rip_web01 ipvsadm-1.26]# /sbin/ipvsadm
171IP Virtual Server version 1.2.1 (size=4096)
172Prot LocalAddress:Port Scheduler Flags
173-> RemoteAddress:Port Forward Weight ActiveConn InActConn
174[root@lvs_rip_web01 ipvsadm-1.26]#
175[root@lvs_rip_web01 ipvsadm-1.26]# lsmod|grep ip_vs
176ip_vs 125694 0
177libcrc32c 1246 1 ip_vs
178ipv6 334932 270 ip_vs,ip6t_REJECT,nf_conntrack_ipv6,nf_defrag_ipv6
179[root@lvs_rip_web01 ipvsadm-1.26]# route
180Kernel IP routing table
181Destination Gateway Genmask Flags Metric Ref Use Iface
182192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
183link-local * 255.255.0.0 U 1002 0 0 eth0
184default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
185[root@lvs_rip_web01 ipvsadm-1.26]# route add default gw 192.168.1.166
186[root@lvs_rip_web01 ipvsadm-1.26]# route del default gw 192.168.1.1
187[root@lvs_rip_web01 ipvsadm-1.26]# route
188Kernel IP routing table
189Destination Gateway Genmask Flags Metric Ref Use Iface
190192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
191link-local * 255.255.0.0 U 1002 0 0 eth0
192default 192.168.1.166 0.0.0.0 UG 0 0 0 eth0
193[root@lvs_rip_web01 ipvsadm-1.26]# ipvsadm -L -n
194IP Virtual Server version 1.2.1 (size=4096)
195Prot LocalAddress:Port Scheduler Flags
196-> RemoteAddress:Port Forward Weight ActiveConn InActConn
197[root@lvs_rip_web01 ipvsadm-1.26]# ifconfig lo:0 192.168.1.250/32
198[root@lvs_rip_web01 ipvsadm-1.26]#
199[root@lvs_rip_web01 ipvsadm-1.26]# yum install httpd -y
200Loaded plugins: fastestmirror, security
201Setting up Install Process
202Loading mirror speeds from cached hostfile
203* base: mirrors.njupt.edu.cn
204* extras: mirrors.njupt.edu.cn
205* updates: ftp.sjtu.edu.cn
206Resolving Dependencies
207--> Running transaction check
208---> Package httpd.x86_64 0:2.2.15-69.el6.centos will be installed
209--> Processing Dependency: httpd-tools = 2.2.15-69.el6.centos for package: httpd-2.2.15-69.el6.centos.x86_64
210--> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-69.el6.centos.x86_64
211--> Running transaction check
212---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be installed
213---> Package httpd-tools.x86_64 0:2.2.15-69.el6.centos will be installed
214--> Finished Dependency Resolution
215
216Dependencies Resolved
217
218================================================================================================================================================
219Package Arch Version Repository Size
220================================================================================================================================================
221Installing:
222httpd x86_64 2.2.15-69.el6.centos base 836 k
223Installing for dependencies:
224apr-util-ldap x86_64 1.3.9-3.el6_0.1 base 15 k
225httpd-tools x86_64 2.2.15-69.el6.centos base 81 k
226
227Transaction Summary
228================================================================================================================================================
229Install 3 Package(s)
230
231Total download size: 932 k
232Installed size: 3.2 M
233Downloading Packages:
234(1/3): apr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpm | 15 kB 00:00
235http://mirrors.njupt.edu.cn/centos/6.10/os/x86_64/Packages/httpd-2.2.15-69.el6.centos.x86_64.rpm: [Errno 14] PYCURL ERROR 7 - "couldn't connect to host"
236Trying other mirror.
237(2/3): httpd-2.2.15-69.el6.centos.x86_64.rpm | 836 kB 00:00
238(3/3): httpd-tools-2.2.15-69.el6.centos.x86_64.rpm | 81 kB 00:00
239------------------------------------------------------------------------------------------------------------------------------------------------
240Total 43 kB/s | 932 kB 00:21
241Running rpm_check_debug
242Running Transaction Test
243Transaction Test Succeeded
244Running Transaction
245Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 1/3
246Installing : httpd-tools-2.2.15-69.el6.centos.x86_64 2/3
247Installing : httpd-2.2.15-69.el6.centos.x86_64 3/3
248Verifying : httpd-tools-2.2.15-69.el6.centos.x86_64 1/3
249Verifying : httpd-2.2.15-69.el6.centos.x86_64 2/3
250Verifying : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 3/3
251
252Installed:
253httpd.x86_64 0:2.2.15-69.el6.centos
254
255Dependency Installed:
256apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 httpd-tools.x86_64 0:2.2.15-69.el6.centos
257
258Complete!
259[root@lvs_rip_web01 ipvsadm-1.26]# ntpdate pool.ntp.org
260 sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
261 setenforce 0
262 /etc/init.d/iptables stop
263 chkconfig iptables off
2641 Nov 19:18:07 ntpdate[1732]: step time server 87.120.166.8 offset -28800.933704 sec
265[root@lvs_rip_web01 ipvsadm-1.26]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
266[root@lvs_rip_web01 ipvsadm-1.26]# setenforce 0
267[root@lvs_rip_web01 ipvsadm-1.26]# /etc/init.d/iptables stop
268iptables: Setting chains to policy ACCEPT: filter [ OK ]
269iptables: Flushing firewall rules: [ OK ]
270iptables: Unloading modules: [ OK ]
271[root@lvs_rip_web01 ipvsadm-1.26]# chkconfig iptables off
272[root@lvs_rip_web01 ipvsadm-1.26]# sed -i "277i ServerName 127.0.0.1:80" /etc/httpd/conf/httpd.conf
273[root@lvs_rip_web01 ipvsadm-1.26]# /etc/init.d/httpd start
274Starting httpd: [ OK ]
275[root@lvs_rip_web01 ipvsadm-1.26]# ll /var/www/html/
276total 0
277[root@lvs_rip_web01 ipvsadm-1.26]# echo '192.168.1.187 this lvs is working'>>/var/www/html/index.html
15.2.3.2.4. lvs_rip_web02安装配置过程
安装配置过程:
1[root@lvs_rip_web02 ~]# mkdir /home/tools -p
2[root@lvs_rip_web02 ~]# ll /home
3total 4
4drwxr-xr-x. 2 root root 4096 Nov 2 02:51 tools
5[root@lvs_rip_web02 ~]# lsmod|grep ip_vs
6[root@lvs_rip_web02 ~]# echo '1'>/proc/sys/net/ipv4/ip_forward
7[root@lvs_rip_web02 ~]# cd /home/tools
8[root@lvs_rip_web02 tools]# pwd
9/home/tools
10[root@lvs_rip_web02 tools]# ls
11[root@lvs_rip_web02 tools]# wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz
12--2018-11-02 02:55:23-- http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz
13Resolving www.linuxvirtualserver.org... 173.255.202.51, 2600:3c00::f03c:91ff:fe96:fcc2
14Connecting to www.linuxvirtualserver.org|173.255.202.51|:80... connected.
15HTTP request sent, awaiting response... 200 OK
16Length: 41700 (41K) [application/x-gzip]
17Saving to: “ipvsadm-1.26.tar.gz”
18
19100%[===================================================================================================================================>] 41,700 189K/s in 0.2s
20
212018-11-02 02:55:25 (189 KB/s) - “ipvsadm-1.26.tar.gz” saved [41700/41700]
22
23[root@lvs_rip_web02 tools]# ls
24ipvsadm-1.26.tar.gz
25[root@lvs_rip_web02 tools]# rpm -qa libnl* popt*
26popt-1.13-7.el6.x86_64
27libnl-1.1.4-2.el6.x86_64
28
29[root@lvs_rip_web02 tools]#
30[root@lvs_rip_web02 tools]# yum install libnl* popt* -y
31Loaded plugins: fastestmirror, security
32Setting up Install Process
33Determining fastest mirrors
34* base: mirrors.huaweicloud.com
35* extras: mirrors.huaweicloud.com
36* updates: mirrors.huaweicloud.com
37base | 3.7 kB 00:00
38base/primary_db | 4.7 MB 00:00
39extras | 3.4 kB 00:00
40extras/primary_db | 26 kB 00:00
41updates | 3.4 kB 00:00
42updates/primary_db | 1.9 MB 00:00
43Package libnl-1.1.4-2.el6.x86_64 already installed and latest version
44Package popt-1.13-7.el6.x86_64 already installed and latest version
45Resolving Dependencies
46--> Running transaction check
47---> Package libnl-devel.x86_64 0:1.1.4-2.el6 will be installed
48---> Package libnl3.x86_64 0:3.2.21-8.el6 will be installed
49---> Package libnl3-cli.x86_64 0:3.2.21-8.el6 will be installed
50---> Package libnl3-devel.x86_64 0:3.2.21-8.el6 will be installed
51---> Package libnl3-doc.x86_64 0:3.2.21-8.el6 will be installed
52---> Package popt-devel.x86_64 0:1.13-7.el6 will be installed
53---> Package popt-static.x86_64 0:1.13-7.el6 will be installed
54--> Finished Dependency Resolution
55
56Dependencies Resolved
57
58=============================================================================================================================================================================
59Package Arch Version Repository Size
60=============================================================================================================================================================================
61Installing:
62libnl-devel x86_64 1.1.4-2.el6 base 707 k
63libnl3 x86_64 3.2.21-8.el6 base 183 k
64libnl3-cli x86_64 3.2.21-8.el6 base 58 k
65libnl3-devel x86_64 3.2.21-8.el6 base 56 k
66libnl3-doc x86_64 3.2.21-8.el6 base 10 M
67popt-devel x86_64 1.13-7.el6 base 21 k
68popt-static x86_64 1.13-7.el6 base 21 k
69
70Transaction Summary
71=============================================================================================================================================================================
72Install 7 Package(s)
73
74Total download size: 11 M
75Installed size: 30 M
76Downloading Packages:
77(1/7): libnl-devel-1.1.4-2.el6.x86_64.rpm | 707 kB 00:00
78(2/7): libnl3-3.2.21-8.el6.x86_64.rpm | 183 kB 00:00
79(3/7): libnl3-cli-3.2.21-8.el6.x86_64.rpm | 58 kB 00:00
80(4/7): libnl3-devel-3.2.21-8.el6.x86_64.rpm | 56 kB 00:00
81(5/7): libnl3-doc-3.2.21-8.el6.x86_64.rpm | 10 MB 00:02
82(6/7): popt-devel-1.13-7.el6.x86_64.rpm | 21 kB 00:00
83(7/7): popt-static-1.13-7.el6.x86_64.rpm | 21 kB 00:00
84-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
85Total 3.7 MB/s | 11 MB 00:02
86Running rpm_check_debug
87Running Transaction Test
88Transaction Test Succeeded
89Running Transaction
90Installing : libnl3-3.2.21-8.el6.x86_64 1/7
91Installing : libnl3-cli-3.2.21-8.el6.x86_64 2/7
92Installing : popt-devel-1.13-7.el6.x86_64 3/7
93Installing : popt-static-1.13-7.el6.x86_64 4/7
94Installing : libnl3-devel-3.2.21-8.el6.x86_64 5/7
95Installing : libnl3-doc-3.2.21-8.el6.x86_64 6/7
96Installing : libnl-devel-1.1.4-2.el6.x86_64 7/7
97Verifying : libnl3-devel-3.2.21-8.el6.x86_64 1/7
98Verifying : libnl-devel-1.1.4-2.el6.x86_64 2/7
99Verifying : popt-static-1.13-7.el6.x86_64 3/7
100Verifying : popt-devel-1.13-7.el6.x86_64 4/7
101Verifying : libnl3-cli-3.2.21-8.el6.x86_64 5/7
102Verifying : libnl3-3.2.21-8.el6.x86_64 6/7
103Verifying : libnl3-doc-3.2.21-8.el6.x86_64 7/7
104
105Installed:
106libnl-devel.x86_64 0:1.1.4-2.el6 libnl3.x86_64 0:3.2.21-8.el6 libnl3-cli.x86_64 0:3.2.21-8.el6 libnl3-devel.x86_64 0:3.2.21-8.el6 libnl3-doc.x86_64 0:3.2.21-8.el6
107popt-devel.x86_64 0:1.13-7.el6 popt-static.x86_64 0:1.13-7.el6
108
109Complete!
110[root@lvs_rip_web02 tools]# rpm -qa libnl* popt*
111libnl3-3.2.21-8.el6.x86_64
112libnl3-devel-3.2.21-8.el6.x86_64
113popt-1.13-7.el6.x86_64
114libnl-1.1.4-2.el6.x86_64
115libnl3-cli-3.2.21-8.el6.x86_64
116popt-static-1.13-7.el6.x86_64
117libnl3-doc-3.2.21-8.el6.x86_64
118popt-devel-1.13-7.el6.x86_64
119libnl-devel-1.1.4-2.el6.x86_64
120[root@lvs_rip_web02 tools]# ls
121ipvsadm-1.26.tar.gz
122[root@lvs_rip_web02 tools]# tar -xf ipvsadm-1.26.tar.gz
123[root@lvs_rip_web02 tools]# ls
124ipvsadm-1.26 ipvsadm-1.26.tar.gz
125[root@lvs_rip_web02 tools]# cd ipvsadm-1.26
126[root@lvs_rip_web02 ipvsadm-1.26]# ls
127config_stream.c contrib dynamic_array.c ipvsadm.8 ipvsadm-restore ipvsadm-save ipvsadm.sh ipvsadm.spec.in Makefile README VERSION
128config_stream.h debian dynamic_array.h ipvsadm.c ipvsadm-restore.8 ipvsadm-save.8 ipvsadm.spec libipvs PERSISTENCE_ENGINES SCHEDULERS
129[root@lvs_rip_web02 ipvsadm-1.26]# make
130make -C libipvs
131make[1]: Entering directory `/home/tools/ipvsadm-1.26/libipvs'`
132gcc -Wall -Wunused -Wstrict-prototypes -g -fPIC -DLIBIPVS_USE_NL -DHAVE_NET_IP_VS_H -c -o libipvs.o libipvs.c
133gcc -Wall -Wunused -Wstrict-prototypes -g -fPIC -DLIBIPVS_USE_NL -DHAVE_NET_IP_VS_H -c -o ip_vs_nl_policy.o ip_vs_nl_policy.c
134ar rv libipvs.a libipvs.o ip_vs_nl_policy.o
135ar: creating libipvs.a
136a - libipvs.o
137a - ip_vs_nl_policy.o
138gcc -shared -Wl,-soname,libipvs.so -o libipvs.so libipvs.o ip_vs_nl_policy.o
139make[1]: Leaving directory `/home/tools/ipvsadm-1.26/libipvs'`
140gcc -Wall -Wunused -Wstrict-prototypes -g -DVERSION=\"1.26\" -DSCHEDULERS=\""rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq"\" -DPE_LIST=\""sip"\" -DHAVE_POPT -DHAVE_NET_IP_VS_H -c -o ipvsadm.o ipvsadm.c
141ipvsadm.c: In function ‘print_largenum’:
142ipvsadm.c:1383: warning: field width should have type ‘int’, but argument 2 has type ‘size_t’
143gcc -Wall -Wunused -Wstrict-prototypes -g -DVERSION=\"1.26\" -DSCHEDULERS=\""rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq"\" -DPE_LIST=\""sip"\" -DHAVE_POPT -DHAVE_NET_IP_VS_H -c -o config_stream.o config_stream.c
144gcc -Wall -Wunused -Wstrict-prototypes -g -DVERSION=\"1.26\" -DSCHEDULERS=\""rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq"\" -DPE_LIST=\""sip"\" -DHAVE_POPT -DHAVE_NET_IP_VS_H -c -o dynamic_array.o dynamic_array.c
145gcc -Wall -Wunused -Wstrict-prototypes -g -o ipvsadm ipvsadm.o config_stream.o dynamic_array.o libipvs/libipvs.a -lpopt -lnl
146[root@lvs_rip_web02 ipvsadm-1.26]# echo $?
1470
148[root@lvs_rip_web02 ipvsadm-1.26]# make install
149make -C libipvs
150make[1]: Entering directory `/home/tools/ipvsadm-1.26/libipvs'`
151make[1]: Nothing to be done for `all'.`
152make[1]: Leaving directory `/home/tools/ipvsadm-1.26/libipvs'`
153if [ ! -d /sbin ]; then mkdir -p /sbin; fi
154install -m 0755 ipvsadm /sbin
155install -m 0755 ipvsadm-save /sbin
156install -m 0755 ipvsadm-restore /sbin
157[ -d /usr/man/man8 ] || mkdir -p /usr/man/man8
158install -m 0644 ipvsadm.8 /usr/man/man8
159install -m 0644 ipvsadm-save.8 /usr/man/man8
160install -m 0644 ipvsadm-restore.8 /usr/man/man8
161[ -d /etc/rc.d/init.d ] || mkdir -p /etc/rc.d/init.d
162install -m 0755 ipvsadm.sh /etc/rc.d/init.d/ipvsadm
163[root@lvs_rip_web02 ipvsadm-1.26]#
164[root@lvs_rip_web02 ipvsadm-1.26]#
165[root@lvs_rip_web02 ipvsadm-1.26]# lsmod|grep ip_vs
166[root@lvs_rip_web02 ipvsadm-1.26]# /sbin/ipvsadm
167IP Virtual Server version 1.2.1 (size=4096)
168Prot LocalAddress:Port Scheduler Flags
169-> RemoteAddress:Port Forward Weight ActiveConn InActConn
170[root@lvs_rip_web02 ipvsadm-1.26]#
171[root@lvs_rip_web02 ipvsadm-1.26]# lsmod|grep ip_vs
172ip_vs 125694 0
173libcrc32c 1246 1 ip_vs
174ipv6 334932 270 ip_vs,ip6t_REJECT,nf_conntrack_ipv6,nf_defrag_ipv6
175[root@lvs_rip_web02 ipvsadm-1.26]# route
176Kernel IP routing table
177Destination Gateway Genmask Flags Metric Ref Use Iface
178192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
179link-local * 255.255.0.0 U 1002 0 0 eth0
180default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
181[root@lvs_rip_web02 ipvsadm-1.26]# route add default gw 192.168.1.166
182[root@lvs_rip_web02 ipvsadm-1.26]# route del default gw 192.168.1.1
183[root@lvs_rip_web02 ipvsadm-1.26]# route
184Kernel IP routing table
185Destination Gateway Genmask Flags Metric Ref Use Iface
186192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
187link-local * 255.255.0.0 U 1002 0 0 eth0
188default 192.168.1.166 0.0.0.0 UG 0 0 0 eth0
189[root@lvs_rip_web02 ipvsadm-1.26]# ipvsadm -L -n
190IP Virtual Server version 1.2.1 (size=4096)
191Prot LocalAddress:Port Scheduler Flags
192-> RemoteAddress:Port Forward Weight ActiveConn InActConn
193[root@lvs_rip_web02 ipvsadm-1.26]# ifconfig lo:0 192.168.1.250/32
194[root@lvs_rip_web02 ipvsadm-1.26]#
195[root@lvs_rip_web02 ipvsadm-1.26]# yum install httpd -y
196Loaded plugins: fastestmirror, security
197Setting up Install Process
198Loading mirror speeds from cached hostfile
199* base: mirrors.huaweicloud.com
200* extras: mirrors.huaweicloud.com
201* updates: mirrors.huaweicloud.com
202Resolving Dependencies
203--> Running transaction check
204---> Package httpd.x86_64 0:2.2.15-69.el6.centos will be installed
205--> Processing Dependency: httpd-tools = 2.2.15-69.el6.centos for package: httpd-2.2.15-69.el6.centos.x86_64
206--> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-69.el6.centos.x86_64
207--> Running transaction check
208---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be installed
209---> Package httpd-tools.x86_64 0:2.2.15-69.el6.centos will be installed
210--> Finished Dependency Resolution
211
212Dependencies Resolved
213
214================================================================================================================================================
215Package Arch Version Repository Size
216================================================================================================================================================
217Installing:
218httpd x86_64 2.2.15-69.el6.centos base 836 k
219Installing for dependencies:
220apr-util-ldap x86_64 1.3.9-3.el6_0.1 base 15 k
221httpd-tools x86_64 2.2.15-69.el6.centos base 81 k
222
223Transaction Summary
224================================================================================================================================================
225Install 3 Package(s)
226
227Total download size: 932 k
228Installed size: 3.2 M
229Downloading Packages:
230(1/3): apr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpm | 15 kB 00:00
231(2/3): httpd-2.2.15-69.el6.centos.x86_64.rpm | 836 kB 00:00
232(3/3): httpd-tools-2.2.15-69.el6.centos.x86_64.rpm | 81 kB 00:00
233------------------------------------------------------------------------------------------------------------------------------------------------
234Total 2.6 MB/s | 932 kB 00:00
235Running rpm_check_debug
236Running Transaction Test
237Transaction Test Succeeded
238Running Transaction
239Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 1/3
240Installing : httpd-tools-2.2.15-69.el6.centos.x86_64 2/3
241Installing : httpd-2.2.15-69.el6.centos.x86_64 3/3
242Verifying : httpd-tools-2.2.15-69.el6.centos.x86_64 1/3
243Verifying : httpd-2.2.15-69.el6.centos.x86_64 2/3
244Verifying : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 3/3
245
246Installed:
247httpd.x86_64 0:2.2.15-69.el6.centos
248
249Dependency Installed:
250apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 httpd-tools.x86_64 0:2.2.15-69.el6.centos
251
252Complete!
253[root@lvs_rip_web02 ipvsadm-1.26]# ntpdate pool.ntp.org
254 sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
255 setenforce 0
256 /etc/init.d/iptables stop
257 chkconfig iptables off
2581 Nov 19:18:08 ntpdate[1629]: step time server 87.120.166.8 offset -28800.981356 sec
259[root@lvs_rip_web02 ipvsadm-1.26]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
260[root@lvs_rip_web02 ipvsadm-1.26]# setenforce 0
261[root@lvs_rip_web02 ipvsadm-1.26]# /etc/init.d/iptables stop
262iptables: Setting chains to policy ACCEPT: filter [ OK ]
263iptables: Flushing firewall rules: [ OK ]
264iptables: Unloading modules: [ OK ]
265[root@lvs_rip_web02 ipvsadm-1.26]# chkconfig iptables off
266[root@lvs_rip_web02 ipvsadm-1.26]# sed -i "277i ServerName 127.0.0.1:80" /etc/httpd/conf/httpd.conf
267[root@lvs_rip_web02 ipvsadm-1.26]# /etc/init.d/httpd start
268Starting httpd: [ OK ]
269[root@lvs_rip_web02 ipvsadm-1.26]# ll /var/www/html/
270total 0
271[root@lvs_rip_web02 ipvsadm-1.26]# echo '192.168.1.163 this lvs is working'>>/var/www/html/index.html
15.2.3.3. 测试
15.2.3.3.1. lvs_vip_01本地测试
1[root@lvs_vip_01 ipvsadm-1.26]# curl http://192.168.1.163
2192.168.1.163 this lvs is working
3[root@lvs_vip_01 ipvsadm-1.26]# curl http://192.168.1.187
4192.168.1.187 this lvs is working
15.2.3.3.2. lvs_rip_web01本地测试
1[root@lvs_rip_web01 ipvsadm-1.26]# curl http://192.168.1.187
2192.168.1.187 this lvs is working
15.2.3.3.3. lvs_rip_web02本地测试
1[root@lvs_rip_web02 ipvsadm-1.26]# curl http://192.168.1.163
2192.168.1.163 this lvs is working
15.2.3.3.4. 抓包分析
- 以下三台服务器都运行相应的命令
- lvs_vip_01
tcpdump -i eth0:0 dst port 80
- lvs_rip_web01
tcpdump -i eth0 src host 192.168.161.137 or dst host 192.168.161.137
- lvs_rip_web02
tcpdump -i eth0 src host 192.168.161.137 or dst host 192.168.161.137
从本地另一个IP为:
192.168.161.137访问,即运行命令:curl http://192.168.1.250查看监控的抓包信息:
15.2.3.4. 开机自启动
需要编写脚本校验然后开启。也可以结合keepalive做。