keepalived1.3.5编译安装

环境:centos7.5 keepalived1.3.5
下载地址:https://www.keepalived.org/software/keepalived-1.3.5.tar.gz

cd /app
tar -xvf keepalived-1.3.5.tar.gz
cd keepalived-1.3.5/
./configure --prefix=/usr/local/keepalived
yum -y install libnl libnl-devel
./configure --prefix=/usr/local/keepalived
yum install -y libnfnetlink-devel
./configure --prefix=/usr/local/keepalived
make && make install
cp ./keepalived-1.3.5/keepalived/etc/init.d/keepalived /etc/init.d/
cp  /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp ./keepalived-1.3.5/keepalived/etc/sysconfig/keepalived /etc/sysconfig/keepalived
#这样就可以执行service keepalived [start | stop | reload | restart ]命令
#修改/usr/lib/systemd/system/keepalived.service
cat /usr/lib/systemd/system/keepalived.service
[Unit]
Description=LVS and VRRP High Availability Monitor
After=syslog.target network-online.target

[Service]
Type=forking
PIDFile=/var/run/keepalived.pid
KillMode=process
EnvironmentFile=-/usr/local/keepalived/etc/sysconfig/keepalived
ExecStart=/usr/local/keepalived/sbin/keepalived -f /etc/keepalived/keepalived.conf $KEEPALIVED_OPTIONS
#ExecStart=/usr/local/keepalived/sbin/keepalived $KEEPALIVED_OPTIONS
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

测试:

cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
   router_id http_test3
}

vrrp_instance VI_1 {
    # MASTER表示是主节点,备份节点是BACKUP
    state MASTER
    # 网卡名称,这个不同的服务器,可能有所不同
    interface ens192
    # 路由标识,MASTER和BACKUP节点的该值要保持一致
    virtual_router_id 99
    # 优先级,MASTER节点的值必须大于BACKUP的值
    priority 100
    # MASTER与BACKUP同步的时间间隔,单位为秒
    advert_int 1
    # lvs对应的真实IP
    #mcast_src_ip=192.168.50.154
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    # 虚拟IP的址
    virtual_ipaddress {
        192.168.50.185
    }
}

virtual_server 192.168.50.185 8222 {
    # 健康检查的时间,单位为秒
    delay_loop 6
    # 负载调度算法,这里设置为rr,即轮询算法
    lb_algo rr
    # 设置DR模式
    lb_kind DR
    # 虚拟地址的子网掩码
    nat_mask 255.255.255.0
    # 会话保持时间,单位为秒
    persistence_timeout 50
    protocol TCP

    # 配置真实服务器信息
    real_server 192.168.50.156 8222 {
        # 节点的权值
        weight 1
        TCP_CHECK {
            # 超时时间
            connect_timeout 3
            # 重试次数
            nb_get_retry 3
            # 重试间隔
            delay_before_retry 3
        }
    }

    real_server 192.168.50.157 8222 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}

搭建过程中出现的错误:
查看/var/log/messager中的错误。可以试着取修改pid的文件路径,再重启,一定要将重启失败的keepalived进程杀掉。也有可能是因为keealived版本和centos版本,导致keepalived.conf文件中,一些keyword是无效的。
参考:https://blog.csdn.net/liyuling52011/article/details/80032317

相关推荐

  1. keepalived1.3.5编译安装

    2024-04-25 22:18:03       34 阅读
  2. ubuntu20.04-编译安装Qt5.15.2-C++

    2024-04-25 22:18:03       58 阅读
  3. 在Ubuntu20.04.6上编译Qt5.15.2源码并安装

    2024-04-25 22:18:03       32 阅读
  4. linux 编译安装libzmq

    2024-04-25 22:18:03       53 阅读
  5. 库的编译安装

    2024-04-25 22:18:03       63 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-25 22:18:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-25 22:18:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-04-25 22:18:03       82 阅读
  4. Python语言-面向对象

    2024-04-25 22:18:03       91 阅读

热门阅读

  1. Netbox 4 VMware OVF快速部署

    2024-04-25 22:18:03       31 阅读
  2. HOT100与剑指Offer

    2024-04-25 22:18:03       33 阅读
  3. C#中的委托

    2024-04-25 22:18:03       27 阅读
  4. MySql CPU激增原因分析

    2024-04-25 22:18:03       33 阅读