Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Anti-crash of MySQL replication slave node

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

In previous versions of MySQL5.6, run-time data replication information was saved in two files in the slave node data directory, master.info and relay-log.info. It is still stored in the data directory by default after MySQL5.6, but it can be set to be stored in a table in the database.

Master-info-repository: when the value of this variable is set to table, the info log information of the primary node is stored in the mysql.slave_master_info data table. When the value of this variable is file, the file with the default file name master.info is created in the file system.

Relay-log-info-repository: when the value of this variable is set to table, the relay log information is saved in the mysql.slave_relay_log_info data table. When the value of this variable is set to file, a file with the default file name of relay-log.info is created in the file system.

By default, these two tables do not contain any information, as follows:

Click (here) to collapse or open

Mysql > select * from mysql.slave_master_info

Empty set (0.00 sec)

Mysql > select * from mysql.slave_relay_log_info

Empty set (0.00 sec) adds the following configuration information to the slave node:

[mysqld]

Master-info-repository=table

Relay-log-info-repository=table

Click (here) to collapse or open

Mysql > select * from mysql.slave_master_info\ G

* * 1. Row *

Number_of_lines: 25

Master_log_name: mysql-bin.000020

Master_log_pos: 344

Host: 192.168.8.57

User_name: repl

User_password: mysql

Port: 3306

Connect_retry: 10

Enabled_ssl: 0

Ssl_ca: / usr/local/mysql/certs/ca-cert.pem

Ssl_capath:

Ssl_cert: / usr/local/mysql/certs/client-cert.pem

Ssl_cipher:

Ssl_key: / usr/local/mysql/certs/client-key.pem

Ssl_verify_server_cert: 0

Heartbeat: 30

Bind:

Ignored_server_ids: 0

Uuid: 9ad24233-aeef-11e7-aa1b-080027768e58

Retry_count: 86400

Ssl_crl:

Ssl_crlpath:

Enabled_auto_position: 0

Channel_name:

Tls_version:

1 row in set (0.00 sec)

Mysql > select * from mysql.slave_relay_log_info\ G

* * 1. Row *

Number_of_lines: 7

Relay_log_name:. / relay-log.000003

Relay_log_pos: 510

Master_log_name: mysql-bin.000020

Master_log_pos: 344

Sql_delay: 0

Number_of_workers: 0

Id: 1

Channel_name:

The default storage engine for 1 row in set (0.00 sec) slave_master_info and slave_relay_log_info is MyISAM. In order to make data replication crash prevention, you need to change the storage engine of these two tables to InnoDB.

Click (here) to collapse or open

Mysql > stop slave

Query OK, 0 rows affected (0.03 sec)

Mysql > alter table mysql.slave_master_info engine=innodb

Query OK, 0 rows affected (0.31 sec)

Records: 0 Duplicates: 0 Warnings: 0

Mysql > alter table mysql.slave_relay_log_info engine=innodb

Query OK, 0 rows affected (0.09 sec)

Records: 0 Duplicates: 0 Warnings: 0

Mysql > start slave

Query OK, 0 rows affected (0.01 sec)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report