首页 > 其他分享 >keepalived主从架构

keepalived主从架构

时间:2022-10-24 11:40:22浏览次数:51  
标签:node 01 架构 bytes keepalived 192.168 174.20 time 主从

一 环境规划

节点

IP

功能

VIP

node-01

192.168.174.120

keepalived master

192.168.174.20

node-02

192.168.174.121

keepalived slave

192.168.174.20

二 抢占模式

抢占模式,即当高优先级的主机恢复在线后,会抢占低先级的主机的master角色,造成网络抖动,建议设置为非抢占模式 nopreempt ,即高优级主机恢复后,并不会抢占低优先级主机的master角色

2.1 修改keepalived配置

2.1.1 node-01节点配置

点击查看代码

root@node-01:/etc/keepalived# cat keepalived.conf
! Configuration File for keepalived
global_defs {

notification_email {

[email protected]

}

notification_email_from [email protected]

smtp_server 192.168.200.1

smtp_connect_timeout 30

router_id node-01

vrrp_skip_check_adv_addr

vrrp_strict

vrrp_garp_interval 0

vrrp_gna_interval 0

}
vrrp_instance VI_1 {

state MASTER

interface ens33

virtual_router_id 101

priority 100

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.174.20

}

}

2.1.2 node-02节点配置

root@node-02:~# cat /etc/keepalived/keepalived.conf 
! Configuration File for keepalived
global_defs {

notification_email {

[email protected]

}

notification_email_from [email protected]

smtp_server 192.168.200.1

smtp_connect_timeout 30

router_id node-02

vrrp_skip_check_adv_addr

vrrp_strict

vrrp_garp_interval 0

vrrp_gna_interval 0

}
vrrp_instance VI_1 {

state BACKUP

interface ens33

virtual_router_id 101

priority 80

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.174.20

}

}

2.2 验证VIP

2.2.1 查看node-01节点

root@node-01:~# hostname -I
192.168.174.120 192.168.174.20
root@node-01:~# ping -c 2 192.168.174.20
PING 192.168.174.20 (192.168.174.20) 56(84) bytes of data.
64 bytes from 192.168.174.20: icmp_seq=1 ttl=64 time=0.013 ms
64 bytes from 192.168.174.20: icmp_seq=2 ttl=64 time=0.026 ms
--- 192.168.174.20 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1016ms

rtt min/avg/max/mdev = 0.013/0.019/0.026/0.006 ms

2.2.2 查看node-02节点

root@node-02:~# hostname -I
192.168.174.121
root@node-02:~# ping -c 2 192.168.174.20
PING 192.168.174.20 (192.168.174.20) 56(84) bytes of data.
64 bytes from 192.168.174.20: icmp_seq=1 ttl=64 time=0.598 ms
64 bytes from 192.168.174.20: icmp_seq=2 ttl=64 time=0.442 ms
--- 192.168.174.20 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1030ms

rtt min/avg/max/mdev = 0.442/0.520/0.598/0.078 ms

2.3 模拟node-01故障

2.3.1 停止node-01节点keepalived

root@node-01:~# systemctl stop keepalived
root@node-01:~# hostname -I
192.168.174.120
root@node-01:~# ping -c 2 192.168.174.20
PING 192.168.174.20 (192.168.174.20) 56(84) bytes of data.
64 bytes from 192.168.174.20: icmp_seq=1 ttl=64 time=0.676 ms
64 bytes from 192.168.174.20: icmp_seq=2 ttl=64 time=0.353 ms
--- 192.168.174.20 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1008ms

rtt min/avg/max/mdev = 0.353/0.514/0.676/0.161 ms

2.3.2 查看node-02节点

root@node-02:~# hostname -I
192.168.174.121 192.168.174.20
root@node-02:~# ping -c 2 192.168.174.20
PING 192.168.174.20 (192.168.174.20) 56(84) bytes of data.
64 bytes from 192.168.174.20: icmp_seq=1 ttl=64 time=0.013 ms
64 bytes from 192.168.174.20: icmp_seq=2 ttl=64 time=0.023 ms
--- 192.168.174.20 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1031ms

rtt min/avg/max/mdev = 0.013/0.018/0.023/0.005 ms

2.4 node-01节点故障恢复

2.4.1 查看node-01节点

root@node-01:~# systemctl start keepalived
root@node-01:~# hostname -I
192.168.174.120 192.168.174.20
root@node-01:~# ping -c 2 192.168.174.20
PING 192.168.174.20 (192.168.174.20) 56(84) bytes of data.
64 bytes from 192.168.174.20: icmp_seq=1 ttl=64 time=0.014 ms
64 bytes from 192.168.174.20: icmp_seq=2 ttl=64 time=0.025 ms
--- 192.168.174.20 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1017ms

