GreatSQL社区

搜索

flywiththewind

史上最全-mha搭建

热度 1flywiththewind 已有 1931 次阅读2023-3-4 09:57 |个人分类:安装配置|系统分类:其他

1 路径及版本说明

本次安装所需要的相关软件存放目录为每台服务器的/soft目录。

1.1 版本说明

操作系统版本:Red Hat Enterprise Linux Server release 7.9 (Maipo)

操作系统内核版本:Linux 3.10.0-1160.el7.x86_64

数据库版本:5.7.41-log

xtrabackup版本: 2.4.27

mydumper版本:0.13.1-2

MHA版本:0.58

1.2 MySQL数据库路径

数据库软件路径:/usr/local/mysql

数据库配置文件:/etc/my.cnf

数据库路径:/data/mysql/data

数据库binlog日志路径:/data/mysql/data

数据库错误日志:/data/mysql/data/mysql_error.log

数据库工作端口:3306

my.cnf配置文件内容:

[client]

port=3306

socket=/data/mysql/data/mysql.sock

[mysql]

socket=/data/mysql/data/mysql.sock

port=3306

prompt = "\u@\h \R:\m:\s [\d]> "

no_auto_rehash

[mysqld]

user=mysql

autocommit=1

general_log=off

explicit_defaults_for_timestamp=true

character-set-server=utf8

lower_case_table_names = 1

log_timestamps=system

transaction-isolation = READ-COMMITTED

secure-file-priv=

bind-address = 0.0.0.0

# system

relay_log_purge=0

basedir=/usr/local/mysql

datadir=/data/mysql/data/

max_allowed_packet=1073741824

max_connections=2000

max_user_connections=900

open_files_limit=65535

pid_file=/data/mysql/data/mysqld.pid

port=3306

server_id=193

skip_name_resolve=ON

socket=/data/mysql/data/mysql.sock

tmpdir=/data/mysql/data/

table_open_cache=4096

#binlog

log-bin=/data/mysql/data/binlog

binlog_cache_size=2097152

binlog_format=row

expire_logs_days=7

log_slave_updates=ON

max_binlog_cache_size=21474836480

max_binlog_size=256M

sync_binlog=1

log_bin_trust_function_creators = 1

#logging

log_error=/data/mysql/data/mysql_error.log

slow_query_log_file=/data/mysql/data/mysql_slow_query.log

log_queries_not_using_indexes=0

slow_query_log=1

log_slave_updates=ON

log_slow_admin_statements=1

long_query_time=1

#relay

relay_log=/data/mysql/data/relaylog

relay_log_index=/data/mysql/data/relay.index

relay_log_info_file=/data/mysql/data/relay-log.info

relay_log_purge = ON

#add by sph 20211022

master_info_repository = TABLE

relay_log_info_repository = TABLE

relay_log_recovery = on

#per session mem

sort_buffer_size               = 8M

read_buffer_size               = 2M

join_buffer_size               = 2M

read_rnd_buffer_size           = 2M

thread_stack                   = 512K

bulk_insert_buffer_size        = 64M

#slave

slave_load_tmpdir=/data/mysql/data/

slave_skip_errors=OFF

#innodb

innodb_data_home_dir=/data/mysql/data/

innodb_log_group_home_dir=/data/mysql/data/

innodb_adaptive_flushing=ON

innodb_adaptive_hash_index=OFF

innodb_autoinc_lock_mode=1

innodb_buffer_pool_instances=8

#default

innodb_change_buffering=all

innodb_checksums=ON

innodb_buffer_pool_size= 350G

innodb_data_file_path=ibdata1:1G:autoextend

innodb_doublewrite=ON

innodb_file_format=Barracuda

innodb_file_per_table=ON

innodb_flush_log_at_trx_commit=1

innodb_flush_method=O_DIRECT

innodb_io_capacity=10000

innodb_lock_wait_timeout=60

innodb_log_buffer_size=8M

innodb_log_file_size=256M

innodb_log_files_in_group=4

innodb_max_dirty_pages_pct=50

innodb_open_files=6000

innodb_purge_threads=4

innodb_read_io_threads=8

innodb_stats_on_metadata=OFF

innodb_support_xa=ON

