A節點操作:
mysql>flush privileges;
B節點操作步驟如上,權限賦予如下:
mysql>flush privileges;
1.3 配置數據同步選項1.3.1 A主機操作log-bin=mysql-bin #同步事件的日志記錄文件
binlog-do-db=ikey_db #提供數據同步服務的數據庫日志
binlog-do-db=ikey_log #提供數據同步服務的數據庫日志
####同步的數據庫
replicate-do-db=ikey_log #同步的數據庫
1.3.2 B主機操作1.3.3 驗證數據同步mysql> show master status;
+------------------+----------+------------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+------------------+------------------+
| mysql-bin.000001 | 98 | ikey_db,ikey_log | |
+------------------+----------+------------------+------------------+
1 row in set (0.00 sec)
mysql> show slave status/G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.101
Master_User: ym
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 98
Relay_Log_File: testBBB-relay-bin.000002
Relay_Log_Pos: 235
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: ikey_db,ikey_log
1.4 同步維護1.4.1 A節點:
mysql> show master status;
+------------------+----------+------------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+------------------+------------------+
| mysql-bin.000002 | 118 | ikey_db,ikey_log | |
+------------------+----------+------------------+------------------+
1 row in set (0.00 sec)
1.4.2 B節點:A方向同步的帳戶權限
mysql>drop user ym@192.168.1.101;
mysql>flush privileges;
mysql>grant replication slave on *.* to ym@192.168.1.103 identified by 'ym';
mysql>flush privileges;
B方向同步配置項:
mysql>CHANGE MASTER TO
-> MASTER_HOST='192.168.1.103', # Master服務器地址
-> MASTER_USER='ym',
Query OK, 0 rows affected (0.02 sec)
mysql> show master status;
+------------------+----------+------------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+------------------+------------------+
| mysql-bin.000003 | 98 | ikey_db,ikey_log | |
+------------------+----------+------------------+------------------+
1 row in set (0.00 sec)
1.4.3 接著A節點:
A方向同步配置項:
mysql>CHANGE MASTER TO
Query OK, 0 rows affected (0.02 sec)
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
即處于正常同步狀態。
[j1]執行同步權限的用戶
[j3]同步帳戶密碼
[j4]執行同步權限的用戶
[j6]同步帳戶密碼
新聞熱點
疑難解答