keepalived 配置vip 漂移

安装keepalived

源码包安装keepalived

源码包下载安装
    [root@master src]# pwd
    /usr/local/src
    [root@master src]# wget http://www.keepalived.org/software/keepalived-2.0.7.tar.gz
    [root@master src]# tar xvf keepalived-2.0.7.tar.gz
    [root@master src]# cd keepalived-2.0.7
    [root@master keepalived-2.0.7]# ./configure --prefix=/usr/local/keepalived
    [root@master keepalived-2.0.7]# make && make install
完成后会在以下路径生成:
    /usr/local/etc/keepalived/keepalived.conf
    /usr/local/etc/sysconfig/keepalived
    /usr/local/sbin/keepalived
初始化及启动
    # keepalived启动脚本变量引用文件,默认文件路径是/etc/sysconfig/,也可以不做软链接,直接修改启动脚本中文件路径即可(安装目录下)
    [root@localhost /]# cp /usr/local/keepalived/etc/sysconfig/keepalived  /etc/sysconfig/keepalived 
    # 将keepalived主程序加入到环境变量(安装目录下)
    [root@localhost /]# cp /usr/local/keepalived/sbin/keepalived /usr/sbin/keepalived
    # keepalived启动脚本(源码目录下),放到/etc/init.d/目录下就可以使用service命令便捷调用
    [root@localhost /]# cp /usr/local/src/keepalived-2.0.7/keepalived/etc/init.d/keepalived  /etc/init.d/keepalived
    # 将配置文件放到默认路径下
    [root@localhost /]# mkdir /etc/keepalived
    [root@localhost /]# cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf

以上安装参考于:https://blog.csdn.net/bbwangj/article/details/80346428

报错

安装报错

1.1 configure: error: no acceptable C compiler found in $PATH

[root@localhost keepalived-1.3.5]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/keepalived-1.3.5':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

原因:安装GCC软件套件
yum install gcc

1.2 checking openssl/ssl.h usability... no

checking whether ETHERTYPE_IPV6 is declared... yes
checking openssl/ssl.h usability... no
checking openssl/ssl.h presence... no
checking for openssl/ssl.h... no
configure: error:
  !!! OpenSSL is not properly installed on your system. !!!
  !!! Can not include OpenSSL headers files.            !!!

原因:缺少openssl软件包
yum -y install openssl-devel

无法启动

  1. pdi file /var/run/keepalived.pid not readable (yet?) after start.

原因:存在僵尸进程pid。

杀掉僵尸进程
ps -ef|grep keepalived
 ps aux    | grep  keepalived  | grep -v grep | awk '{print $2}'| xargs kill
重启: systemctl keepalived restart
posted @   Lannister-leo  阅读(239)  评论(0编辑  收藏  举报
编辑推荐:
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· 现代计算机视觉入门之:什么是图片特征编码
阅读排行:
· 手把手教你在本地部署DeepSeek R1,搭建web-ui ,建议收藏!
· Spring AI + Ollama 实现 deepseek-r1 的API服务和调用
· 数据库服务器 SQL Server 版本升级公告
· C#/.NET/.NET Core技术前沿周刊 | 第 23 期(2025年1.20-1.26)
· 程序员常用高效实用工具推荐,办公效率提升利器!
点击右上角即可分享
微信分享提示