Added error message about MySQL versions lower than 5.5 and monitors without the 'mysql51_replication' enabled.

This commit is contained in:
Markus Makela
2015-07-07 20:14:57 +03:00
parent b47da33a33
commit 058f49eb88
3 changed files with 24 additions and 7 deletions

View File

@ -98,12 +98,12 @@ A list of event names which cause the script to be executed. If this option is n
events=master_down,slave_down events=master_down,slave_down
``` ```
### `mysql51_only` ### `mysql51_replication`
Enable support for MySQL 5.1 replication monitoring. This is needed if a MySQL server older than 5.5 is used as a slave in replication. Enable support for MySQL 5.1 replication monitoring. This is needed if a MySQL server older than 5.5 is used as a slave in replication.
``` ```
mysql51_only=true mysql51_replication=true
``` ```
## Script events ## Script events

View File

@ -2039,6 +2039,7 @@ static char *monitor_params[] =
"passwd", "passwd",
"script", "script",
"events", "events",
"mysql51_replication",
"monitor_interval", "monitor_interval",
"detect_replication_lag", "detect_replication_lag",
"detect_stale_master", "detect_stale_master",

View File

@ -81,6 +81,7 @@ static void set_master_heartbeat(MYSQL_MONITOR *, MONITOR_SERVERS *);
static void set_slave_heartbeat(MONITOR *, MONITOR_SERVERS *); static void set_slave_heartbeat(MONITOR *, MONITOR_SERVERS *);
static int add_slave_to_master(long *, int, long); static int add_slave_to_master(long *, int, long);
bool isMySQLEvent(monitor_event_t event); bool isMySQLEvent(monitor_event_t event);
static bool report_version_err = true;
static MONITOR_OBJECT MyObject = { static MONITOR_OBJECT MyObject = {
startMonitor, startMonitor,
stopMonitor, stopMonitor,
@ -200,7 +201,7 @@ startMonitor(void *arg, void* opt)
else else
have_events = true; have_events = true;
} }
else if(!strcmp(params->name,"mysql51_only")) else if(!strcmp(params->name,"mysql51_replication"))
{ {
handle->mysql51_replication = config_truth_value(params->value); handle->mysql51_replication = config_truth_value(params->value);
} }
@ -539,7 +540,7 @@ static MONITOR_SERVERS *build_mysql51_replication_tree(MONITOR *mon)
if(mysql_field_count(database->con) < 4) if(mysql_field_count(database->con) < 4)
{ {
mysql_free_result(result); mysql_free_result(result);
skygw_log_write(LE,"Error: \"SHOW SLAVE HOSTS\" " skygw_log_write_flush(LE,"Error: \"SHOW SLAVE HOSTS\" "
"returned less than the expected amount of columns. Expected 4 columns." "returned less than the expected amount of columns. Expected 4 columns."
" MySQL Version: %s",version_str); " MySQL Version: %s",version_str);
return NULL; return NULL;
@ -553,6 +554,7 @@ static MONITOR_SERVERS *build_mysql51_replication_tree(MONITOR *mon)
/* get Slave_IO_Running and Slave_SQL_Running values*/ /* get Slave_IO_Running and Slave_SQL_Running values*/
database->server->slaves[nslaves] = atol(row[0]); database->server->slaves[nslaves] = atol(row[0]);
nslaves++; nslaves++;
LOGIF(LD,(skygw_log_write_flush(LD,"Found slave at %s:%d",row[1],row[2])));
} }
database->server->slaves[nslaves] = 0; database->server->slaves[nslaves] = 0;
} }
@ -564,6 +566,10 @@ static MONITOR_SERVERS *build_mysql51_replication_tree(MONITOR *mon)
/* Set the Slave Role */ /* Set the Slave Role */
if (ismaster) if (ismaster)
{ {
LOGIF(LD,(skygw_log_write(LD,"Master server found at %s:%d with %d slaves",
database->server->name,
database->server->port,
nslaves)));
monitor_set_pending_status(database, SERVER_MASTER); monitor_set_pending_status(database, SERVER_MASTER);
if(rval == NULL || rval->server->node_id > database->server->node_id) if(rval == NULL || rval->server->node_id > database->server->node_id)
rval = database; rval = database;
@ -574,7 +580,7 @@ static MONITOR_SERVERS *build_mysql51_replication_tree(MONITOR *mon)
database = mon->databases; database = mon->databases;
/** */ /** Set master server IDs */
while(database) while(database)
{ {
ptr = mon->databases; ptr = mon->databases;
@ -591,7 +597,7 @@ static MONITOR_SERVERS *build_mysql51_replication_tree(MONITOR *mon)
} }
ptr = ptr->next; ptr = ptr->next;
} }
if(database->server->master_id <= 0) if(database->server->master_id <= 0 && SERVER_IS_SLAVE(database->server))
{ {
monitor_set_pending_status(database, SERVER_SLAVE_OF_EXTERNAL_MASTER); monitor_set_pending_status(database, SERVER_SLAVE_OF_EXTERNAL_MASTER);
} }
@ -733,7 +739,17 @@ monitorDatabase(MONITOR *mon, MONITOR_SERVERS *database)
} }
else else
{ {
monitor_mysql51_db(database); if(handle->mysql51_replication)
{
monitor_mysql51_db(database);
}
else if(report_version_err)
{
report_version_err = false;
skygw_log_write(LE,"Error: MySQL version is lower than 5.5 and 'mysql51_replication' option is not enabled,"
" replication tree cannot be resolved. To enable MySQL 5.1 replication detection, "
"add 'mysql51_replication=true' to the monitor section.");
}
} }
} }