MySQL Replication-Cluster Solutions

16.1.2.5.2 Setting the Master Configuration on the Slave

 mysql> CHANGE MASTER TO    ->     MASTER_HOST='master_host_name',    ->     MASTER_USER='replication_user_name',    ->     MASTER_PASSWORD='replication_password',    ->     MASTER_LOG_FILE='recorded_log_file_name',    ->     MASTER_LOG_POS=recorded_log_position;

16.1.2.5.4 Setting Up Replication with Existing Data

slave > change master to  master_host="127.0.0.1", master_port=12047, master_user="msandbox", master_password="msandbox"for channel="master1";

slave > change master to master_host="127.0.0.1", master_port=12048, master_user="msandbox", master_password="msandbox" for channel="master2";

Here is how MySQL replication works.

1.  All database operations are copied to the master’s binary log.

2.  Salves connect to the master and asks for the data.

3.  The slave servers get the masters binary log.

4.  Slaves then apply the binary log to its realy log.

5.  The relay log is read by the SQL thread process and it applies all the operations/data to the slave’s database and its binary log.

16.1.2.5.3 Setting Up Replication between a New Master and Slaves

1.     Start up the MySQL slave and connect to it.

2.     Execute a CHANGE MASTER TO statement to set the master replication server configuration. 

See Section 16.1.2.5.2, “Setting the Master Configuration on the Slave”.

Perform these slave setup steps on each slave.

We have to specify again which channel we want to check:

slave > SHOW SLAVE STATUS FOR CHANNEL="master1"G**1. row ****** 

Slave_IO_State: Waiting for master to send event Master_Host: 127.0.0.1 

Master_User: msandbox 

Master_Port: 12047 

Connect_Retry: 60 

Master_Log_File: mysql-bin.000002 

Read_Master_Log_Pos: 232 

Relay_Log_File: squeeze-relay-bin-master1.000003 

Relay_Log_Pos: 395 

 Relay_Master_Log_File: mysql-bin.000002 

Slave_IO_Running: Yes 

Slave_SQL_Running: Yes