热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

使awsmysql主从_AWSRDSMySQL双活

是的,可以在RDSMySqlEngine中进行Master-Master复制。但它需要一些操作与实例。先决条件:1)为启用二进制日志记录创建两个实例的只

是的,可以在RDS MySql Engine中进行Master-Master复制。但它需要一些操作与实例。先决条件:1)为启用二进制日志记录创建两个实例的只读副本。2)如果不需要,删除它们的只读副本。3)按照下面提到的主从设置说明进行操作。

在Master1上创建复制用户

grant replication slave on *.* to 'admin'@'%' identified by 'admin';

Query OK, 0 rows affected (0.00 sec)

请注意以下命令的输出

show server status

; + ---------------------------- + ---------- + --------- ----- + ------------------ + ------------------- + | 文件| 位置| Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | + ---------------------------- + ---------- + --------- ----- + ------------------ + ------------------- + | mysql-bin-changelog.000007 |120 | | | | + ---------------------------- + ---------- + --------- ----- + ------------------ + ------------------- + 1 row in set( 0.00秒)

在Master2上

mysql> call mysql.rds_set_external_master('master1.endpoint.amazonaws.com',3306,'admin','admin','**mysql-bin-changelog.000007**',**120**,0);

Query OK, 0 rows affected (0.05 sec)

mysql> call mysql.rds_start_replication;

+-------------------------+

| Message |

+-------------------------+

| Slave running normally. |

+-------------------------+

1 row in set (1.01 sec)

mysql -u admin123 -padmin123 -h master2.endpoint.amazonaws.com -e "show slave status\G;" | grep Running

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it

================================================== ====================

在Master2上

grant replication slave on *.* to 'admin'@'%' identified by 'admin';

Query OK, 0 rows affected (0.00 sec)

show master status;

+----------------------------+----------+--------------+------------------+-------------------+

| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |

+----------------------------+----------+--------------+------------------+-------------------+

| **mysql-bin-changelog.000007** | **120** |

| | | +----------------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec)

在Master1上

mysql> call mysql.rds_set_external_master('master2.endpoint.amazonaws.com',3306,'admin','admin','**mysql-bin-changelog.000007**',**120**,0);

Query OK, 0 rows affected (0.05 sec)

mysql> call mysql.rds_start_replication; +-------------------------+ | Message | +-------------------------+ | Slave running normally. | +-------------------------+ 1 row in set (1.01 sec)

mysql -u admin123 -padmin123 -h master1.endpoint.amazonaws.com -e "show slave status\G;" | grep Running

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it



推荐阅读
author-avatar
mobiledu2502927067
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有