一、优化参数
1、参数与linux参数优化一致
2、nginx的健康检查
二、keepalived介绍
1、keepalived服务介绍:
2、keepalived故障切换转移原理
3、VRRP协议介绍
4、keepalived工作原理
三、安装keepalived
1、官网地址:https://www.keepalived.org/;下载地址:https://www.keepalived.org/software/keepalived-2.1.2.tar.gz
wget https://www.keepalived.org/software/keepalived-1.2.16.tar.gz tar -zxvf keepalived-1.2.16.tar.gz cd keepalived-1.2.16 ./configure yum install -y gcc openssl-devel ./configure make make install
2、复制keepalived的启动文件
[root@computer sbin]# cp /usr/local/sbin/keepalived /etc/init.d/
3、复制配置文件
[root@computer sbin]# cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/
4、创建默认路径
[root@computer sbin]# mkdir /etc/keepalived
5、模板拷贝
[root@computer sbin]# cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/
6、拷贝
[root@computer sbin]#cp /usr/local/sbin/keepalived /usr/sbin/
7、模板
8、keepalived+nginx高可用(服务器级别的)
1、拓扑图
keepalived主配置文件:
keepalived从配置文件:
keepalived添加vip地址
删除地址
验证vip IP在哪台机器上
9、写个脚本完善,每个5秒检测nginx服务,宕掉就把keepalived服务停掉。
四、裂脑
1、原因
2、解决裂脑的思路
3、硬件设备解决思路:备节点发现主节点挂了,就把主节点的电源断掉,让主节点彻底宕机。
4、脚本检测裂脑
五、keepalived日志
默认记录在系统日志里面
1、修改记录日志位置
重启服务
六、keepalivd多实例配置