CentOS 5.9下安装配置Keepalived(2)

# mkdir /etc/keepalived/
# cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/ 
# cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
# cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
# ln -s /usr/local/keepalived/sbin/keepalived /sbin/

# service keepalived restart
Stopping keepalived: [FAILED]
Starting keepalived: [  OK  ]

# service keepalived status
keepalived (pid  12092) is running...

# chkconfig keepalived on

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
      valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:50:56:84:04:2c brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.66/24 brd 192.168.1.255 scope global eth0
    inet 192.168.200.16/32 scope global eth0
    inet 192.168.200.17/32 scope global eth0
    inet 192.168.200.18/32 scope global eth0
    inet6 fe80::250:56ff:fe84:42c/64 scope link
      valid_lft forever preferred_lft forever
3: sit0: <NOARP> mtu 1480 qdisc noop
    link/sit 0.0.0.0 brd 0.0.0.0

4、有关keepalived.conf的配置项

[root@HKBO keepalived]# more keepalived.conf
! 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 LVS_DEVEL  //负载均衡器标识,在一个网络内,它应该是唯一的
}

#VRRP实例定义块,负责负载均衡器之间的失败切换
vrrp_instance VI_1 {
    state MASTER                      //只有MASTER和BACKUP 2种状态,主为MASTER,从为BACKUP,使用大写                                       
    interface eth0                    //监控的网络接口                                             
    virtual_router_id 51              //同一实例下virtual_router_id必须相同                         
    priority 100                      //定义优先级,数字越大,优先级越高                           
    advert_int 1                      //MASTER与BACKUP负载均衡器之间同步检查的时间间隔,单位是秒     
    authentication {                  //验证类型和密码                                               
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {                //虚拟ip地址virtual_ipaddress,可以定义多个
        192.168.200.16
        192.168.200.17
        192.168.200.18
    }
}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/456c2d3443fc6af836b7f58e1e19a628.html