Lvs-nat负载

1 篇文章 0 订阅

在这里插入图片描述
P1作为负载调度器
增加一块网卡
在这里插入图片描述
P2P3作为realserver也分别增加一枚网卡
在这里插入图片描述

1、配置好IP并测试

2、配置时间同步

服务器端

[root@localhost ~]# vim /etc/chrony.conf
server 192.168.226.130 iburst
allow 192.168.226.0/24
local stratum 10
[root@localhost ~]# systemctl restart chronyd

客户端

 [root@localhost ~]# vim /etc/chrony.conf
 server 192.168.226.130 iburst
[root@localhost ~]# systemctl restart chronyd
[root@localhost ~]# chronyc sources

在这里插入图片描述

3、负载调度器

1)开启路由转发功能
在这里插入图片描述

永久开启
 [root@localhost ~]# echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
生效
[root@localhost ~]# sysctl -p
net.ipv4.ip_forward = 1

4、准备rs环境

本地rpm包
在这里插入图片描述

[root@localhost ~]# ls
nginx-1.10.0-1.el7.ngx.x86_64.rpm
[root@localhost ~]# yum install nginx-1.10.0-1.el7.ngx.x86_64.rpm -y

[root@localhost ~]# cd /usr/share/nginx/html/
[root@localhost html]# ls 
50x.html  index.html
[root@localhost html]# mv index.html{,.bak}
[root@localhost html]# echo "web1 test page" > index.html
开启服务
[root@localhost html]# systemctl enable --now nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service        to /usr/lib/systemd/system/nginx.service.
本地测试
 [root@localhost html]# curl localhost
web1 test page
rs2,rs3:
[root@localhost html]# echo "web2 test page" > index.html
[root@localhost html]# echo "web3 test page" > index.html

5、lvs-nat负载配置

1)安装ipvsadm

  yum install -y ipvsadm

2)配置

ipvsadm -A -t 192.168.226.130:80 -s rr
ipvsadm -a -t 192.168.226.130:80 -r 192.168.226.131:80 -m
ipvsadm -a -t 192.168.226.130:80 -r 192.168.226.132:80 -m

查看

[root@localhost ~]# ipvsadm -l
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.226.130:http rr
-> 192.168.226.131:http         Masq    1      0          0         
-> 192.168.226.132:http         Masq    1      0          0         

在这里插入图片描述
3)测试
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值