本帖最后由 巴黎的灯光下 于 2019-2-2 10:12 编辑
四 安装Keepalived4.1 下载[url=][/url]
1 [root@Master01 ~]# wget http://www.keepalived.org/software/keepalived-1.3.6.tar.gz 2 [root@Master01 ~]# tar -zvxf keepalived-1.3.6.tar.gz -C /tmp/ 3 [root@Master01 ~]# cd /tmp/keepalived-1.3.6 4 [root@Master01 keepalived-1.3.6]# ./configure --prefix=/usr/local/keepalived/ --sysconf=/etc --with-init=SYSV 5 #注:(upstart|systemd|SYSV|SUSE|openrc) #根据你的系统选择对应的启动方式 6 [root@Master01 keepalived-1.3.6]# make && make install 7 [root@Master01 ~]# ln -s /usr/local/keepalived/sbin/keepalived /sbin 8 [root@Master01 ~]# chmod u+x /etc/init.d/keepalived 9 [root@Master01 ~]# chkconfig --add keepalived 10 [root@Master01 ~]# chkconfig --level 35 keepalived on[url=][/url]
注意:Master02上也需要如上操作。 若出现以下提示,需要执行:yum -y install openssl-devel。 提示:也可采用yum install -y keepalived安装(个人不建议)。 4.2 Master01配置Keepalived默认情况下keepalived启动时会去/etc/keepalived目录下找配置文件。 [url=][/url]
1 [root@Master01 ~]# vim /etc/keepalived/keepalived.conf 2 ! Configuration File for keepalived 3 global_defs { 4 notification_email { 5 x120952576@126.com 6 #表示keepalived在发生诸如切换操作时发送Email给哪些地址,邮件地址可以多个,每行一个。 7 } 8 notification_email_from Alexandre.Cassen@firewall.loc 9 smtp_server 172.24.8.10 10 smtp_connect_timeout 30 11 router_id LVS_DEVEL 12 } 13 vrrp_instance VI_1 { 14 state BACKUP 15 interface eth0 16 virtual_router_id 51 17 #这里设置VRID,这里非常重要,相同的VRID为一个组,他将决定多播的MAC地址 18 priority 100 19 advert_int 1 20 nopreempt 21 #不抢占,只在优先级高的机器上设置即可,优先级低的机器不设置 22 authentication { 23 auth_type PASS 24 auth_pass 1111 25 } 26 track_script { 27 check_mysqld #执行定义的监控脚本 28 } 29 virtual_ipaddress { 30 172.24.8.12 31 } 32 } 33 vrrp_script check_mysqld { 34 script"/etc/keepalived/mysqlcheck/keepalived_check_mysql.sh " 35 interval 2 36 }[url=][/url]
|