一、软件安装
yum install -y keepalived
二、查询已安装的软件及路径
rpm -qc keepalived
/etc/keepalived/keepalived.conf
/etc/sysconfig/keepalived
三、配置抢占式高可用
抢占式主配置
vim /etc/keepalived/keepalived.conf
global_defs {
router_id keepalived01
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 50
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.3
}
}
抢占式备配置
vim /etc/keepalived/keepalived.conf
global_defs {
router_id keepalived02
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 50
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.3
}
}
四、配置非抢占式高可用
非抢占式主配置
vim /etc/keepalived/keepalived.conf
global_defs {
router_id keepalived01
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 50
priority 150
nopreempt
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.3
}
}
非抢占式备配置
vim /etc/keepalived/keepalived.conf
global_defs {
router_id keepalived02
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 50
priority 100
nopreempt
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.3
}
}
网友评论