chema
binlog-ignore-db = phpmyadmin
replicate-do-db = hrkip_zhhwd
replicate-ignore-db = mysql,information_schema
5.检查配置是否正常(l两台服务器上分别检查):
启动 slave 服务 ,在MYSQL命令行执行
mysql> slave start ;
Query OK, 0 rows affected, 1 warning (0.00 sec)
查看slave 状态 ,执行命令:
mysql> show slave status \G ;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.85.1.175
Master_User: replication
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 106
Relay_Log_File: ubutun-relay-bin.000005
Relay_Log_Pos: 251
Relay_Master_Log_File: mysql-bin.000002
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: hrkip_zhhwd
Replicate_Ignore_DB: mysql,information_schema
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: 552
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)
ERROR:
No query specified
如果需要重新启动slave 服务器,首先 执行 slave stop ,再执行 reset slave , 删除 MYSQL 数据库对应的my.cnf 文件中log_bin目录( /var/log/mysql/ )下的" mysql-bin."开头的所有文件,之后再执行slave start 命令 。
6.进行测试,主备是否正常工作,slave 启动时,两个服务器上都启动,启动后不要随意关闭再重启,例如在服务器A上启动后。
在服务器A数据中插入
INSERT INTO ddgl_qdlx ( qdlxmc, lxjc, qdlxbz) VALUES
('175a', '75a', '175a'); 在服务器B中可以看到对应的记录 。
同样在服务器B中插入 :
INSERT INTO ddgl_qdlx (qdlx_id, qdlxmc, lxjc, qdlxbz) VALUES
( '176b', '76b', '176b') ;
在服务器A中可以看到对应的记录 。
测试OK 。