久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

MySQL5.7中MHA怎么添加或刪除slave節(jié)點(diǎn)

共計(jì) 12802 個(gè)字符,預(yù)計(jì)需要花費(fèi) 33 分鐘才能閱讀完成。

這篇文章主要講解了“MySQL5.7 中 MHA 怎么添加或刪除 slave 節(jié)點(diǎn)”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著丸趣 TV 小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“MySQL5.7 中 MHA 怎么添加或刪除 slave 節(jié)點(diǎn)”吧!

數(shù)據(jù)庫(kù)架構(gòu):一主兩從

master:192.168.8.57

slave1:192.168.8.58

slave2:192.168.8.59

manager:192.168.8.60

MHA 工具包:

mha4mysql-manager-0.58.tar.gz

mha4mysql-node-0.58.tar.gz

一、添加節(jié)點(diǎn)

1. 安裝 OS,修改主機(jī)名,hosts

2. 配置 SSH 無(wú)密碼驗(yàn)證

master

ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.8.61

slave1

ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.8.61

slave2

ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.8.61

manager

ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.8.61

slave3

ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.8.57
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.8.58
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.8.59
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.8.60

3. 安裝 MySQL5.7,配置復(fù)制

change master to
master_host= 192.168.8.57 ,
master_port=3306,
master_user= repl ,
master_password= mysql ,
master_auto_position=1;

4. 安裝 mha-node

tar xf mha4mysql-node-0.58.tar.gz
cd mha4mysql-node-0.58
perl Makefile.PL
make   make install

5. 修改 mha 配置文件 app1.cnf

[server4]
hostname=192.168.8.61
port=3306

6. 互信測(cè)試

Mon Oct 29 20:01:59 2018 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Mon Oct 29 20:01:59 2018 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
Mon Oct 29 20:01:59 2018 - [info] Reading server configuration from /etc/masterha/app1.cnf..
Mon Oct 29 20:01:59 2018 - [info] Starting SSH connection tests..
Mon Oct 29 20:02:01 2018 - [debug] 
Mon Oct 29 20:01:59 2018 - [debug] Connecting via SSH from root@192.168.8.57(192.168.8.57:22) to root@192.168.8.58(192.168.8.58:22)..
Mon Oct 29 20:02:00 2018 - [debug] ok.
Mon Oct 29 20:02:00 2018 - [debug] Connecting via SSH from root@192.168.8.57(192.168.8.57:22) to root@192.168.8.59(192.168.8.59:22)..
Mon Oct 29 20:02:00 2018 - [debug] ok.
Mon Oct 29 20:02:00 2018 - [debug] Connecting via SSH from root@192.168.8.57(192.168.8.57:22) to root@192.168.8.61(192.168.8.61:22)..
Mon Oct 29 20:02:01 2018 - [debug] ok.
Mon Oct 29 20:02:02 2018 - [debug] 
Mon Oct 29 20:02:00 2018 - [debug] Connecting via SSH from root@192.168.8.58(192.168.8.58:22) to root@192.168.8.57(192.168.8.57:22)..
Mon Oct 29 20:02:00 2018 - [debug] ok.
Mon Oct 29 20:02:00 2018 - [debug] Connecting via SSH from root@192.168.8.58(192.168.8.58:22) to root@192.168.8.59(192.168.8.59:22)..
Mon Oct 29 20:02:01 2018 - [debug] ok.
Mon Oct 29 20:02:01 2018 - [debug] Connecting via SSH from root@192.168.8.58(192.168.8.58:22) to root@192.168.8.61(192.168.8.61:22)..
Mon Oct 29 20:02:01 2018 - [debug] ok.
Mon Oct 29 20:02:02 2018 - [debug] 
Mon Oct 29 20:02:00 2018 - [debug] Connecting via SSH from root@192.168.8.59(192.168.8.59:22) to root@192.168.8.57(192.168.8.57:22)..
Mon Oct 29 20:02:01 2018 - [debug] ok.
Mon Oct 29 20:02:01 2018 - [debug] Connecting via SSH from root@192.168.8.59(192.168.8.59:22) to root@192.168.8.58(192.168.8.58:22)..
Mon Oct 29 20:02:01 2018 - [debug] ok.
Mon Oct 29 20:02:01 2018 - [debug] Connecting via SSH from root@192.168.8.59(192.168.8.59:22) to root@192.168.8.61(192.168.8.61:22)..
Mon Oct 29 20:02:02 2018 - [debug] ok.
Mon Oct 29 20:02:03 2018 - [debug] 
Mon Oct 29 20:02:01 2018 - [debug] Connecting via SSH from root@192.168.8.61(192.168.8.61:22) to root@192.168.8.57(192.168.8.57:22)..
Mon Oct 29 20:02:01 2018 - [debug] ok.
Mon Oct 29 20:02:01 2018 - [debug] Connecting via SSH from root@192.168.8.61(192.168.8.61:22) to root@192.168.8.58(192.168.8.58:22)..
Mon Oct 29 20:02:02 2018 - [debug] ok.
Mon Oct 29 20:02:02 2018 - [debug] Connecting via SSH from root@192.168.8.61(192.168.8.61:22) to root@192.168.8.59(192.168.8.59:22)..
Mon Oct 29 20:02:02 2018 - [debug] ok.
Mon Oct 29 20:02:03 2018 - [info] All SSH connection tests passed successfully.

