int create_group_replication_user(bool threaded, Sql_service_interface *sql_interface) { DBUG_ENTER("create_group_replication_user"); int error = 0; Sql_service_interface *server_interface= NULL; if (sql_interface == NULL) { server_interface= new Sql_service_interface(); if (!threaded) error = server_interface->open_session(); else error = server_interface->open_thread_session(get_plugin_pointer());
if (error) { /* purecov: begin inspected */ log_message(MY_ERROR_LEVEL, "Can't establish a internal server connection to execute" " plugin operations"); delete server_interface; DBUG_RETURN(error); /* purecov: end */ } } else { server_interface= sql_interface; }
error= server_interface->set_session_user("root"); if (error) { /* purecov: begin inspected */ log_message(MY_ERROR_LEVEL, "Can't use the root account to create the plugin associated user" " account to access the server."); if (sql_interface == NULL) delete server_interface; DBUG_RETURN(error); /* purecov: end */ }
long srv_err= 0; std::string query; query.assign("SET @GR_OLD_LOG_BIN=@@SQL_LOG_BIN;"); if ((srv_err= execute_user_query(server_interface,query))) goto err; /* purecov: inspected */
query.assign("CREATE USER IF NOT EXISTS " GROUPREPL_ACCOUNT " IDENTIFIED" " WITH mysql_native_password AS" " '*7CF5CA9067EC647187EB99FCC27548FBE4839AE3' ACCOUNT LOCK;"); if ((srv_err= execute_user_query(server_interface,query))) goto err; /* purecov: inspected */
query.assign("GRANT SELECT ON performance_schema.replication_connection_status" " TO " GROUPREPL_ACCOUNT); if ((srv_err= execute_user_query(server_interface,query))) goto err; /* purecov: inspected */
query.assign("GRANT SUPER ON *.* TO " GROUPREPL_ACCOUNT); if ((srv_err= execute_user_query(server_interface,query))) goto err; /* purecov: inspected */
2016-12-26T13:20:54.037658+08:00 8 [ERROR] Plugin group_replication reported: 'Can't use the root account to create the plugin associated user account to access the server.' 2016-12-26T13:20:54.037666+08:00 8 [ERROR] Plugin group_replication reported: 'Could not evaluate if the group replication user is present in the server' 2016-12-26T13:20:54.037692+08:00 8 [Note] Plugin group_replication reported: 'Requesting to leave the group despite of not being a member' 2016-12-26T13:20:54.037699+08:00 8 [ERROR] Plugin group_replication reported: 'Error calling group communication interfaces while trying to leave the group'
'Starting group replication recovery with view_id 14829776327826555:2'
1 2 3 4 5 6
2016-12-29T02:17:56.390895-00:00 13 [Note] 'CHANGE MASTER TO FOR CHANNEL 'group_replication_recovery' executed'. Previous state master_host='', master_port= 3306, master_log_file='', master_log_pos= 4, master_bind=''. New state master_host='b9cc57bc41f3', master_port= 3306, master_log_file='', master_log_pos= 4, master_bind=''. 2016-12-29T02:17:56.699417-00:00 13 [Note] Plugin group_replication reported: 'Establishing connection to a group replication recovery donor 1894ecbf-cd6a-11e6-b76f-0242ac110002 at b9cc57bc41f3 port: 3306.' 2016-12-29T02:17:56.700203-00:00 14 [Warning] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. 2016-12-29T02:17:56.730434-00:00 15 [Note] Slave SQL thread for channel 'group_replication_recovery' initialized, starting replication in log 'FIRST' at position 0, relay log '/var/lib/mysql/relaylog-group_replication_recovery.000001' position: 4 2016-12-29T02:18:29.761682-00:00 14 [ERROR] Slave I/O for channel 'group_replication_recovery': error connecting to master 'repl@b9cc57bc41f3:3306' - retry-time: 60 retries: 1, Error_code: 2005 2016-12-29T02:18:29.761741-00:00 14 [Note] Slave I/O thread for channel 'group_replication_recovery' killed while connecting to master ......
There was an error when connecting to the donor server. Check group replication recovery's connection credentials.
当recovery恢复尝试一定次数之后, 会退出MGR Cluster:
1 2
2016-12-29T02:32:29.568996-00:00 13 [ERROR] Plugin group_replication reported: 'Fatal error during the Recovery process of Group Replication. The server will leave the group.'
int configure_group_member_manager() { DBUG_ENTER("configure_group_member_manager");
/* Ensure that group communication interfaces are initialized and ready to use, since plugin can leave the group on errors but continue to be active. */ std::string gcs_local_member_identifier; if (gcs_module->get_local_member_identifier(gcs_local_member_identifier)) { /* purecov: begin inspected */ log_message(MY_ERROR_LEVEL, "Error calling group communication interfaces"); DBUG_RETURN(GROUP_REPLICATION_COMMUNICATION_LAYER_SESSION_ERROR); /* purecov: end */ }
//Configure Group Member Manager char *hostname, *uuid; uint port; unsigned int server_version; get_server_parameters(&hostname, &port, &uuid, &server_version); plugin_version= server_version;
void get_server_parameters(char **hostname, uint *port, char** uuid, unsigned int *out_server_version) { /* use startup option report-host and report-port when provided, as value provided by glob_hostname, which used gethostname() function internally to determine hostname, will not always provide correct network interface, especially in case of multiple network interfaces. */ if (report_host) *hostname= report_host; else *hostname= glob_hostname;
if (report_port) *port= report_port; else *port= mysqld_port;
*uuid= server_uuid;
//Convert server version to hex
ulong major= 0, minor= 0, patch= 0; char *pos= server_version, *end_pos; //extract each server decimal number, e.g., for 5.9.30 -> 5, 9 and 30 major= strtoul(pos, &end_pos, 10); pos=end_pos+1; minor= strtoul(pos, &end_pos, 10); pos=end_pos+1; patch= strtoul(pos, &end_pos, 10);
/* Convert to a equivalent hex representation. 5.9.30 -> 0x050930 version= 0 x 16^5 + 5 x 16^4 + 0 x 16^3 + 9 x 16^2 + 3 x 16^1 + 0 x 16^0 */ int v1= patch / 10; int v0= patch - v1 * 10; int v3= minor / 10; int v2= minor - v3 * 10; int v5= major / 10; int v4= major - v5 * 10;