Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群 (2)

Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群

日志

less /var/log/messages

Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群

Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群

查看ip地址

ip add

Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群

启动keepalived

Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群

检查防火墙是否关闭,backup机器同样需要关闭

iptables -nvL

getenforce

Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群

二、backup配置

关闭firewalld防火墙

Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群

backup 106上编辑配置文件,内容:

https://coding.net/u/aminglinux/p/aminglinux-book/git/blob/master/D21Z/backup_keepalived.conf获取

[root@davery01 ~]# vim /etc/keepalived/keepalived.conf 与主上IP地址有点不同,priority权重也不同90,主上是100

Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群

Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群

106上编辑监控脚本,内容:

https://coding.net/u/aminglinux/p/aminglinux-book/git/blob/master/D21Z/backup_check_ng.sh获取

vim /usr/local/sbin/check_ng.sh

Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群

Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群

给脚本755权限

chmod 777 /usr/local/sbin/check_ng.sh

Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群

106上也启动服务 systemctl start keepalived

Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群

这时候就配置完成了

在网页上输入主ip 192.168.1.101会出现如下内容

Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群

查看nginx的网页配置文件位置

ls /usr/local//nginx/conf/vhost/

Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群

测试高可用

先确定好两台机器上nginx差异,比如可以通过curl -I 来查看nginx版本

测试1:关闭master上的nginx服务

测试2:在master上增加iptabls规则 iptables -I OUTPUT -p vrrp -j DROP

测试3:关闭master上的keepalived服务

测试4:启动master上的keepalived服务

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzffxd.html