博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
keepalived 组播的配置
阅读量:7091 次
发布时间:2019-06-28

本文共 4435 字,大约阅读时间需要 14 分钟。

keepalived 组播的配置

准备主机2台

server hostname ip
keepalived s1 172.20.27.10
keepalived s2 172.20.27.11

S1节点配置

修改keepalived配置文件

[root@s1 ~]# vim /etc/keepalived/keepalived.conf ! Configuration File for keepalivedglobal_defs {   notification_email {        root@mylinuxops.com   }   notification_email_from root@mylinuxops.com   smtp_server 127.0.0.1   smtp_connect_timeout 30   router_id s1.mylinuxops.com   vrrp_skip_check_adv_addr   vrrp_strict   vrrp_iptables   vrrp_garp_interval 0   vrrp_gna_interval 0}vrrp_instance VI_1 {    state MASTER    interface ens33    virtual_router_id 27    priority 100    advert_int 2    authentication {        auth_type PASS        auth_pass 1111    }    virtual_ipaddress {        172.20.27.100 dev ens33 label ens33:0    }}

启动服务

[root@s1 ~]# systemctl restart keepalived

查看vip是否绑定

[root@s1 ~]# ip a | grep ens33:0    inet 172.20.27.100/32 scope global ens33:0

s2节点操作

修改keepalive的配置文件

[root@s2 ~]# vim /etc/keepalived/keepalived.conf ! Configuration File for keepalivedglobal_defs {   notification_email {        root@mylinuxops.com   }   notification_email_from root@mylinuxops.com   smtp_server 127.0.0.1   smtp_connect_timeout 30   router_id s2.mylinuxops.com   vrrp_skip_check_adv_addr   vrrp_strict   vrrp_iptables   vrrp_garp_interval 0   vrrp_gna_interval 0}vrrp_instance VI_1 {    state BACKUP    interface ens33    virtual_router_id 27    priority 80    advert_int 2    authentication {        auth_type PASS        auth_pass 1111    }    virtual_ipaddress {        172.20.27.100 dev ens33 label ens33:0    }}

重启服务

[root@s2 ~]# systemctl start keepalived

抓包查看是否组播

在s1节点上抓包

[root@s1 ~]# tcpdump -i ens33:0 -nn net 224.0.0.18tcpdump: verbose output suppressed, use -v or -vv for full protocol decodelistening on ens33:0, link-type EN10MB (Ethernet), capture size 262144 bytes18:59:35.835747 IP 172.20.27.10 > 224.0.0.18: VRRPv2, Advertisement, vrid 27, prio 100, authtype simple, intvl 2s, length 2018:59:37.837171 IP 172.20.27.10 > 224.0.0.18: VRRPv2, Advertisement, vrid 27, prio 100, authtype simple, intvl 2s, length 20

抓到发往224.0.0.18的信息

测试keepalived

暂停s1的keepalived服务器查看地址是否会漂移到s2节点上

在s1节点上暂停服务

[root@s1 ~]# systemctl stop keepalived

在s2节点上查看VIP是否被移过来了

[root@s2 ~]# ifconfigens33: flags=4163
mtu 1500 inet 172.20.27.11 netmask 255.255.0.0 broadcast 172.20.255.255 inet6 fe80::20c:29ff:fe4d:1ce3 prefixlen 64 scopeid 0x20
ether 00:0c:29:4d:1c:e3 txqueuelen 1000 (Ethernet) RX packets 21578 bytes 1824843 (1.7 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 311 bytes 28607 (27.9 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0ens33:0: flags=4163
mtu 1500 inet 172.20.27.100 netmask 255.255.255.255 broadcast 0.0.0.0 ether 00:0c:29:4d:1c:e3 txqueuelen 1000 (Ethernet)#VIP漂移到s2节点上了lo: flags=73
mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback) RX packets 6 bytes 482 (482.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 6 bytes 482 (482.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

再次启动s1节点查看是否地址是否被夺回

[root@s1 ~]# systemctl start keepalived[root@s1 ~]# ifconfigens33: flags=4163
mtu 1500 inet 172.20.27.10 netmask 255.255.0.0 broadcast 172.20.255.255 inet6 fe80::20c:29ff:fec5:123c prefixlen 64 scopeid 0x20
ether 00:0c:29:c5:12:3c txqueuelen 1000 (Ethernet) RX packets 38095 bytes 2925087 (2.7 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 28612 bytes 7301619 (6.9 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0ens33:0: flags=4163
mtu 1500 inet 172.20.27.100 netmask 255.255.255.255 broadcast 0.0.0.0 ether 00:0c:29:c5:12:3c txqueuelen 1000 (Ethernet)# VIP地址再次被抢回去lo: flags=73
mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback) RX packets 2 bytes 140 (140.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2 bytes 140 (140.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

转载于:https://blog.51cto.com/11886307/2406625

你可能感兴趣的文章
OpenSSL&搭建私人CA
查看>>
MySQL explain
查看>>
Tapestry5中的DI
查看>>
PHP判断文件或者目录是否可写
查看>>
部署java项目二
查看>>
数据库设计三大范式
查看>>
正则表达式
查看>>
我的友情链接
查看>>
安全性测试AppScan工具使用实战
查看>>
《软件测试》学习笔记(Ron Patton编著 第二版)(二)
查看>>
国际化总结—关于script脚本
查看>>
随笔-半成品
查看>>
我的友情链接
查看>>
SurfaceView 连续渲染 SurfaceHolder Canvas
查看>>
压缩磁盘节约磁盘空间
查看>>
自动化运维工具ansible学习+使用ansible批量推送公钥到远程主机[学习马哥]
查看>>
我的友情链接
查看>>
Geek爱旅行 - 龙猫
查看>>
《NLP汉语自然语言处理原理与实践》结构图
查看>>
cache和buffer之区别
查看>>