()

Adopting a Group Replication Deployment into InnoDB Cluster in MySQL

 

If you have an existing deployment of Group Replication and you want to use it to create a cluster, pass the adoptFromGR option to the dba.createCluster() function. The created InnoDB Cluster matches whether the replication group is running as single-primary or multi-primary.


To adopt an existing Group Replication group, connect to a group member using MySQL Shell. In the following example, a single-primary group is adopted. We connect to test-machine01, a primary instance, while test-machine01 is functioning as the group’s secondary. Create a cluster using dba.createCluster(), passing in the adoptFromGR option.

 

We have already configured Group Replication with 3 mysql instances. Click here to read more. We will use the same group replication configuration and will adopt it into InnoDB Cluster.

mysql>
mysql>  select * from performance_schema.replication_group_members ;
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST    | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+
| group_replication_applier | 13c84508-5014-11eb-af41-000c2997dedd | test-machine02 |        3306 | ONLINE       | SECONDARY   | 8.0.22         |
| group_replication_applier | 13ecba9c-444a-11eb-a397-000c29f9d9e6 | test-machine01 |        3306 | ONLINE       | PRIMARY     | 8.0.22         |
| group_replication_applier | 98411332-6aad-11eb-809a-000c29f9d9e6 | test-machine01 |        3307 | ONLINE       | SECONDARY   | 8.0.22         |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+
3 rows in set (0.00 sec)

mysql>

[root@test-machine01 ~]#
[root@test-machine01 ~]# mysqlsh root@localhost:3306

MySQL Shell 8.0.23

Copyright (c) 2016, 2021, 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.
Creating a session to 'root@localhost:3306'
Fetching schema names for autocompletion... Press ^C to stop.
Your MySQL connection id is 121
Server version: 8.0.22 MySQL Community Server - GPL
No default schema selected; type \use <schema> to set one.
 MySQL  localhost:3306 ssl  JS >
 MySQL  localhost:3306 ssl  JS >


 MySQL  localhost:3306 ssl  JS > \status
MySQL Shell version 8.0.23

Connection Id:                123
Current schema:
Current user:                 root@localhost
SSL:                          Cipher in use: ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2
Using delimiter:              ;
Server version:               8.0.22 MySQL Community Server - GPL
Protocol version:             Classic 10
Client library:               8.0.23
Connection:                   localhost via TCP/IP
TCP port:                     3306
Server characterset:          utf8mb4
Schema characterset:          utf8mb4
Client characterset:          utf8mb4
Conn. characterset:           utf8mb4
Result characterset:          utf8mb4
Compression:                  Disabled
Uptime:                       7 days 5 hours 47 min 51.0000 sec

Threads: 6  Questions: 586  Slow queries: 0  Opens: 214  Flush tables: 3  Open tables: 133  Queries per second avg: 0.000
 MySQL  localhost:3306 ssl  JS >



 MySQL  localhost:3306 ssl  JS >
 MySQL  localhost:3306 ssl  JS > var cluster = dba.createCluster('innodbclustertest', {adoptFromGR: true});
A new InnoDB cluster will be created based on the existing replication group on instance 'localhost:3306'.

Creating InnoDB cluster 'innodbclustertest' on 'test-machine01:3306'...

Adding Seed Instance...
Adding Instance 'test-machine02:3306'...
Adding Instance 'test-machine01:3306'...
Adding Instance 'test-machine01:3307'...
Resetting distributed recovery credentials across the cluster...
Cluster successfully created based on existing replication group.

 MySQL  localhost:3306 ssl  JS >



 MySQL  localhost:3306 ssl  JS >
 MySQL  localhost:3306 ssl  JS > cluster.status();
{
    "clusterName": "innodbclustertest",
    "defaultReplicaSet": {
        "name": "default",
        "primary": "test-machine01:3306",
        "ssl": "DISABLED",
        "status": "OK",
        "statusText": "Cluster is ONLINE and can tolerate up to ONE failure.",
        "topology": {
            "test-machine01:3306": {
                "address": "test-machine01:3306",
                "mode": "R/W",
                "readReplicas": {},
                "replicationLag": null,
                "role": "HA",
                "status": "ONLINE",
                "version": "8.0.22"
            },
            "test-machine01:3307": {
                "address": "test-machine01:3307",
                "mode": "R/O",
                "readReplicas": {},
                "replicationLag": null,
                "role": "HA",
                "status": "ONLINE",
                "version": "8.0.22"
            },
            "test-machine02:3306": {
                "address": "test-machine02:3306",
                "mode": "R/O",
                "readReplicas": {},
                "replicationLag": null,
                "role": "HA",
                "status": "ONLINE",
                "version": "8.0.22"
            }
        },
        "topologyMode": "Single-Primary"
    },
    "groupInformationSourceMember": "test-machine01:3306"
}
 MySQL  localhost:3306 ssl  JS >

 MySQL  localhost:3306 ssl  JS > cluster.describe();
{
    "clusterName": "innodbclustertest",
    "defaultReplicaSet": {
        "name": "default",
        "topology": [
            {
                "address": "test-machine02:3306",
                "label": "test-machine02:3306",
                "role": "HA"
            },
            {
                "address": "test-machine01:3306",
                "label": "test-machine01:3306",
                "role": "HA"
            },
            {
                "address": "test-machine01:3307",
                "label": "test-machine01:3307",
                "role": "HA"
            }
        ],
        "topologyMode": "Single-Primary"
    }
}
 MySQL  localhost:3306 ssl  JS >


Reference: Adopting a Group Replication Deployment: https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-innodb-cluster-from-group-replication.html


This document is only for learning purpose and always validate in the LAB environment first before applying in the LIVE environment.


Hope so you like this article
!
Please share your valuable feedback/comments/subscribe and follow us below and don’t forget to click on the bell icon to get the latest update. Click here to know more about our pursuit.

Related Articles


Loading

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Jamsher Khan

Hello and welcome to DBsGuru,I’m Jamsher Khan working as Senior Oracle DBA based in KSA-Jeddah, I have working experience in Oracle DBA, SQL Server, MySql, PostgreSQL, Linux, Golden Gate, ODA.Thanks for the visits!Share Learn Grow!