innodb_use_native_aio=OFF

innodb_write_io_threads=8

#replicat

loose-rpl_semi_sync_master_enabled   = 1

loose-rpl_semi_sync_slave_enabled    = 1

loose-rpl_semi_sync_master_wait_point=AFTER_SYNC

loose-plugin_load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so"

#GTID

gtid_mode=on

enforce_gtid_consistency=on

[mysqld_safe]

datadir=/data/mysql/data/

1.3 MHA相关路径

MHA Manager只安装在192.168.100.195服务器上,一下路径只在这一台服务器。

MHA工作目录路径:/usr/local/mha

MHA配置文件路径:/etc/masterha_default.cnf

MHA切换脚本路径:/usr/local/mha/scripts

MHA工作日志:/usr/local/mha/manager.log

MHA启动脚本:/usr/local/mha/startmha.sh

MHA关闭脚本:/usr/local/mha/stopmha.sh

MHA检查主机互信脚本:/usr/local/mha/checkssh.sh

MHA检查主从同步状态脚本:/usr/local/mha/checkrepl.sh

MHA手工切换演练脚本:/usr/local/mha/manualswitch.sh

MHA手工挂载卸载参考脚本:/usr/local/mha/vip.txt

1.4 操作系统目录


2 MySQL安装

三台服务器操作一致,本文档以第一台服务器为例进行安装说明。

2.1 修改系统参数

修改/etc/sysctl.conf

vm.swappiness=1

fs.file-max=12553500

fs.nr_open=12453500

net.ipv4.ip_forward = 0

kernel.sem = 250 32000 100 128

kernel.shmmni = 4096

kernel.shmall = 8388608

kernel.shmmax = 483183820800

fs.aio-max-nr = 1048576

fs.file-max = 6815744

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

net.ipv4.ip_local_port_range = 1024 65500

2.2 修改用户限制

修改/etc/security/limits.conf

* soft nproc 65535

* hard nproc 65535

* soft nofile 65535

* hard nofile 65535

修改/etc/security/limits.d/20-nproc.conf

*          soft    nproc     unlimited

root       soft    nproc     unlimited

2.2 关闭透明大页

修改/etc/rc.d/rc.local,新增如下

if test -f /sys/kernel/mm/transparent_hugepage/enabled; then

  echo never > /sys/kernel/mm/transparent_hugepage/enabled

fi

if test -f /sys/kernel/mm/transparent_hugepage/defrag; then

  echo never > /sys/kernel/mm/transparent_hugepage/defrag

fi

2.2 创建用户

/usr/sbin/groupadd -g 2000 mysql

/usr/sbin/useradd -g mysql -u 2000 mysql

2.3 创建目录

创建数据库目录并修改权限

mkdir -p /data/mysql/data/

chown -R mysql.mysql /data/

2.4 安装MySQL

软件安装

cd /soft

tar -zxvf mysql-5.7.41-linux-glibc2.12-x86_64.tar.gz

mv mysql-5.7.41-linux-glibc2.12-x86_64 /usr/local/mysql

chown -R mysql.mysql /usr/local/mysql

mysqld --defaults-file=/etc/my.cnf --initialize-insecure --basedir=/usr/local/mysql --datadir=/data/mysql/data/ --user=mysql

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

service mysqld start

service mysqld stop

service mysqld restart

创建用户,只在第一台服务器执行。

mysql

create user 'root'@'%';

create user 'repl'@'192.168.100.%';

grant all privileges on *.* to 'root'@'localhost';

grant all privileges on *.* to 'root'@'%';

grant replication slave,replication client  on *.* to 'repl'@'192.168.100.%';

flush privileges;

alter user 'root'@'%' identified by 'root';

alter user 'root'@'localhost' identified by 'root';

alter user 'repl'@'192.168.100.%' identified by 'Repl1234!';

flush privileges;

2.5 搭建主从复制

本文档以第二台服务器操作进行说明:

mysql -uroot -ppassword -e "reset master;"

mysqldump -uroot -h192.168.100.193 -ppassword --all-databases --default-character-set=utf8 --hex-blob --single-transaction --all-databases --triggers --routines --events --master-data=2 --max_allowed_packet=256M | mysql

