diff --git a/Documentation/Monitors/MySQL-Monitor.md b/Documentation/Monitors/MySQL-Monitor.md index 942f6526e..30490924b 100644 --- a/Documentation/Monitors/MySQL-Monitor.md +++ b/Documentation/Monitors/MySQL-Monitor.md @@ -119,9 +119,10 @@ This functionality is similar to the [Multi-Master Monitor](MM-Monitor.md) functionality. The only difference is that the MySQL monitor will also detect traditional Master-Slave topologies. -### `failover` +### `detect_standalone_master` -Failover mode. This feature takes a boolean parameter is disabled by default. +Detect standalone master servers. This feature takes a boolean parameter and is +disabled by default. In MaxScale 2.1.0, this parameter was called `failover`. This parameter is intended to be used with simple, two node master-slave pairs where the failure of the master can be resolved by "promoting" the slave as the @@ -137,15 +138,16 @@ looking at the system variables of the server in question. By default, MaxScale will only attempt to deduce if the server can be used as a slave server (controlled by the `detect_stale_slave` parameter). When the -`failover` mode is enabled, MaxScale will also attempt to deduce whether the -server can be used as a master server. This is done by checking that the server -is not in read-only mode and that it is not configured as a slave. +`detect_standalone_master` mode is enabled, MaxScale will also attempt to deduce +whether the server can be used as a master server. This is done by checking that +the server is not in read-only mode and that it is not configured as a slave. -The failover mode in mysqlmon is completely passive in the sense that it does -not modify the cluster or any of the servers in it. It only labels the last -remaining server in a cluster as the master server. +This mode in mysqlmon is completely passive in the sense that it does not modify +the cluster or any of the servers in it. It only labels the last remaining +server in a cluster as the master server. -Before a failover can be initiated, the following conditions must have been met: +Before a server is labeled as a standalone master, the following conditions must +have been met: - Previous attempts to connect to other servers in the cluster have failed, controlled by the `failcount` parameter @@ -158,10 +160,7 @@ In 2.1.1, the following additional condition was added: - The last running server is not configured as a slave -When these conditions are met, the monitor will label the last remaining server -as a master. - -If the value of the `failover_recovery` parameter is set to false, the monitor +If the value of the `allow_cluster_recovery` parameter is set to false, the monitor sets all other servers into maintenance mode. This is done to prevent accidental use of the failed servers if they came back online. If the failed servers come back up, the maintenance mode needs to be manually cleared once replication has @@ -173,32 +172,33 @@ been set up. ### `failcount` -Number of failures that must occur on all failed servers before a failover is -initiated. The default value is 5 failures. +Number of failures that must occur on all failed servers before a standalone +server is labeled as a master. The default value is 5 failures. The monitor will attempt to contact all servers once per monitoring cycle. When -_failover_ mode is enabled, all of the failed servers must fail _failcount_ -number of connection attempts before a failover is initiated. +`detect_standalone_master` is enabled, all of the failed servers must fail +_failcount_ number of connection attempts before the last server is labeled as +the master. -The formula for calculating the actual number of milliseconds before failover -can start is `monitor_interval * failcount`. This means that to trigger a -failover after 10 seconds of master failure with a _monitor_interval_ of 1000 -milliseconds, the value of _failcount_ must be 10. +The formula for calculating the actual number of milliseconds before the server +is labeled as the master is `monitor_interval * failcount`. -### `failover_recovery` +### `allow_cluster_recovery` -Allow recovery after failover. This feature takes a boolean parameter is -enabled by default. +Allow recovery after the cluster has dropped down to one server. This feature +takes a boolean parameter is enabled by default. This parameter requires that +`detect_standalone_master` is set to true. In MaxScale 2.1.0, this parameter was +called `failover_recovery`. -When this parameter is disabled, if a failover has been triggered and the last -remaining server is chosen as the master, the monitor will set all of the failed -servers into maintenance mode. When this option is enabled, the failed servers -are allowed to rejoin the cluster. +When this parameter is disabled, if the last remaining server is labeled as the +master, the monitor will set all of the failed servers into maintenance +mode. When this option is enabled, the failed servers are allowed to rejoin the +cluster. -This option should be enabled when failover in MaxScale is used in conjunction -with an external agent that resets the slave status for new master servers. One -of these agents is the _replication-manager_ which clears the slave -configuration for each new master and removes the read-only mode. +This option should be enabled only when MaxScale is used in conjunction with an +external agent that automatically reintegrates failed servers into the +cluster. One of these agents is the _replication-manager_ which automatically +configures the failed servers as new slaves of the current master. ## Example 1 - Monitor script diff --git a/server/modules/monitor/mysqlmon.h b/server/modules/monitor/mysqlmon.h index eca4b6b83..ae000150d 100644 --- a/server/modules/monitor/mysqlmon.h +++ b/server/modules/monitor/mysqlmon.h @@ -74,10 +74,10 @@ typedef struct char* script; /*< Script to call when state changes occur on servers */ uint64_t events; /*< enabled events */ HASHTABLE *server_info; /**< Contains server specific information */ - bool failover; /**< If simple failover is enabled */ + bool detect_standalone_master; /**< If standalone master are detected */ int failcount; /**< How many monitoring cycles servers must be down before failover is initiated */ - bool failover_recovery; /**< Allow servers to rejoin the cluster in failover mode */ + bool allow_cluster_recovery; /**< Allow failed servers to rejoin the cluster */ bool warn_failover; /**< Log a warning when failover happens */ } MYSQL_MONITOR; diff --git a/server/modules/monitor/mysqlmon/mysql_mon.c b/server/modules/monitor/mysqlmon/mysql_mon.c index 8d1b01901..4e429be09 100644 --- a/server/modules/monitor/mysqlmon/mysql_mon.c +++ b/server/modules/monitor/mysqlmon/mysql_mon.c @@ -125,9 +125,9 @@ MXS_MODULE* MXS_CREATE_MODULE() {"detect_stale_slave", MXS_MODULE_PARAM_BOOL, "true"}, {"mysql51_replication", MXS_MODULE_PARAM_BOOL, "false"}, {"multimaster", MXS_MODULE_PARAM_BOOL, "false"}, - {"failover", MXS_MODULE_PARAM_BOOL, "false"}, + {"detect_standalone_master", MXS_MODULE_PARAM_BOOL, "false"}, {"failcount", MXS_MODULE_PARAM_COUNT, "5"}, - {"failover_recovery", MXS_MODULE_PARAM_BOOL, "true"}, + {"allow_cluster_recovery", MXS_MODULE_PARAM_BOOL, "true"}, { "script", MXS_MODULE_PARAM_PATH, @@ -279,9 +279,9 @@ startMonitor(MXS_MONITOR *monitor, const MXS_CONFIG_PARAMETER* params) handle->detectStaleSlave = config_get_bool(params, "detect_stale_slave"); handle->replicationHeartbeat = config_get_bool(params, "detect_replication_lag"); handle->multimaster = config_get_bool(params, "multimaster"); - handle->failover = config_get_bool(params, "failover"); + handle->detect_standalone_master = config_get_bool(params, "detect_standalone_master"); handle->failcount = config_get_integer(params, "failcount"); - handle->failover_recovery = config_get_bool(params, "failover_recovery"); + handle->allow_cluster_recovery = config_get_bool(params, "allow_cluster_recovery"); handle->mysql51_replication = config_get_bool(params, "mysql51_replication"); handle->script = config_copy_string(params, "script"); handle->events = config_get_enum(params, "events", mxs_monitor_event_enum_values); @@ -1010,7 +1010,7 @@ void do_failover(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *db) { MXS_WARNING("Failover initiated, server '%s' is now the master.%s", db->server->unique_name, - handle->failover_recovery ? + handle->allow_cluster_recovery ? "" : " All other servers are set into maintenance mode."); handle->warn_failover = false; } @@ -1019,7 +1019,7 @@ void do_failover(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *db) monitor_set_pending_status(db, SERVER_MASTER); monitor_clear_pending_status(db, SERVER_SLAVE); } - else if (!handle->failover_recovery) + else if (!handle->allow_cluster_recovery) { server_set_status_nolock(db->server, SERVER_MAINT); monitor_set_pending_status(db, SERVER_MAINT); @@ -1298,7 +1298,7 @@ monitorMain(void *arg) /** Now that all servers have their status correctly set, we can check if we need to do a failover */ - if (handle->failover) + if (handle->detect_standalone_master) { if (failover_required(handle, mon->databases)) {