7. 復(fù)制狀況檢查

Mon Oct 29 20:02:15 2018 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Mon Oct 29 20:02:15 2018 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
Mon Oct 29 20:02:15 2018 - [info] Reading server configuration from /etc/masterha/app1.cnf..
Mon Oct 29 20:02:15 2018 - [info] MHA::MasterMonitor version 0.58.
Mon Oct 29 20:02:17 2018 - [info] GTID failover mode = 1
Mon Oct 29 20:02:17 2018 - [info] Dead Servers:
Mon Oct 29 20:02:17 2018 - [info] Alive Servers:
Mon Oct 29 20:02:17 2018 - [info] 192.168.8.57(192.168.8.57:3306)
Mon Oct 29 20:02:17 2018 - [info] 192.168.8.58(192.168.8.58:3306)
Mon Oct 29 20:02:17 2018 - [info] 192.168.8.59(192.168.8.59:3306)
Mon Oct 29 20:02:17 2018 - [info] 192.168.8.61(192.168.8.61:3306)
Mon Oct 29 20:02:17 2018 - [info] Alive Slaves:
Mon Oct 29 20:02:17 2018 - [info] 192.168.8.58(192.168.8.58:3306) Version=5.7.23-log (oldest major version between slaves) log-bin:enabled
Mon Oct 29 20:02:17 2018 - [info] GTID ON
Mon Oct 29 20:02:17 2018 - [info] Replicating from 192.168.8.57(192.168.8.57:3306)
Mon Oct 29 20:02:17 2018 - [info] Primary candidate for the new Master (candidate_master is set)
Mon Oct 29 20:02:17 2018 - [info] 192.168.8.59(192.168.8.59:3306) Version=5.7.23-log (oldest major version between slaves) log-bin:enabled
Mon Oct 29 20:02:17 2018 - [info] GTID ON
Mon Oct 29 20:02:17 2018 - [info] Replicating from 192.168.8.57(192.168.8.57:3306)
Mon Oct 29 20:02:17 2018 - [info] 192.168.8.61(192.168.8.61:3306) Version=5.7.23-log (oldest major version between slaves) log-bin:enabled
Mon Oct 29 20:02:17 2018 - [info] GTID ON
Mon Oct 29 20:02:17 2018 - [info] Replicating from 192.168.8.57(192.168.8.57:3306)
Mon Oct 29 20:02:17 2018 - [info] Current Alive Master: 192.168.8.57(192.168.8.57:3306)
Mon Oct 29 20:02:17 2018 - [info] Checking slave configurations..
Mon Oct 29 20:02:17 2018 - [info] read_only=1 is not set on slave 192.168.8.58(192.168.8.58:3306).
Mon Oct 29 20:02:17 2018 - [info] read_only=1 is not set on slave 192.168.8.59(192.168.8.59:3306).
Mon Oct 29 20:02:17 2018 - [info] read_only=1 is not set on slave 192.168.8.61(192.168.8.61:3306).
Mon Oct 29 20:02:17 2018 - [info] Checking replication filtering settings..
Mon Oct 29 20:02:17 2018 - [info] binlog_do_db= , binlog_ignore_db= 
Mon Oct 29 20:02:17 2018 - [info] Replication filtering check ok.
Mon Oct 29 20:02:17 2018 - [info] GTID (with auto-pos) is supported. Skipping all SSH and Node package checking.
Mon Oct 29 20:02:17 2018 - [info] Checking SSH publickey authentication settings on the current master..
Mon Oct 29 20:02:17 2018 - [info] HealthCheck: SSH to 192.168.8.57 is reachable.
Mon Oct 29 20:02:17 2018 - [info] 
192.168.8.57(192.168.8.57:3306) (current master)
 +--192.168.8.58(192.168.8.58:3306)
 +--192.168.8.59(192.168.8.59:3306)
 +--192.168.8.61(192.168.8.61:3306)