mysql

change master to master_host='192.168.100.193',master_user='repl',master_password='Repl1234!',master_port=3306,master_auto_position=1;

start slave;

show slave status\G


3 MHA安装配置

3.1 软件安装

三台服务器都需要安装mha node

第三台服务器安装mha manager

相关的依赖包:

mha node安装:

yum -y localinstall mha4mysql-node-0.58-0.el7.centos.noarch.rpm

安装文件及路径:

/usr/bin/apply_diff_relay_logs

/usr/bin/filter_mysqlbinlog

/usr/bin/purge_relay_logs

/usr/bin/save_binary_logs

/usr/share/man/man1/apply_diff_relay_logs.1.gz

/usr/share/man/man1/filter_mysqlbinlog.1.gz

/usr/share/man/man1/purge_relay_logs.1.gz

/usr/share/man/man1/save_binary_logs.1.gz

/usr/share/perl5/vendor_perl/MHA/BinlogHeaderParser.pm

/usr/share/perl5/vendor_perl/MHA/BinlogManager.pm

/usr/share/perl5/vendor_perl/MHA/BinlogPosFindManager.pm

/usr/share/perl5/vendor_perl/MHA/BinlogPosFinder.pm

/usr/share/perl5/vendor_perl/MHA/BinlogPosFinderElp.pm

/usr/share/perl5/vendor_perl/MHA/BinlogPosFinderXid.pm

/usr/share/perl5/vendor_perl/MHA/NodeConst.pm

/usr/share/perl5/vendor_perl/MHA/NodeUtil.pm

/usr/share/perl5/vendor_perl/MHA/SlaveUtil.pm

mha manager安装:

yum -y localinstall mha4mysql-manager-0.58-0.el7.centos.noarch.rpm

安装文件及路径:

/usr/bin/masterha_check_repl

/usr/bin/masterha_check_ssh

/usr/bin/masterha_check_status

/usr/bin/masterha_conf_host

/usr/bin/masterha_manager

/usr/bin/masterha_master_monitor

/usr/bin/masterha_master_switch

/usr/bin/masterha_secondary_check

/usr/bin/masterha_stop

/usr/share/man/man1/masterha_check_repl.1.gz

/usr/share/man/man1/masterha_check_ssh.1.gz

/usr/share/man/man1/masterha_check_status.1.gz

/usr/share/man/man1/masterha_conf_host.1.gz

/usr/share/man/man1/masterha_manager.1.gz

/usr/share/man/man1/masterha_master_monitor.1.gz

/usr/share/man/man1/masterha_master_switch.1.gz

/usr/share/man/man1/masterha_secondary_check.1.gz

/usr/share/man/man1/masterha_stop.1.gz

/usr/share/perl5/vendor_perl/MHA/Config.pm

/usr/share/perl5/vendor_perl/MHA/DBHelper.pm

/usr/share/perl5/vendor_perl/MHA/FileStatus.pm

/usr/share/perl5/vendor_perl/MHA/HealthCheck.pm

/usr/share/perl5/vendor_perl/MHA/ManagerAdmin.pm

/usr/share/perl5/vendor_perl/MHA/ManagerAdminWrapper.pm

/usr/share/perl5/vendor_perl/MHA/ManagerConst.pm

/usr/share/perl5/vendor_perl/MHA/ManagerUtil.pm

/usr/share/perl5/vendor_perl/MHA/MasterFailover.pm

/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm

/usr/share/perl5/vendor_perl/MHA/MasterRotate.pm

/usr/share/perl5/vendor_perl/MHA/SSHCheck.pm

/usr/share/perl5/vendor_perl/MHA/Server.pm

/usr/share/perl5/vendor_perl/MHA/ServerManager.pm

3.2 MHA配置

MHA Manager只安装在192.168.100.195服务器上,一下路径只在这一台服务器。

MHA工作目录路径:/usr/local/mha

MHA配置文件路径:/etc/masterha_default.cnf

MHA切换脚本路径:/usr/local/mha/scripts

MHA工作日志:/usr/local/mha/manager.log

MHA启动脚本:/usr/local/mha/startmha.sh

MHA关闭脚本:/usr/local/mha/stopmha.sh

