Rate This Document
Findability
Accuracy
Completeness
Readability

Initializing MGR Authentication Information

The following operations must be performed on the physical machine where the primary K8s node is deployed. To perform these operations, you must log in to each MySQL pod in the MGR group one by one.

  1. Log in to MySQL.
    1
    kubectl exec -it <pod_name> -n <spaces_name> -- mysql -uroot -p
    

    For example:

    1
    2
    3
    kubectl exec -it mysql-1 -n ns-mysql-test -- mysql -uroot -p
    kubectl exec -it mysql-2 -n ns-mysql-test -- mysql -uroot -p
    kubectl exec -it mysql-3 -n ns-mysql-test -- mysql -uroot -p
    
  2. After logging in to the MySQL database, create a replication account.
    SET SQL_LOG_BIN=0;
    CREATE USER rpl_user@'%' IDENTIFIED BY '123456';
    GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%';
    GRANT BACKUP_ADMIN ON *.* TO rpl_user@'%';
    FLUSH PRIVILEGES;
    SET SQL_LOG_BIN=1;
  3. Set the username and password for authentication.
    CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='123456' FOR CHANNEL 'group_replication_recovery';
  4. Restart the MySQL database for the MGR service to take effect.
    shutdown;
    • The SET SQL_LOG_BIN=0; command indicates that all operations in the current session are not recorded in bin_log.
    • If you run the shutdown; command on the MySQL database, the MySQL pod exits and a new pod is automatically deployed, which is equivalent to restarting the MySQL database.
    • After all the mysql_arm.cnf files and MGR authentication information of the MySQL database are initialized, you need to restart the MySQL database for the MGR configuration to take effect.