Skip to content

Replication

Lowy Shin edited this page Mar 17, 2021 · 2 revisions

Check

  • Master
show master status;
-- Check Master position
-- if null, this server is slave or stand-alone
  • Slave
show slave status;
-- Check master position and slave position
-- You can see result on master and slave

Reconnect

  • If replication is broken and reconnect
/* on Slave
*/
show slave status;
-- get Master_Log_file
-- get Exec_Master_Log_Pos

STOP SLAVE;

RESET SLAVE;

CHANGE MASTER TO MASTER_LOG_FILE='<Master_Log_file>', MASTER_LOG_POS=<Exec_Master_Log_Pos>;

START SLAVE;

show slave status;

Fully_initialize

/* on Master =====================
*/

RESET MASTER;
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;

-- get Master_Log_file
-- get Master_Log_Pos

/* run mysqldump on ssh
mysqldump mydata.sql
*/

UNLOCK TABLES;

/* on Slave =====================
*/

STOP SLAVE;

/* import from ssh
mysql -uroot -p < mydata.sql
*/

RESET SLAVE;

CHANGE MASTER TO MASTER_LOG_FILE='<Master_Log_file>', MASTER_LOG_POS=<Master_Log_Pos>;

START SLAVE;

show slave status;

Ref

Translate this page?

Data(DBMS, NoSQL)

Development

Tools

Management

OS

Hardware

Business

Hobby

Lifestyle

Giip(RPA Engine)

Clone this wiki locally