I've tried to setup a testing mysql master-slave replication without success.Here's the steps I've done:
1. Master server
edited etc/my.cnf, added lines in [mysqld]
server-id = 1
log-bin = mysql-bin
binlog-do-db = testdatabase
binlog-ignore-db = mysql
2. Master server
restarted mysql service
3. Slave server
edited etc/my.cnf, added lines in [mysqld]
server-id = 2
master-host=MASTER_IP
master-user=rtest
master-password=rtestpass
replicate-do-db=testdatabase
4. Slave server
restarted mysql service
5. Master server
logged in mysql
created database testdatabase
ran
GRANT REPLICATION SLAVE ON *.* TO 'rtest'@'SLAVE_IP' IDENTIFIED BY 'rtestpass';
FLUSH PRIVILEGES;
USE testdatabase;
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000002 | 1119 | testdatabase | mysql |
6. Slave server
logged in mysql
ran
STOP SLAVE;
CHANGE MASTER TO MASTER_HOST='MASTER_IP', MASTER_USER='rtest', MASTER_PASSWORD='rtestpass', MASTER_LOG_FILE='mysql-bin.000002', MASTER_LOG_POS=1119;
START SLAVE;
but if I make any changes to testdatabase on master, nothing changes in the slave
SHOW SLAVE STATUS\G displays:
*************************** 1. row ***************************
Slave_IO_State: Connecting to master
Master_Host: MASTER_IP
Master_User: rtest
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 1119
Relay_Log_File: server-relay-bin.000001
Relay_Log_Pos: 98
Relay_Master_Log_File: mysql-bin.000002
Slave_IO_Running: No
Slave_SQL_Running: Yes
Replicate_Do_DB: testdatabase
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 1119
Relay_Log_Space: 98
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
1 row in set (0.00 sec)
any ideas what went wrong?
If it helps, the master and the slave are not located within the same datacenter.
1. Master server
edited etc/my.cnf, added lines in [mysqld]
server-id = 1
log-bin = mysql-bin
binlog-do-db = testdatabase
binlog-ignore-db = mysql
2. Master server
restarted mysql service
3. Slave server
edited etc/my.cnf, added lines in [mysqld]
server-id = 2
master-host=MASTER_IP
master-user=rtest
master-password=rtestpass
replicate-do-db=testdatabase
4. Slave server
restarted mysql service
5. Master server
logged in mysql
created database testdatabase
ran
GRANT REPLICATION SLAVE ON *.* TO 'rtest'@'SLAVE_IP' IDENTIFIED BY 'rtestpass';
FLUSH PRIVILEGES;
USE testdatabase;
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000002 | 1119 | testdatabase | mysql |
6. Slave server
logged in mysql
ran
STOP SLAVE;
CHANGE MASTER TO MASTER_HOST='MASTER_IP', MASTER_USER='rtest', MASTER_PASSWORD='rtestpass', MASTER_LOG_FILE='mysql-bin.000002', MASTER_LOG_POS=1119;
START SLAVE;
but if I make any changes to testdatabase on master, nothing changes in the slave
SHOW SLAVE STATUS\G displays:
*************************** 1. row ***************************
Slave_IO_State: Connecting to master
Master_Host: MASTER_IP
Master_User: rtest
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 1119
Relay_Log_File: server-relay-bin.000001
Relay_Log_Pos: 98
Relay_Master_Log_File: mysql-bin.000002
Slave_IO_Running: No
Slave_SQL_Running: Yes
Replicate_Do_DB: testdatabase
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 1119
Relay_Log_Space: 98
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
1 row in set (0.00 sec)
any ideas what went wrong?
If it helps, the master and the slave are not located within the same datacenter.