当前位置:   article > 正文

GTID复制

gtid复制

GTID复制

  1. GTID(global transaction identifier,全局事务ID)是5.6新特性,为每个事务分配一个唯一的ID。事务ID的格式
  2. source_id:transaction_id
  3. source_id通常用实例的server_uuid表示
  4. transaction_id是事务的序列号,从1开始

GTID搭建

  1. 1、参数配置
  2. 主从节点都要配置
  3. root@localhost [mysql]> select @@gtid_mode;
  4. +-------------+
  5. | @@gtid_mode |
  6. +-------------+
  7. | OFF |
  8. +-------------+
  9. 1 row in set (0.01 sec)
  10. root@localhost [mysql]> select @@enforce_gtid_consistency;
  11. +----------------------------+
  12. | @@enforce_gtid_consistency |
  13. +----------------------------+
  14. | OFF |
  15. +----------------------------+
  16. 1 row in set (0.00 sec)
  17. 主从节点都要修改配置文件
  18. gtid_mode=on
  19. enforce_gtid_consistency=1
  20. 添加完参数后,重启服务
  21. [root@node01 mysql]# systemctl restart mysqld
  22. [root@node02 mysql]# systemctl restart mysqld
  23. [root@node03 mysql]# systemctl restart mysqld
  24. root@localhost [hr]> select @@enforce_gtid_consistency;
  25. +----------------------------+
  26. | @@enforce_gtid_consistency |
  27. +----------------------------+
  28. | ON |
  29. +----------------------------+
  30. 1 row in set (0.00 sec)
  31. root@localhost [hr]> select @@gtid_mode;
  32. +-------------+
  33. | @@gtid_mode |
  34. +-------------+
  35. | ON |
  36. +-------------+
  37. 1 row in set (0.00 sec)
  38. 2、change master to
  39. 从库执行
  40. gtid复制只需要设置master_auto_position=1,无需设置maser_log_file和master_log_pos参数
  41. change master to
  42. master_host='192.168.6.101',
  43. master_port=3306,
  44. master_user='repl',
  45. master_password='oracle',
  46. master_auto_position=1,
  47. get_master_public_key=1;
  48. 从库node02执行
  49. 需要先关闭slave
  50. root@localhost [(none)]> stop slave;
  51. Query OK, 0 rows affected, 1 warning (0.00 sec)
  52. node03
  53. root@localhost [(none)]> stop slave;
  54. Query OK, 0 rows affected, 1 warning (0.02 sec)
  55. root@localhost [(none)]>
  56. root@localhost [(none)]> start slave;
  57. Query OK, 0 rows affected, 1 warning (0.00 sec)
  58. root@localhost [(none)]> start slave;
  59. Query OK, 0 rows affected, 1 warning (0.00 sec)
  60. root@localhost [(none)]> show slave status\G
  61. *************************** 1. row ***************************
  62. Slave_IO_State: Waiting for source to send event
  63. Master_Host: 192.168.6.101
  64. Master_User: repl
  65. Master_Port: 3306
  66. Connect_Retry: 60
  67. Master_Log_File: binlog.000010
  68. Read_Master_Log_Pos: 157
  69. Relay_Log_File: node02-relay-bin.000003
  70. Relay_Log_Pos: 367
  71. Relay_Master_Log_File: binlog.000010
  72. Slave_IO_Running: Yes
  73. Slave_SQL_Running: Yes
  74. Replicate_Do_DB:
  75. Replicate_Ignore_DB:
  76. Replicate_Do_Table:
  77. Replicate_Ignore_Table:
  78. Replicate_Wild_Do_Table:
  79. Replicate_Wild_Ignore_Table:
  80. Last_Errno: 0
  81. Last_Error:
  82. Skip_Counter: 0
  83. Exec_Master_Log_Pos: 157
  84. Relay_Log_Space: 758
  85. Until_Condition: None
  86. Until_Log_File:
  87. Until_Log_Pos: 0
  88. Master_SSL_Allowed: No
  89. Master_SSL_CA_File:
  90. Master_SSL_CA_Path:
  91. Master_SSL_Cert:
  92. Master_SSL_Cipher:
  93. Master_SSL_Key:
  94. Seconds_Behind_Master: 0
  95. Master_SSL_Verify_Server_Cert: No
  96. Last_IO_Errno: 0
  97. Last_IO_Error:
  98. Last_SQL_Errno: 0
  99. Last_SQL_Error:
  100. Replicate_Ignore_Server_Ids:
  101. Master_Server_Id: 1001
  102. Master_UUID: 8ba057c3-2d10-11ee-a0fa-000c29004cdf
  103. Master_Info_File: mysql.slave_master_info
  104. SQL_Delay: 0
  105. SQL_Remaining_Delay: NULL
  106. Slave_SQL_Running_State: Replica has read all relay log; waiting for more updates
  107. Master_Retry_Count: 86400
  108. Master_Bind:
  109. Last_IO_Error_Timestamp:
  110. Last_SQL_Error_Timestamp:
  111. Master_SSL_Crl:
  112. Master_SSL_Crlpath:
  113. Retrieved_Gtid_Set:
  114. Executed_Gtid_Set:
  115. Auto_Position: 1
  116. Replicate_Rewrite_DB:
  117. Channel_Name:
  118. Master_TLS_Version:
  119. Master_public_key_path:
  120. Get_master_public_key: 1
  121. Network_Namespace:
  122. 1 row in set, 1 warning (0.00 sec)

