温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

trove mysql replica 使用

发布时间:2020-06-30 02:24:21 来源:网络 阅读:1293 作者:757781091 栏目:MySQL数据库

1、trove mysql replica 一些限制

  • trove 可以同时支持binlog replica 和gtid replica

  • gtid 需要mysql5.6及其以上版本

  • newton trove 对mysql 的 binlog replica 支持不是很好

  • newton trove 对mysql的gtid replica 可以正常工作

  • newton trove 可以创建 mysql5.5 binlog replica

  • detach-replica:Mysql 5.5 binlog 模式可以正常工作

  • eject-replica-source:对binlog复制模式mysql5.5报错,binlog模式报错信息:Could not locate column in row for column 'Master_UUID'

  • promote-to-replica-source:Mysql5.5 binlog 模式报错,操作中会用到gtid

2、与replica 相关的命令

trove create # 创建复制
trove detach-replica # 从复制中移除slave
trove promote-to-replica-source #master,slave都存活的情况下,将指定的slave提升为master,原master降为slave
trove eject-replica-source # 当master失去心跳,可以移除master,trove在slave选择一个合适的节点作为master

3、创建复制

trove create ab 6 --size 5 --databases myDB \
    --users userA:password --datastore_version mysql-5.6 \
    --datastore mysql

trove create ab-slave1 6 --size 5 --replica_of ab --replica_count 2 \
    --datastore_version mysql-5.6     --datastore mysql

4、分离slave

trove show ab-slave2-2
+-------------------+--------------------------------------+
| Property          | Value                                |
+-------------------+--------------------------------------+
| created           | 2017-03-31T03:29:20                  |
| datastore         | mysql                                |
| datastore_version | mysql-5.6                            |
| flavor            | 6                                    |
| id                | caa908f1-5e14-4c65-ac0e-a9ba26536107 |
| ip                | 172.168.10.6                         |
| name              | ab-slave2-2                          |
| replica_of        | 3d39a475-3277-4d24-9467-ebc254e9316f |
| status            | ACTIVE                               |
| updated           | 2017-03-31T06:19:30                  |
| volume            | 5                                    |
| volume_used       | 0.14                                 |
+-------------------+--------------------------------------+

trove detach-replica  ab-slave2-2

trove show  ab-slave2-2
+-------------------+--------------------------------------+
| Property          | Value                                |
+-------------------+--------------------------------------+
| created           | 2017-03-31T03:29:20                  |
| datastore         | mysql                                |
| datastore_version | mysql-5.6                            |
| flavor            | 6                                    |
| id                | caa908f1-5e14-4c65-ac0e-a9ba26536107 |
| ip                | 172.168.10.6                         |
| name              | ab-slave2-2                          |
| status            | ACTIVE                               |
| updated           | 2017-03-31T06:28:45                  |
| volume            | 5                                    |
| volume_used       | 0.14                                 |
+-------------------+--------------------------------------+

5、提升slave为master

trove show ab-slave3-1
+-------------------+--------------------------------------+
| Property          | Value                                |
+-------------------+--------------------------------------+
| created           | 2017-03-31T03:36:16                  |
| datastore         | mysql                                |
| datastore_version | mysql-5.6                            |
| flavor            | 6                                    |
| id                | f303fc8f-819b-47b5-b33a-38184c8aff90 |
| ip                | 172.168.10.14                        |
| name              | ab-slave3-1                          |
| replica_of        | 3d39a475-3277-4d24-9467-ebc254e9316f |
| status            | ACTIVE                               |
| updated           | 2017-03-31T06:19:30                  |
| volume            | 5                                    |
| volume_used       | 0.14                                 |
+-------------------+--------------------------------------+

trove promote-to-replica-source ab-slave3-1

# ab-slave3-1已提升为master
trove show ab-slave3-1
+-------------------+----------------------------------------------------------------------------+
| Property          | Value                                                                      |
+-------------------+----------------------------------------------------------------------------+
| created           | 2017-03-31T03:36:16                                                        |
| datastore         | mysql                                                                      |
| datastore_version | mysql-5.6                                                                  |
| flavor            | 6                                                                          |
| id                | f303fc8f-819b-47b5-b33a-38184c8aff90                                       |
| ip                | 172.168.10.14                                                              |
| name              | ab-slave3-1                                                                |
| replicas          | 3d39a475-3277-4d24-9467-ebc254e9316f, f4b3be64-c204-439d-a9c4-e28cb543a3b9 |
| status            | ACTIVE                                                                     |
| updated           | 2017-03-31T06:33:39                                                        |
| volume            | 5                                                                          |
| volume_used       | 0.14                                                                       |
+-------------------+----------------------------------------------------------------------------+

# master已降级为slave
trove show 3d39a475-3277-4d24-9467-ebc254e9316f
+-------------------+--------------------------------------+
| Property          | Value                                |
+-------------------+--------------------------------------+
| created           | 2017-03-31T06:14:35                  |
| datastore         | mysql                                |
| datastore_version | mysql-5.6                            |
| flavor            | 6                                    |
| id                | 3d39a475-3277-4d24-9467-ebc254e9316f |
| ip                | 172.168.10.8                         |
| name              | ab                                   |
| replica_of        | f303fc8f-819b-47b5-b33a-38184c8aff90 |
| status            | ACTIVE                               |
| updated           | 2017-03-31T06:33:39                  |
| volume            | 5                                    |
| volume_used       | 0.14                                 |
+-------------------+--------------------------------------+

6、移除master

移除master需要在master已经失去心跳的情况下做,如果master尚有心跳是无法移除master的

可以通过停止master上的trove-guestagent模拟master失去心跳

service trove-guestagent stop
trove eject-replica-source


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI