[root@nikash-db2 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
15.68.13.86 nikash-db1
15.68.13.87 nikash-db2
15.68.13.88 nikash-db3
15.68.13.89 nikash-db4
[root@nikash-db2 ~]#
mysql> select member_host,member_role from performance_schema.replication_group_members;
+-------------+-------------+
| member_host | member_role |
+-------------+-------------+
| nikash-db2 | SECONDARY |
| nikash-db4 | PRIMARY |
| nikash-db3 | SECONDARY |
+-------------+-------------+
3 rows in set (0.00 sec)
mysql>
[root@nikash-db2 ~]# mysql --user root --password=Bankasia#2020 --host 10.88.13.87 --port 4407 nikash_np_eft
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 112997
Server version: 8.0.31-cluster MySQL Cluster Community Server - GPL
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select @@hostname;
+------------+
| @@hostname |
+------------+
| nikash-db2 |
+------------+
1 row in set (0.01 sec)
[root@nikash-db2 ~]# mysqlsh
MySQL Shell 8.0.31
Copyright (c) 2016, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.
Type '\help' or '\?' for help; '\quit' to exit.
MySQL JS > root@nikash-db2
SyntaxError: Invalid or unexpected token
MySQL JS > \c root@nikash-db2
Creating a session to 'root@nikash-db2'
Fetching schema names for auto-completion... Press ^C to stop.
Your MySQL connection id is 111803 (X protocol)
Server version: 8.0.31-cluster MySQL Cluster Community Server - GPL
No default schema selected; type \use <schema> to set one.
MySQL nikash-db2:33060+ ssl JS > c.status()
ReferenceError: c is not defined
MySQL nikash-db2:33060+ ssl JS > var c=dba.getCluster()
MySQL nikash-db2:33060+ ssl JS > c.status()
{
"clusterName": "nikash_db_cluster",
"defaultReplicaSet": {
"name": "default",
"primary": "nikash-db4:4407",
"ssl": "REQUIRED",
"status": "OK",
"statusText": "Cluster is ONLINE and can tolerate up to ONE failure.",
"topology": {
"nikash-db2:4407": {
"address": "nikash-db2:4407",
"instanceErrors": [
"WARNING: Instance is NOT a PRIMARY but super_read_only option is OFF."
],
"memberRole": "SECONDARY",
"mode": "R/W",
"readReplicas": {},
"replicationLag": "applier_queue_applied",
"role": "HA",
"status": "ONLINE",
"version": "8.0.31"
},
"nikash-db3:4407": {
"address": "nikash-db3:4407",
"memberRole": "SECONDARY",
"mode": "R/O",
"readReplicas": {},
"replicationLag": "applier_queue_applied",
"role": "HA",
"status": "ONLINE",
"version": "8.0.31"
},
"nikash-db4:4407": {
"address": "nikash-db4:4407",
"memberRole": "PRIMARY",
"mode": "R/W",
"readReplicas": {},
"replicationLag": "applier_queue_applied",
"role": "HA",
"status": "ONLINE",
"version": "8.0.31"
}
},
"topologyMode": "Single-Primary"
},
"groupInformationSourceMember": "nikash-db4:4407"
}
MySQL nikash-db2:33060+ ssl JS >
MySQL nikash-db2:33060+ ssl JS > c.describe()
{
"clusterName": "nikash_db_cluster",
"defaultReplicaSet": {
"name": "default",
"topology": [
{
"address": "nikash-db2:4407",
"label": "nikash-db2:4407",
"role": "HA"
},
{
"address": "nikash-db3:4407",
"label": "nikash-db3:4407",
"role": "HA"
},
{
"address": "nikash-db4:4407",
"label": "nikash-db4:4407",
"role": "HA"
}
],
"topologyMode": "Single-Primary"
}
}
MySQL nikash-db2:33060+ ssl JS >
MySQL nikash-db2:33060+ ssl JS > c.listRouters();
{
"clusterName": "nikash_db_cluster",
"routers": {
"nikash-db2::system": {
"hostname": "nikash-db2",
"lastCheckIn": "2024-10-09 14:25:48",
"roPort": "6447",
"roXPort": "6449",
"rwPort": "6446",
"rwXPort": "6448",
"version": "8.0.31"
}
}
}
MySQL nikash-db2:33060+ ssl JS >
----------------------Remove INSTANCE from InnoDB cluster------------------
MySQL nikash-db2:33060+ ssl JS > c.removeInstance('nikash-db4:4407')
The instance will be removed from the InnoDB cluster. Depending on the instance
being the Seed or not, the Metadata session might become invalid. If so, please
start a new session to the Metadata Storage R/W instance.
* Waiting for instance 'nikash-db4:4407' to synchronize with the primary...
** Transactions replicated ############################################################ 100%
* Instance 'nikash-db4:4407' is attempting to leave the cluster...
The instance 'nikash-db4:4407' was successfully removed from the cluster.
MySQL nikash-db2:33060+ ssl JS >
--------------------Now check Cluster Group Member-------------
mysql> select member_host,member_role from performance_schema.replication_group_members;
+-------------+-------------+
| member_host | member_role |
+-------------+-------------+
| nikash-db2 | PRIMARY |
| nikash-db3 | SECONDARY |
+-------------+-------------+
2 rows in set (0.00 sec)
mysql>
MySQL nikash-db2:33060+ ssl JS > c.removeInstance('nikash-db3:4407')
The instance will be removed from the InnoDB cluster. Depending on the instance
being the Seed or not, the Metadata session might become invalid. If so, please
start a new session to the Metadata Storage R/W instance.
* Waiting for instance 'nikash-db3:4407' to synchronize with the primary...
** Transactions replicated ############################################################ 100%
* Instance 'nikash-db3:4407' is attempting to leave the cluster...
The instance 'nikash-db3:4407' was successfully removed from the cluster.
MySQL nikash-db2:33060+ ssl JS >
mysql> select member_host,member_role from performance_schema.replication_group_members;
+-------------+-------------+
| member_host | member_role |
+-------------+-------------+
| nikash-db2 | PRIMARY |
+-------------+-------------+
1 row in set (0.00 sec)
mysql>
MySQL nikash-db2:33060+ ssl JS > c.status()
{
"clusterName": "nikash_db_cluster",
"defaultReplicaSet": {
"name": "default",
"primary": "nikash-db2:4407",
"ssl": "REQUIRED",
"status": "OK_NO_TOLERANCE",
"statusText": "Cluster is NOT tolerant to any failures.",
"topology": {
"nikash-db2:4407": {
"address": "nikash-db2:4407",
"memberRole": "PRIMARY",
"mode": "R/W",
"readReplicas": {},
"replicationLag": "applier_queue_applied",
"role": "HA",
"status": "ONLINE",
"version": "8.0.31"
}
},
"topologyMode": "Single-Primary"
},
"groupInformationSourceMember": "nikash-db2:4407"
}
MySQL nikash-db2:33060+ ssl JS >
MySQL nikash-db2:33060+ ssl JS > c.describe()
{
"clusterName": "nikash_db_cluster",
"defaultReplicaSet": {
"name": "default",
"topology": [
{
"address": "nikash-db2:4407",
"label": "nikash-db2:4407",
"role": "HA"
}
],
"topologyMode": "Single-Primary"
}
}
MySQL nikash-db2:33060+ ssl JS >