lvs的nat模式httpd /httpds

lvs的nat模式httpd /httpds

[root@localhost network-scripts]# vim ifcfg-ens160 

TYPE=Ethernet
BOOTPROTO=static
NAME=ens160
DEVICE=ens160
ONBOOT=yes
IPADDR0=192.168.11.150
NETMASK0=255.255.255.0
GATEWAY0=192.168.11.2
IPADDR1=192.168.11.250
NETMASK1=255.255.255.0

//重启网卡

[root@localhost network-scripts]# systemctl restart NetworkManager
[root@localhost network-scripts]# ifdown ens160; ifup ens160

[root@localhost network-scripts]# vim ifcfg-ens160 

TYPE=Ethernet
BOOTPROTO=static
NAME=ens160
DEVICE=ens160
ONBOOT=yes
IPADDR0=192.168.11.148
NETMASK0=255.255.255.0
GATEWAY0=192.168.11.150
[root@localhost network-scripts]# ifdown ens160;ifup ens160

[root@localhost network-scripts]# yum -y install net-tools
//开启转发功能
[root@localhost network-scripts]# vim  etc/sysctl.conf
net.ipv4.ip_forward = 1

//重新读取

[root@localhost ~]# sysctl -p
net.ipv4.ip_forward = 1
//添加规则 调度器
[root@localhost ~]# ipvsadm -A -t 192.168.11.250:80 -s rr
[root@localhost ~]# 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.11.250:80 rr
[root@localhost ~]# ipvsadm -a -t 192.168.11.250:80 -r 192.168.11.148:80 -m
[root@localhost ~]# ipvsadm -a -t 192.168.11.250:80 -r 192.168.11.146:8080 -m


保持
[root@localhost ~]# ipvsadm -Sn > /etc/sysconfig/ipvsadm
[root@localhost ~]# cat /etc/sysconfig/ipvsadm
-A -t 192.168.11.250:80 -s rr
-a -t 192.168.11.250:80 -r 192.168.11.146:8080 -m -w 1
-a -t 192.168.11.250:80 -r 192.168.11.148:80 -g -w 1
[root@localhost ~]# 

[root@localhost html]# echo 'esl' > index.html

[root@localhost html]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@localhost html]# 

//关闭防火墙和seliunx
[root@localhost html]# systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost html]# setenforce 0
[root@localhost ~]# curl  http://192.168.11.250
rs2
[root@localhost ~]# curl  http://192.168.11.250
esl
[root@localhost ~]# curl  http://192.168.11.250
rs2
[root@localhost ~]# curl  http://192.168.11.250
esl
[root@localhost ~]# curl  http://192.168.11.250
rs2
[root@localhost ~]# curl  http://192.168.11.250
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens160 

TYPE=Ethernet
BOOTPROTO=static
NAME=ens160
DEVICE=ens160
ONBOOT=yes
IPADDR0=192.168.11.148
NETMASK0=255.255.255.0
GATEWAY0=192.168.11.2
~          
[root@localhost ~]# vim /etc/sysctl.conf 
 net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
[root@localhost ~]# sysctl  -p
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
[root@localhost ~]# 
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens1
IPADDR1=192.168.11.250
NETMASK1=255.255.255.0
~                      

在这里插入图片描述
在这里插入图片描述

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens160 
GATEWAY0=192.168.11.2
//修改内核
 [root@localhost ~]# echo 'net.ipv4.conf.all.arp_ignore = 1'>> /etc/sysctl.conf
 [root@localhost ~]# echo 'net.ipv4.conf.all.arp_announce = 2' >> /etc/sysctl.conf
           
[root@localhost ~]# sysctl -p
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
[root@localhost ~]# 
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens160 

TYPE=Ethernet
BOOTPROTO=static
NAME=ens160
DEVICE=ens160
ONBOOT=yes
IPADDR0=192.168.11.146
NETMASK0=255.255.255.0
GATEWAY0=192.168.11.2
IPADDR1=192.168.11.250
NETMASK1=255.255.255.0
~                      

[root@localhost ~]# ifdown ens160;ifup ens160
[root@localhost ~]# ipvsadm -A -t 192.168.11.250:80 -s rr
[root@localhost ~]# ipvsadm -a -t 192.168.11.250:80 -r 192.168.11.148:80 -g 
[root@localhost ~]# ipvsadm -a -t 192.168.11.250:80 -r 192.168.11.146:8080 -g 
[root@localhost ~]# 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.11.250:80 rr
  -> 192.168.11.146:80            Route   1      0          0         
  -> 192.168.11.148:80            Route   1      0          0         
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值