一、yum安装
1、安装Keepalived:
yum install -y keepalived
2、启动Keepalived服务:
systemctl start keepalived
3、设置Keepalived服务开机自启
systemctl enable keepalived
4、检查Keepalived服务状态:
systemctl status keepalived
二、源码(二进制)安装
1、安装依赖
yum -y install gcc openssl-devel libnfnetlink-devel libnl libnl-devel popt-devel make net-tools wget
2、安装包下载
mkdir -p /data/file #创建文件
cd /data/file #进入文件
wget https://keepalived.org/software/keepalived-2.2.7.tar.gz #下载
3、查看及解压
ll #查看
tar -zxf keepalived-2.2.7.tar.gz
4、编译
cd keepalived-2.2.7 #进入源码包
./configure --prefix=/usr/local/keepalived #编译
5、安装
make && make install
6、查找安装位置
find / -name keepalived
7、把 keepalived的启动文件复制到init.d下,加入开机启动项
cp /data/file/keepalived-2.2.7/keepalived/etc/init.d/keepalived /etc/rc.d/init.d/
8、复制启动服务至 /etc/sysconfig/
cp -r /data/file/keepalived-2.2.7/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
9、把 keepalived 加入系统命令目录
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
出现下面这几种情况,证明安装及配置都成功。因keepalived默认配置文件执行报错的原因
三、重点说明
1、如果你要使用Keepalived,你需要编辑/etc/keepalived/keepalived.conf
文件并授权chmod 644 keepalived.conf
2、书写keepalived.conf文件时一定要查询你当前服务器的网卡是多少,命令可以采用ip addr,这个是centos7的
3、具体的使用请看Redis主备及MySQL主备,如果还有疑问,请记得在评价里面说出问题,我好给你解决