Merge branch 'develop' of github.com:mariadb-corporation/MaxScale into develop

This commit is contained in:
Timofey Turenko
2019-04-24 22:04:19 +03:00
25 changed files with 78 additions and 1056 deletions

View File

@ -21,7 +21,8 @@
## Reference ## Reference
- [MaxAdmin - Admin Interface](Reference/MaxAdmin.md) - [MaxCtrl - Command Line Admin Interface](Reference/MaxCtrl.md)
- [MaxAdmin - Legacy Admin Interface](Reference/MaxAdmin.md)
- [Routing Hints](Reference/Hint-Syntax.md) - [Routing Hints](Reference/Hint-Syntax.md)
- [MaxBinlogCheck](Reference/MaxBinlogCheck.md) - [MaxBinlogCheck](Reference/MaxBinlogCheck.md)
- [MaxScale REST API](REST-API/API.md) - [MaxScale REST API](REST-API/API.md)
@ -69,8 +70,8 @@ of their use.
- [Schemarouter](Routers/SchemaRouter.md) - [Schemarouter](Routers/SchemaRouter.md)
- [Cat](Routers/Cat.md) - [Cat](Routers/Cat.md)
There are also two diagnostic routing modules. The CLI is for MaxAdmin and The legacy diagnostic routing module MaxAdmin has been deprecated: avoid using
the Debug CLI client for Telnet. it.
- [CLI](Routers/CLI.md) - [CLI](Routers/CLI.md)
@ -109,11 +110,6 @@ Module specific documentation.
- [Aurora Monitor](Monitors/Aurora-Monitor.md) - [Aurora Monitor](Monitors/Aurora-Monitor.md)
- [Clustrix Monitor](Monitors/Clustrix-Monitor.md) - [Clustrix Monitor](Monitors/Clustrix-Monitor.md)
Legacy monitors that have been deprecated.
- [Multi-Master Monitor](Monitors/MM-Monitor.md)
- [MySQL Cluster Monitor](Monitors/NDB-Cluster-Monitor.md)
## Protocols ## Protocols
Documentation for MaxScale protocol modules. Documentation for MaxScale protocol modules.

View File

