[MySQL - 4node MHA 구축 & failover테스트] part 2.

part1에 이어 구축 진행 및 failover테스트를 하도록 하겠습니다.

 

part1 : https://jhdatabase.tistory.com/101

 

[MySQL - 4node MHA 구축] part 1.

그동안 master-slave 구조에서의 mha는 2node가 보통입니다. 이번 포스팅에선 총 4node를 구성할 예정이며 master와 slave 3대를 구축하여 LB를 통해 부하분산이 최종 목표입니다. 테스트 환경 Hostname Public I.

jhdatabase.tistory.com

 

 

■ MHA scripts 수정

[root@jh-mgr ~]# cp /root/mha4mysql-manager-0.57/samples/scripts/master_ip_failover  /var/log/masterha/app1/custom_scripts/

[root@jh-mgr ~]# vi /var/log/masterha/app1/custom_scripts/master_ip_failover
:set nu
86~93 주석 처리
     86       ## Creating an app user on the new master
     87       #print "Creating app user on the new master..\n";
     88       #FIXME_xxx_create_user( $new_master_handler->{dbh} );
     89       #$new_master_handler->enable_log_bin_local();
     90       #$new_master_handler->disconnect();
     91
     92       ## Update master ip on the catalog database, etc
     93       #FIXME_xxx;
     94     system("/bin/bash /var/log/masterha/app1/custom_scripts/mha_change_vip.sh $new_master_ip");      ##추가




[root@jh-mgr mha4mysql-manager-0.57]# cp /root/mha4mysql-manager-0.57/samples/scripts/master_ip_online_change  /var/log/masterha/app1/custom_scripts/

[root@jh-mgr ~]# vi /var/log/masterha/app1/custom_scripts/master_ip_online_change
:set nu

149~152 주석 처리
149       ## Drop application user so that nobody can connect. Disabling per-session binlog b    eforehand
150       #$orig_master_handler->disable_log_bin_local();
151       #print current_time_us() . " Drpping app user on the orig master..\n";
152       #FIXME_xxx_drop_app_user($orig_master_handler);

244~248 주석 처리
244       ## Creating an app user on the new master
245       #print current_time_us() . " Creating app user on the new master..\n";
246       #FIXME_xxx_create_app_user($new_master_handler);
247       #$new_master_handler->enable_log_bin_local();
248       #$new_master_handler->disconnect();
249
250       ## Update master ip on the catalog database, etc
251      system("/bin/bash /var/log/masterha/app1/custom_scripts/mha_change_vip.sh $new_master_ip");      ##추가

 

 

■ vip change 스크립트 수정

[root@jh-mgr custom_scripts]# vi mha_change_vip.sh

#!/bin/bash
## Fail-Over VIP Change

V_NEW_MASTER=`cat /etc/hosts | grep $1 | awk '{print $2}'`
V_EXIST_VIP_CHK=`ping -c 1 -W 1 mha-master-vip | grep "packet loss" | awk '{print $6}'`
V_VIP_IP=`cat /etc/hosts | grep mha-master-vip | awk '{print $1}'`

if [ $V_EXIST_VIP_CHK = "0%" ]
then

echo "VIP IS Alive, VIP Relocate $V_NEW_MASTER "
/bin/ssh mha-master-vip /bin/sudo /sbin/ifconfig eth1:1 down &

ssh $V_NEW_MASTER /bin/sudo /sbin/ifconfig eth1:1 $V_VIP_IP netmask 255.255.255.0
ssh $V_NEW_MASTER /sbin/arping -c 5 -D -I eth1:1 -s $V_VIP_IP $V_VIP_IP
VIP_NOHUP_PS=`ps -ef| grep "ifconfig eth1:1" | grep ssh | grep -v grep | awk '{print $2}'` && kill -9 $VIP_NOHUP_PS

elif [ $V_EXIST_VIP_CHK = "100%" ]
then

echo "VIP IS dead, VIP Relocate $V_NEW_MASTER "
/bin/ssh $V_NEW_MASTER /bin/sudo /sbin/ifconfig eth1:1 $V_VIP_IP netmask 255.255.255.0
/bin/ssh $V_NEW_MASTER /sbin/arping -c 5 -D -I eth1:1 -s $V_VIP_IP $V_VIP_IP

fi



[root@jh-mgr custom_scripts]# chmod 755 mha_change_vip.sh


