一、keepalived介绍及搭建环境说明
1、The keepalived The keepalived server implements the vrrpd routing demon which enables
routing failover for a pair (or set) of routers (or LVS directors) and the keepalived
demon which sets up and does the health checking of virtual services in a Linux Virtual Servier.
keepalived使用的vrrp协议方式,虚拟路由冗余协议 (Virtual Router Redundancy Protocol,简称VRRP)
3、master/slave ip和版本和虚拟ip
1)master ip
10.1.10.117
2)master version
cat /etc/debian_version
7.8
3)slave ip
10.1.10.250
4)slave version
cat /etc/debian_version
5.0.1
5)virtual ip
10.1.10.240
二、debian下安装和配置keepalived
1、先查询下
apt-cache search keepalived
keepalived - Failover and monitoring daemon for LVS clusters
11、查看启动日志(master/slave)
1)cat /var/log/keepalived(master这里只截取部分日志信息)
May 25 01:50:10 debian Keepalived: Starting Keepalived v1.2.2 (12/18,2011)
May 25 01:50:10 debian Keepalived: Starting Healthcheck child process, pid=3323
May 25 01:50:10 debian Keepalived: Starting VRRP child process, pid=3324
May 25 01:50:10 debian Keepalived_vrrp: Netlink reflector reports IP 10.1.10.117 added
May 25 01:50:11 debian Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATE
May 25 01:50:12 debian Keepalived_vrrp: VRRP_Instance(VI_1) Entering MASTER STATE
May 25 01:50:12 debian Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 10.1.10.240
May 25 01:50:12 debian Keepalived_healthcheckers: Netlink reflector reports IP 10.1.10.240 added
2)cat /var/log/keepalived(slave这里只截取部分日志信息)
May 25 01:54:01 debian Keepalived:Starting Keepalived v1.1.15 (12/20,2007)
May 25 01:54:01 debian Keepalived_healthcheckers: Using MII-BMSR NIC polling thread...
May 25 01:54:01 debian Keepalived_healthcheckers: Netlink reflector reports IP 10.1.10.250 added
May 25 01:54:01 debian Keepalived_vrrp: 10.1.10.240/24 brd 10.1.10.240 dev eth0 scope global
May 25 01:54:01 debian Keepalived_vrrp: VRRP_Instance(VI_1) Entering BACKUP STATE
May 25 01:54:01 debian Keepalived_vrrp: VRRP sockpool: [ifindex(2), proto(112), fd(8,9)]
12、使用ip命令查看(master)
1) eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:c8:87:a1 brd ff:ff:ff:ff:ff:ff
inet 10.1.10.117/24 brd 10.1.10.255 scope global eth0
inet 10.1.10.240/24 scope global secondary eth0
inet6 fe80::20c:29ff:fec8:87a1/64 scope link
valid_lft forever preferred_lft forever
13、启动参数说明
--use-file, -f keepalived.conf_file Use the specified configuration file.
--dump-conf, -d Dump the configuration data.
--log-detail, -D Detailed log messages (the default with the rc script provided).
--log-facility, -S 0-7 Set syslog facility to LOG_LOCAL[0-7] (default=LOG_DAEMON)