码迷,mamicode.com
首页 > 其他好文 > 详细

Keepalived双主模式配置流程

时间:2019-02-22 23:19:53      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:介绍   ipaddr   interface   host   pass   sts   add   127.0.0.1   解析   

实验说明

1)keepalived 支持配置多个VRRP实例,每个实例对应一个业务
2)本次实验将实现 keepalived 的互为主备:
业务A:keepalived01为Master,keepalived02为Backup
业务B:keepalived01为Backup,keepalived02为Master

环境介绍

1)K1
Hostname:keepalived01.example.com
IP:192.168.3.31
OS:Centos 7
2)K2
Hostname:keepalived02.example.com
IP:192.168.3.25
OS:Centos 7
3)VIP
业务A:192.168.3.33
业务B:192.168.3.133

安装配置

1、环境准备(略)
1)主机名配置
2)hosts文件解析
3)时间同步

2、keepalived01
[root@keepalived01 ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
admin@example.com
yunwei@idoool.com
}
notification_email_from root@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id keepalived01
}
vrrp_instance A1 {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.3.33/24 dev eth0 label eth0:0
}
}
vrrp_instance B1 {
state BACKUP
interface eth0
virtual_router_id 52
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 2222
}
virtual_ipaddress {
192.168.3.133/24 dev eth0 label eth0:1
}
}

3、keepalived01
[root@keepalived02 ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
admin@example.com
}
notification_email_from root@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id keepalived02
}
vrrp_instance A2 {
state BCAKUP
interface eth0
virtual_router_id 51
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.3.33/24 dev eth0 label eth0:0
}
}
vrrp_instance B2 {
state MASTER
interface eth0
virtual_router_id 52
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 2222
}
virtual_ipaddress {
192.168.3.133/24 dev eth0 label eth0:1
}
}

4、配置测试
[root@keepalived01 ~]# systemctl reload keepalived.service
[root@keepalived01 ~]# ifconfig|grep 192.168.3.33|wc -l
1
[root@keepalived01 ~]# ifconfig|grep 192.168.3.133|wc -l
0

[root@keepalived02 ~]# systemctl reload keepalived.service
[root@keepalived02 ~]# ifconfig|grep 192.168.3.33|wc -l
0
[root@keepalived02 ~]# ifconfig|grep 192.168.3.133|wc -l
1

[root@keepalived01 ~]# systemctl stop keepalived.service
[root@keepalived01 ~]# ifconfig|grep 192.168.3.33|wc -l
0
[root@keepalived01 ~]# ifconfig|grep 192.168.3.133|wc -l
0

[root@keepalived02 ~]# ifconfig|grep 192.168.3.33|wc -l
1
[root@keepalived02 ~]# ifconfig|grep 192.168.3.133|wc -l
1

[root@keepalived02 ~]# systemctl stop keepalived.service
[root@keepalived02 ~]# ifconfig|grep 192.168.3.33|wc -l
0
[root@keepalived02 ~]# ifconfig|grep 192.168.3.133|wc -l
0
[root@keepalived01 ~]# systemctl start keepalived.service
[root@keepalived01 ~]# ifconfig|grep 192.168.3.33|wc -l
1
[root@keepalived01 ~]# ifconfig|grep 192.168.3.133|wc -l
1

Keepalived双主模式配置流程

标签:介绍   ipaddr   interface   host   pass   sts   add   127.0.0.1   解析   

原文地址:https://www.cnblogs.com/liming-linux-python/p/10421132.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!