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

MySQL 5.5 commonly used replication environment management commands

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

1. Check the status of Slave nodes

Displays the important parameters of the slave thread.

Mysql > show slave status\ G

* * 1. Row *

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.78.139

Master_User: repl

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000012

Read_Master_Log_Pos: 414

Relay_Log_File: mysqld-relay-bin.000002

Relay_Log_Pos: 560

Relay_Master_Log_File: mysql-bin.000012

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

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: 414

Relay_Log_Space: 717

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: 0

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: 100

1 row in set (0.00 sec)

The Slave_IO_State field is a copy of the State field in the SHOW PROCESSLIST output. This field tells you what the thread is doing.

Slave_IO_Running indicates whether the Icano thread starts and successfully connects to the Master.

Slave_SQL_Running indicates whether the SQL thread starts

Last_IO_Errno, the error number and error log that Last_IO_Error causes the I / O thread to stop running. If the value in Last_IO_Error is not null, the related error will also appear in the error log of the slave node.

Last_SQL_Errno, the error number and error log that caused the SQL thread to stop running. The error number is 0 and the error log is empty, indicating that there are no errors.

Delay time between the Seconds_Behind_Master Slave node and the Master node. When the Slave node is in the process of updating, this field shows the difference between the time available on the Slave node and the processing time of the Master node for the same event. This value is 0 when there are no events on the Slave node.

The name of the binary log of the Master node being read by the Master_Log_File I _ Band O thread

The location of the binary log of the Master node that is being read by the Read_Master_Log_Pos Ipaw O thread

The Master binary log file name where the event (event) recently executed by the Relay_Master_Log_File SQL thread is located

The location where the Master node binary log is read and executed by the Exec_Master_Log_Pos SQL thread, where the next transaction or event will start. You can use the value of this field when you execute the CHANGE MASTER TO statement.

Name of the relay log being read and executed by the Relay_Log_File SQL thread

Location of the relay log being read and executed by the Relay_Log_Pos SQL thread

2. Display thread status

Thread state of the Master node

Mysql > show processlist\ G

ERROR 2006 (HY000): MySQL server has gone away

No connection. Trying to reconnect...

Connection id: 4

Current database: * * NONE * *

* * 1. Row *

Id: 2

User: repl

Host: 192.168.78.137:42524

Db: NULL

Command: Binlog Dump

Time: 63044

State: Master has sent all binlog to slave; waiting for binlog to be updated

Info: NULL

Thread state of the Slave node

Mysql > show processlist\ G

* * 1. Row *

Id: 2

User: system user

Host:

Db: NULL

Command: Connect

Time: 62933

State: Waiting for master to send event

Info: NULL

* 2. Row * *

Id: 3

User: system user

Host:

Db: NULL

Command: Connect

Time: 62831

State: Slave has read all relay log; waiting for the slave I/O thread to update it

Info: NULL

3. Show how many Slave nodes are currently registered to the Master node and execute on the Master node

Mysql > SHOW SLAVE HOSTS

+-+

| | Server_id | Host | Port | Master_id | |

+-+

| | 200 | | 3306 | 100 |

+-+

1 row in set (0.00 sec)

4. Stop the slave thread. SUPER permission is required to execute this command. The recommended best practice is to execute the STOP SLAVE command before shutting down the Slave node database service.

Mysql > stop slave

Query OK, 0 rows affected (0.14 sec)

Mysql > show slave status\ G

* * 1. Row *

Slave_IO_State:

Master_Host: 192.168.78.139

Master_User: repl

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000012

Read_Master_Log_Pos: 414

Relay_Log_File: mysqld-relay-bin.000002

Relay_Log_Pos: 560

Relay_Master_Log_File: mysql-bin.000012

Slave_IO_Running: No

Slave_SQL_Running: No

You can stop a thread separately.

Mysql > stop slave io_thread

Query OK, 0 rows affected (0.00 sec)

5. Start two slave threads. The events O thread is responsible for reading events (events) from the master server and storing them in relay log. The SQL thread is responsible for reading events from the relay log and executing them. SUPER permission is required to execute START SLAVE.

Mysql > start slave

Query OK, 0 rows affected (0.08 sec)

Mysql > stop slave sql_thread

Query OK, 0 rows affected (0.00 sec)

You can start a thread separately

Mysql > start slave sql_thread

Query OK, 0 rows affected (0.00 sec)

Mysql > start slave io_thread

Query OK, 0 rows affected (0.00 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