我按照这本书设置了主从。我在LOAD DATA FROM MASTER;
奴隶上运行了首字母,效果很好。但是当我将数据插入主服务器时,它根本没有被复制到从服务器。我已经尝试重新启动 master 和 slave mysqld 进程,并在 slave 上“slave stop / slave start”。这是怎么回事?
掌握
配置:
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
binlog_do_db = pchelp
binlog_ignore_db = mysql
binlog_ignore_db = test
mysql> 从 pchelp.test_table 中选择 *;
+----+---------+
| id | sometxt |
+----+---------+
| 1 | x |
| 2 | x |
| 3 | y |
| 4 | z |
| 5 | p |
| 6 | i |
+----+---------+
6 rows in set (0.00 sec)
mysql> 显示主机状态 \G
*************************** 1. row ***************************
File: mysql-bin.000009
Position: 106
Binlog_Do_DB: pchelp
Binlog_Ignore_DB: mysql,test
1 row in set (0.00 sec)
奴隶
配置:
server-id = 2
master-host = hidden.x.xx
master-user = replication
master-password = hidden
master-port = 3308
replicate_do_db = pchelp
mysql> 从 pchelp.test_table 中选择 *;
+----+---------+
| id | sometxt |
+----+---------+
| 1 | x |
| 2 | x |
| 3 | y |
| 4 | z |
| 5 | p |
| 6 | i |
+----+---------+
6 rows in set (0.00 sec)
mysql> 显示从站状态 \G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: hidden.x.xx
Master_User: replication
Master_Port: 3308
Connect_Retry: 60
Master_Log_File: mysql-bin.000009
Read_Master_Log_Pos: 106
Relay_Log_File: mysqld-relay-bin.000002
Relay_Log_Pos: 251
Relay_Master_Log_File: mysql-bin.000009
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: pchelp
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: 106
Relay_Log_Space: 407
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: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.01 sec)
掌握
插入 pchelp.test_table (id,sometxt) 值 (7,'q');
Query OK, 1 row affected (0.00 sec)
mysql> 从 pchelp.test_table 中选择 *;
+----+---------+
| id | sometxt |
+----+---------+
| 1 | x |
| 2 | x |
| 3 | y |
| 4 | z |
| 5 | p |
| 6 | i |
| 7 | q |
+----+---------+
7 rows in set (0.01 sec)
mysql> 显示主机状态 \G
*************************** 1. row ***************************
File: mysql-bin.000009
Position: 106
Binlog_Do_DB: pchelp
Binlog_Ignore_DB: mysql,test
1 row in set (0.00 sec)
奴隶(插入主人后)
mysql> 从 pchelp.test_table 中选择 *;
+----+---------+
| id | sometxt |
+----+---------+
| 1 | x |
| 2 | x |
| 3 | y |
| 4 | z |
| 5 | p |
| 6 | i |
+----+---------+
6 rows in set (0.01 sec)
mysql> 显示从站状态 \G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: hidden.x.xx
Master_User: replication
Master_Port: 3308
Connect_Retry: 60
Master_Log_File: mysql-bin.000009
Read_Master_Log_Pos: 106
Relay_Log_File: mysqld-relay-bin.000002
Relay_Log_Pos: 251
Relay_Master_Log_File: mysql-bin.000009
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: pchelp
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: 106
Relay_Log_Space: 407
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: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)
任何人对可能出现的问题有什么好主意?用户“复制”具有完全权限(在主从上运行);
grant replication slave on *.* to replication@'%' identified by 'hidden';
GRANT ALL PRIVILEGES ON pchelp.* TO replication;
再一次,LOAD DATA FROM MASTER;
命令工作得很好..我不明白。