Mon Oct 29 20:02:17 2018 - [info] Checking replication health on 192.168.8.58..
Mon Oct 29 20:02:17 2018 - [info] ok.
Mon Oct 29 20:02:17 2018 - [info] Checking replication health on 192.168.8.59..
Mon Oct 29 20:02:17 2018 - [info] ok.
Mon Oct 29 20:02:17 2018 - [info] Checking replication health on 192.168.8.61..
Mon Oct 29 20:02:17 2018 - [info] ok.
Mon Oct 29 20:02:17 2018 - [info] Checking master_ip_failover_script status:
Mon Oct 29 20:02:17 2018 - [info] /usr/local/bin/master_ip_failover --command=status --ssh_user=root --orig_master_host=192.168.8.57 --orig_master_ip=192.168.8.57 --orig_master_port=3306 
Mon Oct 29 20:02:17 2018 - [info] OK.
Mon Oct 29 20:02:17 2018 - [warning] shutdown_script is not defined.
Mon Oct 29 20:02:17 2018 - [info] Got exit code 0 (Not master dead).
MySQL Replication Health is OK.

8. 復(fù)制測(cè)試

master

mysql  create table t12 (id int(6));
Query OK, 0 rows affected (0.09 sec)
mysql  show tables;
+----------------+
| Tables_in_test |
+----------------+
| t1 |
| t10 |
| t11 |
| t12 |
| t2 |
| t3 |
| t4 |
| t5 |
| t6 |
| t7 |
| t8 |
| t9 |
+----------------+

slave1,slave2,slave3

mysql  show tables;
+----------------+
| Tables_in_test |
+----------------+
| t1 |
| t10 |
| t11 |
| t12 |
| t2 |
| t3 |
| t4 |
| t5 |
| t6 |
| t7 |
| t8 |
| t9 |
+----------------+

三個(gè) slave 節(jié)點(diǎn)數(shù)據(jù)一致,表 t12 創(chuàng)建成功。

二、刪除節(jié)點(diǎn)

1. 關(guān)閉 slave3 復(fù)制

