LVS负载均衡群集

centos01网站配置,挂载光盘
[root@centos01 ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
2)安装httpd
[root@centos01 ~]# yum -y install httpd
3)编辑网站主页
[root@centos01 ~]# echo “www.benet.com” > /var/www/html/index.html
4)开启服务设置开机自启
[root@centos01 ~]# systemctl start httpd
[root@centos01 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
centos02网站配置,挂载光盘

[root@centos02 ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
8)安装httpd
[root@centos02 ~]# yum -y install httpd
9)编辑网站主页
[root@centos02 ~]# echo “www.accp.com” > /var/www/html/index.html
10)开启服务设置开机自启
[root@centos02 ~]# systemctl start httpd
[root@centos02 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
安装LVS群集
1)挂载光盘
[root@centos04 ~]# mount /dev/cdrom /mnt/
'mount: /dev/sr0 写保护,将以只读方式挂载
2)安装LVS
[root@centos04 ~]# yum -y install ipvsadm
3)设置服务开机自启
[root@centos04 ~]# systemctl enable ipvsadm
Created symlink from /etc/systemd/system/multi-user.target.wants/ipvsadm.service to /usr/lib/systemd/system/ipvsadm.service.
4)查看LVS规则
[root@centos04 ~]# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
5)清空规则并保存
[root@centos04 ~]# ipvsadm -C
[root@centos04 ~]# ipvsadm-save
3、配置NAT模式的LVS
1)配置调度服务器ip地址为192.168.200.10:80端口算法使用轮询
[root@centos04 ~]# ipvsadm -A -t 192.168.200.10:80 -s rr
2)调度服务器添加物理服务器100.10和20的80端口映射到vip地址192.168.200.10的80
[root@centos04 ~]# ipvsadm -a -t 192.168.200.10:80 -r 192.168.100.10:80 -m -w 1
[root@centos04 ~]# ipvsadm -a -t 192.168.200.10:80 -r 192.168.100.20:80 -m -w 1
3)保存配置
[root@centos04 ~]# ipvsadm-save
-A -t centos04:http -s rr
-a -t centos04:http -r 192.168.100.10:http -m -w 1
-a -t centos04:http -r 192.168.100.20:http -m -w 1
在这里插入图片描述
centos1查看日志
在这里插入图片描述

在这里插入图片描述
centos2查看日志
在这里插入图片描述

安装nfs系统
[root@centos03 ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@centos03 ~]# yum -y install rpcbind nfs-utils
2)创建共享网站根目录文件
[root@centos03 ~]# mkdir /web
[root@centos03 ~]# echo “www.nfs.com” > /web/index.html
3)修改nfs主配置文件共享/web目录,允许100.10和20读取共享目录数据rw读取和写入
[root@centos03 ~]# vim /etc/exports
/web 192.168.100.10(ro) 192.168.100.20(ro)
4)启动nfs服务
[root@centos03 ~]# systemctl start rpcbind
[root@centos03 ~]# systemctl start nfs
[root@centos03 ~]# systemctl enable nfs
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
[root@centos03 ~]# systemctl enable rpcbind
5)查看共享目录
在这里插入图片描述6)挂载共享目录到网站服务器根
[root@centos02 ~]# mount 192.168.100.30:/web /var/www/html/
[root@centos02 ~]# cat /var/www/html/index.html
www.nfs.com
7)外部客户端访问
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值