keepalived配置_Keepalived+Nginx 高可用集群(主主模式)

接着上篇:搭建Keepalived+Nginx 高可用实例操作:

1、搭建Keepalived+Nginx 高可用

(1)服务器环境准备

192.168.210.85   Nginx 主负载/Keepalived主服务器

192.168.210.177  Nginx 辅负载/Keepalived从服务器

192.168.210.176  后端服务1

192.168.210.195  后端服务2

(2)192.168.210.85服务器配置

[root@k8s-master1~]# vim /etc/keepalived/keepalived.conf

[root@k8s-master1~]# more /etc/keepalived/keepalived.conf

! Configuration File for keepalived

global_defs {

   notification_email {

   hahashen@126.com

   }

vrrp_instance VI_1 {

    state MASTER

    interface ens33

    virtual_router_id 51

    priority 200

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.210.11

    }

}

vrrp_instance VI_2 {

    state BACKUP

    interface ens33

    virtual_router_id 52

    priority 150

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 2222

    }

    virtual_ipaddress {

        192.168.210.12

    }

}

4788ac69bbf41dfa3e7513c46736f1ed.png

重启keepalived

root@k8s-master1 ~]# systemctl restart keepalived

查看IP,还在k8s-master1

81cde6dae61d6bc1b2ff1a9701e737bf.png

(3)192.168.210.177服务器配置

[root@k8s-node1~]# vim /etc/keepalived/keepalived.conf

[root@k8s-node1~]# more /etc/keepalived/keepalived.conf

! Configuration File for keepalived

global_defs {

   notification_email {

   hahashen@126.com

   } 

vrrp_instance VI_1 {

    state BACKUP

    interface ens33

    virtual_router_id 51

    priority 150

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.210.11

    }

}

vrrp_instance VI_2 {

    state MASTER

    interface ens33

    virtual_router_id 52

    priority 200

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 2222

    }

    virtual_ipaddress {

        192.168.210.12

    }

}

2016c489d2cc8eb15f5a85748322a09f.png

[root@k8s-node1 ~]# systemctl restart keepalive

查看k8s-node1上的vip是192.168.210.12

(4)测试

停止k8s-master1上的keepalived

[root@k8s-master1 ~]# systemctl stop keepalived

3adcbbf437ae19362a424595bd320522.png

c5653b78dfa2c1d04efda5000827972f.png

e5299363bf9675bb9b422cd6d42ba530.png

a804e4f13d826cc8f4269c54a73a1b48.png

测试访问keepalived中配置的两个VIP都可以正常调度,当我们停止任意一台keepalived节点,同样还是正常访问。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值