Rate This Document
Findability
Accuracy
Completeness
Readability

Starting the MGR

Log in to the three MySQL databases on the K8s primary node respectively, and start the MGR.

  1. Start the primary database of the MGR (mysql-1 is used as the primary database in this document).

    Log in to the MySQL database by running the following command:

    1
    kubectl exec -it <pod_name> -n <spaces_name> -- mysql -uroot -p
    

    Log in to the mysql-1 database.

    1
    kubectl exec -it mysql-1 -n ns-mysql-test -- mysql -uroot -p
    

    Execute the following statements in mysql-1 to start the MGR:

    SET GLOBAL group_replication_bootstrap_group=ON;
    START GROUP_REPLICATION;
    SET GLOBAL group_replication_bootstrap_group=OFF;

    In MySQL 8.0.21 or later, the START GROUP_REPLICATION; command is replaced with START GROUP_REPLICATION USER='rpl_user', PASSWORD='123456';.

  2. Start the secondary databases of the MGR. In this document, mysql-2 and mysql-3 are used as secondary databases.

    Log in to the MySQL database by running the following command:

    1
    kubectl exec -it <pod_name> -n <spaces_name> --mysql -uroot -p
    

    Log in to the mysql-2 and mysql-3 databases, respectively.

    1
    2
    kubectl exec -it mysql-2 -n ns-mysql-test --mysql -uroot -p
    kubectl exec -it mysql-3 -n ns-mysql-test --mysql -uroot -p
    

    Execute the following statements in mysql-2 and mysql-3 to start the MGR, respectively:

    START GROUP_REPLICATION;

    View the information about group members. You can view any member in the MGR group.

    SELECT * FROM performance_schema.replication_group_members;
    +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
    | CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
    +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
    | group_replication_applier | e44f902b-bf50-11ea-89d7-000000536bb6 | mysql-1     |        3306 | ONLINE       | PRIMARY     | 8.0.19         |
    | group_replication_applier | e51ea27b-bf50-11ea-b256-000000536bb7 | mysql-2     |        3306 | ONLINE       | SECONDARY   | 8.0.19         |
    | group_replication_applier | e5b471d9-bf50-11ea-8639-000000536bb8 | mysql-3     |        3306 | ONLINE       | SECONDARY   | 8.0.19         |
    +---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
    3 rows in set (0.01 sec)