1. Creating the Sandbox InnoDB Cluster
需要安装MySQL shell,否则不能进行。
1.1 创建集群的cluster seed
\connect root@192.168.136.128:13306
\connect root@192.168.136.129:13306
\connect root@192.168.136.130:13306
MySQL localhost:13306 JS > \connect root@192.168.136.128:13306
MySQL 192.168.136.128:13306 JS > var cluster = dba.createCluster('testCluster')
You are connected to an instance that belongs to an unmanaged replication group.
Do you want to setup an InnoDB cluster based on this replication group? [Y/n]: y
A new InnoDB cluster will be created based on the existing replication group on instance 'root@192.168.136.128:13306'.
Creating InnoDB cluster 'testCluster' on 'root@192.168.136.128:13306'...
Adding Seed Instance...
Adding Instance 'wn19testcdb1002:13306'...
Cluster successfully created based on existing replication group.
问题1:
MySQL JS > \connect root@192.168.136.128:13306
Creating a session to 'root@192.168.136.128:13306'
Please provide the password for 'root@192.168.136.128:13306': ********
MySQL Error 1045 (28000): Access denied for user 'root'@'wn19testcdb1001' (using password: YES)
解决方法:
create user 'root'@'192.168.136.%' identified by 'Root@111';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.136.%' WITH GRANT OPTION ;
GRANT PROXY ON ''@'' TO 'root'@'192.168.136.%' WITH GRANT OPTION ;
var cluster = dba.createCluster('testCluster')
1.2 添加instance到InnoDB Cluster
MySQL 192.168.136.128:13306 JS > cluster.addInstance('root@192.168.136.129:13306')
MySQL 192.168.136.130:13306 JS > cluster.addInstance('root@192.168.136.130:13306')
MySQL 192.168.136.130:13306 JS > cluster.rescan()
Rescanning the cluster...
Result of the rescanning operation:
{
"defaultReplicaSet": {
"name": "default",
"newlyDiscoveredInstances": [
{
"host": "wn19testcdb1003:13306",
"member_id": "360bfb62-db39-11e8-b641-000c29beb130",
"name": null
}
],
"unavailableInstances": []
}
}
A new instance 'wn19testcdb1003:13306' was discovered in the HA setup. Would you like to add it to the cluster metadata? [Y/n]: y Adding instance to the cluster metadata...
Please provide the password for 'root@wn19testcdb1003:13306': ******** Save password for 'root@wn19testcdb1003:13306'? [Y]es/[N]o/Ne[v]er (default No): The instance 'root@wn19testcdb1003:13306' was successfully added to the cluster metadata.
MySQL 192.168.136.130:13306 JS > cluster.rescan()
Rescanning the cluster...
Result of the rescanning