一、主服务器上
摘要:重新配置一下主从及半同步复制
mysql> GRANT REPLICATION SLAVE ON *.* to 'root'@'192.168.246.141' identified by 'ayilian';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 | 107 | aa | mysql |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
mysql> INSERT INTO bbb(df) VALUES(now());
Query OK, 1 row affected (0.00 sec)
在主上写入数据
二、从服务器上
###
mysql> reset master;
Query OK, 0 rows affected (0.01 sec)
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 | 107 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
###
mysql> CHANGE MASTER TO MASTER_HOST='192.168.246.140',
-> MASTER_USER='root',
-> MASTER_PASSWORD='ayilian',
-> MASTER_LOG_FILE='mysql-bin.000001',
-> MASTER_LOG_POS=107;
Query OK, 0 rows affected (0.03 sec)
3###
mysql> slave start;
Query OK, 0 rows affected (0.00 sec)
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.246.140
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 107
Relay_Log_File: mysql03-relay-bin.000002
Relay_Log_Pos: 253
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
三、测试数据是否正常
1.主服务器:
mysql> INSERT INTO bbb(df) VALUES(now());
Query OK, 1 row affected (0.01 sec)
mysql> select * from bbb;
+---------------------+
| df |
+---------------------+
| 2015-05-30 11:21:18 |
+---------------------+
1 row in set (0.00 sec)
2.从务器:
mysql> select * from bbb;
+---------------------+
| df |
+---------------------+
| 2015-05-30 11:21:18 |
+---------------------+
1 row in set (0.00 sec)