## script를 한번씩 실행시켜 vip가 잘 넘어가는지 확인
[root@jh-mgr custom_scripts]#  ./mha_change_vip.sh 192.168.100.36
[root@jh-mgr custom_scripts]#  ./mha_change_vip.sh 192.168.100.37
[root@jh-mgr custom_scripts]#  ./mha_change_vip.sh 192.168.100.38
[root@jh-mgr custom_scripts]#  ./mha_change_vip.sh 192.168.100.39



[root@jh-mgr ~]# sshcheck
Wed Jul 20 17:01:55 2022 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Wed Jul 20 17:01:55 2022 - [info] Reading application default configuration from /etc/mha.cnf..
Wed Jul 20 17:01:55 2022 - [info] Reading server configuration from /etc/mha.cnf..
Wed Jul 20 17:01:55 2022 - [info] Starting SSH connection tests..
Wed Jul 20 17:01:56 2022 - [debug]
Wed Jul 20 17:01:55 2022 - [debug]  Connecting via SSH from root@192.168.100.36(192.168.100.36:22) to root@192.168.100.37(192.168.100.37:22)..
Wed Jul 20 17:01:55 2022 - [debug]   ok.
Wed Jul 20 17:01:55 2022 - [debug]  Connecting via SSH from root@192.168.100.36(192.168.100.36:22) to root@192.168.100.38(192.168.100.38:22)..
Wed Jul 20 17:01:55 2022 - [debug]   ok.
Wed Jul 20 17:01:55 2022 - [debug]  Connecting via SSH from root@192.168.100.36(192.168.100.36:22) to root@192.168.100.39(192.168.100.39:22)..
Wed Jul 20 17:01:55 2022 - [debug]   ok.
Wed Jul 20 17:01:56 2022 - [debug]
Wed Jul 20 17:01:55 2022 - [debug]  Connecting via SSH from root@192.168.100.37(192.168.100.37:22) to root@192.168.100.36(192.168.100.36:22)..
Wed Jul 20 17:01:55 2022 - [debug]   ok.
Wed Jul 20 17:01:55 2022 - [debug]  Connecting via SSH from root@192.168.100.37(192.168.100.37:22) to root@192.168.100.38(192.168.100.38:22)..
Wed Jul 20 17:01:56 2022 - [debug]   ok.
Wed Jul 20 17:01:56 2022 - [debug]  Connecting via SSH from root@192.168.100.37(192.168.100.37:22) to root@192.168.100.39(192.168.100.39:22)..
Wed Jul 20 17:01:56 2022 - [debug]   ok.
Wed Jul 20 17:01:57 2022 - [debug]
Wed Jul 20 17:01:56 2022 - [debug]  Connecting via SSH from root@192.168.100.38(192.168.100.38:22) to root@192.168.100.36(192.168.100.36:22)..
Wed Jul 20 17:01:56 2022 - [debug]   ok.
Wed Jul 20 17:01:56 2022 - [debug]  Connecting via SSH from root@192.168.100.38(192.168.100.38:22) to root@192.168.100.37(192.168.100.37:22)..
Wed Jul 20 17:01:56 2022 - [debug]   ok.
Wed Jul 20 17:01:56 2022 - [debug]  Connecting via SSH from root@192.168.100.38(192.168.100.38:22) to root@192.168.100.39(192.168.100.39:22)..
Wed Jul 20 17:01:56 2022 - [debug]   ok.
Wed Jul 20 17:01:58 2022 - [debug]
Wed Jul 20 17:01:56 2022 - [debug]  Connecting via SSH from root@192.168.100.39(192.168.100.39:22) to root@192.168.100.36(192.168.100.36:22)..
Wed Jul 20 17:01:56 2022 - [debug]   ok.
Wed Jul 20 17:01:56 2022 - [debug]  Connecting via SSH from root@192.168.100.39(192.168.100.39:22) to root@192.168.100.37(192.168.100.37:22)..
Wed Jul 20 17:01:57 2022 - [debug]   ok.
Wed Jul 20 17:01:57 2022 - [debug]  Connecting via SSH from root@192.168.100.39(192.168.100.39:22) to root@192.168.100.38(192.168.100.38:22)..
Wed Jul 20 17:01:57 2022 - [debug]   ok.
Wed Jul 20 17:01:58 2022 - [info] All SSH connection tests passed successfully.
Use of uninitialized value in exit at /usr/local/bin/masterha_check_ssh line 44.