mysql  stop slave;
Query OK, 0 rows affected (0.00 sec)
mysql  reset slave;
Query OK, 0 rows affected (0.04 sec)
mysql  show slave status \G
*************************** 1. row ***************************
 Slave_IO_State: 
 Master_Host: 192.168.8.57
 Master_User: repl
 Master_Port: 3306
 Connect_Retry: 60
 Master_Log_File: 
 Read_Master_Log_Pos: 4
 Relay_Log_File: localhost-relay-bin.000001
 Relay_Log_Pos: 4
 Relay_Master_Log_File: 
 Slave_IO_Running: No
 Slave_SQL_Running: No
 Replicate_Do_DB: 
 Replicate_Ignore_DB: 
 Replicate_Do_Table: 
 Replicate_Ignore_Table: 
 Replicate_Wild_Do_Table: 
 Replicate_Wild_Ignore_Table: 
 Last_Errno: 0
 Last_Error: 
 Skip_Counter: 0
 Exec_Master_Log_Pos: 0
 Relay_Log_Space: 217
 Until_Condition: None
 Until_Log_File: 
 Until_Log_Pos: 0
 Master_SSL_Allowed: No
 Master_SSL_CA_File: 
 Master_SSL_CA_Path: 
 Master_SSL_Cert: 
 Master_SSL_Cipher: 
 Master_SSL_Key: 
 Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
 Last_IO_Errno: 0
 Last_IO_Error: 
 Last_SQL_Errno: 0
 Last_SQL_Error: 
 Replicate_Ignore_Server_Ids: 
 Master_Server_Id: 57
 Master_UUID: a92f70a4-d5ea-11e8-af28-080027c0450d
 Master_Info_File: /mysql/data/master.info
 SQL_Delay: 0
 SQL_Remaining_Delay: NULL
 Slave_SQL_Running_State: 
 Master_Retry_Count: 86400
 Master_Bind: 
 Last_IO_Error_Timestamp: 
 Last_SQL_Error_Timestamp: 
 Master_SSL_Crl: 
 Master_SSL_Crlpath: 
 Retrieved_Gtid_Set: 
 Executed_Gtid_Set: a92f70a4-d5ea-11e8-af28-080027c0450b:1-4,
a92f70a4-d5ea-11e8-af28-080027c0450d:1-15,
a92f70a4-d5ea-11e8-af28-080027c0450f:1-8
 Auto_Position: 1
 Replicate_Rewrite_DB: 
 Channel_Name: 
 Master_TLS_Version: 
1 row in set (0.00 sec)

2. 關(guān)閉 slave3 節(jié)點(diǎn) MySQL 進(jìn)程

mysqladmin -uroot -pmysql shutdown

3. 修改 mha 配置文件,刪除以下配置

[server4]
hostname=192.168.8.61
port=3306

4. 重啟 manager 監(jiān)控進(jìn)程

5. 復(fù)制環(huán)境檢查

