3 keepalived 双网卡配置

 

双网卡单VRRP配置

主端配置

global_defs {

        router_id Haweb_1

        }

 

vrrp_sync_group VGM {

        group {

        VI_HA

        }

}

 

vrrp_instance VI_HA {

        state MASTER

        interface eth0

        lvs_sync_daemon_interface eth0

        virtual_router_id 51

        priority 100

        advert_int 5

 

        authentication {

        auth_type PASS

        auth_pass 111

        }

 

        track_interface {

                eth0

                eth1

        }

        virtual_ipaddress {

        10.0.0.17/24 dev eth0

        10.7.7.133/24 dev eth1

        }

}

 

从端配置

 

global_defs {

        router_id Haweb_1

        }

 

 

vrrp_sync_group VGM {

        group {

        VI_HA

        }

}

 

vrrp_instance VI_HA {

        state BACKUP

        interface eth0

        lvs_sync_daemon_interface eth0

        virtual_router_id 51

        priority 99

        advert_int 5

        authentication {

        auth_type PASS

        auth_pass 111

        }

        track_interface {

        eth0

        eth1

        }

        virtual_ipaddress {

        10.0.0.17/24 dev eth0

        10.7.7.133/24 dev eth1

        }

}

 

双网卡双VRRP配置

 

 

 

主端配置

 

global_defs {

        router_id Haweb_1

        }

 

vrrp_sync_group VGM {

        group {

        VI_HA_1

        VI_HA_2

        }

}

 

vrrp_instance VI_HA_1{

        state MASTER

        interface eth0

        lvs_sync_daemon_interface eth0

        virtual_router_id 51

        priority 100

        advert_int 5

 

        authentication {

        auth_type PASS

        auth_pass 111

        }

 

        track_interface {

                eth0

                eth1

        }

        virtual_ipaddress {

        10.0.0.17/24 dev eth0

        }

}

vrrp_instance VI_HA_2{

        state MASTER

        interface eth0

        lvs_sync_daemon_interface eth0

        virtual_router_id 52

        priority 100

        advert_int 5

 

        authentication {

        auth_type PASS

        auth_pass 111

        }

 

        track_interface {

                eth0

                eth1

        }

        virtual_ipaddress {

        10.7.7.133/24 dev eth1

        }

}

 

从端配置

 

global_defs {

        router_id Haweb_1

        }

 

vrrp_sync_group VGM {

        group {

        VI_HA_1

        VI_HA_2

        }

}

 

vrrp_instance VI_HA_1{

        state BACKUP

        interface eth0

        lvs_sync_daemon_interface eth0

        virtual_router_id 51

        priority 99

        advert_int 5

 

        authentication {

        auth_type PASS

        auth_pass 111

        }

 

        track_interface {

                eth0

                eth1

        }

        virtual_ipaddress {

        10.0.0.17/24 dev eth0

        }

}

vrrp_instance VI_HA_2{

        state BACKUP

        interface eth0

        lvs_sync_daemon_interface eth0

        virtual_router_id 52

        priority 99

        advert_int 5

 

        authentication {

        auth_type PASS

        auth_pass 111

        }

 

        track_interface {

                eth0

                eth1

        }

        virtual_ipaddress {

        10.7.7.133/24 dev eth1

        }

}

 

测试 

1  停掉主端的网卡 ifconfig eth0 down.

2    检查从端的 ip  a

 

 

 

2   监控节点资源。

 

        track_script{

        chk_http_port

        }

 

vrrp_script chk_http_port {

        script "killall -0 httpd"

#       script "/tcp/127.0.0.1/80"

        interval 1

}

 

 

 

监控节点资源演示;

 

测试

1   

 

查看1617上的日志。

 

2  

 

 

查看1617上的日志。

 

 

3  抢占问题如何优化

 

 

1   

 

 

 

3   

 

 

 

4  测试,如下图。17的也开启。

 

 

 

 此时关闭17上的httpd服务。查看16是否拿到master权限。

 再重新启动17上的httpd服务。看是否会抢占master权限。

posted @ 2017-02-03 17:32  我爱测试胜于爱自己  阅读(2280)  评论(0)    收藏  举报