MHA检查主机互信脚本:/usr/local/mha/checkssh.sh

MHA检查主从同步状态脚本:/usr/local/mha/checkrepl.sh

MHA手工切换演练脚本:/usr/local/mha/manualswitch.sh

3.3 MHA用的脚本



3.4 MHA相关脚本

3.4.1 checkssh.sh

3.4.2 checkrepl.sh

[root@mysql-mha03 mha]# sh checkrepl.sh

Mon Feb  6 17:35:28 2023 - [info] Reading default configuration from /etc/masterha_default.cnf..

Mon Feb  6 17:35:28 2023 - [info] Reading application default configuration from /etc/masterha_default.cnf..

Mon Feb  6 17:35:28 2023 - [info] Reading server configuration from /etc/masterha_default.cnf..

Mon Feb  6 17:35:28 2023 - [info] MHA::MasterMonitor version 0.58.

Mon Feb  6 17:35:29 2023 - [info] GTID failover mode = 1

Mon Feb  6 17:35:29 2023 - [info] Dead Servers:

Mon Feb  6 17:35:29 2023 - [info] Alive Servers:

Mon Feb  6 17:35:29 2023 - [info]   192.168.100.193(192.168.100.193:3306)

Mon Feb  6 17:35:29 2023 - [info]   192.168.100.194(192.168.100.194:3306)

Mon Feb  6 17:35:29 2023 - [info]   192.168.100.195(192.168.100.195:3306)

Mon Feb  6 17:35:29 2023 - [info] Alive Slaves:

Mon Feb  6 17:35:29 2023 - [info]   192.168.100.194(192.168.100.194:3306)  Version=5.7.41-log (oldest major version between slaves) log-bin:enabled

Mon Feb  6 17:35:29 2023 - [info]     GTID ON

Mon Feb  6 17:35:29 2023 - [info]     Replicating from 192.168.100.193(192.168.100.193:3306)

Mon Feb  6 17:35:29 2023 - [info]     Primary candidate for the new Master (candidate_master is set)

Mon Feb  6 17:35:29 2023 - [info]   192.168.100.195(192.168.100.195:3306)  Version=5.7.41-log (oldest major version between slaves) log-bin:enabled

Mon Feb  6 17:35:29 2023 - [info]     GTID ON

Mon Feb  6 17:35:29 2023 - [info]     Replicating from 192.168.100.193(192.168.100.193:3306)

Mon Feb  6 17:35:29 2023 - [info]     Not candidate for the new Master (no_master is set)

Mon Feb  6 17:35:29 2023 - [info] Current Alive Master: 192.168.100.193(192.168.100.193:3306)

Mon Feb  6 17:35:29 2023 - [info] Checking slave configurations..

Mon Feb  6 17:35:29 2023 - [info]  read_only=1 is not set on slave 192.168.100.194(192.168.100.194:3306).

Mon Feb  6 17:35:29 2023 - [info]  read_only=1 is not set on slave 192.168.100.195(192.168.100.195:3306).

Mon Feb  6 17:35:29 2023 - [info] Checking replication filtering settings..

Mon Feb  6 17:35:29 2023 - [info]  binlog_do_db= , binlog_ignore_db=

Mon Feb  6 17:35:29 2023 - [info]  Replication filtering check ok.

Mon Feb  6 17:35:29 2023 - [info] GTID (with auto-pos) is supported. Skipping all SSH and Node package checking.

Mon Feb  6 17:35:29 2023 - [info] Checking SSH publickey authentication settings on the current master..

Mon Feb  6 17:35:29 2023 - [info] HealthCheck: SSH to 192.168.100.193 is reachable.

Mon Feb  6 17:35:29 2023 - [info]

192.168.100.193(192.168.100.193:3306) (current master)

+--192.168.100.194(192.168.100.194:3306)

+--192.168.100.195(192.168.100.195:3306)

Mon Feb  6 17:35:29 2023 - [info] Checking replication health on 192.168.100.194..

Mon Feb  6 17:35:29 2023 - [info]  ok.

Mon Feb  6 17:35:29 2023 - [info] Checking replication health on 192.168.100.195..

Mon Feb  6 17:35:29 2023 - [info]  ok.

