Home » MySQL » MYSQL master-slave database configuration

MYSQL master-slave database configuration


premise: the same version of the two MYSQL database


1, change the Master library configuration item


[mysqld]
Log-bin=mysql-bin
Server-id = 1 # master-slave library server-id can be different
Binlog-do-db = coreseek_test # to synchronize database name
Binlog-ignore-db=mysql # ignored the database
Expire_logs_days=10 # log retention days


2, change the Slave library configuration item


[mysqld]
Log-bin=mysql-bin
Server-id = 130 # with different
can modify the master-slave library after the restart the master database.


3, log on to the Master database and authorize Slave


GRANT REPLICATION SLAVE ON to ' backup'.; @' 192.168.136.130' identified; by; ' 123' 


mysql> show master status;
+------------------+----------+---------------+------------------+
File Position Binlog_Do_DB | | | | Binlog_Ignore_DB |
+------------------+----------+---------------+------------------+
| mysql-bin.000012 | 107 | coreseek_test | MySQL |
+------------------+----------+---------------+------------------+
1, row, in, set (0, SEC)
4, log on to the Slave database, configure the logs in the Master library, and find


change master to master_host=' 192.168.136.129' master_user=' backup' master_password=', 123' master_log_file=',,; mysql-bin.000012' master_log_pos=107; 
, master_log_file and master_log_post note: the value corresponding to the Master Library 'show master status' file and Position.


mysql>, show, slave, status, G
*************************** 1. row ***************************
Slave_IO_State:, Waiting, for, master, to, send, event
Master_Host: 192.168.136.129
Master_User: backup
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000012
Read_Master_Log_Pos: 107
Relay_Log_File: Local-YSZ-relay-bin.000007
Relay_Log_Pos: 253
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
note: both Slave_IO_Running and Slave_SQL_Running are successful for yes




the rest of the task is to witness the miracle of time...






copyright notice: This article is original article for blogger. Without permission from blogger,.

must not be reprinted

Latest