Mon Oct 29 20:17:37 2018 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Mon Oct 29 20:17:37 2018 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
Mon Oct 29 20:17:37 2018 - [info] Reading server configuration from /etc/masterha/app1.cnf..
Mon Oct 29 20:17:37 2018 - [info] MHA::MasterMonitor version 0.58.
Mon Oct 29 20:17:38 2018 - [info] GTID failover mode = 1
Mon Oct 29 20:17:38 2018 - [info] Dead Servers:
Mon Oct 29 20:17:38 2018 - [info] Alive Servers:
Mon Oct 29 20:17:38 2018 - [info] 192.168.8.57(192.168.8.57:3306)
Mon Oct 29 20:17:38 2018 - [info] 192.168.8.58(192.168.8.58:3306)
Mon Oct 29 20:17:38 2018 - [info] 192.168.8.59(192.168.8.59:3306)
Mon Oct 29 20:17:38 2018 - [info] Alive Slaves:
Mon Oct 29 20:17:38 2018 - [info] 192.168.8.58(192.168.8.58:3306) Version=5.7.23-log (oldest major version between slaves) log-bin:enabled
Mon Oct 29 20:17:38 2018 - [info] GTID ON
Mon Oct 29 20:17:38 2018 - [info] Replicating from 192.168.8.57(192.168.8.57:3306)
Mon Oct 29 20:17:38 2018 - [info] Primary candidate for the new Master (candidate_master is set)
Mon Oct 29 20:17:38 2018 - [info] 192.168.8.59(192.168.8.59:3306) Version=5.7.23-log (oldest major version between slaves) log-bin:enabled
Mon Oct 29 20:17:38 2018 - [info] GTID ON
Mon Oct 29 20:17:38 2018 - [info] Replicating from 192.168.8.57(192.168.8.57:3306)
Mon Oct 29 20:17:38 2018 - [info] Current Alive Master: 192.168.8.57(192.168.8.57:3306)
Mon Oct 29 20:17:38 2018 - [info] Checking slave configurations..
Mon Oct 29 20:17:38 2018 - [info] read_only=1 is not set on slave 192.168.8.58(192.168.8.58:3306).
Mon Oct 29 20:17:38 2018 - [info] read_only=1 is not set on slave 192.168.8.59(192.168.8.59:3306).
Mon Oct 29 20:17:38 2018 - [info] Checking replication filtering settings..
Mon Oct 29 20:17:38 2018 - [info] binlog_do_db= , binlog_ignore_db= 
Mon Oct 29 20:17:38 2018 - [info] Replication filtering check ok.
Mon Oct 29 20:17:38 2018 - [info] GTID (with auto-pos) is supported. Skipping all SSH and Node package checking.
Mon Oct 29 20:17:38 2018 - [info] Checking SSH publickey authentication settings on the current master..
Mon Oct 29 20:17:38 2018 - [info] HealthCheck: SSH to 192.168.8.57 is reachable.
Mon Oct 29 20:17:38 2018 - [info] 
192.168.8.57(192.168.8.57:3306) (current master)
 +--192.168.8.58(192.168.8.58:3306)
 +--192.168.8.59(192.168.8.59:3306)
Mon Oct 29 20:17:38 2018 - [info] Checking replication health on 192.168.8.58..
Mon Oct 29 20:17:38 2018 - [info] ok.
Mon Oct 29 20:17:38 2018 - [info] Checking replication health on 192.168.8.59..
Mon Oct 29 20:17:38 2018 - [info] ok.
Mon Oct 29 20:17:38 2018 - [info] Checking master_ip_failover_script status:
Mon Oct 29 20:17:38 2018 - [info] /usr/local/bin/master_ip_failover --command=status --ssh_user=root --orig_master_host=192.168.8.57 --orig_master_ip=192.168.8.57 --orig_master_port=3306 
Mon Oct 29 20:17:39 2018 - [info] OK.
Mon Oct 29 20:17:39 2018 - [warning] shutdown_script is not defined.
Mon Oct 29 20:17:39 2018 - [info] Got exit code 0 (Not master dead).
MySQL Replication Health is OK.

感謝各位的閱讀,以上就是“MySQL5.7 中 MHA 怎么添加或刪除 slave 節(jié)點(diǎn)”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì) MySQL5.7 中 MHA 怎么添加或刪除 slave 節(jié)點(diǎn)這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是丸趣 TV,丸趣 TV 小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-08-01發(fā)表,共計(jì)12802字。
轉(zhuǎn)載說(shuō)明:除特殊說(shuō)明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請(qǐng)注明出處。
評(píng)論(沒(méi)有評(píng)論)
主站蜘蛛池模板: 伊春市| 龙岩市| 上犹县| 绿春县| 彭阳县| 合山市| 家居| 枣庄市| 闸北区| 岳阳市| 诸暨市| 苏州市| 东光县| 星子县| 姜堰市| 东乌珠穆沁旗| 武汉市| 孙吴县| 玉林市| 新宾| 恩施市| 浪卡子县| 满洲里市| 常德市| 华安县| 建始县| 仙游县| 新田县| 建宁县| 寿阳县| 元氏县| 芜湖市| 农安县| 舞阳县| 开平市| 寿阳县| 罗山县| 合阳县| 筠连县| 吴江市| 宜城市|