GTID复制切换成异步复制

  1. 1、关闭从库
  2. root@node01 [(none)]> show master status;
  3. +---------------+----------+--------------+------------------+------------------------------------------+
  4. | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
  5. +---------------+----------+--------------+------------------+------------------------------------------+
  6. | binlog.000010 | 2105 | | | 8ba057c3-2d10-11ee-a0fa-000c29004cdf:1-8 |
  7. +---------------+----------+--------------+------------------+------------------------------------------+
  8. 1 row in set (0.00 sec)
  9. root@node02 [(none)]> stop slave;
  10. Query OK, 0 rows affected, 1 warning (0.60 sec)
  11. 查看Relay_Master_Log_File和Relay_Master_Log_File的值
  12. root@node02 [(none)]> show slave status\G
  13. Relay_Master_Log_File: binlog.000010
  14. Relay_Master_Log_File: 2105
  15. root@node03 [(none)]> stop slave;
  16. Query OK, 0 rows affected, 1 warning (0.52 sec)
  17. root@node03 [(none)]> show slave status\G
  18. Relay_Master_Log_File: binlog.000010
  19. Exec_Master_Log_Pos: 2105
  20. 2、从库执行change master to命令
  21. change master to
  22. master_auto_position=0,
  23. master_log_file='binlog.000010',
  24. master_log_pos=2105,
  25. get_master_public_key=1;
  26. root@node02 [(none)]> change master to
  27. -> master_auto_position=0,
  28. -> master_log_file='binlog.000010',
  29. -> master_log_pos=2105,
  30. -> get_master_public_key=1;
  31. Query OK, 0 rows affected, 5 warnings (0.30 sec)
  32. root@node03 [(none)]> change master to
  33. -> master_auto_position=0,
  34. -> master_log_file='binlog.000010',
  35. -> master_log_pos=2105,
  36. -> get_master_public_key=1;
  37. Query OK, 0 rows affected, 5 warnings (0.24 sec)
  38. 3、开启复制
  39. root@node02 [(none)]> start slave;
  40. Query OK, 0 rows affected, 1 warning (1.49 sec)
  41. root@node03 [(none)]> start slave;
  42. Query OK, 0 rows affected, 1 warning (1.66 sec)
  43. 从库状态正常
  44. root@node02 [(none)]> show slave status\G
  45. *************************** 1. row ***************************
  46. Slave_IO_State: Waiting for source to send event
  47. Master_Host: 192.168.6.101
  48. Master_User: repl
  49. Master_Port: 3306
  50. Connect_Retry: 60
  51. Master_Log_File: binlog.000010
  52. Read_Master_Log_Pos: 2105
  53. Relay_Log_File: node02-relay-bin.000002
  54. Relay_Log_Pos: 323
  55. Relay_Master_Log_File: binlog.000010
  56. Slave_IO_Running: Yes
  57. Slave_SQL_Running: Yes
  58. Replicate_Do_DB:
  59. Replicate_Ignore_DB:
  60. Replicate_Do_Table:
  61. Replicate_Ignore_Table:
  62. Replicate_Wild_Do_Table:
  63. Replicate_Wild_Ignore_Table:
  64. Last_Errno: 0
  65. Last_Error:
  66. Skip_Counter: 0
  67. Exec_Master_Log_Pos: 2105
  68. Relay_Log_Space: 534
  69. Until_Condition: None
  70. Until_Log_File:
  71. Until_Log_Pos: 0
  72. Master_SSL_Allowed: No
  73. Master_SSL_CA_File:
  74. Master_SSL_CA_Path:
  75. Master_SSL_Cert:
  76. Master_SSL_Cipher:
  77. Master_SSL_Key:
  78. Seconds_Behind_Master: 0
  79. Master_SSL_Verify_Server_Cert: No
  80. Last_IO_Errno: 0
  81. Last_IO_Error:
  82. Last_SQL_Errno: 0
  83. Last_SQL_Error:
  84. Replicate_Ignore_Server_Ids:
  85. Master_Server_Id: 1001
  86. Master_UUID: 8ba057c3-2d10-11ee-a0fa-000c29004cdf
  87. Master_Info_File: mysql.slave_master_info
  88. SQL_Delay: 0
  89. SQL_Remaining_Delay: NULL
  90. Slave_SQL_Running_State: Replica has read all relay log; waiting for more updates
  91. Master_Retry_Count: 86400
  92. Master_Bind:
  93. Last_IO_Error_Timestamp:
  94. Last_SQL_Error_Timestamp:
  95. Master_SSL_Crl:
  96. Master_SSL_Crlpath:
  97. Retrieved_Gtid_Set:
  98. Executed_Gtid_Set: 3ff16ad3-2d17-11ee-aab1-000c297a8cee:1-2,
  99. 8ba057c3-2d10-11ee-a0fa-000c29004cdf:1-8
  100. Auto_Position: 0
  101. Replicate_Rewrite_DB:
  102. Channel_Name:
  103. Master_TLS_Version:
  104. Master_public_key_path:
  105. Get_master_public_key: 1
  106. Network_Namespace:
  107. 1 row in set, 1 warning (0.00 sec)
  108. root@node03 [(none)]> show slave status\G
  109. *************************** 1. row ***************************
  110. Slave_IO_State: Waiting for source to send event
  111. Master_Host: 192.168.6.101
  112. Master_User: repl
  113. Master_Port: 3306
  114. Connect_Retry: 60
  115. Master_Log_File: binlog.000010
  116. Read_Master_Log_Pos: 2105
  117. Relay_Log_File: node03-relay-bin.000002
  118. Relay_Log_Pos: 323
  119. Relay_Master_Log_File: binlog.000010
  120. Slave_IO_Running: Yes
  121. Slave_SQL_Running: Yes
  122. Replicate_Do_DB:
  123. Replicate_Ignore_DB:
  124. Replicate_Do_Table:
  125. Replicate_Ignore_Table:
  126. Replicate_Wild_Do_Table:
  127. Replicate_Wild_Ignore_Table:
  128. Last_Errno: 0
  129. Last_Error:
  130. Skip_Counter: 0
  131. Exec_Master_Log_Pos: 2105
  132. Relay_Log_Space: 534
  133. Until_Condition: None
  134. Until_Log_File:
  135. Until_Log_Pos: 0
  136. Master_SSL_Allowed: No
  137. Master_SSL_CA_File:
  138. Master_SSL_CA_Path:
  139. Master_SSL_Cert:
  140. Master_SSL_Cipher:
  141. Master_SSL_Key:
  142. Seconds_Behind_Master: 0
  143. Master_SSL_Verify_Server_Cert: No
  144. Last_IO_Errno: 0
  145. Last_IO_Error:
  146. Last_SQL_Errno: 0
  147. Last_SQL_Error:
  148. Replicate_Ignore_Server_Ids:
  149. Master_Server_Id: 1001
  150. Master_UUID: 8ba057c3-2d10-11ee-a0fa-000c29004cdf
  151. Master_Info_File: mysql.slave_master_info
  152. SQL_Delay: 0
  153. SQL_Remaining_Delay: NULL
  154. Slave_SQL_Running_State: Replica has read all relay log; waiting for more updates
  155. Master_Retry_Count: 86400
  156. Master_Bind:
  157. Last_IO_Error_Timestamp:
  158. Last_SQL_Error_Timestamp:
  159. Master_SSL_Crl:
  160. Master_SSL_Crlpath:
  161. Retrieved_Gtid_Set:
  162. Executed_Gtid_Set: 42cab633-2d17-11ee-a9e1-000c296e813f:1-2,
  163. 8ba057c3-2d10-11ee-a0fa-000c29004cdf:1-8
  164. Auto_Position: 0
  165. Replicate_Rewrite_DB:
  166. Channel_Name:
  167. Master_TLS_Version:
  168. Master_public_key_path:
  169. Get_master_public_key: 1
  170. Network_Namespace:
  171. 1 row in set, 1 warning (0.02 sec)
  172. 4、设置主从参数gtid_modeON_PERMISSIVE
  173. set global gtid_mode=ON_PERMISSIVE;
  174. root@node01 [(none)]> set global gtid_mode=ON_PERMISSIVE;
  175. Query OK, 0 rows affected (0.30 sec)
  176. root@node02 [(none)]> set global gtid_mode=ON_PERMISSIVE;
  177. Query OK, 0 rows affected (0.15 sec)
  178. root@node03 [(none)]> set global gtid_mode=ON_PERMISSIVE;
  179. Query OK, 0 rows affected (0.07 sec)
  180. 5、设置主从参数gtid_modeOFF_PERMISSIVE
  181. set global gtid_mode=OFF_PERMISSIVE;
  182. root@node01 [(none)]> set global gtid_mode=OFF_PERMISSIVE;
  183. Query OK, 0 rows affected (0.00 sec)
  184. root@node02 [(none)]> set global gtid_mode=OFF_PERMISSIVE;
  185. Query OK, 0 rows affected (0.00 sec)
  186. root@node03 [(none)]> set global gtid_mode=OFF_PERMISSIVE;
  187. Query OK, 0 rows affected (0.00 sec)
  188. 6、检查主从gtid_owned
  189. select @@global.gtid_owned;
  190. root@node01 [(none)]> select @@global.gtid_owned;
  191. +---------------------+
  192. | @@global.gtid_owned |
  193. +---------------------+
  194. | |
  195. +---------------------+
  196. 1 row in set (0.00 sec)
  197. root@node02 [(none)]> select @@global.gtid_owned;
  198. +---------------------+
  199. | @@global.gtid_owned |
  200. +---------------------+
  201. | |
  202. +---------------------+
  203. 1 row in set (0.00 sec)
  204. root@node03 [(none)]> select @@global.gtid_owned;
  205. +---------------------+
  206. | @@global.gtid_owned |
  207. +---------------------+
  208. | |
  209. +---------------------+
  210. 1 row in set (0.00 sec)
  211. 如果值为空,再继续下一步
  212. 7、等待所有的GTID事务应用完毕
  213. 通过MASTER_POS_WAIT函数判断
  214. root@node01 [(none)]> show master status;
  215. +---------------+----------+--------------+------------------+------------------------------------------+
  216. | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
  217. +---------------+----------+--------------+------------------+------------------------------------------+
  218. | binlog.000012 | 197 | | | 8ba057c3-2d10-11ee-a0fa-000c29004cdf:1-8 |
  219. +---------------+----------+--------------+------------------+------------------------------------------+
  220. 1 row in set (0.00 sec)
  221. 从库执行
  222. select MASTER_POS_WAIT('binlog.000012',197);
  223. root@node02 [(none)]> select MASTER_POS_WAIT('binlog.000012',197);
  224. +--------------------------------------+
  225. | MASTER_POS_WAIT('binlog.000012',197) |
  226. +--------------------------------------+
  227. | 0 |
  228. +--------------------------------------+
  229. 1 row in set, 1 warning (0.06 sec)
  230. root@node03 [(none)]> select MASTER_POS_WAIT('binlog.000012',197);
  231. +--------------------------------------+
  232. | MASTER_POS_WAIT('binlog.000012',197) |
  233. +--------------------------------------+
  234. | 0 |
  235. +--------------------------------------+
  236. 1 row in set, 1 warning (0.04 sec)
  237. 8、主从设置gtid_mode OFF
  238. set global gtid_mode=OFF;
  239. root@node01 [(none)]> set global gtid_mode=OFF;
  240. Query OK, 0 rows affected (0.04 sec)
  241. root@node02 [(none)]> set global gtid_mode=OFF;
  242. Query OK, 0 rows affected (0.04 sec)
  243. root@node03 [(none)]> set global gtid_mode=OFF;
  244. Query OK, 0 rows affected (0.04 sec)
  245. 9、修改主从参数,将GTID相关参数值设为OFF
  246. [root@node01 ~]# vim /etc/my.cnf
  247. #gtid
  248. gtid_mode=off
  249. enforce_gtid_consistency=off
  250. [root@node02 ~]# vim /etc/my.cnf
  251. #gtid
  252. gtid_mode=off
  253. enforce_gtid_consistency=off
  254. [root@node03 ~]# vim /etc/my.cnf
  255. #gtid
  256. gtid_mode=off
  257. enforce_gtid_consistency=off
  258. root@node01 [(none)]> show master status;
  259. +---------------+----------+--------------+------------------+------------------------------------------+
  260. | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
  261. +---------------+----------+--------------+------------------+------------------------------------------+
  262. | binlog.000013 | 197 | | | 8ba057c3-2d10-11ee-a0fa-000c29004cdf:1-8 |
  263. +---------------+----------+--------------+------------------+------------------------------------------+
  264. 1 row in set (0.00 sec)