Mon Feb  6 17:35:29 2023 - [info] Checking master_ip_failover_script status:

Mon Feb  6 17:35:29 2023 - [info]   /usr/local/mha/scripts/master_ip_failover --command=status --ssh_user=root --orig_master_host=192.168.100.193 --orig_master_ip=192.168.100.193 --orig_master_port=3306

IN SCRIPT TEST====/usr/sbin/ifconfig bond0:1 down==/usr/sbin/ifconfig bond0:1 10.31.100.196/24===

Checking the Status of the script.. OK

Mon Feb  6 17:35:29 2023 - [info]  OK.

Mon Feb  6 17:35:29 2023 - [warning] shutdown_script is not defined.

Mon Feb  6 17:35:29 2023 - [info] Got exit code 0 (Not master dead).

MySQL Replication Health is OK.

3.4.3 checkmha.sh

sh checkmha.sh

masterha_default is stopped(2:NOT_RUNNING).

3.4.4 manualswitch.sh

[root@mysql-mha03 scripts]# manualswitch.sh 192.168.100.194

Tue Feb  7 16:47:36 2023 - [info] MHA::MasterRotate version 0.58.

Tue Feb  7 16:47:36 2023 - [info] Starting online master switch..

Tue Feb  7 16:47:36 2023 - [info]

Tue Feb  7 16:47:36 2023 - [info] * Phase 1: Configuration Check Phase..

Tue Feb  7 16:47:36 2023 - [info]

Tue Feb  7 16:47:36 2023 - [info] Reading default configuration from /etc/masterha_default.cnf..

Tue Feb  7 16:47:36 2023 - [info] Reading application default configuration from /etc/masterha_default.cnf..

Tue Feb  7 16:47:36 2023 - [info] Reading server configuration from /etc/masterha_default.cnf..

Tue Feb  7 16:47:37 2023 - [info] GTID failover mode = 1

Tue Feb  7 16:47:37 2023 - [info] Current Alive Master: 192.168.100.193(192.168.100.193:3306)

Tue Feb  7 16:47:37 2023 - [info] Alive Slaves:

Tue Feb  7 16:47:37 2023 - [info]   192.168.100.194(192.168.100.194:3306)  Version=5.7.41-log (oldest major version between slaves) log-bin:enabled

Tue Feb  7 16:47:37 2023 - [info]     GTID ON

Tue Feb  7 16:47:37 2023 - [info]     Replicating from 192.168.100.193(192.168.100.193:3306)

Tue Feb  7 16:47:37 2023 - [info]     Primary candidate for the new Master (candidate_master is set)

Tue Feb  7 16:47:37 2023 - [info]   192.168.100.195(192.168.100.195:3306)  Version=5.7.41-log (oldest major version between slaves) log-bin:enabled

Tue Feb  7 16:47:37 2023 - [info]     GTID ON

Tue Feb  7 16:47:37 2023 - [info]     Replicating from 192.168.100.193(192.168.100.193:3306)

Tue Feb  7 16:47:37 2023 - [info]     Not candidate for the new Master (no_master is set)

Tue Feb  7 16:47:37 2023 - [info] Executing FLUSH NO_WRITE_TO_BINLOG TABLES. This may take long time..

Tue Feb  7 16:47:37 2023 - [info]  ok.

Tue Feb  7 16:47:37 2023 - [info] Checking MHA is not monitoring or doing failover..

Tue Feb  7 16:47:37 2023 - [info] Checking replication health on 192.168.100.194..

Tue Feb  7 16:47:37 2023 - [info]  ok.

Tue Feb  7 16:47:37 2023 - [info] Checking replication health on 192.168.100.195..

Tue Feb  7 16:47:37 2023 - [info]  ok.

Tue Feb  7 16:47:37 2023 - [info] 192.168.100.194 can be new master.

Tue Feb  7 16:47:37 2023 - [info]

From:

192.168.100.193(192.168.100.193:3306) (current master)

+--192.168.100.194(192.168.100.194:3306)

+--192.168.100.195(192.168.100.195:3306)

To:

192.168.100.194(192.168.100.194:3306) (new master)

+--192.168.100.195(192.168.100.195:3306)

