[root@lvs ~]# vi /etc/sysctl.conf
[root@lvs ~]# cat /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
net.ipv4.ip_forward = 1 //ip转发
[root@lvs ~]# sysctl -p
net.ipv4.ip_forward = 1
[root@lvs ~]# yum -y install ipvsadm
[root@lvs ~]# ipvsadm -A -t 192.168.136.130:80 -s rr
[root@lvs ~]# ipvsadm -a -t 192.168.136.130:80 -r 192.168.80.128 -m
[root@lvs ~]# ipvsadm -a -t 192.168.136.130:80 -r 192.168.80.130 -m
[root@lvs ~]# 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.136.130:80 rr
-> 192.168.80.128:80 Masq 1 0 0
-> 192.168.80.130:80 Masq 1 0 0
使用终端访问lvs ip——192.168.136.130
观察到前后两次访问内容有变化即成功配置——访问到两个网站
[root@lvs ~]# curl 192.168.136.130
Test Page for the Nginx HTTP Server on Red Hat Enterprise Linux
Welcome to nginx on Red Hat Enterprise Linux!
This page is used to test the proper operation of the
nginx HTTP server after it has been
installed. If you can read this page, it means that the
web server installed at this site is working
properly.
Website Administrator
This is the default index.html page that
is distributed with nginx on
Red Hat Enterprise Linux. It is located in
/usr/share/nginx/html.
You should now put your content in a location of
your choice and edit the root configuration
directive in the nginx
configuration file
/etc/nginx/nginx.conf.