MXS-2428 Add 'dynamic_node_detection' 'health_check_port'

'dynamic_node_detection' specifies whether the Clustrix monitor
should dynamically figure out what nodes there are, or just rely
upon static information.

'health_check_port' specifies the port to be used when perforing
the health check ping.
This commit is contained in:
Johan Wikman 2019-04-15 11:28:31 +03:00
parent df3950dbc0
commit e09a6c8100
5 changed files with 98 additions and 6 deletions

View File

@ -10,9 +10,11 @@ instances within MaxScale.
A minimal configuration for a monitor requires one server in the Clustrix
cluster, and a username and a password to connect to the server. Note that
the Clustrix monitor will only use that server in order to dynamically find
out the configuration of the cluster; after startup it will completely rely
upon information obtained at runtime.
by default the Clustrix monitor will only use that server in order to
dynamically find out the configuration of the cluster; after startup it
will completely rely upon information obtained at runtime. To change the
default behaviour, please see the parameter
[dynamic_node_detection](#dynamic_node_detection).
To ensure that the Clustrix monitor will be able to start, it is adviseable
to provide _more_ than one server to cater for the case that not all nodes
@ -97,6 +99,52 @@ considers a particular node to be down. The default value is 2.
health_check_threshold=3
```
### `dynamic_node_detection`
By default, the Clustrix monitor will only use the bootstrap nodes
in order to connect to the Clustrux cluster and then find out the
cluster configuration dynamically at runtime.
That behaviour can be turned off with this optional parameter, in
which case all Clustrix nodes must manually be defined as shown below.
```
[Node-1]
type=server
address=192.168.121.77
port=3306
...
[Node-2]
...
[Node-3]
...
[Clustrix-Monitor]
type=monitor
module=clustrixmon
servers=Node-1, Node-2, Node-3
dynamic_node_detection=false
```
The default value of `dynamic_node_detection` is `true`.
See also [health_check_port](#health_check_port).
### `health_check_port`
With this optional parameter it can be specified what health check
port to use, if `dynamic_node_detection` has been disabled.
```
health_check_port=4711
```
The default value is `3581`.
Note that this parameter is _ignored_ unless `dynamic_node_detection`
is `false`. Note also that the port must be the same for all nodes.
## Commands
The Clustrix monitor supports the following module commands.

View File

@ -111,6 +111,16 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
MXS_MODULE_PARAM_COUNT,
DEFAULT_HEALTH_CHECK_THRESHOLD_ZVALUE
},
{
DYNAMIC_NODE_DETECTION_NAME,
MXS_MODULE_PARAM_BOOL,
DEFAULT_DYNAMIC_NODE_DETECTION_ZVALUE
},
{
HEALTH_CHECK_PORT_NAME,
MXS_MODULE_PARAM_COUNT,
DEFAULT_HEALTH_CHECK_PORT_ZVALUE
},
{MXS_END_MODULE_PARAMS}
}
};

View File

@ -21,6 +21,14 @@
const long DEFAULT_CLUSTER_MONITOR_INTERVAL_VALUE = 60000;
#define DEFAULT_CLUSTER_MONITOR_INTERVAL_ZVALUE "60000"
#define HEALTH_CHECK_THRESHOLD_NAME "health_check_threshold"
const long DEFAULT_HEALTH_CHECK_THRESHOLD_VALUE = 2;
#define DEFAULT_HEALTH_CHECK_THRESHOLD_ZVALUE "2"
#define HEALTH_CHECK_THRESHOLD_NAME "health_check_threshold"
const long DEFAULT_HEALTH_CHECK_THRESHOLD_VALUE = 2;
#define DEFAULT_HEALTH_CHECK_THRESHOLD_ZVALUE "2"
#define DYNAMIC_NODE_DETECTION_NAME "dynamic_node_detection"
const bool DEFAULT_DYNAMIC_NODE_DETECTION_VALUE = true;
#define DEFAULT_DYNAMIC_NODE_DETECTION_ZVALUE "true"
#define HEALTH_CHECK_PORT_NAME "health_check_port"
const long DEFAULT_HEALTH_CHECK_PORT_VALUE = 3581;
#define DEFAULT_HEALTH_CHECK_PORT_ZVALUE "3581"

View File

@ -175,6 +175,8 @@ bool ClustrixMonitor::configure(const MXS_CONFIG_PARAMETER* pParams)
m_config.set_cluster_monitor_interval(pParams->get_integer(CLUSTER_MONITOR_INTERVAL_NAME));
m_config.set_health_check_threshold(pParams->get_integer(HEALTH_CHECK_THRESHOLD_NAME));
m_config.set_dynamic_node_detection(pParams->get_bool(DYNAMIC_NODE_DETECTION_NAME));
m_config.set_health_check_port(pParams->get_integer(HEALTH_CHECK_PORT_NAME));
return true;
}

View File

@ -33,6 +33,8 @@ public:
Config()
: m_cluster_monitor_interval(DEFAULT_CLUSTER_MONITOR_INTERVAL_VALUE)
, m_health_check_threshold(DEFAULT_HEALTH_CHECK_THRESHOLD_VALUE)
, m_dynamic_node_detection(DEFAULT_DYNAMIC_NODE_DETECTION_VALUE)
, m_health_check_port(DEFAULT_HEALTH_CHECK_PORT_VALUE)
{
};
@ -56,9 +58,31 @@ public:
m_health_check_threshold = l;
}
bool dynamic_node_detection() const
{
return m_dynamic_node_detection;
}
void set_dynamic_node_detection(bool b)
{
m_dynamic_node_detection = b;
}
int health_check_port() const
{
return m_health_check_port;
}
void set_health_check_port(int p)
{
m_health_check_port = p;
}
private:
long m_cluster_monitor_interval;
long m_health_check_threshold;
bool m_dynamic_node_detection;
int m_health_check_port;
};
~ClustrixMonitor();