@ -1773,13 +1773,6 @@ Server databases. This implementation is tailored for the MariaDB MaxScale to
MySQL Database traffic and is not a general purpose implementation of the MySQL MySQL Database traffic and is not a general purpose implementation of the MySQL
protocol. protocol.
##### `telnetd`
The telnetd protocol module is used for connections to MariaDB MaxScale itself
for the purposes of creating interactive user sessions with the MariaDB MaxScale
instance itself. Currently this is used in conjunction with a special router
implementation, the debugcli.
##### `maxscaled` ##### `maxscaled`
The protocol used used by the maxadmin client application in order to connect to The protocol used used by the maxadmin client application in order to connect to
@ -1940,14 +1933,6 @@ Simple sharding on database level:
Binary log server: Binary log server:
* [Binlogrouter](../Routers/Binlogrouter.md) * [Binlogrouter](../Routers/Binlogrouter.md)
## Diagnostic modules
These modules are used for diagnostic purposes and can tell about the status of
MariaDB MaxScale and the cluster it is monitoring.
* [MaxAdmin Module](../Routers/CLI.md)
* [Telnet Module](../Routers/Debug-CLI.md)
## Monitor Modules ## Monitor Modules
Monitor modules are used by MariaDB MaxScale to internally monitor the state of Monitor modules are used by MariaDB MaxScale to internally monitor the state of
@ -1963,8 +1948,6 @@ which sets the status of each server via MaxAdmin is needed.
* [MariaDB Monitor](../Monitors/MariaDB-Monitor.md) * [MariaDB Monitor](../Monitors/MariaDB-Monitor.md)
* [Galera Monitor](../Monitors/Galera-Monitor.md) * [Galera Monitor](../Monitors/Galera-Monitor.md)
* [NDBCluster Monitor](../Monitors/NDB-Cluster-Monitor.md)
* [Multi-Master Monitor](../Monitors/MM-Monitor.md)
## Filter Modules ## Filter Modules
@ -2033,9 +2016,6 @@ password=61DD955512C39A4A8BC4BB1E5F116705
Read the following documents for different methods of altering the MaxScale Read the following documents for different methods of altering the MaxScale
configuration at runtime. configuration at runtime.
* MaxAdmin
* [Runtime Configuration Changes](../Reference/MaxAdmin.md#runtime-configuration-changes)
* MaxCtrl * MaxCtrl
* [`create`](../Reference/MaxCtrl.md#create) * [`create`](../Reference/MaxCtrl.md#create)
* [`destroy`](../Reference/MaxCtrl.md#destroy) * [`destroy`](../Reference/MaxCtrl.md#destroy)
@ -2045,6 +2025,9 @@ configuration at runtime.
* [REST API](../REST-API/API.md) documentation * [REST API](../REST-API/API.md) documentation
* MaxAdmin
* [Runtime Configuration Changes](../Reference/MaxAdmin.md#runtime-configuration-changes)
All changes to the configuration are persisted as individual configuration files All changes to the configuration are persisted as individual configuration files
in `/var/lib/maxscale/maxscale.cnf.d/`. These files are applied after the main in `/var/lib/maxscale/maxscale.cnf.d/`. These files are applied after the main
configuration file and all auxiliary configurations have been loaded. This means configuration file and all auxiliary configurations have been loaded. This means

View File

@ -247,14 +247,10 @@ slave_down |A Slave server has gone down
slave_up |A Slave server has come up slave_up |A Slave server has come up
server_down |A server with no assigned role has gone down server_down |A server with no assigned role has gone down
server_up |A server with no assigned role has come up server_up |A server with no assigned role has come up
ndb_down |A MySQL Cluster node has gone down
ndb_up |A MySQL Cluster node has come up
lost_master |A server lost Master status lost_master |A server lost Master status
lost_slave |A server lost Slave status lost_slave |A server lost Slave status
lost_ndb |A MySQL Cluster node lost node membership
new_master |A new Master was detected new_master |A new Master was detected
new_slave |A new Slave was detected new_slave |A new Slave was detected
new_ndb |A new MySQL Cluster node was found
### `journal_max_age` ### `journal_max_age`

View File

@ -1,24 +0,0 @@
# NDB Cluster Monitor
**NOTE:** This module has been deprecated, do not use it.
## Overview
The MySQL Cluster Monitor is a monitoring module for MaxScale that monitors a MySQL Cluster. It assigns a NDB status for the server if it is a part of a MySQL Cluster.
## Configuration
A minimal configuration for a monitor requires a set of servers for monitoring and a username and a password to connect to these servers. The user requires the REPLICATION CLIENT privilege to successfully monitor the state of the servers.
```
[MySQL-Cluster-Monitor]
type=monitor
module=ndbclustermon
servers=server1,server2,server3
user=myuser
password=mypwd
```
### Common Monitor Parameters
For a list of optional parameters that all monitors support, read the [Monitor Common](Monitor-Common.md) document.

View File

@ -567,7 +567,6 @@ the request. The value of `state` must be one of the following values.
|maintenance| Server is put into maintenance | |maintenance| Server is put into maintenance |
|running | Server is up and running | |running | Server is up and running |
|synced | Server is a Galera node | |synced | Server is a Galera node |
|ndb | Server is a NDBCluster node |
|stale | Server is a stale Master | |stale | Server is a stale Master |
For example, to set the server _db-server-1_ into maintenance mode, a request to For example, to set the server _db-server-1_ into maintenance mode, a request to

View File

@ -47,6 +47,20 @@ administrative users, recreate the user.
## Dropped Features ## Dropped Features
### `debugcli` and `telnetd`
The `debugcli` router and the `telnetd` protocol module it uses have been
removed.
### `ndbclustermon`
The `ndbclustermon` module has been removed.
### `mmmon`
The `mmmon` module has been removed as the `mariadbmon` monitor largely does
what it used to do.
## New Features ## New Features
### Servers can be drained ### Servers can be drained

View File

@ -1,21 +0,0 @@
# Debug CLI
The **debugcli** router is a special kind of statement based router. Rather than direct the statements at an external data source they are handled internally. These statements are simple text commands and the results are the output of debug commands within MariaDB MaxScale. The service and listener definitions for a debug cli service only differ from other services in that they require no backend server definitions.
## Configuration
The definition of the debug cli service is illustrated below
```
[Debug-Service]
type=service
router=debugcli
[Debug-Listener]
type=listener
service=Debug Service
protocol=telnetd
port=4442
```
Connections using the telnet protocol to port 4442 of the MariaDB MaxScale host will result in a new debug CLI session. A default username and password are used for this module, new users may be created using the administrative interface. As soon as any users are explicitly created the default username will no longer continue to work. The default username is `admin` with a password of `mariadb`.

View File

@ -33,7 +33,6 @@ Role|Description
master|A server assigned as a master by one of MariaDB MaxScale monitors. Depending on the monitor implementation, this could be a master server of a Master-Slave replication cluster or a Write-Master of a Galera cluster. master|A server assigned as a master by one of MariaDB MaxScale monitors. Depending on the monitor implementation, this could be a master server of a Master-Slave replication cluster or a Write-Master of a Galera cluster.
slave|A server assigned as a slave of a master. If all slaves are down, but the master is still available, then the router will use the master. slave|A server assigned as a slave of a master. If all slaves are down, but the master is still available, then the router will use the master.
synced| A Galera cluster node which is in a synced state with the cluster. synced| A Galera cluster node which is in a synced state with the cluster.
ndb|A MySQL Replication Cluster node
running|A server that is up and running. All servers that MariaDB MaxScale can connect to are labeled as running. running|A server that is up and running. All servers that MariaDB MaxScale can connect to are labeled as running.
If no `router_options` parameter is configured in the service definition, If no `router_options` parameter is configured in the service definition,

View File

@ -1,364 +0,0 @@
# MySQL Cluster setup and MariaDB MaxScale configuration
## Overview
The document covers the MySQL Cluster 7.2.17 setup and MariaDB MaxScale
configuration for load balancing the SQL nodes access.
## MySQL Cluster setup
The MySQL Cluster 7.2.17 setup is based on two virtual servers with Linux Centos
6.5
- server1:
* NDB Manager process
* SQL data node1
* MySQL 5.5.38 as SQL node1
- server2:
* SQL data node2
* MySQL 5.5.38 as SQL node2
Cluster configuration file is `/var/lib/mysql-cluster/config.ini`, copied on all
servers.
```
[ndbd default]
NoOfReplicas=2
DataMemory=60M
IndexMemory=16M
[ndb_mgmd]
hostname=178.62.38.199
id=21
datadir=/var/lib/mysql-cluster
[mysqld]
hostname=178.62.38.199
[mysqld]
hostname=162.243.90.81
[ndbd]
hostname=178.62.38.199
[ndbd]
hostname=162.243.90.81
```
Note that it’s possible to specify all node id:s and `datadir` as well for each
cluster component.
Example:
```
[ndbd]
hostname=162.243.90.81
id=43
datadir=/usr/local/mysql/data
```
Also, `/etc/my.cnf`, copied as well in all servers.
```
[mysqld]
ndbcluster
ndb-connectstring=178.62.38.199
innodb_buffer_pool_size=16M
[mysql_cluster]
ndb-connectstring=178.62.38.199
```
## Startup of MySQL Cluster
Each cluster node process must be started separately, and on the host where it
resides. The management node should be started first, then the data nodes, and
finally any SQL nodes:
- On the management host, server1, issue the following command from the system
shell to start the management node process:
```
[root@server1 ~]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini
```
- On each of the data node hosts, run this command to start the ndbd process:
```
[root@server1 ~]# ndbd —-initial -—initial-start
[root@server2 ~]# ndbd —-initial -—initial-start
```
- On each SQL node start the MySQL server process:
```
[root@server1 ~]# /etc/init.d/mysql start
[root@server2 ~]# /etc/init.d/mysql start
```
## Check the cluster status
If all has gone well and the cluster has been set up correctly, the cluster
should now be operational.
It’s possible to test this by invoking the `ndb_mgm` management node client.
The output should look as shown here, although you might see some slight
differences in the output depending upon the exact version of MySQL in use:
```
[root@server1 ~]# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: 178.62.38.199:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=24 @178.62.38.199 (mysql-5.5.38 ndb-7.2.17, Nodegroup: 0, *)
id=25 @162.243.90.81 (mysql-5.5.38 ndb-7.2.17, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=21 @178.62.38.199 (mysql-5.5.38 ndb-7.2.17)
[mysqld(API)] 2 node(s)
id=22 @178.62.38.199 (mysql-5.5.38 ndb-7.2.17)
id=23 @162.243.90.81 (mysql-5.5.38 ndb-7.2.17)
ndb_mgm>
```
The SQL node is referenced here as [mysqld(API)], which reflects the fact that
the mysqld process is acting as a MySQL Cluster API node.
## Working with NDBCLUSTER engine in MySQL
- First create a table with NDBCLUSTER engine:
```
[root@server1 ~]# mysql
mysql> CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) ENGINE=NDBCLUSTER;
Query OK, 0 rows affected (3.28 sec)
mysql> show create table t1;
+------- +-------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+-------------------------------------------------------------------------------------------+
| t1 | CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 |
+-------+-------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
```
- Add a row in the table:
```
mysql> insert into test.t1 values(11);
Query OK, 1 row affected (0.15 sec)
```
- Select the current number of rows:
```
mysql> select count(1) from t1;
+----------+
| count(1) |
+----------+
| 1 |
+----------+
1 row in set (0.07 sec)
```
- The same from the MySQL client pointing to SQL node on server2:
```
[root@server2 ~]# mysql
mysql> select count(1) from test.t1;
+----------+
| count(1) |
+----------+
| 1 |
+----------+
1 row in set (0.08 sec)
```
## Configuring MariaDB MaxScale for connection load balancing of SQL nodes
Add these sections into the maxscale.cnf config file:
```
[Cluster-Service]
type=service
router=readconnroute
router_options=ndb
servers=server1,server2
user=test
password=test
version_string=5.5.37-CLUSTER
[Cluster-Listener]
type=listener
service=Cluster-Service
protocol=MariaDBClient
port=4906
[NDB-Cluster-Monitor]
type=monitor
module=ndbclustermon
servers=server1,server2
user=monitor
password=monitor
monitor_interval=8000
[server1]
#SQL node1
type=server
address=127.0.0.1
port=3306
protocol=MariaDBBackend
[server2]
#SQL node2
type=server
address=162.243.90.81
port=3306
protocol=MariaDBBackend
```
Assuming MariaDB MaxScale is installed in server1, start it.
```
[root@server1 ~]# cd /usr/bin
[root@server1 bin]# ./maxscale -c ../
```
Using the debug interface it’s possible to check the status of monitored
servers.
```
MaxScale> show monitors
Monitor: 0x387b880
Name: NDB Cluster Monitor
Monitor running
Sampling interval: 8000 milliseconds
Monitored servers: 127.0.0.1:3306, 162.243.90.81:3306
MaxScale> show servers
Server 0x3873b40 (server1)
Server: 127.0.0.1
Status: NDB, Running
Protocol: MariaDBBackend
Port: 3306
Server Version: 5.5.38-ndb-7.2.17-cluster-gpl
Node Id: 22
Master Id: -1
Repl Depth: 0
Number of connections: 0
Current no. of conns: 0
Current no. of operations: 0
Server 0x3873a40 (server2)
Server: 162.243.90.81
Status: NDB, Running
Protocol: MariaDBBackend
Port: 3306
Server Version: 5.5.38-ndb-7.2.17-cluster-gpl
Node Id: 23
Master Id: -1
Repl Depth: 0
Number of connections: 0
Current no. of conns: 0
Current no. of operations: 0
```
It’s now possible to run basic tests with the read connection load balancing
for the two configured SQL nodes.
(1) test MaxScale load balancing requesting the Ndb_cluster_node_id variable:
```
[root@server1 ~]# mysql -h 127.0.0.1 -P 4906 -u test -ptest -e "SHOW STATUS LIKE 'Ndb_cluster_node_id'"
+---------------------+-------+
| Variable_name | Value |
+---------------------+-------+
| Ndb_cluster_node_id | 23 |
+---------------------+-------+
[root@server1 ~]# mysql -h 127.0.0.1 -P 4906 -u test -ptest -e "SHOW STATUS LIKE 'Ndb_cluster_node_id'"
+---------------------+-------+
| Variable_name | Value |
+---------------------+-------+
| Ndb_cluster_node_id | 22 |
+---------------------+-------+
```
The MariaDB MaxScale connection load balancing is working.
(2) test a select statement on an NBDBCLUSTER table, database test and table t1
created before:
```
[root@server1 ~] mysql -h 127.0.0.1 -P 4906 -utest -ptest -e "SELECT COUNT(1) FROM test.t1"
+----------+
| COUNT(1) |
+----------+
| 1 |
+----------+
```
(3) test an insert statement
```
mysql -h 127.0.0.1 -P 4906 -utest -ptest -e "INSERT INTO test.t1 VALUES (19)"
```
(4) test again the select and check the number of rows
```
[root@server1 ~] mysql -h 127.0.0.1 -P 4906 -utest -ptest -e "SELECT COUNT(1) FROM test.t1"
+----------+
| COUNT(1) |
+----------+
| 2 |
+----------+
```

View File

@ -129,18 +129,14 @@ enum mxs_monitor_event_t
SYNCED_UP_EVENT = (1 << 7), /**< synced_up */ SYNCED_UP_EVENT = (1 << 7), /**< synced_up */
DONOR_DOWN_EVENT = (1 << 8), /**< donor_down */ DONOR_DOWN_EVENT = (1 << 8), /**< donor_down */
DONOR_UP_EVENT = (1 << 9), /**< donor_up */ DONOR_UP_EVENT = (1 << 9), /**< donor_up */
NDB_DOWN_EVENT = (1 << 10), /**< ndb_down */ LOST_MASTER_EVENT = (1 << 10), /**< lost_master */
NDB_UP_EVENT = (1 << 11), /**< ndb_up */ LOST_SLAVE_EVENT = (1 << 11), /**< lost_slave */
LOST_MASTER_EVENT = (1 << 12), /**< lost_master */ LOST_SYNCED_EVENT = (1 << 12), /**< lost_synced */
LOST_SLAVE_EVENT = (1 << 13), /**< lost_slave */ LOST_DONOR_EVENT = (1 << 13), /**< lost_donor */
LOST_SYNCED_EVENT = (1 << 14), /**< lost_synced */ NEW_MASTER_EVENT = (1 << 14), /**< new_master */
LOST_DONOR_EVENT = (1 << 15), /**< lost_donor */ NEW_SLAVE_EVENT = (1 << 15), /**< new_slave */
LOST_NDB_EVENT = (1 << 16), /**< lost_ndb */ NEW_SYNCED_EVENT = (1 << 16), /**< new_synced */
NEW_MASTER_EVENT = (1 << 17), /**< new_master */ NEW_DONOR_EVENT = (1 << 17), /**< new_donor */
NEW_SLAVE_EVENT = (1 << 18), /**< new_slave */
NEW_SYNCED_EVENT = (1 << 19), /**< new_synced */
NEW_DONOR_EVENT = (1 << 20), /**< new_donor */
NEW_NDB_EVENT = (1 << 21), /**< new_ndb */
}; };
enum credentials_approach_t enum credentials_approach_t

View File

@ -47,7 +47,8 @@ extern const char* DEFAULT_RANK;
#define SERVER_AUTH_ERROR (1 << 2) /**<< Authentication error from monitor */ #define SERVER_AUTH_ERROR (1 << 2) /**<< Authentication error from monitor */
#define SERVER_MASTER (1 << 3) /**<< The server is a master, i.e. can handle writes */ #define SERVER_MASTER (1 << 3) /**<< The server is a master, i.e. can handle writes */
#define SERVER_SLAVE (1 << 4) /**<< The server is a slave, i.e. can handle reads */ #define SERVER_SLAVE (1 << 4) /**<< The server is a slave, i.e. can handle reads */
#define SERVER_DRAINING (1 << 5) /**<< The server is being drained, i.e. no new connection should be created. */ #define SERVER_DRAINING (1 << 5) /**<< The server is being drained, i.e. no new connection
* should be created. */
#define SERVER_DISK_SPACE_EXHAUSTED (1 << 6) /**<< The disk space of the server is exhausted */ #define SERVER_DISK_SPACE_EXHAUSTED (1 << 6) /**<< The disk space of the server is exhausted */
// Bits used by MariaDB Monitor (mostly) // Bits used by MariaDB Monitor (mostly)
#define SERVER_SLAVE_OF_EXT_MASTER (1 << 16) /**<< Server is slave of a non-monitored master */ #define SERVER_SLAVE_OF_EXT_MASTER (1 << 16) /**<< Server is slave of a non-monitored master */
@ -55,8 +56,7 @@ extern const char* DEFAULT_RANK;
#define SERVER_WAS_MASTER (1 << 18) /**<< Server was a master but lost all slaves. */ #define SERVER_WAS_MASTER (1 << 18) /**<< Server was a master but lost all slaves. */
// Bits used by other monitors // Bits used by other monitors
#define SERVER_JOINED (1 << 19) /**<< The server is joined in a Galera cluster */ #define SERVER_JOINED (1 << 19) /**<< The server is joined in a Galera cluster */
#define SERVER_NDB (1 << 20) /**<< The server is part of a MySQL cluster setup */ #define SERVER_MASTER_STICKINESS (1 << 20) /**<< Server Master stickiness */
#define SERVER_MASTER_STICKINESS (1 << 21) /**<< Server Master stickiness */
inline bool status_is_connectable(uint64_t status) inline bool status_is_connectable(uint64_t status)
{ {
@ -108,11 +108,6 @@ inline bool status_is_joined(uint64_t status)
return (status & (SERVER_RUNNING | SERVER_JOINED | SERVER_MAINT)) == (SERVER_RUNNING | SERVER_JOINED); return (status & (SERVER_RUNNING | SERVER_JOINED | SERVER_MAINT)) == (SERVER_RUNNING | SERVER_JOINED);
} }
inline bool status_is_ndb(uint64_t status)
{
return (status & (SERVER_RUNNING | SERVER_NDB | SERVER_MAINT)) == (SERVER_RUNNING | SERVER_NDB);
}
inline bool status_is_slave_of_ext_master(uint64_t status) inline bool status_is_slave_of_ext_master(uint64_t status)
{ {
return (status & (SERVER_RUNNING | SERVER_SLAVE_OF_EXT_MASTER)) return (status & (SERVER_RUNNING | SERVER_SLAVE_OF_EXT_MASTER))
@ -429,19 +424,9 @@ public:
return status_is_joined(status); return status_is_joined(status);
} }
/**
* Is the server a SQL node in MySQL Cluster?
*
* @return True, if server is running and with NDB status.
*/
bool is_ndb() const
{
return status_is_ndb(status);
}
bool is_in_cluster() const bool is_in_cluster() const
{ {
return (status & (SERVER_MASTER | SERVER_SLAVE | SERVER_RELAY | SERVER_JOINED | SERVER_NDB)) != 0; return (status & (SERVER_MASTER | SERVER_SLAVE | SERVER_RELAY | SERVER_JOINED)) != 0;
} }
bool is_slave_of_ext_master() const bool is_slave_of_ext_master() const

View File

@ -28,28 +28,24 @@ static const MXS_ENUM_VALUE mxs_monitor_event_default_enum = {"all", ~0ULL};
static const MXS_ENUM_VALUE mxs_monitor_event_enum_values[] = static const MXS_ENUM_VALUE mxs_monitor_event_enum_values[] =
{ {
mxs_monitor_event_default_enum, mxs_monitor_event_default_enum,
{"master_down", MASTER_DOWN_EVENT }, {"master_down", MASTER_DOWN_EVENT},
{"master_up", MASTER_UP_EVENT }, {"master_up", MASTER_UP_EVENT},
{"slave_down", SLAVE_DOWN_EVENT }, {"slave_down", SLAVE_DOWN_EVENT},
{"slave_up", SLAVE_UP_EVENT }, {"slave_up", SLAVE_UP_EVENT},
{"server_down", SERVER_DOWN_EVENT }, {"server_down", SERVER_DOWN_EVENT},
{"server_up", SERVER_UP_EVENT }, {"server_up", SERVER_UP_EVENT},
{"synced_down", SYNCED_DOWN_EVENT }, {"synced_down", SYNCED_DOWN_EVENT},
{"synced_up", SYNCED_UP_EVENT }, {"synced_up", SYNCED_UP_EVENT},
{"donor_down", DONOR_DOWN_EVENT }, {"donor_down", DONOR_DOWN_EVENT},
{"donor_up", DONOR_UP_EVENT }, {"donor_up", DONOR_UP_EVENT},
{"ndb_down", NDB_DOWN_EVENT }, {"lost_master", LOST_MASTER_EVENT},
{"ndb_up", NDB_UP_EVENT }, {"lost_slave", LOST_SLAVE_EVENT},
{"lost_master", LOST_MASTER_EVENT }, {"lost_synced", LOST_SYNCED_EVENT},
{"lost_slave", LOST_SLAVE_EVENT }, {"lost_donor", LOST_DONOR_EVENT},
{"lost_synced", LOST_SYNCED_EVENT }, {"new_master", NEW_MASTER_EVENT},
{"lost_donor", LOST_DONOR_EVENT }, {"new_slave", NEW_SLAVE_EVENT},
{"lost_ndb", LOST_NDB_EVENT }, {"new_synced", NEW_SYNCED_EVENT},
{"new_master", NEW_MASTER_EVENT }, {"new_donor", NEW_DONOR_EVENT},
{"new_slave", NEW_SLAVE_EVENT },
{"new_synced", NEW_SYNCED_EVENT },
{"new_donor", NEW_DONOR_EVENT },
{"new_ndb", NEW_NDB_EVENT },
{NULL} {NULL}
}; };

View File

@ -159,11 +159,11 @@ const char* monitor_state_to_string(monitor_state_t state)
} }
/** Server type specific bits */ /** Server type specific bits */
const uint64_t server_type_bits = SERVER_MASTER | SERVER_SLAVE | SERVER_JOINED | SERVER_NDB; const uint64_t server_type_bits = SERVER_MASTER | SERVER_SLAVE | SERVER_JOINED;
/** All server bits */ /** All server bits */
const uint64_t all_server_bits = SERVER_RUNNING | SERVER_MAINT | SERVER_MASTER | SERVER_SLAVE const uint64_t all_server_bits = SERVER_RUNNING | SERVER_MAINT | SERVER_MASTER | SERVER_SLAVE
| SERVER_JOINED | SERVER_NDB; | SERVER_JOINED;
const char journal_name[] = "monitor.dat"; const char journal_name[] = "monitor.dat";
const char journal_template[] = "%s/%s/%s"; const char journal_template[] = "%s/%s/%s";
@ -1226,12 +1226,7 @@ mxs_monitor_event_t MonitorServer::get_event_type() const
case UP_EVENT: case UP_EVENT:
rval = (present & SERVER_MASTER) ? MASTER_UP_EVENT : rval = (present & SERVER_MASTER) ? MASTER_UP_EVENT :
(present & SERVER_SLAVE) ? SLAVE_UP_EVENT : (present & SERVER_SLAVE) ? SLAVE_UP_EVENT :
(present (present & SERVER_JOINED) ? SYNCED_UP_EVENT :
& SERVER_JOINED) ? SYNCED_UP_EVENT :
(present
& SERVER_NDB) ?
NDB_UP_EVENT
:
SERVER_UP_EVENT; SERVER_UP_EVENT;
break; break;
@ -1239,10 +1234,6 @@ mxs_monitor_event_t MonitorServer::get_event_type() const
rval = (prev & SERVER_MASTER) ? MASTER_DOWN_EVENT : rval = (prev & SERVER_MASTER) ? MASTER_DOWN_EVENT :
(prev & SERVER_SLAVE) ? SLAVE_DOWN_EVENT : (prev & SERVER_SLAVE) ? SLAVE_DOWN_EVENT :
(prev & SERVER_JOINED) ? SYNCED_DOWN_EVENT : (prev & SERVER_JOINED) ? SYNCED_DOWN_EVENT :
(prev
& SERVER_NDB) ?
NDB_DOWN_EVENT
:
SERVER_DOWN_EVENT; SERVER_DOWN_EVENT;
break; break;
@ -1250,22 +1241,13 @@ mxs_monitor_event_t MonitorServer::get_event_type() const
rval = (prev & SERVER_MASTER) ? LOST_MASTER_EVENT : rval = (prev & SERVER_MASTER) ? LOST_MASTER_EVENT :
(prev & SERVER_SLAVE) ? LOST_SLAVE_EVENT : (prev & SERVER_SLAVE) ? LOST_SLAVE_EVENT :
(prev & SERVER_JOINED) ? LOST_SYNCED_EVENT : (prev & SERVER_JOINED) ? LOST_SYNCED_EVENT :
(prev
& SERVER_NDB) ?
LOST_NDB_EVENT
:
UNDEFINED_EVENT; UNDEFINED_EVENT;
break; break;
case NEW_EVENT: case NEW_EVENT:
rval = (present & SERVER_MASTER) ? NEW_MASTER_EVENT : rval = (present & SERVER_MASTER) ? NEW_MASTER_EVENT :
(present & SERVER_SLAVE) ? NEW_SLAVE_EVENT : (present & SERVER_SLAVE) ? NEW_SLAVE_EVENT :
(present (present & SERVER_JOINED) ? NEW_SYNCED_EVENT :
& SERVER_JOINED) ? NEW_SYNCED_EVENT :
(present
& SERVER_NDB) ?
NEW_NDB_EVENT
:
UNDEFINED_EVENT; UNDEFINED_EVENT;
break; break;