+--192.168.100.193(192.168.100.193:3306)

Tue Feb  7 16:47:37 2023 - [info] Checking whether 192.168.100.194(192.168.100.194:3306) is ok for the new master..

Tue Feb  7 16:47:37 2023 - [info]  ok.

Tue Feb  7 16:47:37 2023 - [info] 192.168.100.193(192.168.100.193:3306): SHOW SLAVE STATUS returned empty result. To check replication filtering rules, temporarily executing CHANGE MASTER to a dummy host.

Tue Feb  7 16:47:37 2023 - [info] 192.168.100.193(192.168.100.193:3306): Resetting slave pointing to the dummy host.

Tue Feb  7 16:47:37 2023 - [info] ** Phase 1: Configuration Check Phase completed.

Tue Feb  7 16:47:37 2023 - [info]

Tue Feb  7 16:47:37 2023 - [info] * Phase 2: Rejecting updates Phase..

Tue Feb  7 16:47:37 2023 - [info]

Tue Feb  7 16:47:37 2023 - [info] Executing master ip online change script to disable write on the current master:

Tue Feb  7 16:47:37 2023 - [info]   /usr/local/mha/scripts/master_ip_online_change --command=stop --orig_master_host=192.168.100.193 --orig_master_ip=192.168.100.193 --orig_master_port=3306 --orig_master_user='root' --new_master_host=192.168.100.194 --new_master_ip=192.168.100.194 --new_master_port=3306 --new_master_user='root' --orig_master_ssh_user=root --new_master_ssh_user=root   --orig_master_is_new_slave --orig_master_password=xxx --new_master_password=xxx

ARGS: $VAR1 = [

         '--command=stop',

         '--orig_master_host=192.168.100.193',

         '--orig_master_ip=192.168.100.193',

         '--orig_master_port=3306',

         '--orig_master_user=root',

         '--new_master_host=192.168.100.194',

         '--new_master_ip=192.168.100.194',

         '--new_master_port=3306',

         '--new_master_user=root',

         '--orig_master_ssh_user=root',

         '--new_master_ssh_user=root',

         '--orig_master_is_new_slave',

         '--orig_master_password=root',

         '--new_master_password=root'

       ];

Unknown option: orig_master_ssh_user

Unknown option: new_master_ssh_user

Unknown option: orig_master_is_new_slave

Tue Feb  7 16:47:37 2023 696180 Set read_only on the new master.. ok.

Tue Feb  7 16:47:37 2023 702136 Waiting all running 2 threads are disconnected.. (max 1500 milliseconds)

{'Time' => '252','db' => undef,'Id' => '14','User' => 'repl','State' => 'Master has sent all binlog to slave; waiting for more updates','Command' => 'Binlog Dump GTID','Info' => undef,'Host' => '192.168.100.195:62456'}

{'Time' => '251','db' => undef,'Id' => '15','User' => 'repl','State' => 'Master has sent all binlog to slave; waiting for more updates','Command' => 'Binlog Dump GTID','Info' => undef,'Host' => '192.168.100.194:40884'}

Tue Feb  7 16:47:38 2023 202473 Waiting all running 2 threads are disconnected.. (max 1000 milliseconds)

{'Time' => '253','db' => undef,'Id' => '14','User' => 'repl','State' => 'Master has sent all binlog to slave; waiting for more updates','Command' => 'Binlog Dump GTID','Info' => undef,'Host' => '192.168.100.195:62456'}

{'Time' => '252','db' => undef,'Id' => '15','User' => 'repl','State' => 'Master has sent all binlog to slave; waiting for more updates','Command' => 'Binlog Dump GTID','Info' => undef,'Host' => '192.168.100.194:40884'}

Tue Feb  7 16:47:38 2023 702670 Waiting all running 2 threads are disconnected.. (max 500 milliseconds)

{'Time' => '253','db' => undef,'Id' => '14','User' => 'repl','State' => 'Master has sent all binlog to slave; waiting for more updates','Command' => 'Binlog Dump GTID','Info' => undef,'Host' => '192.168.100.195:62456'}

