CentOS|CentOS 安装 Keepalive 实现节点高可用
【CentOS|CentOS 安装 Keepalive 实现节点高可用】假设现在需要在2台 Centos 服务器(192.168.1.101,192.168.1.102)上安装Keepalive,实现高可用(VIP 192.168.1.201)。
- 安装 keepalived
yum install -y keepalived
- 修改主节点 keepalived 配置
cat <
/etc/keepalived/keepalived.conf global_defs { router_id MASTER01#实例ID,唯一 } vrrp_instance VI_1 { state MASTER#设置主备状态 interface enp0s3#绑定网卡 virtual_router_id 129#分组ID(0-255),主备必须相同 priority 100#优先级,主节点值更高 advert_int 1#VRRP Multicast广播周期秒数 authentication {#认证方式 auth_type PASS auth_pass 123456 } virtual_ipaddress {#VIP设置 192.168.1.244 } } EOF
- 修改备节点 keepalived 配置
cat <
/etc/keepalived/keepalived.conf global_defs { router_id MASTER02#实例ID,唯一 } vrrp_instance VI_1 { state BACKUP#设置主备状态 interface enp0s3#绑定网卡 virtual_router_id 129#分组ID(0-255),主备必须相同 priority 98#优先级,备节点值更低 advert_int 1#VRRP Multicast广播周期秒数 authentication {#认证方式 auth_type PASS auth_pass 123456 } virtual_ipaddress {#VIP设置 192.168.1.244 } } EOF
- 注册 keepalived 服务
systemctl enable keepalived systemctl restart keepalived
- 使用ping VIP方式测试,期间可以重启主节点,可以看到ping不会报错,在不到1毫秒内完成切换
ping 192.168.1.244 PING 192.168.1.244 (192.168.1.244) 56(84) bytes of data. 64 bytes from 192.168.1.244: icmp_seq=13 ttl=64 time=0.061 ms 64 bytes from 192.168.1.244: icmp_seq=14 ttl=64 time=0.063 ms 64 bytes from 192.168.1.244: icmp_seq=15 ttl=64 time=0.061 ms 64 bytes from 192.168.1.244: icmp_seq=16 ttl=64 time=0.070 ms 64 bytes from 192.168.1.244: icmp_seq=17 ttl=64 time=0.130 ms 64 bytes from 192.168.1.244: icmp_seq=18 ttl=64 time=0.115 ms 64 bytes from 192.168.1.244: icmp_seq=19 ttl=64 time=0.065 ms 64 bytes from 192.168.1.244: icmp_seq=20 ttl=64 time=0.110 ms 64 bytes from 192.168.1.244: icmp_seq=21 ttl=64 time=0.057 ms 64 bytes from 192.168.1.244: icmp_seq=22 ttl=64 time=0.089 ms
推荐阅读
- Mac安装Chromedriver
- MongoDB,Wondows下免安装版|MongoDB,Wondows下免安装版 (简化版操作)
- MAC安装Mongo
- 【Hadoop踩雷】Mac下安装Hadoop3以及Java版本问题
- react|react 安装
- VueX--VUE核心插件
- python-安装sublime遇到异常
- typeScript入门基础介绍
- 监控nginx
- 使用homeBrew|使用homeBrew 安装Goland