Some related commands for MySQL master-slave replication replication

Source: Internet
Author: User

Related commands on the primary server:
Show master status;

Mysql>Show Master Status\g*************************** 1. Row***************************             File: Host2-Bin.000002Position:420binlog_do_db:binlog_ignore_db:executed_gtid_set:5abd564e-2b4f-11e5-A7f1-000C2954CCDE:1, 780aa541-2b93-11e5-A9ad-000C29EF36A8:11Rowinch Set(0.00Sec

Show slave hosts;

Mysql>show slave hosts;+-----------+-----------------+------+-----------+--------------------------------------+|server_id|Host|Port|master_id|Slave_uuid|+-----------+-----------------+------+-----------+--------------------------------------+|         1 | 192.168.203.133 | 3306 |         2 |780aa541-2b93-11e5-A9ad-000c29ef36a8||         3 | 192.168.203.134 | 3306 |         2 |5abd564e-2b4f-11e5-A7f1-000c2954ccde|+-----------+-----------------+------+-----------+--------------------------------------+2Rowsinch Set(0.00Sec

Show binary logs;

Mysql>Showbinarylogs;+------------------+-----------+|Log_name|File_size|+------------------+-----------+|Host2-Bin.000001 |       413 ||Host2-Bin.000002 |       420 |+------------------+-----------+2Rowsinch Set(0.00Sec

Show Binlog events;

Mysql>show Binlog events;+------------------+-----+----------------+-----------+-------------+----------------------------------------- --------------------------+|Log_name|Pos|Event_type|server_id|End_log_pos|Info|+------------------+-----+----------------+-----------+-------------+----------------------------------------- --------------------------+|Host2-Bin.000001 |   4 |Format_desc|         2 |          - |Server ver:5.6. --Log, Binlog ver:4                             ||Host2-Bin.000001 |  - |Previous_gtids|         2 |         151 |                                                                   ||Host2-Bin.000001 | 151 |Gtid|         1 |         199 | SET @ @SESSION. Gtid_next= '780aa541-2b93-11e5-a9ad-000c29ef36a8:1' ||Host2-Bin.000001 | 199 |Query|         1 |         262 | BEGIN                                                             ||Host2-Bin.000001 | 262 |Table_map|         1 |         309 |TABLE_ID: -(TESTDB.T1)||Host2-Bin.000001 | 309 |Delete_rows|         1 |         359 |TABLE_ID: -Flags:stmt_end_f||Host2-Bin.000001 | 359 |Xid|         1 |         390 | COMMIT /*xid=423*/                                              ||Host2-Bin.000001 | 390 |Stop|         2 |         413 |                                                                   |+------------------+-----+----------------+-----------+-------------+----------------------------------------- --------------------------+8Rowsinch Set(0.00Sec

The following are some of the deletions are binary related, do not make a demonstration, the specific can be searched for usage:

Purge logs to ' log_name ';
Purge logs before ' date ';
Reset master; (old version flush Master)
Set sql_log_bin=

From the relevant command on the server:
Slave start
Slave stop
SLAVE STOP io_thread//This thread writes the log of the master segment to a local
SLAVE Start Io_thread
SLAVE STOP sql_thread//This thread applies the logs written locally to the database
SLAVE Start Sql_thread
Reset Slave
SET GLOBAL Sql_slave_skip_counter
Load data from Master
Show slave status (Super,replication CLIENT)
Change Master to master_host=, master_port=,master_user=, master_password=//changing Master information dynamically
PURGE Master [before ' date '] Delete logs that have been synchronized on the master side

Some related commands for MySQL master-slave replication replication

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.