异步复制切换成GTID复制

  1. root@node01 [(none)]> select @@gtid_mode;
  2. +-------------+
  3. | @@gtid_mode |
  4. +-------------+
  5. | OFF |
  6. +-------------+
  7. 1 row in set (0.00 sec)
  8. root@node02 [(none)]> select @@gtid_mode;
  9. +-------------+
  10. | @@gtid_mode |
  11. +-------------+
  12. | OFF |
  13. +-------------+
  14. 1 row in set (0.00 sec)
  15. root@node03 [(none)]> select @@gtid_mode;
  16. +-------------+
  17. | @@gtid_mode |
  18. +-------------+
  19. | OFF |
  20. +-------------+
  21. 1 row in set (0.00 sec)
  22. 1、分别在主从将enforce_gtid_consistency设置为warn
  23. root@node01 [(none)]> select @@enforce_gtid_consistency;
  24. +----------------------------+
  25. | @@enforce_gtid_consistency |
  26. +----------------------------+
  27. | OFF |
  28. +----------------------------+
  29. 1 row in set (0.01 sec)
  30. root@node01 [(none)]> set @@global.enforce_gtid_consistency=warn;
  31. Query OK, 0 rows affected (0.13 sec)
  32. root@node02 [(none)]> set @@global.enforce_gtid_consistency=warn;
  33. Query OK, 0 rows affected (0.03 sec)
  34. root@node03 [(none)]> set @@global.enforce_gtid_consistency=warn;
  35. Query OK, 0 rows affected (0.03 sec)
  36. 2、分别在主从上将enforce_gtid_consistency设为on
  37. root@node01 [(none)]> set @@global.enforce_gtid_consistency=on;
  38. Query OK, 0 rows affected (0.00 sec)
  39. root@node02 [(none)]> set @@global.enforce_gtid_consistency=on;
  40. Query OK, 0 rows affected (0.00 sec)
  41. root@node03 [(none)]> set @@global.enforce_gtid_consistency=on;
  42. Query OK, 0 rows affected (0.00 sec)
  43. 3、分别在主从将gtid_mode设置off_permissive
  44. root@node01 [(none)]> set @@global.gtid_mode=off_permissive;
  45. Query OK, 0 rows affected (0.22 sec)
  46. root@node02 [(none)]> set @@global.gtid_mode=off_permissive;
  47. Query OK, 0 rows affected (0.00 sec)
  48. root@node03 [(none)]> set @@global.gtid_mode=off_permissive;
  49. Query OK, 0 rows affected (0.03 sec)
  50. 4、分别在主从将gtid_mode设置on_permissive
  51. root@node01 [(none)]> set @@global.gtid_mode=on_permissive;
  52. Query OK, 0 rows affected (0.02 sec)
  53. root@node02 [(none)]> set @@global.gtid_mode=on_permissive;
  54. Query OK, 0 rows affected (0.02 sec)
  55. root@node03 [(none)]> set @@global.gtid_mode=on_permissive;
  56. Query OK, 0 rows affected (0.01 sec)
  57. 5、分别在主从上检查状态变量Ongoing_anonymous_transaction_count
  58. root@node01 [(none)]> show status like '%ongoing%';
  59. +-------------------------------------+-------+
  60. | Variable_name | Value |
  61. +-------------------------------------+-------+
  62. | Ongoing_anonymous_transaction_count | 0 |
  63. +-------------------------------------+-------+
  64. 1 row in set (0.76 sec)
  65. root@node02 [(none)]> show status like '%ongoing%';
  66. +-------------------------------------+-------+
  67. | Variable_name | Value |
  68. +-------------------------------------+-------+
  69. | Ongoing_anonymous_transaction_count | 0 |
  70. +-------------------------------------+-------+
  71. 1 row in set (0.63 sec)
  72. root@node03 [(none)]> show status like '%ongoing%';
  73. +-------------------------------------+-------+
  74. | Variable_name | Value |
  75. +-------------------------------------+-------+
  76. | Ongoing_anonymous_transaction_count | 0 |
  77. +-------------------------------------+-------+
  78. 1 row in set (0.00 sec)
  79. 6、等待从库上匿名事务应用完毕
  80. root@node01 [(none)]> show master status;
  81. +---------------+----------+--------------+------------------+-------------------+
  82. | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
  83. +---------------+----------+--------------+------------------+-------------------+
  84. | binlog.000016 | 157 | | | |
  85. +---------------+----------+--------------+------------------+-------------------+
  86. 1 row in set (0.00 sec)
  87. 在从上查看,返回0说明事务应用完毕
  88. root@node02 [(none)]> select master_pos_wait('binlog.000016',157);
  89. +--------------------------------------+
  90. | master_pos_wait('binlog.000016',157) |
  91. +--------------------------------------+
  92. | 0 |
  93. +--------------------------------------+
  94. 1 row in set, 1 warning (0.05 sec)
  95. root@node03 [(none)]> select master_pos_wait('binlog.000016',157);
  96. +--------------------------------------+
  97. | master_pos_wait('binlog.000016',157) |
  98. +--------------------------------------+
  99. | 0 |
  100. +--------------------------------------+
  101. 1 row in set, 1 warning (0.05 sec)
  102. 7、分别在从库上将gtid_mode设为on
  103. root@node01 [(none)]> set @@global.gtid_mode=on;
  104. Query OK, 0 rows affected (0.02 sec)
  105. root@node02 [(none)]> set @@global.gtid_mode=on;
  106. Query OK, 0 rows affected (0.02 sec)
  107. root@node03 [(none)]> set @@global.gtid_mode=on;
  108. Query OK, 0 rows affected (0.02 sec)
  109. 8、修改主从参数文件
  110. [root@node01 ~]# vim /etc/my.cnf
  111. #gtid
  112. gtid_mode=on
  113. enforce_gtid_consistency=on
  114. [root@node02 ~]# vim /etc/my.cnf
  115. #gtid
  116. gtid_mode=on
  117. enforce_gtid_consistency=on
  118. [root@node03 ~]# vim /etc/my.cnf
  119. #gtid
  120. gtid_mode=on
  121. enforce_gtid_consistency=on
  122. 9、将基于binlog位置点的复制改为gtid复制
  123. root@node02 [(none)]> stop slave;
  124. Query OK, 0 rows affected, 1 warning (0.12 sec)
  125. root@node02 [(none)]> stop slave;
  126. Query OK, 0 rows affected, 1 warning (0.12 sec)
  127. root@node02 [(none)]> change master to
  128. -> master_host='192.168.6.101',
  129. -> master_port=3306,
  130. -> master_user='repl',
  131. -> master_password='oracle',
  132. -> master_auto_position=1,
  133. -> get_master_public_key=1;
  134. Query OK, 0 rows affected, 8 warnings (0.02 sec)
  135. root@node02 [(none)]> start slave;
  136. Query OK, 0 rows affected, 1 warning (0.06 sec)
  137. root@node02 [(none)]> show slave status\G
  138. *************************** 1. row ***************************
  139. Slave_IO_State: Waiting for source to send event
  140. Master_Host: 192.168.6.101
  141. Master_User: repl
  142. Master_Port: 3306
  143. Connect_Retry: 60
  144. Master_Log_File: binlog.000017
  145. Read_Master_Log_Pos: 157
  146. Relay_Log_File: node02-relay-bin.000002
  147. Relay_Log_Pos: 367
  148. Relay_Master_Log_File: binlog.000017
  149. Slave_IO_Running: Yes
  150. Slave_SQL_Running: Yes
  151. Replicate_Do_DB:
  152. Replicate_Ignore_DB:
  153. Replicate_Do_Table:
  154. Replicate_Ignore_Table:
  155. Replicate_Wild_Do_Table:
  156. Replicate_Wild_Ignore_Table:
  157. Last_Errno: 0
  158. Last_Error:
  159. Skip_Counter: 0
  160. Exec_Master_Log_Pos: 157
  161. Relay_Log_Space: 578
  162. Until_Condition: None
  163. Until_Log_File:
  164. Until_Log_Pos: 0
  165. Master_SSL_Allowed: No
  166. Master_SSL_CA_File:
  167. Master_SSL_CA_Path:
  168. Master_SSL_Cert:
  169. Master_SSL_Cipher:
  170. Master_SSL_Key:
  171. Seconds_Behind_Master: 0
  172. Master_SSL_Verify_Server_Cert: No
  173. Last_IO_Errno: 0
  174. Last_IO_Error:
  175. Last_SQL_Errno: 0
  176. Last_SQL_Error:
  177. Replicate_Ignore_Server_Ids:
  178. Master_Server_Id: 1001
  179. Master_UUID: b0ae4cca-32af-11ee-8ff1-000c29004cdf
  180. Master_Info_File: mysql.slave_master_info
  181. SQL_Delay: 0
  182. SQL_Remaining_Delay: NULL
  183. Slave_SQL_Running_State: Replica has read all relay log; waiting for more updates
  184. Master_Retry_Count: 86400
  185. Master_Bind:
  186. Last_IO_Error_Timestamp:
  187. Last_SQL_Error_Timestamp:
  188. Master_SSL_Crl:
  189. Master_SSL_Crlpath:
  190. Retrieved_Gtid_Set:
  191. Executed_Gtid_Set:
  192. Auto_Position: 1
  193. Replicate_Rewrite_DB:
  194. Channel_Name:
  195. Master_TLS_Version:
  196. Master_public_key_path:
  197. Get_master_public_key: 1
  198. Network_Namespace:
  199. 1 row in set, 1 warning (0.00 sec)
  200. root@node03 [(none)]> stop slave;
  201. Query OK, 0 rows affected, 1 warning (0.00 sec)
  202. root@node03 [(none)]> change master to
  203. -> master_host='192.168.6.101',
  204. -> master_port=3306,
  205. -> master_user='repl',
  206. -> master_password='oracle',
  207. -> master_auto_position=1,
  208. -> get_master_public_key=1;
  209. Query OK, 0 rows affected, 8 warnings (0.01 sec)
  210. root@node03 [(none)]> start slave;
  211. Query OK, 0 rows affected, 1 warning (0.00 sec)
  212. root@node03 [(none)]> show slave status\G
  213. *************************** 1. row ***************************
  214. Slave_IO_State: Waiting for source to send event
  215. Master_Host: 192.168.6.101
  216. Master_User: repl
  217. Master_Port: 3306
  218. Connect_Retry: 60
  219. Master_Log_File: binlog.000017
  220. Read_Master_Log_Pos: 157
  221. Relay_Log_File: node03-relay-bin.000002
  222. Relay_Log_Pos: 367
  223. Relay_Master_Log_File: binlog.000017
  224. Slave_IO_Running: Yes
  225. Slave_SQL_Running: Yes
  226. Replicate_Do_DB:
  227. Replicate_Ignore_DB:
  228. Replicate_Do_Table:
  229. Replicate_Ignore_Table:
  230. Replicate_Wild_Do_Table:
  231. Replicate_Wild_Ignore_Table:
  232. Last_Errno: 0
  233. Last_Error:
  234. Skip_Counter: 0
  235. Exec_Master_Log_Pos: 157
  236. Relay_Log_Space: 578
  237. Until_Condition: None
  238. Until_Log_File:
  239. Until_Log_Pos: 0
  240. Master_SSL_Allowed: No
  241. Master_SSL_CA_File:
  242. Master_SSL_CA_Path:
  243. Master_SSL_Cert:
  244. Master_SSL_Cipher:
  245. Master_SSL_Key:
  246. Seconds_Behind_Master: 0
  247. Master_SSL_Verify_Server_Cert: No
  248. Last_IO_Errno: 0
  249. Last_IO_Error:
  250. Last_SQL_Errno: 0
  251. Last_SQL_Error:
  252. Replicate_Ignore_Server_Ids:
  253. Master_Server_Id: 1001
  254. Master_UUID: b0ae4cca-32af-11ee-8ff1-000c29004cdf
  255. Master_Info_File: mysql.slave_master_info
  256. SQL_Delay: 0
  257. SQL_Remaining_Delay: NULL
  258. Slave_SQL_Running_State: Replica has read all relay log; waiting for more updates
  259. Master_Retry_Count: 86400
  260. Master_Bind:
  261. Last_IO_Error_Timestamp:
  262. Last_SQL_Error_Timestamp:
  263. Master_SSL_Crl:
  264. Master_SSL_Crlpath:
  265. Retrieved_Gtid_Set:
  266. Executed_Gtid_Set:
  267. Auto_Position: 1
  268. Replicate_Rewrite_DB:
  269. Channel_Name:
  270. Master_TLS_Version:
  271. Master_public_key_path:
  272. Get_master_public_key: 1
  273. Network_Namespace:
  274. 1 row in set, 1 warning (0.00 sec)
  275. root@node01 [(none)]> show master status;
  276. +---------------+----------+--------------+------------------+-------------------+
  277. | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
  278. +---------------+----------+--------------+------------------+-------------------+
  279. | binlog.000017 | 157 | | | |
  280. +---------------+----------+--------------+------------------+-------------------+
  281. 1 row in set (0.00 sec)
  282. root@node01 [(none)]> select * from sh.customer;
  283. +------+
  284. | id |
  285. +------+
  286. | 1001 |
  287. | 1002 |
  288. | 1003 |
  289. | 1004 |
  290. | 1005 |
  291. +------+
  292. 5 rows in set (0.34 sec)
  293. root@node01 [(none)]> insert into sh.customer values(1006);
  294. Query OK, 1 row affected (0.28 sec)
  295. root@node01 [(none)]> show master status;
  296. +---------------+----------+--------------+------------------+----------------------------------------+
  297. | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
  298. +---------------+----------+--------------+------------------+----------------------------------------+
  299. | binlog.000017 | 430 | | | b0ae4cca-32af-11ee-8ff1-000c29004cdf:1 |
  300. +---------------+----------+--------------+------------------+----------------------------------------+
  301. 1 row in set (0.00 sec)
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/959298
推荐阅读
相关标签
  

闽ICP备14008679号