How To Control Mysql Replication ZT 1. Environment
In 192.168.1.202
Database: RMC_BILLING
DB Account: root
DB Password:
In 192.168.1.204
Database: RMC_BILLING
DB Account: root
DB Password:
We need to replicate the following tables from 192.168.1.204 to 192.168.1.202.
users
plan
profile
promotion_plan
roles
service_settings
credit_cards
currency_exchange
country
conference_plan
2. Steps
Because we need replicate the data from 204 to 202, So, Mysql server in 204 is master, and the 202 is slave.
a. Ssh to 204, Open /etc/mysql/my.cnf mysql configuration file. Make sure the following two lines is uncommented.
c. Connect to master mysql server, Create a mysql user for replication.
mysql> grant replication slave on *.* to 'rep'@'%' identified by 'rep';
d. Lock the tables on master mysql server, So we can dump the master server's data and import to slave server. Make master and slave has the same data.
mysql> flush tables with read lock;
e. Show master status, and record the data.
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000002 | 228 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
f. Connect to slave server and run the following commands. Notice, the data of MASTER_LOG_FILE and MASTER_LOG_POS come from step 6.