keepalived双机热备份

一,安装keepalived和LVS
[root@centos1 ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@centos1 ~]# yum -y install ipvsadm keepalived
在这里插入图片描述
2)设置服务开机自启
[root@centos1 ~]# chkconfig --level 35 keepalived on
3)备份主配置文件
[root@centos1 ~]# cp /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bak
4)编辑主配置文件
[root@centos1 ~]# vim /etc/keepalived/keepalived.conf
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
5)启动服务
[root@centos1 ~]# systemctl start keepalived
4、配置双机热备备份节点
1)安装LVS和keepalived
[root@centos2 ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@centos2 ~]# yum -y install ipvsadm keepalived
在这里插入图片描述

2)设置服务开机自启
[root@centos2 ~]# chkconfig --level 35 keepalived on
3)备份主配置文件
[root@centos2 ~]# cp /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bak
4)编辑主配置文件
[root@centos2 ~]# vim /etc/keepalived/keepalived.conf
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
5)启动服务
[root@centos2 ~]# systemctl start keepalived
安装httpd服务
[root@centos3 ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@centos3 ~]# yum -y install httpd
在这里插入图片描述

[root@centos4 ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@centos4 ~]# yum -y install httpd
在这里插入图片描述

2)写入测试数据
[root@centos3 ~]# echo “www.benet.com” > /var/www/html/index.html
[root@centos4 ~]# echo “www.accp.com” > /var/www/html/index.html
3)启动服务并设置开机自启
[root@centos3 ~]# systemctl start httpd

[root@centos3 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

[root@centos4 ~]# systemctl start httpd

[root@centos4 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
生成虚拟网卡监听地址为lvs服务器的vip地址
[root@centos3 ~]# cp /etc/sysconfig/network-scripts/ifcfg-lo /etc/sysconfig/network-scripts/ifcfg-lo:0
[root@centos3 ~]# vim /etc/sysconfig/network-scripts/ifcfg-lo:0
DEVICE=lo:0
IPADDR=192.168.100.200
NETMASK=255.255.255.255
ONBOOT=yes
重启网卡
[root@centos3 ~]# systemctl restart network
修改内核参数
[root@centos3 ~]# vim /etc/sysctl.conf
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.default.arp_ignore = 1
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2

[root@centos4 ~]# sysctl -p
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.default.arp_ignore = 1
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2

在这里插入图片描述
在这里插入图片描述
6 、配置nfs
1)安装nfs系统
[root@centos5 ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@centos5 ~]# yum -y install rpcbind nfs-utils
在这里插入图片描述

2)创建共享网站根目录文件
[root@centos5 ~]# mkdir /web
[root@centos5 ~]# echo “www.nfs.com” > /web/index.html
3)修改nfs主配置文件共享/web目录,允许100.10和20读取共享目录数据rw读取和写入
[root@centos5 ~]# vim /etc/exports
/web 192.168.100.10(ro) 192.168.100.20(ro)
4)启动nfs服务
[root@centos5 ~]# systemctl start rpcbind
[root@centos5 ~]# systemctl start nfs
[root@centos5 ~]# systemctl enable nfs
[root@centos5 ~]# systemctl enable rpcbind
5)查看共享目录
[root@centos5 ~]# showmount -e 192.168.100.30
Export list for 192.168.100.30:
/web 192.168.100.20,192.168.100.10

6)设置开机自动挂载
[root@centos5 ~]# vim /etc/fstab
192.168.100.30:/web /var/www/html nfs defaults 0 0
[root@centos5 ~]# reboot
[root@centos5 ~]# vim /etc/fstab
192.168.100.30:/web /var/www/html nfs defaults 0 0
[root@centos5 ~]# reboot
验证:
在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值