常用操作命令 ./mysqlsh –mysql –uri dba@localhost:3008 –password=5d63f33c10b8f430
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 MySQL localhost:3008 ssl JS > dba.getCluster() Dba.getCluster: This function is not available through a session to an instance belonging to an unmanaged replication group (RuntimeError) MySQL localhost:3008 ssl JS > dba.createCluster('test2020' ) A new InnoDB cluster will be created on instance 'localhost:3008' . 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]: YCreating InnoDB cluster 'test2020' on '10.162.16.15:3008' .. . Adding Seed Instance.. . NOTE: Metadata schema found in target instance Adding Instance '10.162.16.17:3010' .. . Adding Instance '10.162.16.16:3009' .. . Adding Instance '10.162.16.15:3008' .. . Resetting distributed recovery credentials across the cluster.. . WARNING: User 'mysql_innodb_cluster_3' @'%' already existed at instance '10.162.16.15:3008' . It will be deleted and created again with a new password. WARNING: User 'mysql_innodb_cluster_2' @'%' already existed at instance '10.162.16.15:3008' . It will be deleted and created again with a new password. WARNING: User 'mysql_innodb_cluster_1' @'%' already existed at instance '10.162.16.15:3008' . It will be deleted and created again with a new password. Cluster successfully created based on existing replication group.
元数据表 cluster 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 mysql> select * from clusters; +-------------------------------------- +-------------- +----------------- +--------- +----------------------------------------------------------------------------------------------------------------------------------------- +-------------- +-------------- +---------------- + | cluster_id | cluster_name | description | options | attributes | cluster_type | primary_mode | router_options | +-------------------------------------- +-------------- +----------------- +--------- +----------------------------------------------------------------------------------------------------------------------------------------- +-------------- +-------------- +---------------- + | 010041bc-9b41-11ea-88ad-08688d61c0e5 | test2020 | Default Cluster | NULL | {"adopted" : 1, "default" : true , "opt_gtidSetIsComplete" : false , "group_replication_group_name" : "291e41a2-6f40-11ea-a9da-74867aea62bc" } | gr | pm | NULL | +-------------------------------------- +-------------- +----------------- +--------- +----------------------------------------------------------------------------------------------------------------------------------------- +-------------- +-------------- +---------------- + 1 row in set (0.00 sec) mysql> select * from v2_gr_clusters; +-------------- +-------------- +-------------------------------------- +-------------- +-------------------------------------- +----------------------------------------------------------------------------------------------------------------------------------------- +--------- +---------------- +----------------- +----------------------- + | cluster_type | primary_mode | cluster_id | cluster_name | group_name | attributes | options | router_options | description | replicated_cluster_id | +-------------- +-------------- +-------------------------------------- +-------------- +-------------------------------------- +----------------------------------------------------------------------------------------------------------------------------------------- +--------- +---------------- +----------------- +----------------------- + | gr | pm | 010041bc-9b41-11ea-88ad-08688d61c0e5 | test2020 | 291e41a2-6f40-11ea-a9da-74867aea62bc | {"adopted" : 1, "default" : true , "opt_gtidSetIsComplete" : false , "group_replication_group_name" : "291e41a2-6f40-11ea-a9da-74867aea62bc" } | NULL | NULL | Default Cluster | NULL | +-------------- +-------------- +-------------------------------------- +-------------- +-------------------------------------- +----------------------------------------------------------------------------------------------------------------------------------------- +--------- +---------------- +----------------- +----------------------- + 1 row in set (0.00 sec)
instance 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 mysql> select * from instances; +-------------+--------------------------------------+-------------------+--------------------------------------+-------------------+--------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------+ | instance_id | cluster_id | address | mysql_server_uuid | instance_name | addresses | attributes | description | +-------------+--------------------------------------+-------------------+--------------------------------------+-------------------+--------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------+ | 1 | 010041 bc-9 b41-11 ea-88 ad-08688 d61c0e5 | 10.162 .16 .17 :3010 | 7704 c3a4-8927 -11 ea-b68b-08688 d61c0df | 10.162 .16 .17 :3010 | {"mysqlX" : "10.162.16.17:33060" , "grLocal" : "10.162.16.17:33061" , "mysqlClassic" : "10.162.16.17:3010" } | {"recoveryAccountHost" : "%" , "recoveryAccountUser" : "mysql_innodb_cluster_3" } | NULL | | 2 | 010041 bc-9 b41-11 ea-88 ad-08688 d61c0e5 | 10.162 .16 .16 :3009 | acf9368d-8923 -11 ea-825 b-08688 d61c1b7 | 10.162 .16 .16 :3009 | {"mysqlX" : "10.162.16.16:33060" , "grLocal" : "10.162.16.16:33061" , "mysqlClassic" : "10.162.16.16:3009" } | {"recoveryAccountHost" : "%" , "recoveryAccountUser" : "mysql_innodb_cluster_2" } | NULL | | 3 | 010041 bc-9 b41-11 ea-88 ad-08688 d61c0e5 | 10.162 .16 .15 :3008 | bc0d147b-891f -11 ea-ae49-08688 d61c0e5 | 10.162 .16 .15 :3008 | {"mysqlX" : "10.162.16.15:33060" , "grLocal" : "10.162.16.15:33061" , "mysqlClassic" : "10.162.16.15:3008" } | {"recoveryAccountHost" : "%" , "recoveryAccountUser" : "mysql_innodb_cluster_1" } | NULL | +-------------+--------------------------------------+-------------------+--------------------------------------+-------------------+--------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------+ 3 rows in set (0.00 sec)mysql> select * from v2_instances; +-------------+--------------------------------------+-------------------+--------------------------------------+-------------------+-------------------+--------------------+-------------------------------------------------------------------------------+ | instance_id | cluster_id | label | mysql_server_uuid | address | endpoint | xendpoint | attributes | +-------------+--------------------------------------+-------------------+--------------------------------------+-------------------+-------------------+--------------------+-------------------------------------------------------------------------------+ | 1 | 010041 bc-9 b41-11 ea-88 ad-08688 d61c0e5 | 10.162 .16 .17 :3010 | 7704 c3a4-8927 -11 ea-b68b-08688 d61c0df | 10.162 .16 .17 :3010 | 10.162 .16 .17 :3010 | 10.162 .16 .17 :33060 | {"recoveryAccountHost" : "%" , "recoveryAccountUser" : "mysql_innodb_cluster_3" } | | 2 | 010041 bc-9 b41-11 ea-88 ad-08688 d61c0e5 | 10.162 .16 .16 :3009 | acf9368d-8923 -11 ea-825 b-08688 d61c1b7 | 10.162 .16 .16 :3009 | 10.162 .16 .16 :3009 | 10.162 .16 .16 :33060 | {"recoveryAccountHost" : "%" , "recoveryAccountUser" : "mysql_innodb_cluster_2" } | | 3 | 010041 bc-9 b41-11 ea-88 ad-08688 d61c0e5 | 10.162 .16 .15 :3008 | bc0d147b-891f -11 ea-ae49-08688 d61c0e5 | 10.162 .16 .15 :3008 | 10.162 .16 .15 :3008 | 10.162 .16 .15 :33060 | {"recoveryAccountHost" : "%" , "recoveryAccountUser" : "mysql_innodb_cluster_1" } | +-------------+--------------------------------------+-------------------+--------------------------------------+-------------------+-------------------+--------------------+-------------------------------------------------------------------------------+ 3 rows in set (0.00 sec)
1 2 3 4 5 6 7 mysql> select * from v2_this_ instance; +--------------------------------------+ -------------+--------------+ --------------+| cluster_id | instance_ id | cluster_name | cluster_ type | +--------------------------------------+ -------------+--------------+ --------------+| 010041bc-9b41-11ea-88ad-08688d61c0e5 | 3 | test2020 | gr | +--------------------------------------+ -------------+--------------+ --------------+1 row in set (0.01 sec)
api