标签:keepalived安装
路由映射:NAT 映射地址为:192.168.1.1
先安装支持软件:
kernel-devel、openssl-devel、popt-devel、ipvsadm
./configure --prefix=/ --with-kernel-dir=/usr/src/kernels/2.6.32-131.0.15.el6.i686
之间安装到根目录
看到
Keepalived configuration
------------------------
Keepalived version : 1.2.15
Compiler : gcc
Compiler flags : -g -O2
Extra Lib : -lssl -lcrypto -lcrypt
Use IPVS Framework : Yes
IPVS sync daemon support : Yes
IPVS use libnl : No
fwmark socket support : Yes
Use VRRP Framework : Yes
Use VRRP VMAC : Yes
SNMP support : No
SHA1 support : No
Use Debug flags : No
说明安装成功了。
make && make install
ls -l /etc/init.d/keepalived
chkconfig --add keepalived
chkconfig keepalived on
主服务器IP 192.168.74.130
备服务器ip192.168.74.128
漂移ip192.168.74.129
v 配置文件keepalived.conf
§ 全局设置:global_defs { ... }
§ 热备设置:vrrp_instance 实例名称 { ... }
§ 样例文件位于:/etc/keepalived/samples/...
v 主服务器配置
§ state:设置本节点状态,MASTER、SLAVE
§ priority:设置竞选优先级,数值越大优先级越高
§ virtual_ipaddress { ... }:设置漂移IP地址
[root@localhost ~]# vi /etc/keepalived/keepalived.conf
global_defs {
router_id HA_TEST_R1 //本服务器的名称
}
vrrp_instance VI_1 { //定义VRRP热备实例
state MASTER //MASTER表示主服务器
interface eth0 //承载VIP地址的物理接口
virtual_router_id 1 //虚拟路由器的ID号
priority 100 //优先级,数值越大优先级越高
advert_int 1 //通告间隔秒数(心跳频率)
authentication { //认证信息
auth_type PASS //认证类型
auth_pass 123456 //密码字串
}
virtual_ipaddress {
172.16.16.172 //指定漂移地址(VIP)
}
}
v 备用服务器配置
§ router_id设为自有名称
§ state设为SLAVE
§ priority值低于主服务器
—— 其余所有配置均与主服务器相同
[root@localhost ~]# vi /etc/keepalived/keepalived.conf
global_defs {
router_id HA_TEST_R2 //本服务器的名称
}
vrrp_instance VI_1 {
state SLAVE //SLAVE表示从服务器
interface eth0
virtual_router_id 1
priority 99 //优先级,低于主服务器
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
172.16.16.172
}
}
启动keepalived服务
service keepalived start
ip addr show dev eth0
主服务器会自动设置VIP地址
本文出自 “晴空” 博客,谢绝转载!
标签:keepalived安装
原文地址:http://7179867.blog.51cto.com/7169867/1627979