KeepAlive安装以及简单配置

操作系统:Centos7.3

一.依赖安装

首先安装相关依赖:

yum install -y gcc openssl-devel popt-devel
yum -y install libnl libnl-devel
yum install -y libnfnetlink-devel

基本依赖就安装完毕了,如果还缺少什么依赖在下一步编译的时候会有warning,百度去解决就好了

二.编译安装源码

首先下载源码到指定目录:

cd /usr/local/src
wget http://www.keepalived.org/software/keepalived-1.3.4.tar.gz

然后解压,配置

tar zxvf keepalived-1.3.4.tar.gz 
cd keepalived-1.3.4
./configure --prefix=/usr/local/keepalived

之后编译

make  
make install

注意这一步make之后可能会有warning,一般都是缺少依赖造成的,把warning关键字百度一下去yum安装对应依赖就可以了

三.修改配置文件地址

安装完成后,keepalived的默认配置文件地址和我们安装的地址不一样,所以cp过去就可以了

cp ../keepalived-1.3.4/keepalived/etc/init.d/keepalived /etc/init.d/
mkdir /etc/keepalived
cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp keepalived-1.3.4/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/

之后只要修改/etc/keepalived/ 目录下的keepalived.conf配置文件就可以了

使用service start keepalived启动服务

四.附keepalived简单配置文件

! Configuration File for keepalived

global_defs {
   router_id lb01 #设置本机路由id,做区分的
}

vrrp_instance VI_1 {
    state MASTER #主从标记,仅做标识
    interface eth0 #虚拟路由的网卡名
    virtual_router_id 51 #虚拟路由路由id,想要配置在同一个虚拟ip必须要有相同id
    priority 150 #优先级,优先级最高的自动为主机,主机宕机后按照优先级选择热备从机
    advert_int 1 #主备通讯时间间隔
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
         172.17.0.199 #配置到哪个虚拟ip,这里我是在docker中,所以是这个docker的默认网段的一个ip,主备机这个地方ip要相同
    }
}
版权声明:除特殊说明,博客文章均为intotw原创,依据CC BY-SA 4.0许可证进行授权,转载请附上出处链接及本声明。
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
下一篇