mysql-js> dba.deploySandboxInstance(3310) A new MySQL sandbox instance will be created on this host in /root/mysql-sandboxes/3310
输入密码之后,一个3310端口的MySQL服务就启动了。 Please enter a MySQL root password for the new instance: Deploying new MySQL instance... Instance localhost:3310 successfully deployed and started. Use shell.connect('root@localhost:3310'); to connect to the instance. 接着创建另外两个节点 3320,3330 dba.deploySandboxInstance(3320) dba.deploySandboxInstance(3330) 我们切换到3310的MySQL实例,准备开始创建Cluster mysql-js> /connect root@localhost:3310 Creating a Session to 'root@localhost:3310' Enter password: Closing old connection... Classic Session successfully established. No default schema selected.
Please enter MySQL password for root: Bootstrapping system MySQL Router instance... MySQL Router has now been configured for the InnoDB cluster 'testCluster'. The following connection information can be used to connect to the cluster. Classic MySQL protocol connections to cluster 'testCluster': - Read/Write Connections: localhost:6446 - Read/Only Connections: localhost:6447 X protocol connections to cluster 'testCluster': - Read/Write Connections: localhost:64460 - Read/Only Connections: localhost:64470 可以从上面的日志看出来,分配的读写端口是6446,只读端口是6447,还有x协议连接的端口为64460,64470 启动MySQL Router # mysqlrouter & [1] 2913
mysql-js> cluster.rejoinInstance('root@localhost:3310') Rejoining the instance to the InnoDB cluster. Depending on the original problem that made the instance unavailable, the rejoin operation might not be successful and further manual steps will be needed to fix the underlying problem. Please monitor the output of the rejoin operation and take necessary action if the instance cannot rejoin. Please provide the password for 'root@localhost:3310': Rejoining instance to the cluster ... The instance 'root@localhost:3310' was successfully rejoined on the cluster. The instance 'localhost:3310' was successfully added to the MySQL Cluster. mysql-js>