Keepalived高可用集群
Keepalived高可用集群
keepalived高可用集群是指一个主服务器,一个备份服务器,共同使用一个虚拟的ip地址,当主服务器宕掉之后,备份服务器开始工作,这样就避免了访问事故。
搭建keepalived高可用集群
[master]
#yum -y install keepalived
#vim /etc/keepalived/keepalived.conf
vrrp_instance webha {
state MASTER 主服务器
interface eth0 网卡口
priority 130 优先级
authentication {
auth_type PASS
auth_pass 123456 主、备密码相同
}
virtual_ipaddress {
192.168.4.251 虚拟的网络地址
}
}
#service keepalived start
#chkconfig keepalived on 开机自启
#chkconfig --list | grep keepalived
#ip add show | grep 192.168.4 查看虚拟ip在哪台服务器上
[slave]
#vim /etc/keepalived/keepalived.conf
vrrp_instance webha {
state SLAVE/BACKUP 备份服务器
interface eth0 网卡口
priority 130 优先级
authentication {
auth_type PASS
auth_pass 123456 主、备密码相同
}
virtual_ipaddress {
192.168.4.251 虚拟的网络地址
}
}
#service keepalived start
#curl http://192.168.4.251
网页题目:Keepalived高可用集群
网站网址:http://scyanting.com/article/jsepid.html