[root@jh-mgr ~]# replcheck
Wed Jul 20 17:26:57 2022 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Wed Jul 20 17:26:57 2022 - [info] Reading application default configuration from /etc/mha.cnf..
Wed Jul 20 17:26:57 2022 - [info] Reading server configuration from /etc/mha.cnf..
Wed Jul 20 17:26:57 2022 - [info] MHA::MasterMonitor version 0.57.
Wed Jul 20 17:26:58 2022 - [info] GTID failover mode = 0
Wed Jul 20 17:26:58 2022 - [info] Dead Servers:
Wed Jul 20 17:26:58 2022 - [info] Alive Servers:
Wed Jul 20 17:26:58 2022 - [info]   master(192.168.100.36:3306)
Wed Jul 20 17:26:58 2022 - [info]   slave1(192.168.100.37:3306)
Wed Jul 20 17:26:58 2022 - [info]   slave2(192.168.100.38:3306)
Wed Jul 20 17:26:58 2022 - [info]   slave3(192.168.100.39:3306)
Wed Jul 20 17:26:58 2022 - [info] Alive Slaves:
Wed Jul 20 17:26:58 2022 - [info]   slave1(192.168.100.37:3306)  Version=8.0.28 (oldest major version between slaves) log-bin:enabled
Wed Jul 20 17:26:58 2022 - [info]     Replicating from 192.168.100.36(192.168.100.36:3306)
Wed Jul 20 17:26:58 2022 - [info]   slave2(192.168.100.38:3306)  Version=8.0.28 (oldest major version between slaves) log-bin:enabled
Wed Jul 20 17:26:58 2022 - [info]     Replicating from 192.168.100.36(192.168.100.36:3306)
Wed Jul 20 17:26:58 2022 - [info]   slave3(192.168.100.39:3306)  Version=8.0.28 (oldest major version between slaves) log-bin:enabled
Wed Jul 20 17:26:58 2022 - [info]     Replicating from 192.168.100.36(192.168.100.36:3306)
Wed Jul 20 17:26:58 2022 - [info] Current Alive Master: master(192.168.100.36:3306)
Wed Jul 20 17:26:58 2022 - [info] Checking slave configurations..
Wed Jul 20 17:26:58 2022 - [info]  read_only=1 is not set on slave slave1(192.168.100.37:3306).
Wed Jul 20 17:26:58 2022 - [info]  read_only=1 is not set on slave slave2(192.168.100.38:3306).
Wed Jul 20 17:26:58 2022 - [info]  read_only=1 is not set on slave slave3(192.168.100.39:3306).
Wed Jul 20 17:26:58 2022 - [info] Checking replication filtering settings..
Wed Jul 20 17:26:58 2022 - [info]  binlog_do_db= , binlog_ignore_db=
Wed Jul 20 17:26:58 2022 - [info]  Replication filtering check ok.
Wed Jul 20 17:26:58 2022 - [info] GTID (with auto-pos) is not supported
Wed Jul 20 17:26:58 2022 - [info] Starting SSH connection tests..
Wed Jul 20 17:27:01 2022 - [info] All SSH connection tests passed successfully.
Wed Jul 20 17:27:01 2022 - [info] Checking MHA Node version..
Wed Jul 20 17:27:02 2022 - [info]  Version check ok.
Wed Jul 20 17:27:02 2022 - [info] Checking SSH publickey authentication settings on the current master..
Wed Jul 20 17:27:02 2022 - [info] HealthCheck: SSH to master is reachable.
Wed Jul 20 17:27:02 2022 - [info] Master MHA Node version is 0.57.
Wed Jul 20 17:27:02 2022 - [info] Checking recovery script configurations on master(192.168.100.36:3306)..
Wed Jul 20 17:27:02 2022 - [info]   Executing command: save_binary_logs --command=test --start_pos=4 --binlog_dir=/data --output_file=/var/log/masterha/app5/save_binary_logs_test --manager_version=0.57 --start_file=mariadb-bin.000005
Wed Jul 20 17:27:02 2022 - [info]   Connecting to root@192.168.100.36(master:22)..
  Creating /var/log/masterha/app5 if not exists..    ok.
  Checking output directory is accessible or not..
   ok.
  Binlog found at /data, up to mariadb-bin.000005