View File

@ -643,7 +643,6 @@ string SERVER::status_to_string(uint64_t flags, int nConnections)
const string relay = "Relay Master"; const string relay = "Relay Master";
const string slave = "Slave"; const string slave = "Slave";
const string synced = "Synced"; const string synced = "Synced";
const string ndb = "NDB";
const string slave_ext = "Slave of External Server"; const string slave_ext = "Slave of External Server";
const string sticky = "Master Stickiness"; const string sticky = "Master Stickiness";
const string auth_err = "Auth Error"; const string auth_err = "Auth Error";
@ -683,7 +682,6 @@ string SERVER::status_to_string(uint64_t flags, int nConnections)
// The following Galera and Cluster bits may be combined with master/slave. // The following Galera and Cluster bits may be combined with master/slave.
concatenate_if(status_is_joined(flags), synced); concatenate_if(status_is_joined(flags), synced);
concatenate_if(status_is_ndb(flags), ndb);
// May be combined with other MariaDB monitor flags. // May be combined with other MariaDB monitor flags.
concatenate_if(flags & SERVER_SLAVE_OF_EXT_MASTER, slave_ext); concatenate_if(flags & SERVER_SLAVE_OF_EXT_MASTER, slave_ext);
@ -847,16 +845,15 @@ uint64_t SERVER::status_from_string(const char* str)
uint64_t bit; uint64_t bit;
} ServerBits[] = } ServerBits[] =
{ {
{"running", SERVER_RUNNING }, {"running", SERVER_RUNNING},
{"master", SERVER_MASTER }, {"master", SERVER_MASTER},
{"slave", SERVER_SLAVE }, {"slave", SERVER_SLAVE},
{"synced", SERVER_JOINED }, {"synced", SERVER_JOINED},
{"ndb", SERVER_NDB }, {"maintenance", SERVER_MAINT},
{"maintenance", SERVER_MAINT }, {"maint", SERVER_MAINT},
{"maint", SERVER_MAINT }, {"stale", SERVER_WAS_MASTER},
{"stale", SERVER_WAS_MASTER }, {"drain", SERVER_DRAINING},
{"drain", SERVER_DRAINING }, {NULL, 0}
{NULL, 0 }
}; };
for (int i = 0; ServerBits[i].str; i++) for (int i = 0; ServerBits[i].str; i++)

