Keepalived实现双机热备
Posted 静小妞
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Keepalived实现双机热备相关的知识,希望对你有一定的参考价值。
一、主机从机都安装keepalived
1.安装yum install -y keepalived2.备份cd /etc/keepalived
cp keepalived.conf keepalived.conf.back
二、主机配置并启动
1.创建配置文件echo "! Configuration File for keepalived
#主机配置
global_defs {
#id,主从不同
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
#主机设置为MASTER
state MASTER
#网卡1
interface eth0
#主从id要一样
virtual_router_id 51
#主机权重高于从机
priority 80
#广播时间,1秒
advert_int 1
#配置主从要一样
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
#虚拟的ip,多个ip换行写即可
192.168.1.237
}
}
">./keepalived.conf2.启动keepalived -d -f /etc/keepalived/keepalived.conf
二、从机配置
1.创建配置文件echo "! Configuration File for keepalived
#主机配置
global_defs {
#id,主从不同
router_id LVS_DEVEL2
}
vrrp_instance VI_1 {
#从机设置为BACKUP
state BACKUP
#网卡1
interface eth0
#主从id要一样
virtual_router_id 51
#主机权重高于从机
priority 20
#广播时间,1秒
advert_int 1
#配置主从要一样
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
#虚拟的ip,多个ip换行写即可 主从一致
192.168.1.237
}
}
">./keepalived.conf2.启动从机keepalived -d -f /etc/keepalived/keepalived.conf完成,访问192.168.1.237,其中一台机器断开在访问依然不会崩掉!注意2台机器的防火墙要关掉!
以上是关于Keepalived实现双机热备的主要内容,如果未能解决你的问题,请参考以下文章