Wed Jul 20 17:27:02 2022 - [info] Binlog setting check done.
Wed Jul 20 17:27:02 2022 - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers..
Wed Jul 20 17:27:02 2022 - [info]   Executing command : apply_diff_relay_logs --command=test --slave_user='repl' --slave_host=slave1 --slave_ip=192.168.100.37 --slave_port=3306 --workdir=/var/log/masterha/app5 --target_version=8.0.28 --manager_version=0.57 --relay_dir=/data --current_relay_log=relay-log.000004  --slave_pass=xxx
Wed Jul 20 17:27:02 2022 - [info]   Connecting to root@192.168.100.37(slave1:22)..
  Checking slave recovery environment settings..
    Relay log found at /data, up to relay-log.000004
    Temporary relay log file is /data/relay-log.000004
    Testing mysql connection and privileges..mysql: [Warning] Using a password on the command line interface can be insecure.
done.
    Testing mysqlbinlog output.. done.
    Cleaning up test file(s).. done.
Wed Jul 20 17:27:02 2022 - [info]   Executing command : apply_diff_relay_logs --command=test --slave_user='repl' --slave_host=slave2 --slave_ip=192.168.100.38 --slave_port=3306 --workdir=/var/log/masterha/app5 --target_version=8.0.28 --manager_version=0.57 --relay_dir=/data --current_relay_log=relay-log.000004  --slave_pass=xxx
Wed Jul 20 17:27:02 2022 - [info]   Connecting to root@192.168.100.38(slave2:22)..
  Checking slave recovery environment settings..
    Relay log found at /data, up to relay-log.000004
    Temporary relay log file is /data/relay-log.000004
    Testing mysql connection and privileges..mysql: [Warning] Using a password on the command line interface can be insecure.
done.
    Testing mysqlbinlog output.. done.
    Cleaning up test file(s).. done.
Wed Jul 20 17:27:03 2022 - [info]   Executing command : apply_diff_relay_logs --command=test --slave_user='repl' --slave_host=slave3 --slave_ip=192.168.100.39 --slave_port=3306 --workdir=/var/log/masterha/app5 --target_version=8.0.28 --manager_version=0.57 --relay_dir=/data --current_relay_log=relay-log.000004  --slave_pass=xxx
Wed Jul 20 17:27:03 2022 - [info]   Connecting to root@192.168.100.39(slave3:22)..
  Checking slave recovery environment settings..
    Relay log found at /data, up to relay-log.000004
    Temporary relay log file is /data/relay-log.000004
    Testing mysql connection and privileges..mysql: [Warning] Using a password on the command line interface can be insecure.
done.
    Testing mysqlbinlog output.. done.
    Cleaning up test file(s).. done.
Wed Jul 20 17:27:03 2022 - [info] Slaves settings check done.
Wed Jul 20 17:27:03 2022 - [info]
master(192.168.100.36:3306) (current master)
+--slave1(192.168.100.37:3306)
+--slave2(192.168.100.38:3306)
+--slave3(192.168.100.39:3306)

Wed Jul 20 17:27:03 2022 - [info] Checking replication health on slave1..
Wed Jul 20 17:27:03 2022 - [info]  ok.
Wed Jul 20 17:27:03 2022 - [info] Checking replication health on slave2..
Wed Jul 20 17:27:03 2022 - [info]  ok.
Wed Jul 20 17:27:03 2022 - [info] Checking replication health on slave3..
Wed Jul 20 17:27:03 2022 - [info]  ok.
Wed Jul 20 17:27:03 2022 - [info] Checking master_ip_failover_script status:
Wed Jul 20 17:27:03 2022 - [info]   /var/log/masterha/app1/custom_scripts/master_ip_failover --command=status --ssh_user=root --orig_master_host=master --orig_master_ip=192.168.100.36 --orig_master_port=3306
Wed Jul 20 17:27:03 2022 - [info]  OK.
Wed Jul 20 17:27:03 2022 - [warning] shutdown_script is not defined.
Wed Jul 20 17:27:03 2022 - [info] Got exit code 0 (Not master dead).

MySQL Replication Health is OK.




[root@jh-mgr custom_scripts]# start

[root@jh-mgr ~]# status
mha (pid:1575) is running(0:PING_OK), master:192.168.100.36

 

 

