AWS RDS Active-Active 雙活配置

是的,可以在RDS MySql Engine中進行Master-Master複製。但它需要一些操作與實例。先決條件:1)為啟用二進位日誌記錄創建兩個實例的只讀副本。2)如果不需要,刪除它們的只讀副本。3)按照下面提到的主從設置說明進行操作。

在Master1上創建複製用戶

grant replication slave on *.* to admin@% identified by admin;nQuery OK, 0 rows affected (0.00 sec)n請注意以下命令的輸出nshow server statusn; + ---------------------------- + ---------- + --------- ----- + ------------------ + ------------------- + | 文件| 位置| Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | + ---------------------------- + ---------- + --------- ----- + ------------------ + ------------------- + | mysql-bin-changelog.000007 |120 | | | | + ---------------------------- + ---------- + --------- ----- + ------------------ + ------------------- + 1 row in set( 0.00秒)n

在Master2上

mysql> call mysql.rds_set_external_master(master1.endpoint.amazonaws.com,3306,admin,admin,**mysql-bin-changelog.000007**,**120**,0);nQuery OK, 0 rows affected (0.05 sec)nnmysql> call mysql.rds_start_replication; n+-------------------------+ n| Message |n+-------------------------+ n| Slave running normally. | n+-------------------------+ nn1 row in set (1.01 sec)nnmysql -u admin123 -padmin123 -h master2.endpoint.amazonaws.com -e "show slave statusG;" | grep Runningn Slave_IO_Running: Yesn Slave_SQL_Running: Yesn Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update itn================================================== ====================n

在Master2上

grant replication slave on *.* to admin@% identified by admin;nQuery OK, 0 rows affected (0.00 sec)nnshow master status; n+----------------------------+----------+--------------+------------------+-------------------+ n| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | n+----------------------------+----------+--------------+------------------+-------------------+ n| **mysql-bin-changelog.000007** | **120** | nn| | | +----------------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec)n在Master1上nmysql> call mysql.rds_set_external_master(master2.endpoint.amazonaws.com,3306,admin,admin,**mysql-bin-changelog.000007**,**120**,0);nQuery OK, 0 rows affected (0.05 sec)nnmysql> call mysql.rds_start_replication; +-------------------------+ | Message | +-------------------------+ | Slave running normally. | +-------------------------+ 1 row in set (1.01 sec)nnmysql -u admin123 -padmin123 -h master1.endpoint.amazonaws.com -e "show slave statusG;" | grep Runningn Slave_IO_Running: Yesn Slave_SQL_Running: Yesn Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update itn

推薦閱讀:

12 條用於 Linux 的 MySQL/MariaDB 安全最佳實踐
mysql 的事件調度器(Event Scheduler)穩定性如何?主要用在什麼場合?
PHP擴展 Mysql 與 Mysqli

TAG:AmazonWebServicesAWS | 数据库 | MySQL |