rtt min/avg/max/mdev = 0.014/0.019/0.025/0.005 ms

2.4.2 查看node-02节点

root@node-02:~# hostname -I
192.168.174.121
root@node-02:~# ping -c 2 192.168.174.20
PING 192.168.174.20 (192.168.174.20) 56(84) bytes of data.
64 bytes from 192.168.174.20: icmp_seq=1 ttl=64 time=0.284 ms
64 bytes from 192.168.174.20: icmp_seq=2 ttl=64 time=0.271 ms
--- 192.168.174.20 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1013ms

rtt min/avg/max/mdev = 0.271/0.277/0.284/0.006 ms

三 非抢占模式

注意:要关闭 VIP抢占,必须将各 keepalived 服务器state配置为BACKUP

3.1 设置keepalived.conf文件

3.1.1 node-01节点

点击查看代码

root@node-01:~# cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {

notification_email {

[email protected]

}

notification_email_from [email protected]

smtp_server 192.168.200.1

smtp_connect_timeout 30

router_id node-01

vrrp_skip_check_adv_addr

vrrp_strict

vrrp_garp_interval 0

vrrp_gna_interval 0

}
vrrp_instance VI_1 {

state BACKUP

interface ens33

virtual_router_id 101

priority 100

advert_int 1

nopreempt

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.174.20

}

}

3.1.2 node-02节点

点击查看代码

root@node-02:~# cat /etc/keepalived/keepalived.conf 
! Configuration File for keepalived
global_defs {

notification_email {

[email protected]

}

notification_email_from [email protected]

smtp_server 192.168.200.1

smtp_connect_timeout 30

router_id node-02

vrrp_skip_check_adv_addr

vrrp_strict

vrrp_garp_interval 0

vrrp_gna_interval 0

}
vrrp_instance VI_1 {

state BACKUP

interface ens33

virtual_router_id 101

priority 80

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.174.20

}

}

 

 



标签:node,01,架构,bytes,keepalived,192.168,174.20,time,主从
From: https://blog.51cto.com/u_4028786/5789201

相关文章

  • ubuntu20.04部署keepalived
    一环境准备1.1设置时间同步root@node-01:~#apt-yinstallchronyroot@node-01:~#systemctlenablechrony二在线安装2.1查看keepalived软件版本root@node-01:~#apt-......
  • 概念介绍_软件架构和概念介绍_资源分类
    概念介绍_软件架构:web概念概述Javaweb:使用iava语言开发基于互联网的项目软件架构∶1.c/s:client/server客户端/服务器端在用户本地有一个客户端程序,在远程有一个......
  • 浅谈软件架构师的素质与职责
    最近开始学习如何成为一名合格的架构师。首先参照别人的观点,在结合自己的实际经验,写出自己对如何成为一名架构师的理解,希望大家热心于与援手,能够指点......
  • Thanos 架构剖析(五)历史数据怎么办
    ThanosCompactor组件是针对Prometheus2.x存储引擎的生成的数据来进行压缩和降准的组件。对于数据压缩来说,并行操作是存在一定安全风险的,所以ThanosCompactor组件......
  • Thanos 架构剖析(六)告警规则如何管理
    ThanosRule组件通过thanosrule命令来启动,通过重复查询Query来评估告警是否触发,如果有多个Query,那么会通过轮询来保持平衡。默认情况下,Rule评估结果以Prometheu......
  • PostGresql13主从搭建
    1、安装好网络源(主1.11、从1.12)yuminstall-yhttps://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm 2、安装......
  • Thanos 架构剖析(三)如何选择 Sidecar 和 Receiver
    Sidecar和Receiver是Thanos和Prometheus进行数据交互的两个核心组件,我们来看看这两个组件有什么区别,分别都是怎么使用的。SidecarThanosSidecar组件需要和Porm......
  • Thanos 架构剖析(四)数据存储和运维工具
    ThanosStore主要提供查询历史数据功能,当Querier组件调用Stroe接口,Stroe再通过对象存储接口获取数据,并将存储数据转换成Querier所需的数据格式。Thanos数据存储Thanos......
  • VMware Horizon 8 2209 - 虚拟桌面基础架构 (VDI) 和应用软件
    请访问原文链接:https://sysin.org/blog/vmware-horizon-8-2209/,查看最新版。原创作品,转载请保留出处。作者主页:www.sysin.orgVersion2209DocumentationRelea......
  • 升级Xcode14之后如何打出带有armv7架构的SDK包
    Xcode14以前是默认armv7和arm64的,升级Xcode之后就被苹果这厮移除了,所以答案是Xcode14是打不出来armv7的包的,因为某些资本家的理念:宁可兼容到每一个古董机型,也不......