1 installation of necessary related packages
Yum-y Install kernel-devel openssl* popt popt-devel
2 Download and install
wget http://www.keepalived.org/software/keepalived-1.2.9.tar.gz
TAR-XF keepalived-1.2.9.tar.gz
Mkdir/usr/local/keepalived
CD ~/keepalived-1.2.9
./configure--prefix=/usr/local/keepalived/
Make && make install
cp/usr/local/keepalived/sbin/keepalived/usr/sbin/
Cp/usr/local/keepalived/etc/sysconfig/keepalived/etc/sysconfig
cp/usr/local/keepalived/etc/rc.d/init.d/keepalived/etc/init.d/
chmod +x/etc/init.d/keepalived
Mkdir/etc/keepalived
Cp/usr/local/keepalived/etc/keepalived/keepalived.conf/etc/keepalived
3 Modify the configuration file as follows
[Email protected] ~]# vim/etc/keepalived/keepalived.conf
Global_defs {
Notification_email {
[Email protected]
}
Notification_email_from [email protected]
Smtp_server smtp.126.com # Mail server address
Smtp_connect_timeout 30 # Connection time-out
router_id Lvs_master
}
Vrrp_script Chk_http_port {
Script "/etc/keepalived/check_haproxy.sh" # Haproxy Run detection script [haproxy restart Haproxy service]
Interval 5 # Script execution interval
WEIGHT-5 # Priority change after script execution: 5 means priority +5;-5 is priority-5
}
Vrrp_instance Vi_a {
State MASTER # Lord This value is master, from top to backup
Interface eth0
VIRTUAL_ROUTER_ID 50 # This value must be consistent between master and slave
Priority 100
Advert_int 1
Authentication {# Authentication two parameter values, master and slave must also be consistent
Auth_type PASS
Auth_pass Yiban
}
Track_script {
Chk_http_port
}
virtual_ipaddress {
192.168.78.220
}
}
5 Start keepalived
Ensure network uptime
Service Network Restart (do not do this on line)
/etc/init.d/keepalived start
View Results
IP A
This article is from the "Snow Cane Six" blog, please be sure to keep this source http://879100963.blog.51cto.com/6686639/1705086
MySQL Cluster keepalived simple setup