标签:lov doc ipaddress 路径 family virtual 查看 bin 拷贝
Keepalived安装教程
安装命令:yum install keepalived –y
查看版本:rpm –qa keepalived(只适合yum安装)
1、拷贝包keepalived-1.2.18.tar.gz到/usr/local/src目录下
2、进入/usr/local/src目录,并解压该压缩包
cd /usr/local/src
tar –zxvf keepalived-1.2.18.tar.gz
3、进入到解压后的keepalived-1.2.18目录
cd keepalived-1.2.18
4、编译和安装
./configure –preifx=/opt/keepalived(编译)
make && make install(安装执行完成后会在/opt下面生成keepalived目录)
5、进入/opt/keepalived目录,并执行如下指令
cd /opt/keepalived
cp /opt/keepalived/sbin/keepalived /usr/sbin/
cp /opt/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /opt/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
cp -r /opt/keepalived/etc/keepalived/ /etc/keepalived/
6、启动keepaliced服务并检查
启动命令:/etc/init.d/keepalived start
检查命令:ps –ef |grep keep|grep –v grep (有三个进程表示安装正确)
7、关闭keepalived服务
停止命令:/etc/init.d/keepalived stop(或者killall keepalived)
8、添加开机启动
chkconfig –add keepalived
配置文件路径为/etc/keepalived/keepalived.conf(注:不使用/opt/keepalived/)
! Configuration File for keepalived
global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id docker39
}
#**********以上这一段是配置全局定义,没什么用,就改一下rooter_id(服务器路由标识,在一个局域网内应该是唯一的。)就行 * ******************#
vrrp_instance VI_1 { #表示定义一个叫VI_1的实例
state MASTER #只有 MASTER和BACKUP两种状态
interface eth0 #网络通信接口,一般就是这个
virtual_router_id 50 #虚拟路由ID标识,最好是一个数字,在一个conf中是唯一的
priority 150 #定义优先级,一般MASTER比BACKUP要大50
advert_int 1 #定义同步时间间隔,默认为1秒
authentication { #定义的权限认证
auth_type PASS #有PASS和AH两种认证方式,官方推荐PASS
auth_pass 1111 #设置的密码,两台要一样
}
virtual_ipaddress { #配置虚拟IP的信息(IP,接口,label等)
172.25.2.222/24 dev eth0 label eth0:VIP
}
}
#***************以上是VRRP(虚拟路由冗余协议)实例定义区块********************#
配置完成之后,使用命令:/etc/init.d/keepalived start启动服务
查看是否有虚拟IP:ip addr|grep 172.25.2.222
1、先在MASTER上查看是否获得虚拟IP
2、停止keepalived服务,在BACKUP上面查看是否获得虚拟IP
3、重启MASTERkeepalived,看是否归还
标签:lov doc ipaddress 路径 family virtual 查看 bin 拷贝
原文地址:http://www.cnblogs.com/cf532088799/p/7425512.html