• MHA日常笔记


    1、启动mha:

    [root@pxc2 ~]# masterha_manager --conf=/opt/mha/conf/mha.cnf 

    Mon Jun 29 00:29:03 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
    Mon Jun 29 00:29:03 2020 - [info] Reading application default configuration from /opt/mha/conf/mha.cnf..
    Mon Jun 29 00:29:03 2020 - [info] Reading server configuration from /opt/mha/conf/mha.cnf..

    2、查看ssh登陆是否成功:

    [root@pxc2 ~]# masterha_check_ssh --conf=/opt/mha/conf/mha.cnf
    Mon Jun 29 00:33:47 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
    Mon Jun 29 00:33:47 2020 - [info] Reading application default configuration from /opt/mha/conf/mha.cnf..
    Mon Jun 29 00:33:47 2020 - [info] Reading server configuration from /opt/mha/conf/mha.cnf..
    Mon Jun 29 00:33:47 2020 - [info] Starting SSH connection tests..
    Mon Jun 29 00:33:48 2020 - [debug]
    Mon Jun 29 00:33:47 2020 - [debug] Connecting via SSH from root@pxc1(192.168.56.121:22) to root@pxc2(192.168.56.130:22)..
    Mon Jun 29 00:33:48 2020 - [debug] ok.
    Mon Jun 29 00:33:48 2020 - [debug] Connecting via SSH from root@pxc1(192.168.56.121:22) to root@pxc3(192.168.56.122:22)..
    Mon Jun 29 00:33:48 2020 - [debug] ok.
    Mon Jun 29 00:33:48 2020 - [debug]
    Mon Jun 29 00:33:48 2020 - [debug] Connecting via SSH from root@pxc2(192.168.56.130:22) to root@pxc1(192.168.56.121:22)..
    Mon Jun 29 00:33:48 2020 - [debug] ok.
    Mon Jun 29 00:33:48 2020 - [debug] Connecting via SSH from root@pxc2(192.168.56.130:22) to root@pxc3(192.168.56.122:22)..
    Mon Jun 29 00:33:48 2020 - [debug] ok.
    Mon Jun 29 00:33:49 2020 - [debug]
    Mon Jun 29 00:33:48 2020 - [debug] Connecting via SSH from root@pxc3(192.168.56.122:22) to root@pxc1(192.168.56.121:22)..
    Mon Jun 29 00:33:49 2020 - [debug] ok.
    Mon Jun 29 00:33:49 2020 - [debug] Connecting via SSH from root@pxc3(192.168.56.122:22) to root@pxc2(192.168.56.130:22)..
    Mon Jun 29 00:33:49 2020 - [debug] ok.
    Mon Jun 29 00:33:49 2020 - [info] All SSH connection tests passed successfully.

    3、查看复制是否建立好:

    [root@pxc2 ~]# masterha_check_repl --conf=/opt/mha/conf/mha.cnf
    Mon Jun 29 00:35:30 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
    Mon Jun 29 00:35:30 2020 - [info] Reading application default configuration from /opt/mha/conf/mha.cnf..
    Mon Jun 29 00:35:30 2020 - [info] Reading server configuration from /opt/mha/conf/mha.cnf..
    Mon Jun 29 00:35:30 2020 - [info] MHA::MasterMonitor version 0.56.
    Mon Jun 29 00:35:31 2020 - [info] GTID failover mode = 1
    Mon Jun 29 00:35:31 2020 - [info] Dead Servers:
    Mon Jun 29 00:35:31 2020 - [info] Alive Servers:
    Mon Jun 29 00:35:31 2020 - [info] pxc1(192.168.56.121:13306)
    Mon Jun 29 00:35:31 2020 - [info] pxc2(192.168.56.130:13306)
    Mon Jun 29 00:35:31 2020 - [info] pxc3(192.168.56.122:13306)
    Mon Jun 29 00:35:31 2020 - [info] Alive Slaves:
    Mon Jun 29 00:35:31 2020 - [info] pxc1(192.168.56.121:13306) Version=5.7.22-log (oldest major version between slaves) log-bin:enabled
    Mon Jun 29 00:35:31 2020 - [info] GTID ON
    Mon Jun 29 00:35:31 2020 - [info] Replicating from 192.168.56.130(192.168.56.130:13306)
    Mon Jun 29 00:35:31 2020 - [info] pxc3(192.168.56.122:13306) Version=5.7.25-log (oldest major version between slaves) log-bin:enabled
    Mon Jun 29 00:35:31 2020 - [info] GTID ON
    Mon Jun 29 00:35:31 2020 - [info] Replicating from 192.168.56.130(192.168.56.130:13306)
    Mon Jun 29 00:35:31 2020 - [info] Current Alive Master: pxc2(192.168.56.130:13306)
    Mon Jun 29 00:35:31 2020 - [info] Checking slave configurations..
    Mon Jun 29 00:35:31 2020 - [info] read_only=1 is not set on slave pxc1(192.168.56.121:13306).
    Mon Jun 29 00:35:31 2020 - [info] Checking replication filtering settings..
    Mon Jun 29 00:35:31 2020 - [info] binlog_do_db= , binlog_ignore_db=
    Mon Jun 29 00:35:31 2020 - [info] Replication filtering check ok.
    Mon Jun 29 00:35:31 2020 - [info] GTID (with auto-pos) is supported. Skipping all SSH and Node package checking.
    Mon Jun 29 00:35:31 2020 - [info] Checking SSH publickey authentication settings on the current master..
    Mon Jun 29 00:35:31 2020 - [info] HealthCheck: SSH to pxc2 is reachable.
    Mon Jun 29 00:35:31 2020 - [info]
    pxc2(192.168.56.130:13306) (current master)
    +--pxc1(192.168.56.121:13306)
    +--pxc3(192.168.56.122:13306)

    Mon Jun 29 00:35:31 2020 - [info] Checking replication health on pxc1..
    Mon Jun 29 00:35:31 2020 - [info] ok.
    Mon Jun 29 00:35:31 2020 - [info] Checking replication health on pxc3..
    Mon Jun 29 00:35:31 2020 - [info] ok.
    Mon Jun 29 00:35:31 2020 - [info] Checking master_ip_failover_script status:
    Mon Jun 29 00:35:31 2020 - [info] /root/master_ip_failover --command=status --ssh_user=root --orig_master_host=pxc2 --orig_master_ip=192.168.56.130 --orig_master_port=13306


    IN SCRIPT TEST====/sbin/ifconfig eth0:0 down==/sbin/ifconfig eth0:0 192.168.56.100/24===

    Checking the Status of the script.. OK
    Mon Jun 29 00:35:31 2020 - [info] OK.
    Mon Jun 29 00:35:31 2020 - [warning] shutdown_script is not defined.
    Mon Jun 29 00:35:31 2020 - [info] Got exit code 0 (Not master dead).

    MySQL Replication Health is OK.

    4、查看mha状态:

    [root@pxc2 ~]# masterha_check_status --conf=/opt/mha/conf/mha.cnf
    mha (pid:7129) is running(0:PING_OK), master:pxc2

    5、停止mha:

    [root@pxc2 ~]# masterha_stop --conf=/opt/mha/conf/mha.cnf
    Stopped mha successfully.
    [root@pxc2 ~]# masterha_check_status --conf=/opt/mha/conf/mha.cnf
    mha is stopped(2:NOT_RUNNING).

    6、手动在线切换方法:

    1)关闭MHA监控

    masterha_stop --conf=/opt/mha/conf/mha.cnf 

    2)switch

    masterha_master_switch  --conf=/opt/mha/conf/mha.cnf  --master_state=alive --new_master_host=pxc3 --new_master_port=13306 --orig_master_is_new_slave --running_updates_limit=10000

    --orig_master_is_new_slave切换时加上此参数是将原master变为slave节点,如果不加此参数,原来的master将不启动。

    --running_updates_limit=10000 切换时候选master如果有延迟的话,mha切换不能成功,加上此参数表示延迟在此时间范围内都可切换(单位为s),但是切换的时间长短是由recover时relay日志的大小决定。

  • 相关阅读:
    读《编写可维护的JavaScript》第七章总结
    读《编写可维护的JavaScript》第六章总结
    最新Blog
    cnUVA情况
    Casio普通计算器编程
    大家AK杯 灰天飞雁NOIP模拟赛题解/数据/标程
    Pascal <-> C/C++ 转换简明教程
    [互动][扫盲]信息学奥林匹克竞赛是什么
    以后这个博客可能不会用啦 请到新地址...
    算法专题训练 搜索a-T3 Ni骑士(ni)
  • 原文地址:https://www.cnblogs.com/vzhangxk/p/13208339.html
Copyright © 2020-2023  润新知