{'Time' => '252','db' => undef,'Id' => '15','User' => 'repl','State' => 'Master has sent all binlog to slave; waiting for more updates','Command' => 'Binlog Dump GTID','Info' => undef,'Host' => '192.168.100.194:40884'}

bind: Cannot assign requested address

Tue Feb  7 16:47:39 2023 346663 Set read_only=1 on the orig master.. ok.

Tue Feb  7 16:47:39 2023 347666 Waiting all running 2 queries are disconnected.. (max 500 milliseconds)

{'Time' => '254','db' => undef,'Id' => '14','User' => 'repl','State' => 'Master has sent all binlog to slave; waiting for more updates','Command' => 'Binlog Dump GTID','Info' => undef,'Host' => '192.168.100.195:62456'}

{'Time' => '253','db' => undef,'Id' => '15','User' => 'repl','State' => 'Master has sent all binlog to slave; waiting for more updates','Command' => 'Binlog Dump GTID','Info' => undef,'Host' => '192.168.100.194:40884'}

Tue Feb  7 16:47:39 2023 763928 Killing all application threads..

Tue Feb  7 16:47:39 2023 795379 done.

STOP ARGS: $VAR1 = [];

Tue Feb  7 16:47:39 2023 - [info]  ok.

Tue Feb  7 16:47:39 2023 - [info] Locking all tables on the orig master to reject updates from everybody (including root):

Tue Feb  7 16:47:39 2023 - [info] Executing FLUSH TABLES WITH READ LOCK..

Tue Feb  7 16:47:39 2023 - [info]  ok.

Tue Feb  7 16:47:39 2023 - [info] Orig master binlog:pos is binlog.000015:378.

Tue Feb  7 16:47:39 2023 - [info]  Waiting to execute all relay logs on 192.168.100.194(192.168.100.194:3306)..

Tue Feb  7 16:47:39 2023 - [info]  master_pos_wait(binlog.000015:378) completed on 192.168.100.194(192.168.100.194:3306). Executed 0 events.

Tue Feb  7 16:47:39 2023 - [info]   done.

Tue Feb  7 16:47:39 2023 - [info] Getting new master's binlog name and position..

Tue Feb  7 16:47:39 2023 - [info]  binlog.000004:3212

Tue Feb  7 16:47:39 2023 - [info]  All other slaves should start replication from here. Statement should be: CHANGE MASTER TO MASTER_HOST='192.168.100.194', MASTER_PORT=3306, MASTER_AUTO_POSITION=1, MASTER_USER='repl', MASTER_PASSWORD='xxx';

Tue Feb  7 16:47:39 2023 - [info] Executing master ip online change script to allow write on the new master:

Tue Feb  7 16:47:39 2023 - [info]   /usr/local/mha/scripts/master_ip_online_change --command=start --orig_master_host=192.168.100.193 --orig_master_ip=192.168.100.193 --orig_master_port=3306 --orig_master_user='root' --new_master_host=192.168.100.194 --new_master_ip=192.168.100.194 --new_master_port=3306 --new_master_user='root' --orig_master_ssh_user=root --new_master_ssh_user=root   --orig_master_is_new_slave --orig_master_password=xxx --new_master_password=xxx

ARGS: $VAR1 = [

         '--command=start',

         '--orig_master_host=192.168.100.193',

         '--orig_master_ip=192.168.100.193',

         '--orig_master_port=3306',

         '--orig_master_user=root',

         '--new_master_host=192.168.100.194',

         '--new_master_ip=192.168.100.194',

         '--new_master_port=3306',

         '--new_master_user=root',

         '--orig_master_ssh_user=root',

         '--new_master_ssh_user=root',

         '--orig_master_is_new_slave',

         '--orig_master_password=root',

         '--new_master_password=root'

       ];

Unknown option: orig_master_ssh_user

Unknown option: new_master_ssh_user

Unknown option: orig_master_is_new_slave

Tue Feb  7 16:47:40 2023 003781 Set read_only=0 on the new master.

Tue Feb  7 16:47:41 2023 - [info]  ok.

Tue Feb  7 16:47:41 2023 - [info]

Tue Feb  7 16:47:41 2023 - [info] * Switching slaves in parallel..

Tue Feb  7 16:47:41 2023 - [info]

