Keepalived

1、安装keepalived(10.0.0.5/10.0.0.6)

yum install keepalived -y
rpm -qa keepalived
#keepalived-1.3.5-8.el7_6.x86_64

ls /etc/keepalived/keepalived.conf 

2、配置主(10.0.0.5)

[root@lb01 keepalived]# cat keepalived.conf
global_defs {
   router_id LVS_DEVEL
}
vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        10.0.0.3/24 dev eth0 label eth0:1 
    }
}

3、配置备(10.0.0.6)

[root@lb02 ~]# cat /etc/keepalived/keepalived.conf 
global_defs {
   router_id LVS_BACKUP
}
vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 50
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        10.0.0.3/24 dev eth0 label eth0:1 
    }
}

主备区别:3点

router_id
state
priority

4、分别启动主备

systemctl start keepalived
[root@lb01 keepalived]# ps -ef|grep keep|grep -v grep
root       8613      1  0 20:58 ?        00:00:00 /usr/sbin/keepalived -D
root       8614   8613  0 20:58 ?        00:00:00 /usr/sbin/keepalived -D
root       8615   8613  0 20:58 ?        00:00:00 /usr/sbin/keepalived -D

5、测试

停掉主的keepalived,看备节点是否接管
恢复主的keepalived,看备节点是否释放

6、出错了 看日志

cat /var/log/messages

你可能感兴趣的:(Keepalived)