我要评分
获取效率
正确性
完整性
易理解

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. Create a replication account.
    1
    2
    3
    4
    5
    6
    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.
    1
    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.
    1
    shutdown;
    
    • SET SQL_LOG_BIN=0; 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.