■ Failover test
Master -> Slave1
 
※ Master role 선정 방법
1) 마스터DB 장애 발생시 세 대의 slave DB 중 가장 최신의 slave DB 탐색합니다.
2) 나머지 slave DB의 SQL thread가 relay log 를 모두 읽을 때 까지 대기합니다.
3) 이후 , 최신 slave DB와 비교 하여 값 적용

 

최신 Slave 찾는 방법 
1)show slave status\G로 각 slave DB의 relay log를 확인
2)relay log에서 end_log_pos 값 비교
<Master>
[root@jh-master ~]# ps -ef | grep mysql
root      22833  19707  0 14:53 pts/1    00:00:00 /bin/sh /mysql/bin/mysqld_safe --user=mysql
mysql     23080  22833  0 14:53 pts/1    00:00:00 /mysql/bin/mysqld --basedir=/mysql --datadir=/data --plugin-dir=/mysql/lib/plugin --user=mysql --log-error=/log/mariadb.log --pid-file=/log/mariadb.pid --socket=/tmp/mysql.sock
root      23594  19707  0 14:54 pts/1    00:00:00 grep --color=auto mysql


[root@jh-master ~]# kill -9 23080 22833



<Master>
[root@jh-master ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.41.216.208  netmask 255.255.254.0  broadcast 10.41.217.255
        ether f2:20:cd:e1:e4:64  txqueuelen 1000  (Ethernet)
        RX packets 318635  bytes 1307578034 (1.2 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 195905  bytes 25655179 (24.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.36  netmask 255.255.255.0  broadcast 192.168.100.255
        ether f2:d7:cf:cc:bb:f0  txqueuelen 1000  (Ethernet)
        RX packets 114467  bytes 7938512 (7.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 47184  bytes 5884806 (5.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1  (Local Loopback)
        RX packets 12  bytes 1164 (1.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12  bytes 1164 (1.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0



<Slave1>
[root@jh-slave1 app5]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.41.42.80  netmask 255.255.254.0  broadcast 10.41.43.255
        ether f2:20:cd:a6:26:a6  txqueuelen 1000  (Ethernet)
        RX packets 1711020  bytes 1413540589 (1.3 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 415801  bytes 161079865 (153.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.37  netmask 255.255.255.0  broadcast 192.168.100.255
        ether f2:d7:cf:b6:15:ef  txqueuelen 1000  (Ethernet)
        RX packets 2567403  bytes 203430207 (194.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1660750  bytes 195603259 (186.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.40  netmask 255.255.255.0  broadcast 192.168.100.255
        ether f2:d7:cf:b6:15:ef  txqueuelen 1000  (Ethernet)

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1  (Local Loopback)
        RX packets 937  bytes 162686 (158.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 937  bytes 162686 (158.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0




[root@jh-mgr custom_scripts]# log
Selected 192.168.100.37(192.168.100.37:3306) as a new master.
192.168.100.37(192.168.100.37:3306): OK: Applying all logs succeeded.
192.168.100.37(192.168.100.37:3306): OK: Activated master IP address.
192.168.100.39(192.168.100.39:3306): This host has the latest relay log events.
192.168.100.38(192.168.100.38:3306): This host has the latest relay log events.
Generating relay diff files from the latest slave succeeded.
192.168.100.38(192.168.100.38:3306): OK: Applying all logs succeeded. Slave started, replicating from 192.168.100.37(192.168.100.37:3306)
192.168.100.39(192.168.100.39:3306): OK: Applying all logs succeeded. Slave started, replicating from 192.168.100.37(192.168.100.37:3306)
192.168.100.37(192.168.100.37:3306): Resetting slave info succeeded.
Master failover to 192.168.100.37(192.168.100.37:3306) completed successfully.

 

 

Slave1 -> Master

## 예전 master를 현master의 slave로 등록
mysql> CHANGE MASTER TO MASTER_HOST='192.168.100.37', MASTER_USER='repl',MASTER_PASSWORD='repl',MASTER_PORT=3306,MASTER_LOG_FILE='mariadb-bin.000008', MASTER_LOG_POS=157,MASTER_CONNECT_RETRY=10;
Query OK, 0 rows affected, 10 warnings (0.02 sec)


mysql> start slave;
Query OK, 0 rows affected, 1 warning (0.01 sec)


[root@jh-mgr ~]# sshcheck

[root@jh-mgr ~]# replcheck
...(생략)
Tue Jul 26 16:04:47 2022 - [info] Checking replication health on 192.168.100.36..
Tue Jul 26 16:04:47 2022 - [info]  ok.
Tue Jul 26 16:04:47 2022 - [info] Checking replication health on 192.168.100.38..
Tue Jul 26 16:04:47 2022 - [info]  ok.
Tue Jul 26 16:04:47 2022 - [info] Checking replication health on 192.168.100.39..
Tue Jul 26 16:04:47 2022 - [info]  ok.
Tue Jul 26 16:04:47 2022 - [info] Checking master_ip_failover_script status:
Tue Jul 26 16:04:47 2022 - [info]   /var/log/masterha/app1/custom_scripts/master_ip_failover --command=status --ssh_user=root --orig_master_host=192.168.100.37 --orig_master_ip=192.168.100.37 --orig_master_port=3306
Tue Jul 26 16:04:47 2022 - [info]  OK.
Tue Jul 26 16:04:47 2022 - [warning] shutdown_script is not defined.
Tue Jul 26 16:04:47 2022 - [info] Got exit code 0 (Not master dead).

MySQL Replication Health is OK.


## failover 이후 만들어지는 파일 삭제
[root@jh-mgr app1]# rm -rf /var/log/masterha/app1/mha.failover.complete


[root@jh-mgr ~]# start
[5] 3380
[root@jh-mgr ~]# Tue Jul 26 16:05:48 2022 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Tue Jul 26 16:05:48 2022 - [info] Reading application default configuration from /etc/mha.cnf..
Tue Jul 26 16:05:48 2022 - [info] Reading server configuration from /etc/mha.cnf..


[root@jh-mgr ~]# status
mha (pid:3380) is running(0:PING_OK), master:192.168.100.37





<Slave1> mysql kill
[root@jh-slave1 ~]# ps -ef | grep mysql
root     21851 19672  0 14:36 pts/0    00:00:00 /bin/sh /mysql/bin/mysqld_safe --user=mysql
mysql    22098 21851  0 14:36 pts/0    00:00:18 /mysql/bin/mysqld --basedir=/mysql --datadir=/data --plugin-dir=/mysql/lib/plugin --user=mysql --log-error=/log/mariadb.log --pid-file=/log/mariadb.pid --socket=/tmp/mysql.sock
root     27331 19672  0 16:07 pts/0    00:00:00 grep --color=auto mysql

[root@jh-slave1 ~]# kill -9 21851 22098



[root@jh-slave1 ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.41.42.80  netmask 255.255.254.0  broadcast 10.41.43.255
        ether f2:20:cd:a6:26:a6  txqueuelen 1000  (Ethernet)
        RX packets 1726198  bytes 1414715485 (1.3 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 417688  bytes 162547392 (155.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.37  netmask 255.255.255.0  broadcast 192.168.100.255
        ether f2:d7:cf:b6:15:ef  txqueuelen 1000  (Ethernet)
        RX packets 2596325  bytes 205991937 (196.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1680919  bytes 198115365 (188.9 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1  (Local Loopback)
        RX packets 937  bytes 162686 (158.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 937  bytes 162686 (158.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0




[root@jh-master ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.41.216.208  netmask 255.255.254.0  broadcast 10.41.217.255
        ether f2:20:cd:e1:e4:64  txqueuelen 1000  (Ethernet)
        RX packets 1695115  bytes 1415112531 (1.3 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 341152  bytes 170990651 (163.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.36  netmask 255.255.255.0  broadcast 192.168.100.255
        ether f2:d7:cf:cc:bb:f0  txqueuelen 1000  (Ethernet)
        RX packets 1215697  bytes 64396280 (61.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 204667  bytes 18203625 (17.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.40  netmask 255.255.255.0  broadcast 192.168.100.255
        ether f2:d7:cf:cc:bb:f0  txqueuelen 1000  (Ethernet)

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1  (Local Loopback)
        RX packets 655  bytes 111811 (109.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 655  bytes 111811 (109.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

 

참고 & 사진 출처

 

https://hoing.io/archives/9175

 

MySQL MHA(Master High Availability) 1 - MHA 기능 설명 및 아키텍처 설명

 

hoing.io