centos6 安装 keepalived
Posted shijiu520
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos6 安装 keepalived相关的知识,希望对你有一定的参考价值。
安装keepalived
yum -y install kernel-devel
ln -s /usr/src/kernels/2.6.32-642.15.1.el6.x86_64/ /usr/src/linux
cd /usr/local/src/
wget http://www.keepalived.org/software/keepalived-1.2.20.tar.gz
tar -zxvf keepalived-1.2.20.tar.gz
cd keepalived-1.2.20
./configure
make && make install
生成keepalived 的启动命令
cp /usr/local/etc/rc.d/init.d/keepalived /etc/init.d/
配置启动脚本的参数:
cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/
配置文件默认路径:
mkdir /etc/keepalived
拷贝配置文件到默认路径:
cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/sbin/keepalived /usr/sbin/
/etc/init.d/keepalived start
ps -ef |grep keepalived
cd /etc/keepalived/
cp keepalived.conf keepalived.conf.default
vim keepalived.conf
: notification_email {
[email protected]
}
router_id LVS_01
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.1.190/24 (2台机都一样,是ip addr 添加的虚拟IP)
}
}
/etc/init.d/keepalived start
ip addr add 192.168.1.190/24 dev eth0
ip addr
ip add|grep 192.168.1.190(只能在一台机有结果输出,不然就是裂脑了)
可以ping 同主,backup 有VIP(虚拟IP) 就认为是裂脑了
以上是关于centos6 安装 keepalived的主要内容,如果未能解决你的问题,请参考以下文章