Keepalived是集群管理中保证集群高可用的一个服务软件,其功能类似于heartbeat,用来防止单点故障。
官网
Keepalived for Linuxhttps://www.keepalived.org/
安装
1、编译安装
下载地址:Keepalived for Linuxhttps://www.keepalived.org/download.html#
下载完成后,使用 ./configure 编译安装
注:
报错提示
configure: error:
!!! OpenSSL is not properly installed on your system. !!!
!!! Can not include OpenSSL headers files. !!!
解决方法:
yum install openssl-devel #安装依赖
2、yum安装
yum install keepalived
基本配置
使用yum安装后配置文件在
/etc/keepalived/keepalived.conf
这里我是两台机器配置
第一台机器
! Configuration File for keepalived
global_defs {
router_id lb001
}
vrrp_instance cper {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.111.138
}
}
第二台机器
! Configuration File for keepalived
global_defs {
router_id lb002
}
vrrp_instance cper {
state BACKUP
interface ens33
virtual_router_id 51
priority 50
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.111.138
}
}
启动命令
systemctl start keepalived