美文网首页
keepalived + mysql5.7 虚IP双主配置

keepalived + mysql5.7 虚IP双主配置

作者: 哈叽哈叽叽歪歪 | 来源:发表于2024-03-13 13:11 被阅读0次

mysql5.7 双主配置

参考以下文章
mysql5.7双主配置 - 简书 (jianshu.com)

keeplived 配置

vim /etc/keepalived/keepalived.conf
  • keeplived1 配置如下
! Configuration File for keepalived

global_defs {
   notification_email {
     acassen@firewall.loc
     failover@firewall.loc
     sysadmin@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
   vrrp_skip_check_adv_addr
   #vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
}


# check mysql
vrrp_script chk_mysql {
    script "/usr/bin/killall -0 mysqld"
}

vrrp_instance VI_1 {
    state BACKUP
    interface ens192
    virtual_router_id 51
    priority 50
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        # 配置虚IP地址
    }

    # checck script
    track_script {
        chk_mysql
    }
}
  • keepalived2配置
! Configuration File for keepalived

global_defs {
   notification_email {
     acassen@firewall.loc
     failover@firewall.loc
     sysadmin@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
   vrrp_skip_check_adv_addr
   #vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
}


# check mysql
vrrp_script chk_mysql {
    script "/usr/bin/killall -0 mysqld"
}

vrrp_instance VI_1 {
    state MASTER
    interface ens192
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        #虚IP地址
    }

    # checck script
    track_script {
        chk_mysql
    }
}
  • 分别启动 keeplived
systemctl start keeplived

测试

相关文章

网友评论

      本文标题:keepalived + mysql5.7 虚IP双主配置

      本文链接:https://www.haomeiwen.com/subject/gptizdtx.html