zoukankan      html  css  js  c++  java
  • mysql主主高可用方案

    masterA配置:

    yum -y install keepalived

    vim /etc/keepalived/keepalived.conf

    router_id LVS_MASTER-A

     interface ens33

    nopreempt

     track_script {

    mysql
    }

    vim /opt/mysql.sh     //编写脚本

    脚本内容:

    #!/bin/bash
    counter=$(netstat -na|grep "LISTEN"|grep "3306"|wc -l)
    if [ "${counter}" -eq 0 ]; then
    systemctl stop keepalived
    fi

    chmod +x /opt/mysql.sh 

     systemctl start keepalived    //重启keepalived

     ip a | grep ens33

      tail -f /var/log/messages

     masterB配置:

    yum -y install keepalived

    vim /etc/keepalived/keepalived.conf 

      router_id LVS_MASTER-B

     interface ens32

    priority 99

    track_script {
    mysql
    }

    vim /opt/mysql.sh

    脚本内容:

    #!/bin/bash
    counter=$(netstat -na|grep "LISTEN"|grep "3306"|wc -l)
    if [ "${counter}" -eq 0 ]; then
    systemctl stop keepalived
    fi

    chmod +x /opt/mysql.sh

    systemctl start keepalived

     tail -f /var/log/messages

    测试VIP转移

    masterA配置

    systemctl stop mariadb

    ip a | grep ens33

      ps aux | grep mysql

     masterB 配置

    ip a | grep ens32

     tail -f /var/log/messages

     在远程客户端测试

    所有mysql服务器授权

    mysql -uroot -p000000

     grant all on *.* to 'root'@'192.168.96.%' identified by '123456';

    flush privileges;

    通过VIP登录测试:

    mysql -uroot -p123456 -h 192.168.96.16

  • 相关阅读:
    第13周作业集
    软件工程结课作业
    第13次作业--邮箱的正则表达式
    第12次作业--你的生日
    第11次作业
    第10次作业
    找回感觉的练习
    第16周作业
    第15周作业
    第14周作业
  • 原文地址:https://www.cnblogs.com/XXXX001/p/11691024.html
Copyright © 2011-2022 走看看