高并发与负载均衡--lvs-DR模型试验
注意:搭建时注意主机IP(VIP)和分机IP(RIP)的先后顺序,首先先创建主机IP,再配置RIP。
LVS搭建
LVS主机VIP配置操作如下:
[[email protected] ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.159.10 netmask 255.255.255.0 broadcast 192.168.159.255
inet6 fe80::20c:29ff:fe99:5ef2 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:99:5e:f2 txqueuelen 1000 (Ethernet)
RX packets 1349266 bytes 1278637291 (1.1 GiB)
RX errors 101 dropped 0 overruns 0 frame 0
TX packets 344151 bytes 24511218 (23.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 19 base 0x2000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 208 bytes 17968 (17.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 208 bytes 17968 (17.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:98:fb:a9 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[[email protected] ~]# ifconfig eth33:2 192.168.159.100/24
SIOCSIFADDR: 没有那个设备
eth33:2: ERROR while getting interface flags: 没有那个设备
SIOCSIFNETMASK: 没有那个设备
[[email protected] ~]# ifconfig ens33:2 192.168.159.100/24
[[email protected] ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.159.10 netmask 255.255.255.0 broadcast 192.168.159.255
inet6 fe80::20c:29ff:fe99:5ef2 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:99:5e:f2 txqueuelen 1000 (Ethernet)
RX packets 1349468 bytes 1278652342 (1.1 GiB)
RX errors 101 dropped 0 overruns 0 frame 0
TX packets 344250 bytes 24522004 (23.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 19 base 0x2000
ens33:2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.159.100 netmask 255.255.255.0 broadcast 192.168.159.255
ether 00:0c:29:99:5e:f2 txqueuelen 1000 (Ethernet)
device interrupt 19 base 0x2000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 208 bytes 17968 (17.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 208 bytes 17968 (17.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:98:fb:a9 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[[email protected] ~]# echo 1 > /proc/sys/net/ipv4/ip_forward
[[email protected] ~]# yum install ipvsadm -y
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
updates/7/x86_64/primary_db | 5.8 MB 00:00:02
正在解决依赖关系
--> 正在检查事务
---> 软件包 ipvsadm.x86_64.0.1.27-7.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
=================================================================================
Package 架构 版本 源 大小
=================================================================================
正在安装:
ipvsadm x86_64 1.27-7.el7 base 45 k
事务概要
=================================================================================
安装 1 软件包
总下载量:45 k
安装大小:75 k
Downloading packages:
ipvsadm-1.27-7.el7.x86_64.rpm | 45 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : ipvsadm-1.27-7.el7.x86_64 1/1
验证中 : ipvsadm-1.27-7.el7.x86_64 1/1
已安装:
ipvsadm.x86_64 0:1.27-7.el7
完毕!
[[email protected] ~]# ipvsadm -A -t 192.168.159.100:80 -s rr
[[email protected] ~]# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.159.100:80 rr
[[email protected] ~]# ipvsadm -a -t 192.168.159.100:80 -r 192.168.159.12:80 -g
[[email protected] ~]# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.159.100:80 rr
-> 192.168.159.12:80 Route 1 0 0
[[email protected] ~]# ipvsadm -a -t 192.168.159.100:80 -r 192.168.159.13:80 -g
[[email protected] ~]# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.159.100:80 rr
-> 192.168.159.12:80 Route 1 0 0
-> 192.168.159.13:80 Route 1 0 0
[[email protected] ~]# netstat -natp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN 5444/X
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 7418/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 5251/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 5253/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 5517/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 15857/sshd: [email protected]
tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN 17400/sshd: [email protected]
tcp 0 36 192.168.159.10:22 192.168.159.1:52194 ESTABLISHED 17400/sshd: [email protected]
tcp 0 0 192.168.159.10:22 192.168.159.1:51437 ESTABLISHED 15857/sshd: [email protected]
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::6000 :::* LISTEN 5444/X
tcp6 0 0 :::22 :::* LISTEN 5251/sshd
tcp6 0 0 ::1:631 :::* LISTEN 5253/cupsd
tcp6 0 0 ::1:25 :::* LISTEN 5517/master
tcp6 0 0 ::1:6010 :::* LISTEN 15857/sshd: [email protected]
tcp6 0 0 ::1:6011 :::* LISTEN 17400/sshd: [email protected]
[[email protected] ~]# ipvsadm -lnc
IPVS connection entries
pro expire state source virtual destination
TCP 00:42 FIN_WAIT 192.168.159.1:55978 192.168.159.100:80 192.168.159.13:80
TCP 01:13 FIN_WAIT 192.168.159.1:56101 192.168.159.100:80 192.168.159.12:80
TCP 01:01 FIN_WAIT 192.168.159.1:56038 192.168.159.100:80 192.168.159.12:80
TCP 01:13 FIN_WAIT 192.168.159.1:56102 192.168.159.100:80 192.168.159.13:80
TCP 01:06 FIN_WAIT 192.168.159.1:56073 192.168.159.100:80 192.168.159.12:80
TCP 01:01 FIN_WAIT 192.168.159.1:56037 192.168.159.100:80 192.168.159.13:80
TCP 01:06 FIN_WAIT 192.168.159.1:56072 192.168.159.100:80 192.168.159.13:80
RIP配置操作
第一台 RIP 服务器配置操作如下:
[[email protected] ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.159.12 netmask 255.255.255.0 broadcast 192.168.159.255
inet6 fe80::20c:29ff:fe62:a1 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:62:00:a1 txqueuelen 1000 (Ethernet)
RX packets 3195 bytes 227705 (222.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 516 bytes 45434 (44.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 19 base 0x2000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:98:fb:a9 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[[email protected] ~]# cd /proc/sys/net/ipv4/conf
[[email protected] conf]# ll
总用量 0
dr-xr-xr-x 1 root root 0 12月 9 14:33 all
dr-xr-xr-x 1 root root 0 12月 9 14:33 default
dr-xr-xr-x 1 root root 0 12月 9 16:23 ens33
dr-xr-xr-x 1 root root 0 12月 9 16:23 lo
dr-xr-xr-x 1 root root 0 12月 9 16:23 virbr0
dr-xr-xr-x 1 root root 0 12月 9 16:23 virbr0-nic
[[email protected] conf]# cd ens33
[[email protected] ens33]# ls
accept_local arp_notify mc_forwarding secure_redirects
accept_redirects bootp_relay medium_id send_redirects
accept_source_route disable_policy promote_secondaries shared_media
arp_accept disable_xfrm proxy_arp src_valid_mark
arp_announce force_igmp_version proxy_arp_pvlan tag
arp_filter forwarding route_localnet
arp_ignore log_martians rp_filter
[[email protected] ens33]# echo 1 > arp_ignore
[[email protected] ens33]# echo 2 > arp_announce
[[email protected] ens33]# pwd
/proc/sys/net/ipv4/conf/ens33
[[email protected] ens33]# cd ..
[[email protected] conf]# ll
总用量 0
dr-xr-xr-x 1 root root 0 12月 9 14:33 all
dr-xr-xr-x 1 root root 0 12月 9 14:33 default
dr-xr-xr-x 1 root root 0 12月 9 16:23 ens33
dr-xr-xr-x 1 root root 0 12月 9 16:23 lo
dr-xr-xr-x 1 root root 0 12月 9 16:23 virbr0
dr-xr-xr-x 1 root root 0 12月 9 16:23 virbr0-nic
[[email protected] conf]# cd all
[[email protected] all]# ll
总用量 0
-rw-r--r-- 1 root root 0 12月 9 16:25 accept_local
-rw-r--r-- 1 root root 0 12月 9 16:25 accept_redirects
-rw-r--r-- 1 root root 0 12月 9 14:36 accept_source_route
-rw-r--r-- 1 root root 0 12月 9 16:25 arp_accept
-rw-r--r-- 1 root root 0 12月 9 16:25 arp_announce
-rw-r--r-- 1 root root 0 12月 9 16:25 arp_filter
-rw-r--r-- 1 root root 0 12月 9 16:25 arp_ignore
-rw-r--r-- 1 root root 0 12月 9 16:25 arp_notify
-rw-r--r-- 1 root root 0 12月 9 16:25 bootp_relay
-rw-r--r-- 1 root root 0 12月 9 16:25 disable_policy
-rw-r--r-- 1 root root 0 12月 9 16:25 disable_xfrm
-rw-r--r-- 1 root root 0 12月 9 16:25 force_igmp_version
-rw-r--r-- 1 root root 0 12月 9 16:25 forwarding
-rw-r--r-- 1 root root 0 12月 9 16:25 log_martians
-r--r--r-- 1 root root 0 12月 9 16:25 mc_forwarding
-rw-r--r-- 1 root root 0 12月 9 16:25 medium_id
-rw-r--r-- 1 root root 0 12月 9 14:36 promote_secondaries
-rw-r--r-- 1 root root 0 12月 9 16:25 proxy_arp
-rw-r--r-- 1 root root 0 12月 9 16:25 proxy_arp_pvlan
-rw-r--r-- 1 root root 0 12月 9 16:25 route_localnet
-rw-r--r-- 1 root root 0 12月 9 14:36 rp_filter
-rw-r--r-- 1 root root 0 12月 9 16:25 secure_redirects
-rw-r--r-- 1 root root 0 12月 9 16:25 send_redirects
-rw-r--r-- 1 root root 0 12月 9 16:25 shared_media
-rw-r--r-- 1 root root 0 12月 9 16:25 src_valid_mark
-rw-r--r-- 1 root root 0 12月 9 16:25 tag
[[email protected] all]# ls
accept_local arp_notify mc_forwarding secure_redirects
accept_redirects bootp_relay medium_id send_redirects
accept_source_route disable_policy promote_secondaries shared_media
arp_accept disable_xfrm proxy_arp src_valid_mark
arp_announce force_igmp_version proxy_arp_pvlan tag
arp_filter forwarding route_localnet
arp_ignore log_martians rp_filter
[[email protected] all]# echo 1 > arp_ignore
[[email protected] all]# echo 2 > arp_announce
[[email protected] all]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.159.12 netmask 255.255.255.0 broadcast 192.168.159.255
inet6 fe80::20c:29ff:fe62:a1 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:62:00:a1 txqueuelen 1000 (Ethernet)
RX packets 4014 bytes 288438 (281.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 833 bytes 79030 (77.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 19 base 0x2000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:98:fb:a9 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[[email protected] all]# ifconfig lo:8 192.168.159.100 netmask 255.255.255.255
[[email protected] all]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.159.12 netmask 255.255.255.0 broadcast 192.168.159.255
inet6 fe80::20c:29ff:fe62:a1 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:62:00:a1 txqueuelen 1000 (Ethernet)
RX packets 4161 bytes 299376 (292.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 901 bytes 86502 (84.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 19 base 0x2000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo:8: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 192.168.159.100 netmask 255.255.255.255
loop txqueuelen 1000 (Local Loopback)
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:98:fb:a9 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[[email protected] all]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.159.2 0.0.0.0 UG 100 0 0 ens33
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
192.168.159.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
[[email protected] ~]# yum install httpd
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
* base: mirrors.cn99.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
updates/7/x86_64/primary_db | 5.8 MB 00:00:02
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-90.el7.centos 将被 安装
--> 正在处理依赖关系 httpd-tools = 2.4.6-90.el7.centos,它被软件包 httpd-2.4.6-90.el7.centos.x86_64 需要
--> 正在处理依赖关系 /etc/mime.types,它被软件包 httpd-2.4.6-90.el7.centos.x86_64 需要
--> 正在处理依赖关系 libaprutil-1.so.0()(64bit),它被软件包 httpd-2.4.6-90.el7.centos.x86_64 需要
--> 正在处理依赖关系 libapr-1.so.0()(64bit),它被软件包 httpd-2.4.6-90.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 apr.x86_64.0.1.4.8-5.el7 将被 安装
---> 软件包 apr-util.x86_64.0.1.5.2-6.el7 将被 安装
---> 软件包 httpd-tools.x86_64.0.2.4.6-90.el7.centos 将被 安装
---> 软件包 mailcap.noarch.0.2.1.41-2.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
===================================================================================================================================================================
Package 架构 版本 源 大小
===================================================================================================================================================================
正在安装:
httpd x86_64 2.4.6-90.el7.centos base 2.7 M
为依赖而安装:
apr x86_64 1.4.8-5.el7 base 103 k
apr-util x86_64 1.5.2-6.el7 base 92 k
httpd-tools x86_64 2.4.6-90.el7.centos base 91 k
mailcap noarch 2.1.41-2.el7 base 31 k
事务概要
===================================================================================================================================================================
安装 1 软件包 (+4 依赖软件包)
总下载量:3.0 M
安装大小:10 M
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/base/packages/httpd-tools-2.4.6-90.el7.centos.x86_64.rpm: 头V3 RSA/SHA256 Signature, ** ID f4a80eb5: NOKEYs | 0 B --:--:-- ETA
httpd-tools-2.4.6-90.el7.centos.x86_64.rpm 的公钥尚未安装
(1/5): httpd-tools-2.4.6-90.el7.centos.x86_64.rpm | 91 kB 00:00:00
(2/5): apr-1.4.8-5.el7.x86_64.rpm | 103 kB 00:00:01
(3/5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:01
(4/5): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:01
(5/5): httpd-2.4.6-90.el7.centos.x86_64.rpm | 2.7 MB 00:00:01
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计 1.8 MB/s | 3.0 MB 00:00:01
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 检索**
导入 GPG key 0xF4A80EB5:
用户ID : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
指纹 : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
软件包 : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : apr-1.4.8-5.el7.x86_64 1/5
正在安装 : apr-util-1.5.2-6.el7.x86_64 2/5
正在安装 : httpd-tools-2.4.6-90.el7.centos.x86_64 3/5
正在安装 : mailcap-2.1.41-2.el7.noarch 4/5
正在安装 : httpd-2.4.6-90.el7.centos.x86_64 5/5
验证中 : apr-1.4.8-5.el7.x86_64 1/5
验证中 : mailcap-2.1.41-2.el7.noarch 2/5
验证中 : httpd-tools-2.4.6-90.el7.centos.x86_64 3/5
验证中 : apr-util-1.5.2-6.el7.x86_64 4/5
验证中 : httpd-2.4.6-90.el7.centos.x86_64 5/5
已安装:
httpd.x86_64 0:2.4.6-90.el7.centos
作为依赖被安装:
apr.x86_64 0:1.4.8-5.el7 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-90.el7.centos mailcap.noarch 0:2.1.41-2.el7
完毕!
[[email protected] ~]# cd /var/www/html/
[[email protected] html]# ll
总用量 0
[[email protected] html]# vi index.html
[[email protected] html]# cat index.html
from 192.168.159.12
[[email protected] html]# service httpd start
Redirecting to /bin/systemctl start httpd.service
[[email protected] html]# systemctl start httpd
[[email protected] html]# netstat -natp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 192.168.159.100:80 192.168.159.1:56038 SYN_RECV -
tcp 0 0 192.168.159.100:80 192.168.159.1:56070 SYN_RECV -
tcp 0 0 192.168.159.100:80 192.168.159.1:56101 SYN_RECV -
tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN 5617/X
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 7636/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 5442/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 5405/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 5657/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 15887/sshd: [email protected]
tcp 0 36 192.168.159.12:22 192.168.159.1:52236 ESTABLISHED 15887/sshd: [email protected]
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::80 :::* LISTEN 16936/httpd
tcp6 0 0 :::6000 :::* LISTEN 5617/X
tcp6 0 0 :::22 :::* LISTEN 5442/sshd
tcp6 0 0 ::1:631 :::* LISTEN 5405/cupsd
tcp6 0 0 ::1:25 :::* LISTEN 5657/master
tcp6 0 0 ::1:6010 :::* LISTEN 15887/sshd: [email protected]
tcp6 0 0 192.168.159.12:80 192.168.159.1:56030 TIME_WAIT -
tcp6 0 0 192.168.159.100:80 192.168.159.1:56073 FIN_WAIT2 -
tcp6 0 0 192.168.159.100:80 192.168.159.1:56028 TIME_WAIT -
第二台 RIP服务器配置操作如下:
[[email protected] ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.159.13 netmask 255.255.255.0 broadcast 192.168.159.255
inet6 fe80::20c:29ff:fefe:f43b prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:fe:f4:3b txqueuelen 1000 (Ethernet)
RX packets 2896 bytes 201753 (197.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 329 bytes 39095 (38.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 19 base 0x2000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:98:fb:a9 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[[email protected] ~]# clear
[[email protected] ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.159.13 netmask 255.255.255.0 broadcast 192.168.159.255
inet6 fe80::20c:29ff:fefe:f43b prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:fe:f4:3b txqueuelen 1000 (Ethernet)
RX packets 2979 bytes 208124 (203.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 345 bytes 41563 (40.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 19 base 0x2000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:98:fb:a9 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[[email protected] ~]# echo 1 > /proc/sys/net/ipv4/conf/ens33/arp_ignore
[[email protected] ~]# echo 2 > /proc/sys/net/ipv4/conf/ens33/arp_announce
[[email protected] ~]# echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
[[email protected] ~]# echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
[[email protected] ~]# ifconfig lo:0 192.168.159.100 netmask 255.255.255.255
[[email protected] ~]# yum install httpd -y
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
12: Timeout on http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): extras/7/x86_64/primary_db | 153 kB 00:00:00
(2/2): updates/7/x86_64/primary_db | 5.8 MB 00:00:02
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-90.el7.centos 将被 安装
--> 正在处理依赖关系 httpd-tools = 2.4.6-90.el7.centos,它被软件包 httpd-2.4.6-90.el7.centos.x86_64 需要
--> 正在处理依赖关系 /etc/mime.types,它被软件包 httpd-2.4.6-90.el7.centos.x86_64 需要
--> 正在处理依赖关系 libaprutil-1.so.0()(64bit),它被软件包 httpd-2.4.6-90.el7.centos.x86_64 需要
--> 正在处理依赖关系 libapr-1.so.0()(64bit),它被软件包 httpd-2.4.6-90.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 apr.x86_64.0.1.4.8-5.el7 将被 安装
---> 软件包 apr-util.x86_64.0.1.5.2-6.el7 将被 安装
---> 软件包 httpd-tools.x86_64.0.2.4.6-90.el7.centos 将被 安装
---> 软件包 mailcap.noarch.0.2.1.41-2.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
===================================================================================================================================================================
Package 架构 版本 源 大小
===================================================================================================================================================================
正在安装:
httpd x86_64 2.4.6-90.el7.centos base 2.7 M
为依赖而安装:
apr x86_64 1.4.8-5.el7 base 103 k
apr-util x86_64 1.5.2-6.el7 base 92 k
httpd-tools x86_64 2.4.6-90.el7.centos base 91 k
mailcap noarch 2.1.41-2.el7 base 31 k
事务概要
===================================================================================================================================================================
安装 1 软件包 (+4 依赖软件包)
总下载量:3.0 M
安装大小:10 M
Downloading packages:
警告:/var/cache/yum/x86_64/7/base/packages/apr-1.4.8-5.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, ** ID f4a80eb5: NOKEY ] 0.0 B/s | 0 B --:--:-- ETA
apr-1.4.8-5.el7.x86_64.rpm 的公钥尚未安装
(1/5): apr-1.4.8-5.el7.x86_64.rpm | 103 kB 00:00:01
(2/5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:01
(3/5): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:01
(4/5): httpd-tools-2.4.6-90.el7.centos.x86_64.rpm | 91 kB 00:00:01
(5/5): httpd-2.4.6-90.el7.centos.x86_64.rpm | 2.7 MB 00:00:06
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计 482 kB/s | 3.0 MB 00:00:06
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 检索**
导入 GPG key 0xF4A80EB5:
用户ID : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
指纹 : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
软件包 : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : apr-1.4.8-5.el7.x86_64 1/5
正在安装 : apr-util-1.5.2-6.el7.x86_64 2/5
正在安装 : httpd-tools-2.4.6-90.el7.centos.x86_64 3/5
正在安装 : mailcap-2.1.41-2.el7.noarch 4/5
正在安装 : httpd-2.4.6-90.el7.centos.x86_64 5/5
验证中 : apr-1.4.8-5.el7.x86_64 1/5
验证中 : mailcap-2.1.41-2.el7.noarch 2/5
验证中 : httpd-tools-2.4.6-90.el7.centos.x86_64 3/5
验证中 : apr-util-1.5.2-6.el7.x86_64 4/5
验证中 : httpd-2.4.6-90.el7.centos.x86_64 5/5
已安装:
httpd.x86_64 0:2.4.6-90.el7.centos
作为依赖被安装:
apr.x86_64 0:1.4.8-5.el7 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-90.el7.centos mailcap.noarch 0:2.1.41-2.el7
完毕!
[[email protected] ~]# cd /var/www/html/
[[email protected] html]# ll
总用量 0
[[email protected] html]# vi index.html
[[email protected] html]# cat index.html
from 192.168.159.13
[[email protected] html]# systemctl start httpd
[[email protected] html]# netstat -natp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN 5612/X
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 7685/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 5432/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 5399/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 5651/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 15881/sshd: [email protected]
tcp 0 36 192.168.159.13:22 192.168.159.1:52237 ESTABLISHED 15881/sshd: [email protected]
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::80 :::* LISTEN 16933/httpd
tcp6 0 0 :::6000 :::* LISTEN 5612/X
tcp6 0 0 :::22 :::* LISTEN 5432/sshd
tcp6 0 0 ::1:631 :::* LISTEN 5399/cupsd
tcp6 0 0 ::1:25 :::* LISTEN 5651/master
tcp6 0 0 ::1:6010 :::* LISTEN 15881/sshd: [email protected]
tcp6 0 0 192.168.159.100:80 192.168.159.1:56102 FIN_WAIT2 -
tcp6 0 0 192.168.159.100:80 192.168.159.1:56072 FIN_WAIT2 -
tcp6 0 0 192.168.159.100:80 192.168.159.1:56037 FIN_WAIT2 -