1、下载tar包

https://www.keepalived.org/download.html

2、编译安装

  1. # 解压
  2. tar -xvf keepalived-1.4.5.tar.gz -C /opt/keepalivedll
  3. # 安装依赖库
  4. yum install -y gcc openssl-devel popt-devel -y
  5. # 编译,-with-init=SYSV 编译生成启动脚本
  6. ./configure --prefix=/opt/keepalived -with-init=SYSV
  7. # 安装
  8. make && make install

3、运行前准备

  1. ln -s /opt/keepalived/etc/keepalived /etc/
  2. ln -s /opt/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
  3. ln -s /opt/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
  4. ln -s /opt/keepalived/sbin/ /sbin/
  5. chmod +x /opt/keepalived/etc/rc.d/init.d/keepalived

4、修改配置文件

vim /etc/keepalived/keepalived.conf

5、启动

  1. # 使用systemctl 管理需要将配置添加一个/etc/keepalived/keepalived.conf配置文件,可以执行
  2. # ln -s /opt/keepalived/etc/keepalived /etc/
  3. systemctl enable keepalived
  4. systemctl start keepalived