【MySQL Shell】9.3 创建 InnoDB ReplicaSet
创始人
2024-05-13 14:43:23
0

配置实例后,通过完成以下步骤创建 InnoDB ReplicaSet:

  1. 连接到一个实例,并使用dba.createReplicaSet()创建一个使用 MySQL 异步复制的托管 ReplicaSet, 而不是 InnoDB Cluster 使用的 MySQL 组复制。M ySQL Shell 所连接的 MySQL 实例用作 ReplicaSet 的初始主实例。

    dba.createReplicaSet()操作执行多项检查,以确保实例状态和配置与托管 ReplicaSet 兼容,如果是,则在实例上初始化元数据模式。

    如果 ReplicaSet 创建成功,则返回ReplicaSet对象。因此,最好将返回的ReplicaSet分配给变量。这使您能够使用 ReplicaSet, 例如,通过调用status()操作。要在实例 rs-1 上创建一个名为 example 的ReplicaSet 并将其分配给 rs 变量,请执行:

    mysql-js> \connect root@rs-1:3306
    ...
    mysql-js> var rs = dba.createReplicaSet("example")
    A new replicaset with instance 'rs-1:3306' will be created.* Checking MySQL instance at rs-1:3306This instance reports its own address as rs-1:3306
    rs-1:3306: Instance configuration is suitable.* Updating metadata...ReplicaSet object successfully created for rs-1:3306.
    Use rs.addInstance() to add more asynchronously replicated instances to this replicaset
    and rs.status() to check its status.
    
  2. 使用返回的 ReplicaSet 对象验证操作是否成功。例如,这提供了ReplicaSet.status()操作,该操作显示有关 ReplicaSet 的信息。返回的 ReplicaSet 已分配给变量 rs, 因此执行:

    mysql-js> rs.status()
    {"replicaSet": {"name": "example","primary": "rs-1:3306","status": "AVAILABLE","statusText": "All instances available.","topology": {"rs-1:3306": {"address": "rs-1:3306","instanceRole": "PRIMARY","mode": "R/W","status": "ONLINE"}},"type": "ASYNC"}
    }
    

    此输出表明已创建了名为 example 的 ReplicaSet ,并且主示例是 rs-1 。 目前,只有一个实例,下一个任务是向 ReplicaSet 添加更多实例。

    注意
    从 8.0.32 开始,所有新的复制通道都是在启用 SSL 的情况下创建的。对于 MySQL Shell 8.0.32 采用的复制组,情况并非如此。它们的复制通道保持未加密。

InnoDB ReplicaSet replicationAllowedHost

使用 MySQL Shell 8.0.28 及更高版本创建 InnoDB ReplicaSet 时,如果您有安全要求,希望 AdminAPI 自动创建的所有帐户都具有严格的身份验证要求,则可以为 ReplicaSet 的replicationAllowedHost配置选项设置一个值。MySQL Shell 选项replicationAllowedHost允许您将 ReplicaSet 内部管理的复制帐户设置为严格的基于子网的筛选器,而不是默认的通配符值%r eplicationAllowedHost选项可以采用字符串值。例如,要将replicationAllowedHost设置为192.0.20/24, 请执行:

mysql-js> var rs = dba.createReplicaSet('example', {replicationAllowedHost:'192.0.2.0/24'})A new replicaset with instance 'rs-1:3306' will be created.* Checking MySQL instance at rs-1:3306This instance reports its own address as rs-1:3306
rs-1:3306: Instance configuration is suitable.* Updating metadata...ReplicaSet object successfully created for rs-1:3306.
Use rs.addInstance() to add more asynchronously replicated instances to this replicaset 
and rs.status() to check its status.

InnoDB ReplicaSet 可以在创建后进行修改,通过setOption配置选项设置变量replicationAllowedHost,执行:

mysql-js> rs.setOption('replicationAllowedHost', '192.0.2.0/24')

相关内容

热门资讯

中证A500ETF摩根(560... 8月22日,截止午间收盘,中证A500ETF摩根(560530)涨1.19%,报1.106元,成交额...
A500ETF易方达(1593... 8月22日,截止午间收盘,A500ETF易方达(159361)涨1.28%,报1.104元,成交额1...
何小鹏斥资约2.5亿港元增持小... 每经记者|孙磊    每经编辑|裴健如 8月21日晚间,小鹏汽车发布公告称,公司联...
中证500ETF基金(1593... 8月22日,截止午间收盘,中证500ETF基金(159337)涨0.94%,报1.509元,成交额2...
中证A500ETF华安(159... 8月22日,截止午间收盘,中证A500ETF华安(159359)涨1.15%,报1.139元,成交额...
科创AIETF(588790)... 8月22日,截止午间收盘,科创AIETF(588790)涨4.83%,报0.760元,成交额6.98...
创业板50ETF嘉实(1593... 8月22日,截止午间收盘,创业板50ETF嘉实(159373)涨2.61%,报1.296元,成交额1...
港股异动丨航空股大幅走低 中国... 港股航空股大幅下跌,其中,中国国航跌近7%表现最弱,中国东方航空跌近5%,中国南方航空跌超3%,美兰...
电网设备ETF(159326)... 8月22日,截止午间收盘,电网设备ETF(159326)跌0.25%,报1.198元,成交额409....
红利ETF国企(530880)... 8月22日,截止午间收盘,红利ETF国企(530880)跌0.67%,报1.034元,成交额29.0...