View File

@ -238,8 +238,8 @@ int test_enum(config::Enum<Enum>& value)
int test_path(config::Path& value) int test_path(config::Path& value)
{ {
char path[PATH_MAX]; static char path[PATH_MAX];
char* strpath = getcwd(path, sizeof(path)); static char* strpath = getcwd(path, sizeof(path));
static const TestEntry<config::Path::value_type> entries[] = static const TestEntry<config::Path::value_type> entries[] =
{ {

View File

@ -4,4 +4,3 @@ add_subdirectory(csmon)
add_subdirectory(galeramon) add_subdirectory(galeramon)
add_subdirectory(grmon) add_subdirectory(grmon)
add_subdirectory(mariadbmon) add_subdirectory(mariadbmon)
add_subdirectory(ndbclustermon)

View File

@ -1,5 +0,0 @@
add_library(ndbclustermon SHARED ndbclustermon.cc)
target_link_libraries(ndbclustermon maxscale-common)
add_dependencies(ndbclustermon pcre2)
set_target_properties(ndbclustermon PROPERTIES VERSION "2.1.0" LINK_FLAGS -Wl,-z,defs)
install_module(ndbclustermon core)

View File

@ -1,155 +0,0 @@
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2022-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
/**
* @file ndbcluster_mon.c - A MySQL cluster SQL node monitor
*/
#define MXS_MODULE_NAME "ndbclustermon"
#include "ndbclustermon.hh"
#include <maxscale/alloc.h>
#include <maxscale/mysql_utils.hh>
NDBCMonitor::NDBCMonitor(const std::string& name, const std::string& module)
: MonitorWorkerSimple(name, module)
{
}
NDBCMonitor::~NDBCMonitor()
{
}
// static
NDBCMonitor* NDBCMonitor::create(const std::string& name, const std::string& module)
{
return new NDBCMonitor(name, module);
}
bool NDBCMonitor::has_sufficient_permissions()
{
return test_permissions("SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'");
}
void NDBCMonitor::update_server_status(mxs::MonitorServer* monitored_server)
{
MYSQL_ROW row;
MYSQL_RES* result;
int isjoined = 0;
/* get server version string */
mxs_mysql_update_server_version(monitored_server->server, monitored_server->con);
/* Check if the the SQL node is able to contact one or more data nodes */
if (mxs_mysql_query(monitored_server->con, "SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'") == 0
&& (result = mysql_store_result(monitored_server->con)) != NULL)
{
if (mysql_field_count(monitored_server->con) < 2)
{
mysql_free_result(result);
MXS_ERROR("Unexpected result for \"SHOW STATUS LIKE "
"'Ndb_number_of_ready_data_nodes'\". Expected 2 columns."
" MySQL Version: %s",
monitored_server->server->version_string().c_str());
return;
}
while ((row = mysql_fetch_row(result)))
{
if (atoi(row[1]) > 0)
{
isjoined = 1;
}
}
mysql_free_result(result);
}
else
{
monitored_server->mon_report_query_error();
}
/* Check the the SQL node id in the MySQL cluster */
if (mxs_mysql_query(monitored_server->con, "SHOW STATUS LIKE 'Ndb_cluster_node_id'") == 0
&& (result = mysql_store_result(monitored_server->con)) != NULL)
{
if (mysql_field_count(monitored_server->con) < 2)
{
mysql_free_result(result);
MXS_ERROR("Unexpected result for \"SHOW STATUS LIKE 'Ndb_cluster_node_id'\". "
"Expected 2 columns."
" MySQL Version: %s",
monitored_server->server->version_string().c_str());
return;
}
long cluster_node_id = -1;
while ((row = mysql_fetch_row(result)))
{
cluster_node_id = strtol(row[1], NULL, 10);
if ((errno == ERANGE && (cluster_node_id == LONG_MAX
|| cluster_node_id == LONG_MIN)) || (errno != 0 && cluster_node_id == 0))
{
cluster_node_id = -1;
}
monitored_server->server->node_id = cluster_node_id;
}
mysql_free_result(result);
}
else
{
monitored_server->mon_report_query_error();
}
if (isjoined)
{
monitored_server->set_pending_status(SERVER_NDB);
}
else
{
monitored_server->clear_pending_status(SERVER_NDB);
}
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
* "module object", this is a structure with the set of
* external entry points for this module.
*
* @return The module object
*/
extern "C" MXS_MODULE* MXS_CREATE_MODULE()
{
MXS_NOTICE("Initialise the MySQL Cluster Monitor module.");
static MXS_MODULE info =
{
MXS_MODULE_API_MONITOR,
MXS_MODULE_BETA_RELEASE,
MXS_MONITOR_VERSION,
"A MySQL cluster SQL node monitor",
"V2.1.0",
MXS_NO_MODULE_CAPABILITIES,
&maxscale::MonitorApi<NDBCMonitor>::s_api,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS} // No parameters
}
};
return &info;
}

View File

@ -1,37 +0,0 @@
/*
* Copyright (c) 2018 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2022-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#pragma once
#include <maxscale/ccdefs.hh>
#include <maxscale/monitor.hh>
/**
* @file ndbcclustermon.hh A NDBC cluster monitor
*/
class NDBCMonitor : public maxscale::MonitorWorkerSimple
{
public:
NDBCMonitor(const NDBCMonitor&) = delete;
NDBCMonitor& operator=(const NDBCMonitor&) = delete;
~NDBCMonitor();
static NDBCMonitor* create(const std::string& name, const std::string& module);
protected:
bool has_sufficient_permissions();
void update_server_status(mxs::MonitorServer* monitored_server);
private:
NDBCMonitor(const std::string& name, const std::string& module);
};

View File

@ -7,7 +7,6 @@ endif()
add_subdirectory(cat) add_subdirectory(cat)
add_subdirectory(cli) add_subdirectory(cli)
add_subdirectory(debugcli)
add_subdirectory(hintrouter) add_subdirectory(hintrouter)
add_subdirectory(maxinfo) add_subdirectory(maxinfo)
add_subdirectory(readconnroute) add_subdirectory(readconnroute)

View File

@ -1,4 +1,4 @@
add_library(cli SHARED cli.cc ../debugcli/debugcmd.cc) add_library(cli SHARED cli.cc debugcmd.cc)
target_link_libraries(cli maxscale-common) target_link_libraries(cli maxscale-common)
set_target_properties(cli PROPERTIES VERSION "1.0.0" LINK_FLAGS -Wl,-z,defs) set_target_properties(cli PROPERTIES VERSION "1.0.0" LINK_FLAGS -Wl,-z,defs)
install_module(cli core) install_module(cli core)

View File

@ -1,4 +0,0 @@
add_library(debugcli SHARED debugcli.cc debugcmd.cc)
target_link_libraries(debugcli maxscale-common)
set_target_properties(debugcli PROPERTIES VERSION "1.1.1" LINK_FLAGS -Wl,-z,defs)
install_module(debugcli core)

View File

@ -1,304 +0,0 @@
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2022-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
/**
* @file debugcli.c - A "routing module" that in fact merely gives
* access to debug commands within the gateway
*
* @verbatim
* Revision History
*
* Date Who Description
* 18/06/13 Mark Riddoch Initial implementation
*
* @endverbatim
*/
#define MXS_MODULE_NAME "debugcli"
#include <debugcli.hh>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <maxbase/atomic.h>
#include <maxscale/alloc.h>
#include <maxscale/dcb.hh>
#include <maxscale/modinfo.h>
#include <maxscale/poll.hh>
#include <maxscale/router.hh>
#include <maxscale/service.hh>
#include <maxscale/session.hh>
/* The router entry points */
static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params);
static MXS_ROUTER_SESSION* newSession(MXS_ROUTER* instance, MXS_SESSION* session);
static void closeSession(MXS_ROUTER* instance, MXS_ROUTER_SESSION* router_session);
static void freeSession(MXS_ROUTER* instance, MXS_ROUTER_SESSION* router_session);
static int execute(MXS_ROUTER* instance, MXS_ROUTER_SESSION* router_session, GWBUF* queue);
static void diagnostics(MXS_ROUTER* instance, DCB* dcb);
static json_t* diagnostics_json(const MXS_ROUTER* instance);
static uint64_t getCapabilities(MXS_ROUTER* instance);
extern int execute_cmd(CLI_SESSION* cli);
static pthread_mutex_t instlock;
static CLI_INSTANCE* instances;
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
* "module object", this is a structure with the set of
* external entry points for this module.
*
* @return The module object
*/
extern "C" MXS_MODULE* MXS_CREATE_MODULE()
{
MXS_WARNING("THE 'debugcli' MODULE IS DEPRECATED");
pthread_mutex_init(&instlock, NULL);
instances = NULL;
static MXS_ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
execute,
diagnostics,
diagnostics_json,
NULL,
NULL,
getCapabilities,
NULL
};
static MXS_MODULE info =
{
MXS_MODULE_API_ROUTER,
MXS_MODULE_GA,
MXS_ROUTER_VERSION,
"The debug user interface",
"V1.1.1",
RCAP_TYPE_NO_AUTH,
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;
}
/**
* Create an instance of the router for a particular service
* within the gateway.
*
* @param service The service this router is being create for
* @param options Any array of options for the query router
*
* @return The instance data for this new instance
*/
static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params)
{
CLI_INSTANCE* inst;
if ((inst = static_cast<CLI_INSTANCE*>(MXS_MALLOC(sizeof(CLI_INSTANCE)))) == NULL)
{
return NULL;
}
inst->service = service;
pthread_mutex_init(&inst->lock, NULL);
inst->sessions = NULL;
/*
* We have completed the creation of the instance data, so now
* insert this router instance into the linked list of routers
* that have been created with this module.
*/
pthread_mutex_lock(&instlock);
inst->next = instances;
instances = inst;
pthread_mutex_unlock(&instlock);
return (MXS_ROUTER*)inst;
}
/**
* Associate a new session with this instance of the router.
*
* @param instance The router instance data
* @param session The session itself
* @return Session specific data for this session
*/
static MXS_ROUTER_SESSION* newSession(MXS_ROUTER* instance, MXS_SESSION* session)
{
CLI_INSTANCE* inst = (CLI_INSTANCE*)instance;
CLI_SESSION* client;
if ((client = (CLI_SESSION*)MXS_MALLOC(sizeof(CLI_SESSION))) == NULL)
{
return NULL;
}
client->session = session;
memset(client->cmdbuf, 0, 80);
pthread_mutex_lock(&inst->lock);
client->next = inst->sessions;
inst->sessions = client;
pthread_mutex_unlock(&inst->lock);
session->state = SESSION_STATE_CREATED;
dcb_printf(session->client_dcb, "Welcome to the MariaDB Corporation MaxScale Debug Interface.\n");
dcb_printf(session->client_dcb, "Type help for a list of available commands.\n\n");
return reinterpret_cast<MXS_ROUTER_SESSION*>(client);
}
/**
* Close a session with the router, this is the mechanism
* by which a router may cleanup data structure etc.
*
* @param instance The router instance data
* @param router_session The session being closed
*/
static void closeSession(MXS_ROUTER* instance, MXS_ROUTER_SESSION* router_session)
{
CLI_INSTANCE* inst = (CLI_INSTANCE*)instance;
CLI_SESSION* session = (CLI_SESSION*)router_session;
pthread_mutex_lock(&inst->lock);
if (inst->sessions == session)
{
inst->sessions = session->next;
}
else
{
CLI_SESSION* ptr = inst->sessions;
while (ptr && ptr->next != session)
{
ptr = ptr->next;
}
if (ptr)
{
ptr->next = session->next;
}
}
pthread_mutex_unlock(&inst->lock);
/**
* Router session is freed in session.c:session_close, when session who
* owns it, is freed.
*/
}
/**
* Free a debugcli session
*
* @param router_instance The router session
* @param router_client_session The router session as returned from newSession
*/
static void freeSession(MXS_ROUTER* router_instance,
MXS_ROUTER_SESSION* router_client_session)
{
MXS_FREE(router_client_session);
return;
}
/**
* We have data from the client, we must route it to the backend.
* This is simply a case of sending it to the connection that was
* chosen when we started the client session.
*
* @param instance The router instance
* @param router_session The router session returned from the newSession call
* @param queue The queue of data buffers to route
* @return The number of bytes sent
*/
static int execute(MXS_ROUTER* instance, MXS_ROUTER_SESSION* router_session, GWBUF* queue)
{
CLI_SESSION* session = (CLI_SESSION*)router_session;
char* cmdbuf = session->cmdbuf;
int cmdlen = 0;
*cmdbuf = 0;
/* Extract the characters */
while (queue && (cmdlen < CMDBUFLEN - 1))
{
const char* data = (char*)GWBUF_DATA(queue);
int len = GWBUF_LENGTH(queue);
int n = MXS_MIN(len, CMDBUFLEN - cmdlen - 1);
if (n != len)
{
MXS_WARNING("Too long user command truncated.");
}
strncat(cmdbuf, data, n);
cmdlen += n;
cmdbuf += n;
queue = gwbuf_consume(queue, GWBUF_LENGTH(queue));
}
if (strrchr(session->cmdbuf, '\n'))
{
if (execute_cmd(session))
{
dcb_printf(session->session->client_dcb, "MaxScale> ");
}
else
{
dcb_close(session->session->client_dcb);
}
}
return 1;
}
/**
* Display router diagnostics
*
* @param instance Instance of the router
* @param dcb DCB to send diagnostics to
*/
static void diagnostics(MXS_ROUTER* instance, DCB* dcb)
{
return; /* Nothing to do currently */
}
/**
* Display router diagnostics
*
* @param instance Instance of the router
* @param dcb DCB to send diagnostics to
*/
static json_t* diagnostics_json(const MXS_ROUTER* instance)
{
return NULL;
}
static uint64_t getCapabilities(MXS_ROUTER* instance)
{
return RCAP_TYPE_NONE;
}

View File

@ -137,15 +137,10 @@ bool RCR::configure(MXS_CONFIG_PARAMETER* params)
bitmask |= (SERVER_JOINED); bitmask |= (SERVER_JOINED);
bitvalue |= SERVER_JOINED; bitvalue |= SERVER_JOINED;
} }
else if (!strcasecmp(opt.c_str(), "ndb"))
{
bitmask |= (SERVER_NDB);
bitvalue |= SERVER_NDB;
}
else else
{ {
MXS_ERROR("Unsupported router option \'%s\' for readconnroute. " MXS_ERROR("Unsupported router option \'%s\' for readconnroute. "
"Expected router options are [slave|master|synced|ndb|running]", "Expected router options are [slave|master|synced|running]",
opt.c_str()); opt.c_str());
ok = false; ok = false;
} }