\connect [email protected]:13306
\connect [email protected]:13306
\connect [email protected]:13306
MySQL localhost:13306 JS > \connect [email protected]: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 '[email protected]:13306'.
Creating InnoDB cluster 'testCluster' on '[email protected]:13306'...
Adding Seed Instance...
Adding Instance 'wn19testcdb1002:13306'...
Cluster successfully created based on existing replication group.
MySQL JS > \connect [email protected]:13306
Creating a session to '[email protected]:13306'
Please provide the password for '[email protected]: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')
MySQL 192.168.136.128:13306 JS > cluster.addInstance('[email protected]:13306')
MySQL 192.168.136.130:13306 JS > cluster.addInstance('[email protected]: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 operation:
{
"defaultReplicaSet": {
"name": "default",
"newlyDiscoveredInstances": [],
"unavailableInstances": []
}
}
\connect [email protected]:13306
cluster.addInstance('[email protected]:13306')
\connect [email protected]:13306
cluster.addInstance('[email protected]:13306')
cluster.rescan()
[root@wn19testcdb1001 ~]# mysqlsh
mysql-js> \connect [email protected]:13306
mysql-js> dba.configureLocalInstance('[email protected]:13306')
group_replication_allow_local_disjoint_gtids_join = OFF
group_replication_allow_local_lower_version_join = OFF
group_replication_auto_increment_increment = 7
group_replication_components_stop_timeout = 31536000
group_replication_compression_threshold = 1000000
group_replication_flow_control_applier_threshold = 25000
group_replication_flow_control_certifier_threshold = 25000
group_replication_flow_control_mode = QUOTA
group_replication_force_members
group_replication_gtid_assignment_block_size = 1000000
group_replication_ip_whitelist = AUTOMATIC
group_replication_member_weight = 50
group_replication_poll_spin_loops = 0
group_replication_recovery_complete_at = TRANSACTIONS_APPLIED
group_replication_recovery_reconnect_interval = 60
group_replication_recovery_retry_count = 10
group_replication_recovery_ssl_ca
group_replication_recovery_ssl_capath
group_replication_recovery_ssl_cert
group_replication_recovery_ssl_cipher
group_replication_recovery_ssl_crl
group_replication_recovery_ssl_crlpath
group_replication_recovery_ssl_key
group_replication_recovery_ssl_verify_server_cert = OFF
group_replication_recovery_use_ssl = OFF
group_replication_ssl_mode = DISABLED
group_replication_transaction_size_limit = 0
group_replication_unreachable_majority_timeout = 0
auto_increment_increment = 7
auto_increment_offset = 10
以此类推: 2.2. 192.168.136.129 上添加持久化配置在/etc/my.cnf里
[root@wn19testcdb1002 ~]# mysqlsh
mysql-js> \connect [email protected]:13306
mysql-js> dba.configureLocalInstance('[email protected]:13306')
[root@wn19testcdb1003 ~]# mysqlsh
mysql-js> \connect [email protected]:13306
mysql-js> dba.configureLocalInstance('[email protected]:13306')
GRANT ALL PRIVILEGES ON mysql_innodb_cluster_metadata.* TO your_user@'%' WITH GRANT OPTION;
GRANT RELOAD, SHUTDOWN, PROCESS, FILE, SUPER, REPLICATION SLAVE, REPLICATION CLIENT, CREATE USER ON *.* TO your_user@'%' WITH GRANT OPTION;
GRANT SELECT ON *.* TO your_user@'%' WITH GRANT OPTION;
GRANT SELECT ON mysql_innodb_cluster_metadata.* TO your_user@'%';
GRANT SELECT ON performance_schema.global_status TO your_user@'%';
GRANT SELECT ON performance_schema.replication_applier_configuration TO your_user@'%';
GRANT SELECT ON performance_schema.replication_applier_status TO your_user@'%';
GRANT SELECT ON performance_schema.replication_applier_status_by_coordinator TO your_user@'%';
GRANT SELECT ON performance_schema.replication_applier_status_by_worker TO your_user@'%';
GRANT SELECT ON performance_schema.replication_connection_configuration TO your_user@'%';
GRANT SELECT ON performance_schema.replication_connection_status TO your_user@'%';
GRANT SELECT ON performance_schema.replication_group_member_stats TO your_user@'%';
GRANT SELECT ON performance_schema.replication_group_members TO your_user@'%';
root@localhost03:30:53[mysql_innodb_cluster_metadata]>exit
Bye
mysql@wn19testcdb1001:/home/db/mysql$ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.136.128 wn19testcdb1001
192.168.136.129 wn19testcdb1002
192.168.136.130 wn19testcdb1003
192.168.136.150 testc-vip
shell> mysqlsh --log-level=DEBUG3
mysql-js> dba.verbose=2
dba.checkInstanceConfiguration('[email protected]:13306')
dba.checkInstanceConfiguration('[email protected]:13306')
dba.checkInstanceConfiguration('[email protected]:13306')
MySQL JS > dba.checkInstanceConfiguration('[email protected]:13306')
Please provide the password for '[email protected]:13306': ********
Save password for '[email protected]:13306'? [Y]es/[N]o/Ne[v]er (default No): Y
Dba.checkInstanceConfiguration: This function is not available through a session to an instance already in an InnoDB cluster (RuntimeError)
在192.168.136.128/192.168.136.129/192.168.136.130上关掉组复制
stop group_replication
MySQL JS > dba.checkInstanceConfiguration('[email protected]:13306')
Validating local MySQL instance listening at port 13306 for use in an InnoDB cluster...
This instance reports its own address as wn19testcdb1001
Clients and other cluster members will communicate with it through this address by default. If this is not correct, the report_host MySQL system variable should be changed.
Checking whether existing tables comply with Group Replication requirements...
No incompatible tables detected
Checking instance configuration...
Note: verifyMyCnf option was not given so only dynamic configuration will be verified.
Instance configuration is compatible with InnoDB cluster
The instance '192.168.136.128:13306' is valid for InnoDB cluster usage.
{
"status": "ok"
}
MySQL JS > dba.checkInstanceConfiguration('[email protected]:13306')
Validating MySQL instance at 192.168.136.129:13306 for use in an InnoDB cluster...
This instance reports its own address as wn19testcdb1002
Clients and other cluster members will communicate with it through this address by default. If this is not correct, the report_host MySQL system variable should be changed.
Checking whether existing tables comply with Group Replication requirements...
No incompatible tables detected
Checking instance configuration...
Note: verifyMyCnf option was not given so only dynamic configuration will be verified.
Instance configuration is compatible with InnoDB cluster
The instance '192.168.136.129:13306' is valid for InnoDB cluster usage.
{
"status": "ok"
}
MySQL JS > dba.checkInstanceConfiguration('[email protected]:13306')
Validating MySQL instance at 192.168.136.129:13306 for use in an InnoDB cluster...
This instance reports its own address as wn19testcdb1002
Clients and other cluster members will communicate with it through this address by default. If this is not correct, the report_host MySQL system variable should be changed.
Checking whether existing tables comply with Group Replication requirements...
No incompatible tables detected
Checking instance configuration...
Note: verifyMyCnf option was not given so only dynamic configuration will be verified.
Instance configuration is compatible with InnoDB cluster
The instance '192.168.136.129:13306' is valid for InnoDB cluster usage.
{
"status": "ok"
}
MySQL JS > dba.checkInstanceConfiguration('[email protected]:13306')
Please provide the password for '[email protected]:13306': ********
Save password for '[email protected]:13306'? [Y]es/[N]o/Ne[v]er (default No): y
Dba.checkInstanceConfiguration: This function is not available through a session to an instance already in an InnoDB cluster (RuntimeError)
MySQL JS > dba.checkInstanceConfiguration('[email protected]:13306')
Validating MySQL instance at 192.168.136.130:13306 for use in an InnoDB cluster...
This instance reports its own address as wn19testcdb1003
Clients and other cluster members will communicate with it through this address by default. If this is not correct, the report_host MySQL system variable should be changed.
Checking whether existing tables comply with Group Replication requirements...
No incompatible tables detected
Checking instance configuration...
Note: verifyMyCnf option was not given so only dynamic configuration will be verified.
Instance configuration is compatible with InnoDB cluster
The instance '192.168.136.130:13306' is valid for InnoDB cluster usage.
{
"status": "ok"
}
[root@wn19testcdb1001 ~]# mysqlsh
mysql-js> \connect [email protected]:13306
mysql-js> dba.configureLocalInstance('[email protected]:13306')
[root@wn19testcdb1002 ~]# mysqlsh
mysql-js> \connect [email protected]:13306
mysql-js> dba.configureLocalInstance('[email protected]:13306')
[root@wn19testcdb1003 ~]# mysqlsh
mysql-js> \connect [email protected]:13306
mysql-js> dba.configureLocalInstance('[email protected]:13306')
shell> mysqlsh --uri 192.168.136.128:13306
mysql-js> var cluster = dba.createCluster('testCluster')
mysql-js> cluster.addInstance('192.168.136.128:13306');
mysql-js> cluster.addInstance('192.168.136.129:13306');
mysql-js> var cluster = dba.createCluster('testCluster', {adoptFromGR: true});
MySQL 192.168.136.128:13306 JS > dba.help('getCluster')
MySQL 192.168.136.128:13306 JS > dba.getCluster('testCluster')
MySQL 192.168.136.128:13306 JS > var cluster=dba.getCluster('testCluster')
MySQL 192.168.136.128:13306 JS > cluster.rescan()
MySQL 192.168.136.128:13306 JS > cluster.status()
{
"clusterName": "testCluster",
"defaultReplicaSet": {
"name": "default",
"primary": "wn19testcdb1001:13306",
"ssl": "DISABLED",
"status": "OK",
"statusText": "Cluster is ONLINE and can tolerate up to ONE failure.",
"topology": {
"wn19testcdb1001:13306": {
"address": "wn19testcdb1001:13306",
"mode": "R/W",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
},
"wn19testcdb1002:13306": {
"address": "wn19testcdb1002:13306",
"mode": "R/O",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
},
"wn19testcdb1003:13306": {
"address": "wn19testcdb1003:13306",
"mode": "R/O",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
}
}
},
"groupInformationSourceMember": "mysql://[email protected]:13306"
}