Tue Feb  7 16:47:41 2023 - [info] -- Slave switch on host 192.168.100.195(192.168.100.195:3306) started, pid: 36825

Tue Feb  7 16:47:41 2023 - [info]

Tue Feb  7 16:47:42 2023 - [info] Log messages from 192.168.100.195 ...

Tue Feb  7 16:47:42 2023 - [info]

Tue Feb  7 16:47:41 2023 - [info]  Waiting to execute all relay logs on 192.168.100.195(192.168.100.195:3306)..

Tue Feb  7 16:47:41 2023 - [info]  master_pos_wait(binlog.000015:378) completed on 192.168.100.195(192.168.100.195:3306). Executed 0 events.

Tue Feb  7 16:47:41 2023 - [info]   done.

Tue Feb  7 16:47:41 2023 - [info]  Resetting slave 192.168.100.195(192.168.100.195:3306) and starting replication from the new master 192.168.100.194(192.168.100.194:3306)..

Tue Feb  7 16:47:41 2023 - [info]  Executed CHANGE MASTER.

Tue Feb  7 16:47:41 2023 - [info]  Slave started.

Tue Feb  7 16:47:42 2023 - [info] End of log messages from 192.168.100.195 ...

Tue Feb  7 16:47:42 2023 - [info]

Tue Feb  7 16:47:42 2023 - [info] -- Slave switch on host 192.168.100.195(192.168.100.195:3306) succeeded.

Tue Feb  7 16:47:42 2023 - [info] Unlocking all tables on the orig master:

Tue Feb  7 16:47:42 2023 - [info] Executing UNLOCK TABLES..

Tue Feb  7 16:47:42 2023 - [info]  ok.

Tue Feb  7 16:47:42 2023 - [info] Starting orig master as a new slave..

Tue Feb  7 16:47:42 2023 - [info]  Resetting slave 192.168.100.193(192.168.100.193:3306) and starting replication from the new master 192.168.100.194(192.168.100.194:3306)..

Tue Feb  7 16:47:42 2023 - [info]  Executed CHANGE MASTER.

Tue Feb  7 16:47:43 2023 - [info]  Slave started.

Tue Feb  7 16:47:43 2023 - [info] All new slave servers switched successfully.

Tue Feb  7 16:47:43 2023 - [info]

Tue Feb  7 16:47:43 2023 - [info] * Phase 5: New master cleanup phase..

Tue Feb  7 16:47:43 2023 - [info]

Tue Feb  7 16:47:43 2023 - [info]  192.168.100.194: Resetting slave info succeeded.

Tue Feb  7 16:47:43 2023 - [info] Switching master to 192.168.100.194(192.168.100.194:3306) completed successfully.

3.4.5 startmha.sh

[root@mysql-mha03 mha]# sh startmha.sh

[root@mysql-mha03 mha]# nohup: appending output to ‘nohup.out’

[root@mysql-mha03 mha]#

[root@mysql-mha03 mha]# sh checkmha.sh

masterha_default (pid:21426) is running(0:PING_OK), master:192.168.100.194

3.4.6 startmha_nodelete.sh

[root@mysql-mha03 mha]# cat startmha_nodelete.sh

nohup masterha_manager --conf=/etc/masterha_default.cnf --ignore_last_failover &

3.4.6 stopmha.sh

[root@mysql-mha03 mha]# sh stopmha.sh

Stopped masterha_default successfully.

[root@mysql-mha03 mha]# sh checkmha.sh

masterha_default is stopped(2:NOT_RUNNING).

发表评论 评论 (2 个评论)

回复 lizibin 2023-3-8 16:25
不懂就问,生产MHA用的多吗。它有什么优势/缺陷呢
回复 flywiththewind 2023-3-11 22:20
lizibin: 不懂就问,生产MHA用的多吗。它有什么优势/缺陷呢
只能说是存量还有,新建架构都建议mgr了

facelist

您需要登录后才可以评论 登录 | 立即注册

合作电话:010-64087828

社区邮箱:greatsql@greatdb.com

社区公众号
社区小助手
QQ群
GMT+8, 2024-4-19 10:32 , Processed in 0.014398 second(s), 9 queries , Redis On.
返回顶部