软件仓
zookeeper操作
zookeeper单机安装
zookeeper集群安装
keeplived安装
Tomcat安装
Tomcat配置
tomcat问题
Ftp操作
proftpd文件共享
vsftpd文件共享
NFS文件共享(挂载)
NFS问题
ISCSI网络存储
Samba服务器
Rsync文件同步
Inotify工具
Inotify+Rsync脚本
DHCP服务器
DNS服务器
从DNS服务器
Etcd常用操作
etcd api常用操作
etcd 备份与恢复
Etcd web管理界面
etcd集群搭建
etcd集群管理
Screen终端软件
NTP时间服务
本文档使用MrDoc发布
返回首页
-
+
keeplived安装
2020年2月14日 16:28
admin
##方法一: ###下载网址 https://www.keepalived.org/download.html ./configure --prefix=/ \ --mandir=/usr/local/share/man \ --with-kernel-dir=/usr/src/kernels/2.6.9-67.EL-smp-i686/ make make install ##方法二: ###安装 yum -y install keepalived ###启动与停止 systemctl start keepalived.service systemctl status keepalived.service ###修改主配置 vim /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } notification_email_from Alexandre.Cassen@firewall.loc smtp_server 192.168.200.1 smtp_connect_timeout 30 router_id MySQL1 vrrp_skip_check_adv_addr vrrp_garp_interval 0 vrrp_gna_interval 0 } vrrp_script check_nginx { script "/etc/keepalived/nginx_check.sh" interval 2 } vrrp_instance VI_1 { state BACKUP #角色 interface ens33 #绑定网卡 virtual_router_id 60 priority 100 #优先级,越高为主 advert_int 1 nopreempt #非抢占模式 authentication { auth_type PASS auth_pass 1qaz@WSX } track_script { check_nginx #监控脚本 } virtual_ipaddress { 192.168.31.240 } } ####主脚本 vim /etc/keepalived/nginx_check.sh #!/bin/bash Ng=`ps -C nginx --no-header | wc -l` if [ $Ng -eq 0 ];then pkill keepalived fi ###修改从配置 vim /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } notification_email_from Alexandre.Cassen@firewall.loc smtp_server 192.168.200.1 smtp_connect_timeout 30 router_id MySQL1 vrrp_skip_check_adv_addr vrrp_garp_interval 0 vrrp_gna_interval 0 } vrrp_script check_nginx { script "/etc/keepalived/nginx_check.sh" interval 2 } vrrp_instance VI_1 { state BACKUP #角色 interface ens33 #绑定网卡 virtual_router_id 60 priority 90 #优先级,越高为主 advert_int 1 nopreempt #非抢占模式 authentication { auth_type PASS auth_pass 1qaz@WSX } track_script { check_nginx #监控脚本 } virtual_ipaddress { 192.168.31.240 } } ####从脚本 vim /etc/keepalived/mysql_down.sh #!/bin/bash Ng=`ps -C nginx --no-header | wc -l` if [ $Ng -eq 0 ];then pkill keepalived fi ###keepalived配置,解决vip无法ping通,虚拟服务器端口无法访问的问题 keepalived.conf中vip配置好后,通过ip addr可以看到vip已经顺利挂载,但是无法ping通,并且防火墙都已关闭,**原因是keepalived.conf配置中默认vrrp_strict打开了,需要把它注释掉。重启keepalived即可ping通。**
分享到: