Fixed formatting.

This commit is contained in:
Markus Makela 2015-09-07 13:19:11 +03:00
parent 0779673403
commit 42fc2db65d
9 changed files with 1160 additions and 1164 deletions

View File

@ -47,23 +47,23 @@ The MaxScale 1.0 GA release contains an implementation of a tee filter that allo
## Filter Definition
Filters are defined in the configuration file, MaxScale.ini, using a section for each filter instance. The content of the filter sections in the configuration file various from filter to filter, however there are always to entries present for every filter, the type and module.
[MyFilter]
type=filter
module=xxxfilter
```
[MyFilter]
type=filter
module=xxxfilter
```
The type is used by the configuration manager within MaxScale to determine what this section is defining and the module is the name of the plugin that implements the filter.
When a filter is used within a service in MaxScale the entry filters= is added to the service definition in the ini file section for the service. Multiple filters can be defined using a syntax akin to the Linux shell pipe syntax.
[Split Service]
type=service
router=readwritesplit
servers=dbserver1,dbserver2,dbserver3,dbserver4
user=massi
passwd=6628C50E07CCE1F0392EDEEB9D1203F3
filters=hints | top10
```
[Split Service]
type=service
router=readwritesplit
servers=dbserver1,dbserver2,dbserver3,dbserver4
user=massi
passwd=6628C50E07CCE1F0392EDEEB9D1203F3
filters=hints | top10
```
The names used in the filters= parameter are the names of the filter definition sections in the ini file. The same filter definition can be used in multiple services and the same filter module can have multiple instances, each with its own section in the ini file.
## Filter Examples
@ -75,46 +75,45 @@ The filters that are bundled with the MaxScale 1.0 GA release are documented sep
The top filter can be used to measure the execution time of every statement within a connection and log the details of the longest running statements.
The first thing to do is to define a filter entry in the ini file for the top filter. In this case we will call it "top30". The type is filter and the module that implements the filter is called topfilter.
[top30]
type=filter
module=topfilter
count=30
filebase=/var/log/DBSessions/top30
```
[top30]
type=filter
module=topfilter
count=30
filebase=/var/log/DBSessions/top30
```
In the definition above we have defined two filter specific parameters, the count of the number of statement to be logged and a filebase that is used to define where to log the information. This filename is a stem to which a session id is added for each new connection that uses the filter.
The filter keeps track of every statement that is executed, monitors the time it takes for a response to come back and uses this as the measure of execution time for the statement. If the time is longer than the other statements that have been recorded, then this is added to the ordered list within the filter. Once 30 statements have been recorded those statements that have been recorded with the least time are discarded from the list. The result is that at any time the filter has a list of the 30 longest running statements in each session.
It is possible to see what is in the current list by using the maxadmin tool to view the state of the filter by looking at the session data. First you need to find the session id for the session of interest, this can be done using commands such as list sessions. You can then use the show session command to see the details for a particular session.
```
MaxScale> show session 0x736680
MaxScale> show session 0x736680
Session 0x736680
State: Session ready for routing
Service: Split Service (0x719f60)
Client DCB: 0x7361a0
Client Address: 127.0.0.1
Connected: Thu Jun 26 10:10:44 2014
Session 0x736680
State: Session ready for routing
Service: Split Service (0x719f60)
Client DCB: 0x7361a0
Client Address: 127.0.0.1
Connected: Thu Jun 26 10:10:44 2014
Filter: top30
Report size 30
Logging to file /var/log/DBSessions/top30.1.
Current Top 30:
Filter: top30
Report size 30
Logging to file /var/log/DBSessions/top30.1.
Current Top 30:
1 place:
Execution time: 23.826 seconds
SQL: select sum(salary), year(from_date) from salaries s, (select distinct year(from_date) as y1 from salaries) y where (makedate(y.y1, 1) between s.from_date and s.to_date) group by y.y1 ("1988-08-01?
1 place:
Execution time: 23.826 seconds
SQL: select sum(salary), year(from_date) from salaries s, (select distinct year(from_date) as y1 from salaries) y where (makedate(y.y1, 1) between s.from_date and s.to_date) group by y.y1 ("1988-08-01?
2 place:
Execution time: 5.251 seconds
SQL: select d.dept_name as "Department", y.y1 as "Year", count(*) as "Count" from departments d, dept_emp de, (select distinct year(from_date) as y1 from dept_emp order by 1) y where d.dept_no = de.dept_no and (makedate(y.y1, 1) between de.from_date and de.to_date) group by y.y1, d.dept_name order by 1, 2
2 place:
Execution time: 5.251 seconds
SQL: select d.dept_name as "Department", y.y1 as "Year", count(*) as "Count" from departments d, dept_emp de, (select distinct year(from_date) as y1 from dept_emp order by 1) y where d.dept_no = de.dept_no and (makedate(y.y1, 1) between de.from_date and de.to_date) group by y.y1, d.dept_name order by 1, 2
3 place:
Execution time: 2.903 seconds
SQL: select year(now()) - year(birth_date) as age, gender, avg(salary) as "Average Salary" from employees e, salaries s where e.emp_no = s.emp_no and ("1988-08-01" between from_date AND to_date) group by year(now()) - year(birth_date), gender order by 1,2
...
3 place:
Execution time: 2.903 seconds
SQL: select year(now()) - year(birth_date) as age, gender, avg(salary) as "Average Salary" from employees e, salaries s where e.emp_no = s.emp_no and ("1988-08-01" between from_date AND to_date) group by year(now()) - year(birth_date), gender order by 1,2
```
When the session ends a report will be written for the session into the logfile defined. That report will include the top 30 longest running statements, plus summary data for the session;
@ -133,46 +132,46 @@ When the session ends a report will be written for the session into the logfile
### Duplicate Data From Your Application Into Cassandra
The scenario we are using in this example is one in which you have an online gaming application that is designed to work with a MariaDB/MySQL database. The database schema includes a high score table which you would like to have access to in a Cassandra cluster. The application is already using MaxScale to connect to a MariaDB Galera cluster, using a service names BubbleGame. The definition of that service is as follows
[BubbleGame]
type=service
router=readwritesplit
servers=dbbubble1,dbbubble2,dbbubble3,dbbubble4,dbbubble5
user=maxscale
passwd=6628C50E07CCE1F0392EDEEB9D1203F3
```
[BubbleGame]
type=service
router=readwritesplit
servers=dbbubble1,dbbubble2,dbbubble3,dbbubble4,dbbubble5
user=maxscale
passwd=6628C50E07CCE1F0392EDEEB9D1203F3
```
The table you wish to store in Cassandra in called HighScore and will contain the same columns in both the MariaDB table and the Cassandra table. The first step is to install a MariaDB instance with the Cassandra storage engine to act as a bridge server between the relational database and Cassandra. In this bridge server add a table definition for the HighScore table with the engine type set to cassandra. Add this server into the MaxScale configuration and create a service that will connect to this server.
[CassandraDB]
type=server
address=192.168.4.28
port=3306
protocol=MySQLBackend
[Cassandra]
type=service
router=readconnrouter
router_options=running
servers=CassandraDB
user=maxscale
passwd=6628C50E07CCE1F0392EDEEB9D1203F3
```
[CassandraDB]
type=server
address=192.168.4.28
port=3306
protocol=MySQLBackend
[Cassandra]
type=service
router=readconnrouter
router_options=running
servers=CassandraDB
user=maxscale
passwd=6628C50E07CCE1F0392EDEEB9D1203F3
```
Next add a filter definition for the tee filter that will duplication insert statements that are destined for the HighScore table to this new service.
[HighScores]
type=filter
module=teefilter
match=insert.*HighScore.*values
service=Cassandra
```
[HighScores]
type=filter
module=teefilter
match=insert.*HighScore.*values
service=Cassandra
```
The above filter definition will cause all statements that match the regular expression inset.*HighScore.*values to be duplication and sent not just to the original destination, via the router but also to the service named Cassandra.
The final step is to add the filter to the BubbleGame service to enable the use of the filter.
[BubbleGame]
type=service
router=readwritesplit
servers=dbbubble1,dbbubble2,dbbubble3,dbbubble4,dbbubble5
user=maxscale
passwd=6628C50E07CCE1F0392EDEEB9D1203F3
filters=HighScores
```
[BubbleGame]
type=service
router=readwritesplit
servers=dbbubble1,dbbubble2,dbbubble3,dbbubble4,dbbubble5
user=maxscale
passwd=6628C50E07CCE1F0392EDEEB9D1203F3
filters=HighScores
```

View File

@ -65,158 +65,159 @@ If you wish to use two different usernames for the two different roles of monito
MaxScale configuration is held in an ini file that is located in the file maxscale.cnf in the directory /etc, if you have installed in the default location then this file is available in /etc/maxscale.cnf. This is not created as part of the installation process and must be manually created. A template file does exist within the /usr/share/maxscale directory that may be use as a basis for your configuration.
A global, maxscale, section is included within every MaxScale configuration file; this is used to set the values of various MaxScale wide parameters, perhaps the most important of these is the number of threads that MaxScale will use to execute the code that forwards requests and handles responses for clients.
[maxscale]
threads=4
```
[maxscale]
threads=4
```
The first step is to create a service for our Read/Write Splitter. Create a section in your MaxScale.ini file and set the type to service, the section names are the names of the services themselves and should be meaningful to the administrator. Names may contain whitespace.
[Splitter Service]
type=service
```
[Splitter Service]
type=service
```
The router for we need to use for this configuration is the readwritesplit module, also the services should be provided with the list of servers that will be part of the cluster. The server names given here are actually the names of server sections in the configuration file and not the physical hostnames or addresses of the servers.
[Splitter Service]
type=service
router=readwritesplit
servers=dbserv1, dbserv2, dbserv3
```
[Splitter Service]
type=service
router=readwritesplit
servers=dbserv1, dbserv2, dbserv3
```
The final step in the service sections is to add the username and password that will be used to populate the user data from the database cluster. There are two options for representing the password, either plain text or encrypted passwords may be used. In order to use encrypted passwords a set of keys must be generated that will be used by the encryption and decryption process. To generate the keys use the maxkeys command and pass the name of the secrets file in which the keys are stored.
% maxkeys /var/lib/maxscale/.secrets
%
```
% maxkeys /var/lib/maxscale/.secrets
%
```
Once the keys have been created the maxpasswd command can be used to generate the encrypted password.
% maxpasswd plainpassword
96F99AA1315BDC3604B006F427DD9484
%
```
% maxpasswd plainpassword
96F99AA1315BDC3604B006F427DD9484
%
```
The username and password, either encrypted or plain text, are stored in the service section using the user and passwd parameters.
[Splitter Service]
type=service
router=readwritesplit
servers=dbserv1, dbserv2, dbserv3
user=maxscale
passwd=96F99AA1315BDC3604B006F427DD9484
```
[Splitter Service]
type=service
router=readwritesplit
servers=dbserv1, dbserv2, dbserv3
user=maxscale
passwd=96F99AA1315BDC3604B006F427DD9484
```
This completes the definitions required by the service, however listening ports must be associated with the service in order to allow network connections. This is done by creating a series of listener sections. This section again is named for the convenience of the administrator and should be of type listener with an entry labeled service which contains the name of the service to associate the listener with. A service may have multiple listeners.
[Splitter Listener]
type=listener
service=Splitter Service
```
[Splitter Listener]
type=listener
service=Splitter Service
```
A listener must also define the protocol module it will use for the incoming network protocol, currently this should be the MySQLClient protocol for all database listeners. The listener may then supply a network port to listen on and/or a socket within the file system.
[Splitter Listener]
type=listener
service=Splitter Service
protocol=MySQLClient
port=3306
socket=/tmp/ClusterMaster
```
[Splitter Listener]
type=listener
service=Splitter Service
protocol=MySQLClient
port=3306
socket=/tmp/ClusterMaster
```
An address parameter may be given if the listener is required to bind to a particular network address when using hosts with multiple network addresses. The default behavior is to listen on all network interfaces.
The next stage is the configuration is to define the server information. This defines how to connect to each of the servers within the cluster, again a section is created for each server, with the type set to server, the network address and port to connect to and the protocol to use to connect to the server. Currently the protocol module for all database connections in MySQLBackend.
```
[dbserv1]
type=server
address=192.168.2.1
port=3306
protocol=MySQLBackend
[dbserv1]
type=server
address=192.168.2.1
port=3306
protocol=MySQLBackend
[dbserv2]
type=server
address=192.168.2.2
port=3306
protocol=MySQLBackend
[dbserv3]
type=server
address=192.168.2.3
port=3306
protocol=MySQLBackend
[dbserv2]
type=server
address=192.168.2.2
port=3306
protocol=MySQLBackend
[dbserv3]
type=server
address=192.168.2.3
port=3306
protocol=MySQLBackend
```
In order for MaxScale to monitor the servers using the correct monitoring mechanisms a section should be provided that defines the monitor to use and the servers to monitor. Once again a section is created with a symbolic name for the monitor, with the type set to monitor. Parameters are added for the module to use, the list of servers to monitor and the username and password to use when connecting to the the servers with the monitor.
[Galera Monitor]
type=monitor
module=galeramon
servers=dbserv1, dbserv2, dbserv3
user=maxscale
passwd=96F99AA1315BDC3604B006F427DD9484
```
[Galera Monitor]
type=monitor
module=galeramon
servers=dbserv1, dbserv2, dbserv3
user=maxscale
passwd=96F99AA1315BDC3604B006F427DD9484
```
As with the password definition in the server either plain text or encrypted passwords may be used.
This monitor module will assign one node within the Galera Cluster as the current master and other nodes as slave. Only those nodes that are active members of the cluster are considered when making the choice of master node. Normally the master node will be the node with the lowest value of the status variable, WSREP_LOCAL_INDEX. When cluster membership changes a new master may be elected. In order to prevent changes of the node that is currently master, a parameter can be added to the monitor that will result in the current master remaining as master even if a node with a lower value of WSREP_LOCAL_INDEX joins the cluster. This parameter is called disable_master_failback.
[Galera Monitor]
type=monitor
module=galeramon
diable_master_failback=1
servers=dbserv1, dbserv2, dbserv3
user=maxscale
passwd=96F99AA1315BDC3604B006F427DD9484
```
[Galera Monitor]
type=monitor
module=galeramon
diable_master_failback=1
servers=dbserv1, dbserv2, dbserv3
user=maxscale
passwd=96F99AA1315BDC3604B006F427DD9484
```
Using this option the master node will only change if there is a problem with the current master and never because other nodes have joined the cluster.
The final stage in the configuration is to add the option service which is used by the maxadmin command to connect to MaxScale for monitoring and administration purposes. This creates a service section and a listener section.
```
[CLI]
type=service
router=cli
[CLI]
type=service
router=cli
[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
address=localhost
port=6603
[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
address=localhost
port=6603
```
In the case of the example above it should be noted that an address parameter has been given to the listener, this limits connections to maxadmin commands that are executed on the same machine that hosts MaxScale.
## Starting MaxScale
Upon completion of the configuration process MaxScale is ready to be started for the first time. This may either be done manually by running the maxscale command or via the service interface.
% maxscale
```
% maxscale
```
or
% service maxscale start
```
% service maxscale start
```
Check the error log in /var/log/maxscale to see if any errors are detected in the configuration file and to confirm MaxScale has been started. Also the maxadmin command may be used to confirm that MaxScale is running and the services, listeners etc have been correctly configured.
```
% maxadmin -pmariadb list services
% maxadmin -pmariadb list services
Services.
--------------------------+----------------------+--------+---------------
Service Name | Router Module | #Users | Total Sessions
--------------------------+----------------------+--------+---------------
Splitter Service | readwritesplit | 1 | 1
CLI | cli | 2 | 2
--------------------------+----------------------+--------+---------------
% maxadmin -pmariadb list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
dbserv1 | 192.168.2.1 | 3306 | 0 | Running, Synced, Master
dbserv2 | 192.168.2.2 | 3306 | 0 | Running, Synced, Slave
dbserv3 | 192.168.2.3 | 3306 | 0 | Running, Synced, Slave
-------------------+-----------------+-------+-------------+--------------------
Services.
--------------------------+----------------------+--------+---------------
Service Name | Router Module | #Users | Total Sessions
--------------------------+----------------------+--------+---------------
Splitter Service | readwritesplit | 1 | 1
CLI | cli | 2 | 2
--------------------------+----------------------+--------+---------------
% maxadmin -pmariadb list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
dbserv1 | 192.168.2.1 | 3306 | 0 | Running, Synced, Master
dbserv2 | 192.168.2.2 | 3306 | 0 | Running, Synced, Slave
dbserv3 | 192.168.2.3 | 3306 | 0 | Running, Synced, Slave
-------------------+-----------------+-------+-------------+--------------------
```
A Galera Cluster is a multi-master clustering technology, however the monitor is able to impose false notions of master and slave roles within a Galera Cluster in order to facilitate the use of Galera as if it were a standard MySQL Replication setup. This is merely an internal MaxScale convenience and has no impact on the behavior of the cluster but does allow the monitor to create these pseudo roles which are utilized by the Read/Write Splitter.
```
% maxadmin -pmariadb list listeners
% maxadmin -pmariadb list listeners
Listeners.
---------------------+--------------------+-----------------+-------+--------
Service Name | Protocol Module | Address | Port | State
---------------------+--------------------+-----------------+-------+--------
Splitter Service | MySQLClient | * | 3306 | Running
CLI | maxscaled | localhost | 6603 | Running
---------------------+--------------------+-----------------+-------+--------
%
Listeners.
---------------------+--------------------+-----------------+-------+--------
Service Name | Protocol Module | Address | Port | State
---------------------+--------------------+-----------------+-------+--------
Splitter Service | MySQLClient | * | 3306 | Running
CLI | maxscaled | localhost | 6603 | Running
---------------------+--------------------+-----------------+-------+--------
```
MaxScale is now ready to start accepting client connections and routing them to the master or slaves within your cluster. Other configuration options are available that can alter the criteria used for routing, these include monitoring the replication lag within the cluster and routing only to slaves that are within a predetermined delay from the current master or using weights to obtain unequal balancing operations. These options may be found in the MaxScale Configuration Guide. More detail on the use of maxadmin can be found in the document "MaxAdmin - The MaxScale Administration & Monitoring Client Application".

View File

@ -12,31 +12,31 @@ The specified user, with the password (plain or encrypted via maxpassword utilit
Currently the user can connect to maxinfo from any remote IP and to localhost as well.
```
[MaxInfo]
type=service
router=maxinfo
user=monitor
passwd=EBD2F49C3B375812A8CDEBA632ED8BBC
[MaxInfo]
type=service
router=maxinfo
user=monitor
passwd=EBD2F49C3B375812A8CDEBA632ED8BBC
```
The listener section defines the protocol, port and other information needed to create a listener for the service. To listen on a port using the MySQL protocol a section as shown below should be added to the configuration file.
```
[MaxInfo Listener]
type=listener
service=MaxInfo
protocol=MySQLClient
port=9003
[MaxInfo Listener]
type=listener
service=MaxInfo
protocol=MySQLClient
port=9003
```
To listen with the HTTP protocol and hence return JSON documents a section as should below is required.
```
[MaxInfo JSON Listener]
type=listener
service=MaxInfo
protocol=HTTPD
port=8003
[MaxInfo JSON Listener]
type=listener
service=MaxInfo
protocol=HTTPD
port=8003
```
@ -45,12 +45,12 @@ If both the MySQL and JSON responses are required then a single service can be c
As with any other listeners within MaxScale the listeners can be bound to a particular interface by use of the address= parameter. This allows the access to the maxinfo data to be limited to the localhost by adding an address=localhost parameter in the configuration file.
```
[MaxInfo Listener]
type=listener
service=MaxInfo
protocol=MySQLClient
address=localhost
port=9003
[MaxInfo Listener]
type=listener
service=MaxInfo
protocol=MySQLClient
address=localhost
port=9003
```
# MySQL Interface to maxinfo
@ -58,11 +58,11 @@ As with any other listeners within MaxScale the listeners can be bound to a part
The maxinfo supports a small subset of SQL statements in addition to the MySQL status and ping requests. These may be used for simple monitoring of MaxScale.
```
% mysqladmin -hmaxscale.mariadb.com -P9003 -umonitor -pxyz ping
mysqld is alive
% mysqladmin -hmaxscale.mariadb.com -P9003 -umonitor -pxyz status
Uptime: 72 Threads: 1 Sessions: 11
%
% mysqladmin -hmaxscale.mariadb.com -P9003 -umonitor -pxyz ping
mysqld is alive
% mysqladmin -hmaxscale.mariadb.com -P9003 -umonitor -pxyz status
Uptime: 72 Threads: 1 Sessions: 11
%
```
The SQL command used to interact with maxinfo is the show command, a variety of show commands are available and will be described in the following sections.
@ -72,64 +72,64 @@ The SQL command used to interact with maxinfo is the show command, a variety of
The show variables command will display a set of name and value pairs for a number of MaxScale system variables.
```
mysql> show variables;
+--------------------+-------------------------+
| Variable_name | Value |
+--------------------+-------------------------+
| version | 1.0.6-unstable |
| version_comment | MariaDB MaxScale |
| basedir | /home/mriddoch/skygate2 |
| MAXSCALE_VERSION | 1.0.6-unstable |
| MAXSCALE_THREADS | 1 |
| MAXSCALE_NBPOLLS | 3 |
| MAXSCALE_POLLSLEEP | 1000 |
| MAXSCALE_UPTIME | 223 |
| MAXSCALE_SESSIONS | 11 |
+--------------------+-------------------------+
9 rows in set (0.02 sec)
mysql>
mysql> show variables;
+--------------------+-------------------------+
| Variable_name | Value |
+--------------------+-------------------------+
| version | 1.0.6-unstable |
| version_comment | MariaDB MaxScale |
| basedir | /home/mriddoch/skygate2 |
| MAXSCALE_VERSION | 1.0.6-unstable |
| MAXSCALE_THREADS | 1 |
| MAXSCALE_NBPOLLS | 3 |
| MAXSCALE_POLLSLEEP | 1000 |
| MAXSCALE_UPTIME | 223 |
| MAXSCALE_SESSIONS | 11 |
+--------------------+-------------------------+
9 rows in set (0.02 sec)
mysql>
```
The show variables command can also accept a limited like clause. This like clause must either be a literal string to match, a pattern starting with a %, a pattern ending with a % or a string with a % at both the start and the end.
```
mysql> show variables like 'version';
+---------------+----------------+
| Variable_name | Value |
+---------------+----------------+
| version | 1.0.6-unstable |
+---------------+----------------+
1 row in set (0.02 sec)
mysql> show variables like 'version%';
+-----------------+------------------+
| Variable_name | Value |
+-----------------+------------------+
| version | 1.0.6-unstable |
| version_comment | MariaDB MaxScale |
+-----------------+------------------+
2 rows in set (0.02 sec)
mysql> show variables like '%comment';
+-----------------+------------------+
| Variable_name | Value |
+-----------------+------------------+
| version_comment | MariaDB MaxScale |
+-----------------+------------------+
1 row in set (0.02 sec)
mysql> show variables like '%ers%';
+------------------+------------------+
| Variable_name | Value |
+------------------+------------------+
| version | 1.0.6-unstable |
| version_comment | MariaDB MaxScale |
| MAXSCALE_VERSION | 1.0.6-unstable |
+------------------+------------------+
3 rows in set (0.02 sec)
mysql>
mysql> show variables like 'version';
+---------------+----------------+
| Variable_name | Value |
+---------------+----------------+
| version | 1.0.6-unstable |
+---------------+----------------+
1 row in set (0.02 sec)
mysql> show variables like 'version%';
+-----------------+------------------+
| Variable_name | Value |
+-----------------+------------------+
| version | 1.0.6-unstable |
| version_comment | MariaDB MaxScale |
+-----------------+------------------+
2 rows in set (0.02 sec)
mysql> show variables like '%comment';
+-----------------+------------------+
| Variable_name | Value |
+-----------------+------------------+
| version_comment | MariaDB MaxScale |
+-----------------+------------------+
1 row in set (0.02 sec)
mysql> show variables like '%ers%';
+------------------+------------------+
| Variable_name | Value |
+------------------+------------------+
| version | 1.0.6-unstable |
| version_comment | MariaDB MaxScale |
| MAXSCALE_VERSION | 1.0.6-unstable |
+------------------+------------------+
3 rows in set (0.02 sec)
mysql>
```
## Show status
@ -137,36 +137,36 @@ The show variables command can also accept a limited like clause. This like clau
The show status command displays a set of status counters, as with show variables the show status command can be passed a simplified like clause to limit the values returned.
```
mysql> show status;
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| Uptime | 156 |
| Uptime_since_flush_status | 156 |
| Threads_created | 1 |
| Threads_running | 1 |
| Threadpool_threads | 1 |
| Threads_connected | 11 |
| Connections | 11 |
| Client_connections | 2 |
| Backend_connections | 0 |
| Listeners | 9 |
| Zombie_connections | 0 |
| Internal_descriptors | 2 |
| Read_events | 22 |
| Write_events | 24 |
| Hangup_events | 0 |
| Error_events | 0 |
| Accept_events | 2 |
| Event_queue_length | 1 |
| Pending_events | 0 |
| Max_event_queue_length | 1 |
| Max_event_queue_time | 0 |
| Max_event_execution_time | 0 |
+---------------------------+-------+
22 rows in set (0.02 sec)
mysql>
mysql> show status;
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| Uptime | 156 |
| Uptime_since_flush_status | 156 |
| Threads_created | 1 |
| Threads_running | 1 |
| Threadpool_threads | 1 |
| Threads_connected | 11 |
| Connections | 11 |
| Client_connections | 2 |
| Backend_connections | 0 |
| Listeners | 9 |
| Zombie_connections | 0 |
| Internal_descriptors | 2 |
| Read_events | 22 |
| Write_events | 24 |
| Hangup_events | 0 |
| Error_events | 0 |
| Accept_events | 2 |
| Event_queue_length | 1 |
| Pending_events | 0 |
| Max_event_queue_length | 1 |
| Max_event_queue_time | 0 |
| Max_event_execution_time | 0 |
+---------------------------+-------+
22 rows in set (0.02 sec)
mysql>
```
## Show services
@ -174,22 +174,22 @@ The show status command displays a set of status counters, as with show variable
The show services command will return a set of basic statistics regarding each of the configured services within MaxScale.
```
mysql> show services;
+----------------+----------------+--------------+----------------+
| Service Name | Router Module | No. Sessions | Total Sessions |
+----------------+----------------+--------------+----------------+
| Test Service | readconnroute | 1 | 1 |
| Split Service | readwritesplit | 1 | 1 |
| Filter Service | readconnroute | 1 | 1 |
| Named Service | readwritesplit | 1 | 1 |
| QLA Service | readconnroute | 1 | 1 |
| Debug Service | debugcli | 1 | 1 |
| CLI | cli | 1 | 1 |
| MaxInfo | maxinfo | 4 | 4 |
+----------------+----------------+--------------+----------------+
8 rows in set (0.02 sec)
mysql>
mysql> show services;
+----------------+----------------+--------------+----------------+
| Service Name | Router Module | No. Sessions | Total Sessions |
+----------------+----------------+--------------+----------------+
| Test Service | readconnroute | 1 | 1 |
| Split Service | readwritesplit | 1 | 1 |
| Filter Service | readconnroute | 1 | 1 |
| Named Service | readwritesplit | 1 | 1 |
| QLA Service | readconnroute | 1 | 1 |
| Debug Service | debugcli | 1 | 1 |
| CLI | cli | 1 | 1 |
| MaxInfo | maxinfo | 4 | 4 |
+----------------+----------------+--------------+----------------+
8 rows in set (0.02 sec)
mysql>
```
The show services command does not accept a like clause and will ignore any like clause that is given.
@ -199,23 +199,23 @@ The show services command does not accept a like clause and will ignore any like
The show listeners command will return a set of status information for every listener defined within the MaxScale configuration file.
```
mysql> show listeners;
+----------------+-----------------+-----------+------+---------+
| Service Name | Protocol Module | Address | Port | State |
+----------------+-----------------+-----------+------+---------+
| Test Service | MySQLClient | * | 4006 | Running |
| Split Service | MySQLClient | * | 4007 | Running |
| Filter Service | MySQLClient | * | 4008 | Running |
| Named Service | MySQLClient | * | 4010 | Running |
| QLA Service | MySQLClient | * | 4009 | Running |
| Debug Service | telnetd | localhost | 4242 | Running |
| CLI | maxscaled | localhost | 6603 | Running |
| MaxInfo | MySQLClient | * | 9003 | Running |
| MaxInfo | HTTPD | * | 8003 | Running |
+----------------+-----------------+-----------+------+---------+
9 rows in set (0.02 sec)
mysql>
mysql> show listeners;
+----------------+-----------------+-----------+------+---------+
| Service Name | Protocol Module | Address | Port | State |
+----------------+-----------------+-----------+------+---------+
| Test Service | MySQLClient | * | 4006 | Running |
| Split Service | MySQLClient | * | 4007 | Running |
| Filter Service | MySQLClient | * | 4008 | Running |
| Named Service | MySQLClient | * | 4010 | Running |
| QLA Service | MySQLClient | * | 4009 | Running |
| Debug Service | telnetd | localhost | 4242 | Running |
| CLI | maxscaled | localhost | 6603 | Running |
| MaxInfo | MySQLClient | * | 9003 | Running |
| MaxInfo | HTTPD | * | 8003 | Running |
+----------------+-----------------+-----------+------+---------+
9 rows in set (0.02 sec)
mysql>
```
The show listeners command will ignore any like clause passed to it.
@ -225,25 +225,25 @@ The show listeners command will ignore any like clause passed to it.
The show sessions command returns information on every active session within MaxScale. It will ignore any like clause passed to it.
```
mysql> show sessions;
+-----------+---------------+----------------+---------------------------+
| Session | Client | Service | State |
+-----------+---------------+----------------+---------------------------+
| 0x1a92a60 | 127.0.0.1 | MaxInfo | Session ready for routing |
| 0x1a92100 | 80.240.130.35 | MaxInfo | Session ready for routing |
| 0x1a76a00 | | MaxInfo | Listener Session |
| 0x1a76020 | | MaxInfo | Listener Session |
| 0x1a75d40 | | CLI | Listener Session |
| 0x1a75220 | | Debug Service | Listener Session |
| 0x1a774b0 | | QLA Service | Listener Session |
| 0x1a78630 | | Named Service | Listener Session |
| 0x1a60270 | | Filter Service | Listener Session |
| 0x1a606f0 | | Split Service | Listener Session |
| 0x19b0380 | | Test Service | Listener Session |
+-----------+---------------+----------------+---------------------------+
11 rows in set (0.02 sec)
mysql>
mysql> show sessions;
+-----------+---------------+----------------+---------------------------+
| Session | Client | Service | State |
+-----------+---------------+----------------+---------------------------+
| 0x1a92a60 | 127.0.0.1 | MaxInfo | Session ready for routing |
| 0x1a92100 | 80.240.130.35 | MaxInfo | Session ready for routing |
| 0x1a76a00 | | MaxInfo | Listener Session |
| 0x1a76020 | | MaxInfo | Listener Session |
| 0x1a75d40 | | CLI | Listener Session |
| 0x1a75220 | | Debug Service | Listener Session |
| 0x1a774b0 | | QLA Service | Listener Session |
| 0x1a78630 | | Named Service | Listener Session |
| 0x1a60270 | | Filter Service | Listener Session |
| 0x1a606f0 | | Split Service | Listener Session |
| 0x19b0380 | | Test Service | Listener Session |
+-----------+---------------+----------------+---------------------------+
11 rows in set (0.02 sec)
mysql>
```
## Show clients
@ -251,16 +251,16 @@ The show sessions command returns information on every active session within Max
The show clients command reports a row for every client application connected to MaxScale. Like clauses are not available of the show clients command.
```
mysql> show clients;
+-----------+---------------+---------+---------------------------+
| Session | Client | Service | State |
+-----------+---------------+---------+---------------------------+
| 0x1a92a60 | 127.0.0.1 | MaxInfo | Session ready for routing |
| 0x1a92100 | 80.240.130.35 | MaxInfo | Session ready for routing |
+-----------+---------------+---------+---------------------------+
2 rows in set (0.02 sec)
mysql>
mysql> show clients;
+-----------+---------------+---------+---------------------------+
| Session | Client | Service | State |
+-----------+---------------+---------+---------------------------+
| 0x1a92a60 | 127.0.0.1 | MaxInfo | Session ready for routing |
| 0x1a92100 | 80.240.130.35 | MaxInfo | Session ready for routing |
+-----------+---------------+---------+---------------------------+
2 rows in set (0.02 sec)
mysql>
```
## Show servers
@ -268,18 +268,18 @@ The show clients command reports a row for every client application connected to
The show servers command returns data for each backend server configured within the MaxScale configuration file. This data includes the current number of connections MaxScale has to that server and the state of that server as monitored by MaxScale.
```
mysql> show servers;
+---------+-----------+------+-------------+---------+
| Server | Address | Port | Connections | Status |
+---------+-----------+------+-------------+---------+
| server1 | 127.0.0.1 | 3306 | 0 | Running |
| server2 | 127.0.0.1 | 3307 | 0 | Down |
| server3 | 127.0.0.1 | 3308 | 0 | Down |
| server4 | 127.0.0.1 | 3309 | 0 | Down |
+---------+-----------+------+-------------+---------+
4 rows in set (0.02 sec)
mysql>
mysql> show servers;
+---------+-----------+------+-------------+---------+
| Server | Address | Port | Connections | Status |
+---------+-----------+------+-------------+---------+
| server1 | 127.0.0.1 | 3306 | 0 | Running |
| server2 | 127.0.0.1 | 3307 | 0 | Down |
| server3 | 127.0.0.1 | 3308 | 0 | Down |
| server4 | 127.0.0.1 | 3309 | 0 | Down |
+---------+-----------+------+-------------+---------+
4 rows in set (0.02 sec)
mysql>
```
## Show modules
@ -287,24 +287,24 @@ The show servers command returns data for each backend server configured within
The show modules command reports the information on the modules currently loaded into MaxScale. This includes the name type and version of each module. It also includes the API version the module has been written against and the current release status of the module.
```
mysql> show modules;
+----------------+-------------+---------+-------------+----------------+
| Module Name | Module Type | Version | API Version | Status |
+----------------+-------------+---------+-------------+----------------+
| HTTPD | Protocol | V1.0.1 | 1.0.0 | In Development |
| maxscaled | Protocol | V1.0.0 | 1.0.0 | GA |
| telnetd | Protocol | V1.0.1 | 1.0.0 | GA |
| MySQLClient | Protocol | V1.0.0 | 1.0.0 | GA |
| mysqlmon | Monitor | V1.4.0 | 1.0.0 | GA |
| readwritesplit | Router | V1.0.2 | 1.0.0 | GA |
| readconnroute | Router | V1.1.0 | 1.0.0 | GA |
| debugcli | Router | V1.1.1 | 1.0.0 | GA |
| cli | Router | V1.0.0 | 1.0.0 | GA |
| maxinfo | Router | V1.0.0 | 1.0.0 | Alpha |
+----------------+-------------+---------+-------------+----------------+
10 rows in set (0.02 sec)
mysql>
mysql> show modules;
+----------------+-------------+---------+-------------+----------------+
| Module Name | Module Type | Version | API Version | Status |
+----------------+-------------+---------+-------------+----------------+
| HTTPD | Protocol | V1.0.1 | 1.0.0 | In Development |
| maxscaled | Protocol | V1.0.0 | 1.0.0 | GA |
| telnetd | Protocol | V1.0.1 | 1.0.0 | GA |
| MySQLClient | Protocol | V1.0.0 | 1.0.0 | GA |
| mysqlmon | Monitor | V1.4.0 | 1.0.0 | GA |
| readwritesplit | Router | V1.0.2 | 1.0.0 | GA |
| readconnroute | Router | V1.1.0 | 1.0.0 | GA |
| debugcli | Router | V1.1.1 | 1.0.0 | GA |
| cli | Router | V1.0.0 | 1.0.0 | GA |
| maxinfo | Router | V1.0.0 | 1.0.0 | Alpha |
+----------------+-------------+---------+-------------+----------------+
10 rows in set (0.02 sec)
mysql>
```
## Show monitors
@ -312,15 +312,15 @@ The show modules command reports the information on the modules currently loaded
The show monitors command reports each monitor configured within the system and the state of that monitor.
```
mysql> show monitors;
+---------------+---------+
| Monitor | Status |
+---------------+---------+
| MySQL Monitor | Running |
+---------------+---------+
1 row in set (0.02 sec)
mysql>
mysql> show monitors;
+---------------+---------+
| Monitor | Status |
+---------------+---------+
| MySQL Monitor | Running |
+---------------+---------+
1 row in set (0.02 sec)
mysql>
```
## Show eventTimes
@ -328,44 +328,44 @@ The show monitors command reports each monitor configured within the system and
The show eventTimes command returns a table of statistics that reflect the performance of the event queuing and execution portion of the MaxScale core.
```
mysql> show eventTimes;
+---------------+-------------------+---------------------+
| Duration | No. Events Queued | No. Events Executed |
+---------------+-------------------+---------------------+
| < 100ms | 460 | 456 |
| 100 - 200ms | 0 | 3 |
| 200 - 300ms | 0 | 0 |
| 300 - 400ms | 0 | 0 |
| 400 - 500ms | 0 | 0 |
| 500 - 600ms | 0 | 0 |
| 600 - 700ms | 0 | 0 |
| 700 - 800ms | 0 | 0 |
| 800 - 900ms | 0 | 0 |
| 900 - 1000ms | 0 | 0 |
| 1000 - 1100ms | 0 | 0 |
| 1100 - 1200ms | 0 | 0 |
| 1200 - 1300ms | 0 | 0 |
| 1300 - 1400ms | 0 | 0 |
| 1400 - 1500ms | 0 | 0 |
| 1500 - 1600ms | 0 | 0 |
| 1600 - 1700ms | 0 | 0 |
| 1700 - 1800ms | 0 | 0 |
| 1800 - 1900ms | 0 | 0 |
| 1900 - 2000ms | 0 | 0 |
| 2000 - 2100ms | 0 | 0 |
| 2100 - 2200ms | 0 | 0 |
| 2200 - 2300ms | 0 | 0 |
| 2300 - 2400ms | 0 | 0 |
| 2400 - 2500ms | 0 | 0 |
| 2500 - 2600ms | 0 | 0 |
| 2600 - 2700ms | 0 | 0 |
| 2700 - 2800ms | 0 | 0 |
| 2800 - 2900ms | 0 | 0 |
| > 3000ms | 0 | 0 |
+---------------+-------------------+---------------------+
30 rows in set (0.02 sec)
mysql>
mysql> show eventTimes;
+---------------+-------------------+---------------------+
| Duration | No. Events Queued | No. Events Executed |
+---------------+-------------------+---------------------+
| < 100ms | 460 | 456 |
| 100 - 200ms | 0 | 3 |
| 200 - 300ms | 0 | 0 |
| 300 - 400ms | 0 | 0 |
| 400 - 500ms | 0 | 0 |
| 500 - 600ms | 0 | 0 |
| 600 - 700ms | 0 | 0 |
| 700 - 800ms | 0 | 0 |
| 800 - 900ms | 0 | 0 |
| 900 - 1000ms | 0 | 0 |
| 1000 - 1100ms | 0 | 0 |
| 1100 - 1200ms | 0 | 0 |
| 1200 - 1300ms | 0 | 0 |
| 1300 - 1400ms | 0 | 0 |
| 1400 - 1500ms | 0 | 0 |
| 1500 - 1600ms | 0 | 0 |
| 1600 - 1700ms | 0 | 0 |
| 1700 - 1800ms | 0 | 0 |
| 1800 - 1900ms | 0 | 0 |
| 1900 - 2000ms | 0 | 0 |
| 2000 - 2100ms | 0 | 0 |
| 2100 - 2200ms | 0 | 0 |
| 2200 - 2300ms | 0 | 0 |
| 2300 - 2400ms | 0 | 0 |
| 2400 - 2500ms | 0 | 0 |
| 2500 - 2600ms | 0 | 0 |
| 2600 - 2700ms | 0 | 0 |
| 2700 - 2800ms | 0 | 0 |
| 2800 - 2900ms | 0 | 0 |
| > 3000ms | 0 | 0 |
+---------------+-------------------+---------------------+
30 rows in set (0.02 sec)
mysql>
```
Each row represents a time interval, in 100ms increments, with the counts representing the number of events that were in the event queue for the length of time that row represents and the number of events that were executing of the time indicated by the row.
@ -379,17 +379,17 @@ The simplified JSON interface takes the URL of the request made to maxinfo and m
The /variables URL will return the MaxScale variables, these variables can not be filtered via this interface.
```
$ curl http://maxscale.mariadb.com:8003/variables
[ { "Variable_name" : "version", "Value" : "1.0.6-unstable"},
{ "Variable_name" : "version_comment", "Value" : "MariaDB MaxScale"},
{ "Variable_name" : "basedir", "Value" : "/home/mriddoch/skygate2"},
{ "Variable_name" : "MAXSCALE_VERSION", "Value" : "1.0.6-unstable"},
{ "Variable_name" : "MAXSCALE_THREADS", "Value" : 1},
{ "Variable_name" : "MAXSCALE_NBPOLLS", "Value" : 3},
{ "Variable_name" : "MAXSCALE_POLLSLEEP", "Value" : 1000},
{ "Variable_name" : "MAXSCALE_UPTIME", "Value" : 3948},
{ "Variable_name" : "MAXSCALE_SESSIONS", "Value" : 12}]
$
$ curl http://maxscale.mariadb.com:8003/variables
[ { "Variable_name" : "version", "Value" : "1.0.6-unstable"},
{ "Variable_name" : "version_comment", "Value" : "MariaDB MaxScale"},
{ "Variable_name" : "basedir", "Value" : "/home/mriddoch/skygate2"},
{ "Variable_name" : "MAXSCALE_VERSION", "Value" : "1.0.6-unstable"},
{ "Variable_name" : "MAXSCALE_THREADS", "Value" : 1},
{ "Variable_name" : "MAXSCALE_NBPOLLS", "Value" : 3},
{ "Variable_name" : "MAXSCALE_POLLSLEEP", "Value" : 1000},
{ "Variable_name" : "MAXSCALE_UPTIME", "Value" : 3948},
{ "Variable_name" : "MAXSCALE_SESSIONS", "Value" : 12}]
$
```
## Status
@ -397,47 +397,47 @@ The /variables URL will return the MaxScale variables, these variables can not b
Use of the /status URI will return the status information that would normally be returned by the show status command. No filtering of the status information is available via this interface
```
$ curl http://maxscale.mariadb.com:8003/status
[ { "Variable_name" : "Uptime", "Value" : 3831},
{ "Variable_name" : "Uptime_since_flush_status", "Value" : 3831},
{ "Variable_name" : "Threads_created", "Value" : 1},
{ "Variable_name" : "Threads_running", "Value" : 1},
{ "Variable_name" : "Threadpool_threads", "Value" : 1},
{ "Variable_name" : "Threads_connected", "Value" : 12},
{ "Variable_name" : "Connections", "Value" : 12},
{ "Variable_name" : "Client_connections", "Value" : 3},
{ "Variable_name" : "Backend_connections", "Value" : 0},
{ "Variable_name" : "Listeners", "Value" : 9},
{ "Variable_name" : "Zombie_connections", "Value" : 0},
{ "Variable_name" : "Internal_descriptors", "Value" : 3},
{ "Variable_name" : "Read_events", "Value" : 469},
{ "Variable_name" : "Write_events", "Value" : 479},
{ "Variable_name" : "Hangup_events", "Value" : 12},
{ "Variable_name" : "Error_events", "Value" : 0},
{ "Variable_name" : "Accept_events", "Value" : 15},
{ "Variable_name" : "Event_queue_length", "Value" : 1},
{ "Variable_name" : "Pending_events", "Value" : 0},
{ "Variable_name" : "Max_event_queue_length", "Value" : 1},
{ "Variable_name" : "Max_event_queue_time", "Value" : 0},
{ "Variable_name" : "Max_event_execution_time", "Value" : 1}]
$
$ curl http://maxscale.mariadb.com:8003/status
[ { "Variable_name" : "Uptime", "Value" : 3831},
{ "Variable_name" : "Uptime_since_flush_status", "Value" : 3831},
{ "Variable_name" : "Threads_created", "Value" : 1},
{ "Variable_name" : "Threads_running", "Value" : 1},
{ "Variable_name" : "Threadpool_threads", "Value" : 1},
{ "Variable_name" : "Threads_connected", "Value" : 12},
{ "Variable_name" : "Connections", "Value" : 12},
{ "Variable_name" : "Client_connections", "Value" : 3},
{ "Variable_name" : "Backend_connections", "Value" : 0},
{ "Variable_name" : "Listeners", "Value" : 9},
{ "Variable_name" : "Zombie_connections", "Value" : 0},
{ "Variable_name" : "Internal_descriptors", "Value" : 3},
{ "Variable_name" : "Read_events", "Value" : 469},
{ "Variable_name" : "Write_events", "Value" : 479},
{ "Variable_name" : "Hangup_events", "Value" : 12},
{ "Variable_name" : "Error_events", "Value" : 0},
{ "Variable_name" : "Accept_events", "Value" : 15},
{ "Variable_name" : "Event_queue_length", "Value" : 1},
{ "Variable_name" : "Pending_events", "Value" : 0},
{ "Variable_name" : "Max_event_queue_length", "Value" : 1},
{ "Variable_name" : "Max_event_queue_time", "Value" : 0},
{ "Variable_name" : "Max_event_execution_time", "Value" : 1}]
$
```
## Services
The /services URI returns the data regarding the services defined within the configuration of MaxScale. Two counters are returned, the current number of sessions attached to this service and the total number connected since the service started.
```
$ curl http://maxscale.mariadb.com:8003/services
[ { "Service Name" : "Test Service", "Router Module" : "readconnroute", "No. Sessions" : 1, "Total Sessions" : 1},
{ "Service Name" : "Split Service", "Router Module" : "readwritesplit", "No. Sessions" : 1, "Total Sessions" : 1},
{ "Service Name" : "Filter Service", "Router Module" : "readconnroute", "No. Sessions" : 1, "Total Sessions" : 1},
{ "Service Name" : "Named Service", "Router Module" : "readwritesplit", "No. Sessions" : 1, "Total Sessions" : 1},
{ "Service Name" : "QLA Service", "Router Module" : "readconnroute", "No. Sessions" : 1, "Total Sessions" : 1},
{ "Service Name" : "Debug Service", "Router Module" : "debugcli", "No. Sessions" : 1, "Total Sessions" : 1},
{ "Service Name" : "CLI", "Router Module" : "cli", "No. Sessions" : 1, "Total Sessions" : 1},
{ "Service Name" : "MaxInfo", "Router Module" : "maxinfo", "No. Sessions" : 5, "Total Sessions" : 20}]
$
$ curl http://maxscale.mariadb.com:8003/services
[ { "Service Name" : "Test Service", "Router Module" : "readconnroute", "No. Sessions" : 1, "Total Sessions" : 1},
{ "Service Name" : "Split Service", "Router Module" : "readwritesplit", "No. Sessions" : 1, "Total Sessions" : 1},
{ "Service Name" : "Filter Service", "Router Module" : "readconnroute", "No. Sessions" : 1, "Total Sessions" : 1},
{ "Service Name" : "Named Service", "Router Module" : "readwritesplit", "No. Sessions" : 1, "Total Sessions" : 1},
{ "Service Name" : "QLA Service", "Router Module" : "readconnroute", "No. Sessions" : 1, "Total Sessions" : 1},
{ "Service Name" : "Debug Service", "Router Module" : "debugcli", "No. Sessions" : 1, "Total Sessions" : 1},
{ "Service Name" : "CLI", "Router Module" : "cli", "No. Sessions" : 1, "Total Sessions" : 1},
{ "Service Name" : "MaxInfo", "Router Module" : "maxinfo", "No. Sessions" : 5, "Total Sessions" : 20}]
$
```
## Listeners
@ -445,17 +445,17 @@ The /services URI returns the data regarding the services defined within the con
The /listeners URI will return a JSON array with one entry per listener, each entry is a JSON object that describes the configuration and state of that listener.
```
$ curl http://maxscale.mariadb.com:8003/listeners
[ { "Service Name" : "Test Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4006, "State" : "Running"},
{ "Service Name" : "Split Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4007, "State" : "Running"},
{ "Service Name" : "Filter Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4008, "State" : "Running"},
{ "Service Name" : "Named Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4010, "State" : "Running"},
{ "Service Name" : "QLA Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4009, "State" : "Running"},
{ "Service Name" : "Debug Service", "Protocol Module" : "telnetd", "Address" : "localhost", "Port" : 4242, "State" : "Running"},
{ "Service Name" : "CLI", "Protocol Module" : "maxscaled", "Address" : "localhost", "Port" : 6603, "State" : "Running"},
{ "Service Name" : "MaxInfo", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 9003, "State" : "Running"},
{ "Service Name" : "MaxInfo", "Protocol Module" : "HTTPD", "Address" : "*", "Port" : 8003, "State" : "Running"}]
$
$ curl http://maxscale.mariadb.com:8003/listeners
[ { "Service Name" : "Test Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4006, "State" : "Running"},
{ "Service Name" : "Split Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4007, "State" : "Running"},
{ "Service Name" : "Filter Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4008, "State" : "Running"},
{ "Service Name" : "Named Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4010, "State" : "Running"},
{ "Service Name" : "QLA Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4009, "State" : "Running"},
{ "Service Name" : "Debug Service", "Protocol Module" : "telnetd", "Address" : "localhost", "Port" : 4242, "State" : "Running"},
{ "Service Name" : "CLI", "Protocol Module" : "maxscaled", "Address" : "localhost", "Port" : 6603, "State" : "Running"},
{ "Service Name" : "MaxInfo", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 9003, "State" : "Running"},
{ "Service Name" : "MaxInfo", "Protocol Module" : "HTTPD", "Address" : "*", "Port" : 8003, "State" : "Running"}]
$
```
## Modules
@ -463,18 +463,18 @@ The /listeners URI will return a JSON array with one entry per listener, each en
The /modules URI returns data for each plugin that has been loaded into MaxScale. The plugin name, type and version are returned as is the version of the plugin API that the plugin was built against and the release status of the plugin.
```
$ curl http://maxscale.mariadb.com:8003/modules
[ { "Module Name" : "HTTPD", "Module Type" : "Protocol", "Version" : "V1.0.1", "API Version" : "1.0.0", "Status" : "In Development"},
{ "Module Name" : "maxscaled", "Module Type" : "Protocol", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "GA"},
{ "Module Name" : "telnetd", "Module Type" : "Protocol", "Version" : "V1.0.1", "API Version" : "1.0.0", "Status" : "GA"},
{ "Module Name" : "MySQLClient", "Module Type" : "Protocol", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "GA"},
{ "Module Name" : "mysqlmon", "Module Type" : "Monitor", "Version" : "V1.4.0", "API Version" : "1.0.0", "Status" : "GA"},
{ "Module Name" : "readwritesplit", "Module Type" : "Router", "Version" : "V1.0.2", "API Version" : "1.0.0", "Status" : "GA"},
{ "Module Name" : "readconnroute", "Module Type" : "Router", "Version" : "V1.1.0", "API Version" : "1.0.0", "Status" : "GA"},
{ "Module Name" : "debugcli", "Module Type" : "Router", "Version" : "V1.1.1", "API Version" : "1.0.0", "Status" : "GA"},
{ "Module Name" : "cli", "Module Type" : "Router", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "GA"},
{ "Module Name" : "maxinfo", "Module Type" : "Router", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "Alpha"}]
$
$ curl http://maxscale.mariadb.com:8003/modules
[ { "Module Name" : "HTTPD", "Module Type" : "Protocol", "Version" : "V1.0.1", "API Version" : "1.0.0", "Status" : "In Development"},
{ "Module Name" : "maxscaled", "Module Type" : "Protocol", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "GA"},
{ "Module Name" : "telnetd", "Module Type" : "Protocol", "Version" : "V1.0.1", "API Version" : "1.0.0", "Status" : "GA"},
{ "Module Name" : "MySQLClient", "Module Type" : "Protocol", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "GA"},
{ "Module Name" : "mysqlmon", "Module Type" : "Monitor", "Version" : "V1.4.0", "API Version" : "1.0.0", "Status" : "GA"},
{ "Module Name" : "readwritesplit", "Module Type" : "Router", "Version" : "V1.0.2", "API Version" : "1.0.0", "Status" : "GA"},
{ "Module Name" : "readconnroute", "Module Type" : "Router", "Version" : "V1.1.0", "API Version" : "1.0.0", "Status" : "GA"},
{ "Module Name" : "debugcli", "Module Type" : "Router", "Version" : "V1.1.1", "API Version" : "1.0.0", "Status" : "GA"},
{ "Module Name" : "cli", "Module Type" : "Router", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "GA"},
{ "Module Name" : "maxinfo", "Module Type" : "Router", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "Alpha"}]
$
```
## Sessions
@ -482,31 +482,31 @@ The /modules URI returns data for each plugin that has been loaded into MaxScale
The /sessions URI returns a JSON array with an object for each active session within MaxScale.
```
$ curl http://maxscale.mariadb.com:8003/sessions
[ { "Session" : "0x1a8e9a0", "Client" : "80.176.79.245", "Service" : "MaxInfo", "State" : "Session ready for routing"},
{ "Session" : "0x1a8e6d0", "Client" : "80.240.130.35", "Service" : "MaxInfo", "State" : "Session ready for routing"},
{ "Session" : "0x1a8ddd0", "Client" : , "Service" : "MaxInfo", "State" : "Listener Session"},
{ "Session" : "0x1a92da0", "Client" : , "Service" : "MaxInfo", "State" : "Listener Session"},
{ "Session" : "0x1a92ac0", "Client" : , "Service" : "CLI", "State" : "Listener Session"},
{ "Session" : "0x1a70e90", "Client" : , "Service" : "Debug Service", "State" : "Listener Session"},
{ "Session" : "0x1a758d0", "Client" : , "Service" : "QLA Service", "State" : "Listener Session"},
{ "Session" : "0x1a73a90", "Client" : , "Service" : "Named Service", "State" : "Listener Session"},
{ "Session" : "0x1a5c0b0", "Client" : , "Service" : "Filter Service", "State" : "Listener Session"},
{ "Session" : "0x1a5c530", "Client" : , "Service" : "Split Service", "State" : "Listener Session"},
{ "Session" : "0x19ac1c0", "Client" : , "Service" : "Test Service", "State" : "Listener Session"}]
$
$ curl http://maxscale.mariadb.com:8003/sessions
[ { "Session" : "0x1a8e9a0", "Client" : "80.176.79.245", "Service" : "MaxInfo", "State" : "Session ready for routing"},
{ "Session" : "0x1a8e6d0", "Client" : "80.240.130.35", "Service" : "MaxInfo", "State" : "Session ready for routing"},
{ "Session" : "0x1a8ddd0", "Client" : , "Service" : "MaxInfo", "State" : "Listener Session"},
{ "Session" : "0x1a92da0", "Client" : , "Service" : "MaxInfo", "State" : "Listener Session"},
{ "Session" : "0x1a92ac0", "Client" : , "Service" : "CLI", "State" : "Listener Session"},
{ "Session" : "0x1a70e90", "Client" : , "Service" : "Debug Service", "State" : "Listener Session"},
{ "Session" : "0x1a758d0", "Client" : , "Service" : "QLA Service", "State" : "Listener Session"},
{ "Session" : "0x1a73a90", "Client" : , "Service" : "Named Service", "State" : "Listener Session"},
{ "Session" : "0x1a5c0b0", "Client" : , "Service" : "Filter Service", "State" : "Listener Session"},
{ "Session" : "0x1a5c530", "Client" : , "Service" : "Split Service", "State" : "Listener Session"},
{ "Session" : "0x19ac1c0", "Client" : , "Service" : "Test Service", "State" : "Listener Session"}]
$
```
## Clients
The /clients URI is a limited version of the /sessions, in this case it only returns an entry for a session that represents a client connection.
```
$ curl http://maxscale.mariadb.com:8003/clients
[ { "Session" : "0x1a90be0", "Client" : "80.176.79.245", "Service" : "MaxInfo", "State" : "Session ready for routing"},
{ "Session" : "0x1a8e9a0", "Client" : "127.0.0.1", "Service" : "MaxInfo", "State" : "Session ready for routing"},
{ "Session" : "0x1a8e6d0", "Client" : "80.240.130.35", "Service" : "MaxInfo", "State" : "Session ready for routing"}]
$
$ curl http://maxscale.mariadb.com:8003/clients
[ { "Session" : "0x1a90be0", "Client" : "80.176.79.245", "Service" : "MaxInfo", "State" : "Session ready for routing"},
{ "Session" : "0x1a8e9a0", "Client" : "127.0.0.1", "Service" : "MaxInfo", "State" : "Session ready for routing"},
{ "Session" : "0x1a8e6d0", "Client" : "80.240.130.35", "Service" : "MaxInfo", "State" : "Session ready for routing"}]
$
```
## Servers
@ -514,12 +514,12 @@ The /clients URI is a limited version of the /sessions, in this case it only ret
The /servers URI is used to retrieve information for each of the servers defined within the MaxScale configuration. This information includes the connection count and the current status as monitored by MaxScale. The connection count is only those connections made by MaxScale to those servers.
```
$ curl http://maxscale.mariadb.com:8003/servers
[ { "Server" : "server1", "Address" : "127.0.0.1", "Port" : 3306, "Connections" : 0, "Status" : "Running"},
{ "Server" : "server2", "Address" : "127.0.0.1", "Port" : 3307, "Connections" : 0, "Status" : "Down"},
{ "Server" : "server3", "Address" : "127.0.0.1", "Port" : 3308, "Connections" : 0, "Status" : "Down"},
{ "Server" : "server4", "Address" : "127.0.0.1", "Port" : 3309, "Connections" : 0, "Status" : "Down"}]
$
$ curl http://maxscale.mariadb.com:8003/servers
[ { "Server" : "server1", "Address" : "127.0.0.1", "Port" : 3306, "Connections" : 0, "Status" : "Running"},
{ "Server" : "server2", "Address" : "127.0.0.1", "Port" : 3307, "Connections" : 0, "Status" : "Down"},
{ "Server" : "server3", "Address" : "127.0.0.1", "Port" : 3308, "Connections" : 0, "Status" : "Down"},
{ "Server" : "server4", "Address" : "127.0.0.1", "Port" : 3309, "Connections" : 0, "Status" : "Down"}]
$
```
## Event Times
@ -527,35 +527,35 @@ The /servers URI is used to retrieve information for each of the servers defined
The /event/times URI returns an array of statistics that reflect the performance of the event queuing and execution portion of the MaxScale core. Each element is an object that represents a time bucket, in 100ms increments, with the counts representing the number of events that were in the event queue for the length of time that row represents and the number of events that were executing of the time indicated by the object.
```
$ curl http://maxscale.mariadb.com:8003/event/times
[ { "Duration" : "< 100ms", "No. Events Queued" : 64, "No. Events Executed" : 63},
{ "Duration" : " 100 - 200ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 200 - 300ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 300 - 400ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 400 - 500ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 500 - 600ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 600 - 700ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 700 - 800ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 800 - 900ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 900 - 1000ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1000 - 1100ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1100 - 1200ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1200 - 1300ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1300 - 1400ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1400 - 1500ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1500 - 1600ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1600 - 1700ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1700 - 1800ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1800 - 1900ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1900 - 2000ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2000 - 2100ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2100 - 2200ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2200 - 2300ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2300 - 2400ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2400 - 2500ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2500 - 2600ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2600 - 2700ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2700 - 2800ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2800 - 2900ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "> 3000ms", "No. Events Queued" : 0, "No. Events Executed" : 0}]
$ curl http://maxscale.mariadb.com:8003/event/times
[ { "Duration" : "< 100ms", "No. Events Queued" : 64, "No. Events Executed" : 63},
{ "Duration" : " 100 - 200ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 200 - 300ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 300 - 400ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 400 - 500ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 500 - 600ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 600 - 700ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 700 - 800ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 800 - 900ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 900 - 1000ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1000 - 1100ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1100 - 1200ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1200 - 1300ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1300 - 1400ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1400 - 1500ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1500 - 1600ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1600 - 1700ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1700 - 1800ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1800 - 1900ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1900 - 2000ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2000 - 2100ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2100 - 2200ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2200 - 2300ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2300 - 2400ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2400 - 2500ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2500 - 2600ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2600 - 2700ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2700 - 2800ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2800 - 2900ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "> 3000ms", "No. Events Queued" : 0, "No. Events Executed" : 0}]
```

View File

@ -46,67 +46,73 @@ 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
```
[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
[ndb_mgmd]
hostname=178.62.38.199
id=21
datadir=/var/lib/mysql-cluster
[ndbd]
hostname=178.62.38.199
[mysqld]
hostname=178.62.38.199
[ndbd]
hostname=162.243.90.81
[mysqld]
hostname=162.243.90.81
[ndbd]
hostname=178.62.38.199
[ndbd]
hostname=162.243.90.81
```
Note, it’s possible to specify all node ids and datadir as well for each cluster component
Example:
[ndbd]
hostname=162.243.90.81
id=43
datadir=/usr/local/mysql/data
```
[ndbd]
hostname=162.243.90.81
id=43
datadir=/usr/local/mysql/data
```
and /etc/my.cnf, copied as well in all servers
[mysqld]
ndbcluster
ndb-connectstring=178.62.38.199
innodb_buffer_pool_size=16M
```
[mysqld]
ndbcluster
ndb-connectstring=178.62.38.199
innodb_buffer_pool_size=16M
[mysql_cluster]
ndb-connectstring=178.62.38.199
[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, followed by the data nodes, and then finally by 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
```
[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@server1 ~]# ndbd —-initial -—initial-start
[root@server2 ~]# 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@server1 ~]# /etc/init.d/mysql start
[root@server2 ~]# /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.
@ -114,7 +120,7 @@ If all has gone well, and the cluster has been set up correctly, the cluster sho
It’s possible to test this by invoking the ndb_mgm management node client.
The output should look like that shown here, although you might see some slight differences in the output depending upon the exact version of MySQL that you are using:
```
[root@server1 ~]# ndb_mgm
-- NDB Cluster -- Management Client --
@ -127,216 +133,217 @@ Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
[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=24 @178.62.38.199 (mysql-5.5.38 ndb-7.2.17, Nodegroup: 0, *)
id=22 @178.62.38.199 (mysql-5.5.38 ndb-7.2.17)
id=25 @162.243.90.81 (mysql-5.5.38 ndb-7.2.17, Nodegroup: 0)
id=23 @162.243.90.81 (mysql-5.5.38 ndb-7.2.17)
[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:
- First create a table with NDBCLUSTER engine:
```
[root@server1 ~]# mysql
mysql> CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) ENGINE=NDBCLUSTER;
mysql> CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) ENGINE=NDBCLUSTER;
Query OK, 0 rows affected (3.28 sec)
Query OK, 0 rows affected (3.28 sec)
mysql> show create table t1;
mysql> show create table t1;
+------- +-------------------------------------------------------------------------------------------+
| Table | Create Table |
+------- +-------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+-------------------------------------------------------------------------------------------+
+-------+-------------------------------------------------------------------------------------------+
| t1 | CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
| t1 | CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 |
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 |
+-------+-------------------------------------------------------------------------------------------+
+-------+-------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
1 row in set (0.01 sec)
```
- Just add a row in the table:
```
mysql> insert into test.t1 values(11);
- Just add a row in the table:
Query OK, 1 row affected (0.15 sec)
```
- Select the current number of rows:
```
mysql> select count(1) from t1;
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)
+----------+
| 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;
mysql> select count(1) from test.t1;
+----------+
| count(1) |
+----------+
| 1 |
+----------+
1 row in set (0.08 sec)
+----------+
| count(1) |
+----------+
| 1 |
+----------+
1 row in set (0.08 sec)
```
## Configuring MaxScale for connection load balancing of SQL nodes
Add these sections in maxscale.cnf config file:
```
[Cluster Service]
type=service
router=readconnroute
router_options=ndb
servers=server1,server2
user=test
passwd=test
version_string=5.5.37-CLUSTER
[Cluster Service]
type=service
router=readconnroute
router_options=ndb
servers=server1,server2
user=test
passwd=test
version_string=5.5.37-CLUSTER
[Cluster Listener]
type=listener
service=Cluster Service
protocol=MySQLClient
port=4906
[Cluster Listener]
type=listener
service=Cluster Service
protocol=MySQLClient
port=4906
[NDB Cluster Monitor]
type=monitor
module=ndbclustermon
servers=server1,server2
user=monitor
passwd=monitor
monitor_interval=8000
[NDB Cluster Monitor]
type=monitor
module=ndbclustermon
servers=server1,server2
user=monitor
passwd=monitor
monitor_interval=8000
[server1]
[server1]
#SQL node1
type=server
address=127.0.0.1
port=3306
protocol=MySQLBackend
[server2]
#SQL node2
type=server
address=162.243.90.81
port=3306
protocol=MySQLBackend
#SQL node1
type=server
address=127.0.0.1
port=3306
protocol=MySQLBackend
[server2]
#SQL node2
type=server
address=162.243.90.81
port=3306
protocol=MySQLBackend
```
Assuming MaxScale is installed in server1, start it
```
[root@server1 ~]# cd /usr/bin
[root@server1 ~]# cd /usr/bin
[root@server1 bin]# ./maxscale -c ../
[root@server1 bin]# ./maxscale -c ../
```
Using the debug interface it’s possible to check the status of monitored servers
```
MaxScale> show monitors
MaxScale> show monitors
Monitor: 0x387b880
Monitor: 0x387b880
Name: NDB Cluster Monitor
Monitor running
Sampling interval: 8000 milliseconds
Monitored servers: 127.0.0.1:3306, 162.243.90.81:3306
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
MaxScale> show servers
Server 0x3873b40 (server1)
Server 0x3873b40 (server1)
Server: 127.0.0.1
Status: NDB, Running
Protocol: MySQLBackend
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: 127.0.0.1
Status: NDB, Running
Protocol: MySQLBackend
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: MySQLBackend
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
Server 0x3873a40 (server2)
Server: 162.243.90.81
Status: NDB, Running
Protocol: MySQLBackend
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'"
[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 |
+---------------------+-------+
+---------------------+-------+
| 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 |
+---------------------+-------+
[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 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"
[root@server1 ~] mysql -h 127.0.0.1 -P 4906 -utest -ptest -e "SELECT COUNT(1) FROM test.t1"
+----------+
| COUNT(1) |
+----------+
| 1 |
+----------+
+----------+
| 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 |
+----------+
```
[root@server1 ~] mysql -h 127.0.0.1 -P 4906 -utest -ptest -e "SELECT COUNT(1) FROM test.t1"
+----------+
| COUNT(1) |
+----------+
| 2 |
+----------+
```

View File

@ -36,18 +36,23 @@ The first user required must be able to select data from the table mysql.user, t
2. Create the user, substituting the username, password and host on which maxscale runs within your environment
```
MariaDB [(none)]> create user '*username*'@'*maxscalehost*' identified by '*password*';
**Query OK, 0 rows affected (0.00 sec)**
```
3. Grant select privileges on the mysql.user table.
```
MariaDB [(none)]> grant SELECT on mysql.user to '*username*'@'*maxscalehost*';
**Query OK, 0 rows affected (0.03 sec)**
```
Additionally, GRANT SELECT on the mysql.db table and SHOW DATABASES privileges are required in order to load databases name and grants suitable for database name authorization.
```
MariaDB [(none)]> GRANT SELECT ON mysql.db TO 'username'@'maxscalehost';
**Query OK, 0 rows affected (0.00 sec)**
@ -56,8 +61,10 @@ MariaDB [(none)]> GRANT SHOW DATABASES ON *.* TO 'username'@'maxscalehost';
**Query OK, 0 rows affected (0.00 sec)**
```
The second user is used to monitored the state of the cluster. This user, which may be the same username as the first, requires permissions to access the various sources of monitoring data. In order to monitor a replication cluster this user must be granted the roles REPLICATION SLAVE and REPLICATION CLIENT
```
MariaDB [(none)]> grant REPLICATION SLAVE on *.* to '*username*'@'*maxscalehost*';
**Query OK, 0 rows affected (0.00 sec)**
@ -66,6 +73,7 @@ MariaDB [(none)]> grant REPLICATION CLIENT on *.* to '*username*'@'*maxscalehost
**Query OK, 0 rows affected (0.00 sec)**
```
If you wish to use two different usernames for the two different roles of monitoring and collecting user information then create a different username using the first two steps from above.
## Creating Your MaxScale Configuration
@ -74,160 +82,139 @@ MaxScale configuration is held in an ini file that is located in the file maxsca
A global, maxscale, section is included within every MaxScale configuration file; this is used to set the values of various MaxScale wide parameters, perhaps the most important of these is the number of threads that MaxScale will use to execute the code that forwards requests and handles responses for clients.
```
[maxscale]
threads=4
```
The first step is to create a service for our Read/Write Splitter. Create a section in your MaxScale.ini file and set the type to service, the section names are the names of the services themselves and should be meaningful to the administrator. Names may contain whitespace.
```
[Splitter Service]
type=service
```
The router for we need to use for this configuration is the readwritesplit module, also the services should be provided with the list of servers that will be part of the cluster. The server names given here are actually the names of server sections in the configuration file and not the physical hostnames or addresses of the servers.
```
[Splitter Service]
type=service
router=readwritesplit
servers=dbserv1, dbserv2, dbserv3
```
The final step in the service sections is to add the username and password that will be used to populate the user data from the database cluster. There are two options for representing the password, either plain text or encrypted passwords may be used. In order to use encrypted passwords a set of keys must be generated that will be used by the encryption and decryption process. To generate the keys use the maxkeys command and pass the name of the secrets file in which the keys are stored.
% maxkeys /var/lib/maxscale/.secrets
```
maxkeys /var/lib/maxscale/.secrets
%
```
Once the keys have been created the maxpasswd command can be used to generate the encrypted password.
% maxpasswd plainpassword
```
maxpasswd plainpassword
96F99AA1315BDC3604B006F427DD9484
%
```
The username and password, either encrypted or plain text, are stored in the service section using the user and passwd parameters.
```
[Splitter Service]
type=service
router=readwritesplit
servers=dbserv1, dbserv2, dbserv3
user=maxscale
passwd=96F99AA1315BDC3604B006F427DD9484
```
This completes the definitions required by the service, however listening ports must be associated with the service in order to allow network connections. This is done by creating a series of listener sections. This section again is named for the convenience of the administrator and should be of type listener with an entry labeled service which contains the name of the service to associate the listener with. A service may have multiple listeners.
```
[Splitter Listener]
type=listener
service=Splitter Service
```
A listener must also define the protocol module it will use for the incoming network protocol, currently this should be the MySQLClient protocol for all database listeners. The listener may then supply a network port to listen on and/or a socket within the file system.
```
[Splitter Listener]
type=listener
service=Splitter Service
protocol=MySQLClient
port=3306
socket=/tmp/ClusterMaster
```
An address parameter may be given if the listener is required to bind to a particular network address when using hosts with multiple network addresses. The default behaviour is to listen on all network interfaces.
The next stage is the configuration is to define the server information. This defines how to connect to each of the servers within the cluster, again a section is created for each server, with the type set to server, the network address and port to connect to and the protocol to use to connect to the server. Currently the protocol module for all database connections in MySQLBackend.
```
[dbserv1]
type=server
address=192.168.2.1
port=3306
protocol=MySQLBackend
[dbserv2]
type=server
address=192.168.2.2
port=3306
protocol=MySQLBackend
[dbserv3]
type=server
address=192.168.2.3
port=3306
protocol=MySQLBackend
```
In order for MaxScale to monitor the servers using the correct monitoring mechanisms a section should be provided that defines the monitor to use and the servers to monitor. Once again a section is created with a symbolic name for the monitor, with the type set to monitor. Parameters are added for the module to use, the list of servers to monitor and the username and password to use when connecting to the the servers with the monitor.
```
[Replication Monitor]
type=monitor
module=mysqlmon
servers=dbserv1, dbserv2, dbserv3
user=maxscale
passwd=96F99AA1315BDC3604B006F427DD9484
```
As with the password definition in the server either plain text or encrypted passwords may be used.
The final stage in the configuration is to add the option service which is used by the maxadmin command to connect to MaxScale for monitoring and administration purposes. This creates a service section and a listener section.
```
[CLI]
type=service
router=cli
[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
address=localhost
port=6603
```
In the case of the example above it should be noted that an address parameter has been given to the listener, this limits connections to maxadmin commands that are executed on the same machine that hosts MaxScale.
# Starting MaxScale
Upon completion of the configuration process MaxScale is ready to be started for the first time. This may either be done manually by running the maxscale command or via the service interface.
```
% maxscale
```
or
```
% service maxscale start
```
Check the error log in /var/log/maxscale to see if any errors are detected in the configuration file and to confirm MaxScale has been started. Also the maxadmin command may be used to confirm that MaxScale is running and the services, listeners etc have been correctly configured.
```
% maxadmin -pmariadb list services
Services.
@ -277,8 +264,8 @@ Splitter Service | MySQLClient | * | 3306 | Running
CLI | maxscaled | localhost | 6603 | Running
---------------------+--------------------+-----------------+-------+--------
```
%
MaxScale is now ready to start accepting client connections and routing them to the master or slaves within your cluster. Other configuration options are available that can alter the criteria used for routing, these include monitoring the replication lag within the cluster and routing only to slaves that are within a predetermined delay from the current master or using weights to obtain unequal balancing operations. These options may be found in the MaxScale Configuration Guide. More detail on the use of maxadmin can be found in the document "MaxAdmin - The MaxScale Administration & Monitoring Client Application".

View File

@ -45,17 +45,17 @@ In order to use these scripts on your Nagios Server, you need to copy them from
MaxScale must be configured with 'maxscaled' protocol for the administration interface:
Example of maxscale.cnf file:
```
[AdminInterface]
type=service
router=cli
[AdminInterface]
type=service
router=cli
[AdminListener]
type=listener
service=AdminInterface
protocol=maxscaled
port=6603
[AdminListener]
type=listener
service=AdminInterface
protocol=maxscaled
port=6603
```
## Prepare Nagios configuration files.
Assuming Nagios installed on a separated server and the plugins are in /usr/lib64/nagios/plugins and configuration files are in /etc/nagios:
@ -66,8 +66,10 @@ Assuming Nagios installed on a separated server and the plugins are in /usr/lib6
and add (just after localhost.cfg or commnads.cfg)
cfg_file=/etc/nagios/objects/maxscale_commands.cfg
cfg_file=/etc/nagios/objects/server1.cfg
```
cfg_file=/etc/nagios/objects/maxscale_commands.cfg
cfg_file=/etc/nagios/objects/server1.cfg
```
### Please note:
- modify server IP address in server1.cfg, pointing to MaxScale server
@ -80,6 +82,7 @@ and add (just after localhost.cfg or commnads.cfg)
This example shows configuration that needs to be done on Nagios server in order to communicate to MaxScale server that is running on host server1.
In this example we are using the check_maxscale_resource as the check command
```
#Check MaxScale sessions, on the remote machine.
define service{
use local-service
@ -88,6 +91,7 @@ In this example we are using the check_maxscale_resource as the check command
check_command check_maxscale_resource!6603!admin!mariadb!sessions!/path_to/maxadmin
notifications_enabled 0
}
```
### Check new running monitors
* Restart Nagios and check new monitors are running in HTTP Interface "Current Status -> Services" on Nagios Server
@ -143,15 +147,17 @@ In this example we are using the check_maxscale_resource as the check command
# Output description:
Example for 'services'
```
#./check_maxscale_resources.pl -r resources
#./check_maxscale_resources.pl -r resources
OK: 7 services found | services1=RW_Router;readwritesplit;1;1 services2=RW_Split;readwritesplit;1;1 services3=Test Service;readconnroute;1;1 services4=Master Service;readconnroute;2;2 services5=Debug Service;debugcli;1;1 services6=CLI;cli;2;145 services7=MaxInfo;maxinfo;2;2
OK: 7 services found | services1=RW_Router;readwritesplit;1;1 services2=RW_Split;readwritesplit;1;1 services3=Test Service;readconnroute;1;1 services4=Master Service;readconnroute;2;2 services5=Debug Service;debugcli;1;1 services6=CLI;cli;2;145 services7=MaxInfo;maxinfo;2;2
```
Returns OK and the number of services
Returns CRITICAL if no services are found
The data after | char are so called performance data and may be collected by Nagios
output format is:
servicex=Name;router_module;NumUsers;TotalSessions
```
servicex=Name;router_module;NumUsers;TotalSessions
```

View File

@ -34,11 +34,12 @@ It tries to send data and if there is any failure (timeout, server is down, etc)
This feature is not enabled by default: MaxScale must be configured in [feedback] section:
[feedback]
feedback_enable=1
feedback_url=https://enterprise.mariadb.com/feedback/post
feedback_user_info=x-y-z-w
```
[feedback]
feedback_enable=1
feedback_url=https://enterprise.mariadb.com/feedback/post
feedback_user_info=x-y-z-w
```
The activation code that will be provided by MariaDB corp upon request by the customer and it should be put in feedback_user_info.
@ -63,32 +64,33 @@ MaxScale shall send the generated feedback report to a feedback server specified
If it’s not possible to send data due to firewall or security settings the report could be generated manually (feedback_user_info is required) via MaxAdmin
```
MaxScale>show feedbackreport
```
Report could be saved to report.txt file:
```
maxadmin -uxxx -pyyy show feedbackreport > ./report.txt
curl -F data=@./report.txt https://mariadb.org/feedback_plugin/post
```
Report Example:
FEEDBACK_SERVER_UID 6B5C44AEA73137D049B02E6D1C7629EF431A350F
FEEDBACK_USER_INFO 0467009f-b04d-45b1-a77b-b6b2ec9c6cf4
VERSION 1.0.6-unstable
NOW 1425914890
PRODUCT maxscale
Uname_sysname Linux
Uname_distribution CentOS release 6.5 (Final)
module_maxscaled_type Protocol
module_maxscaled_version V1.0.0
module_maxscaled_api 1.0.0
module_maxscaled_releasestatus GA
module_telnetd_type Protocol
module_telnetd_version V1.0.1
module_telnetd_api 1.0.0
module_telnetd_releasestatus GA
```
FEEDBACK_SERVER_UID 6B5C44AEA73137D049B02E6D1C7629EF431A350F
FEEDBACK_USER_INFO 0467009f-b04d-45b1-a77b-b6b2ec9c6cf4
VERSION 1.0.6-unstable
NOW 1425914890
PRODUCT maxscale
Uname_sysname Linux
Uname_distribution CentOS release 6.5 (Final)
module_maxscaled_type Protocol
module_maxscaled_version V1.0.0
module_maxscaled_api 1.0.0
module_maxscaled_releasestatus GA
module_telnetd_type Protocol
module_telnetd_version V1.0.1
module_telnetd_api 1.0.0
module_telnetd_releasestatus GA
```

View File

@ -10,31 +10,31 @@ The software install setup provides RPM and DEB packaging and traditional compil
On Centos 6.5 using fedora / RHEL rpm get the rpm from [http://www.rabbitmq.com/](http://www.rabbitmq.com/ "RabbitMQ")
rabbitmq-server-3.3.4-1.noarch.rpm
rabbitmq-server-3.3.4-1.noarch.rpm
Please note, before installing RabbitMQ, you must install Erlang.
Example:
yum install erlang
Package erlang-R14B-04.3.el6.x86_64 already installed and latest version
yum install erlang
Package erlang-R14B-04.3.el6.x86_64 already installed and latest version
## Step 2 - Install and Start the Server
Install the packages using your distribution's package manager and start the server:
yum install rabbitmq-server-3.3.4-1.noarch.rpm
systemctl start rabbitmq-server.service
yum install rabbitmq-server-3.3.4-1.noarch.rpm
systemctl start rabbitmq-server.service
To configure your RabbitMQ server, please refer to the RabbitMQ website: [http://www.rabbitmq.com/](http://www.rabbitmq.com/ RabbitMQ website).
rabbitmqctl is a command line tool for managing a RabbitMQ broker. It performs all actions by connecting to one of the broker's nodes.
rabbitmqctl list_queues
rabbitmqctl list_queues | list_exchanges| cluster_status | list_bindings | list_connections | list_consumers | status
```
rabbitmqctl list_queues
rabbitmqctl list_queues | list_exchanges| cluster_status | list_bindings | list_connections | list_consumers | status
```
Example output:
```
[root@maxscale-02 MaxScale]# rabbitmqctl status
Status of node 'rabbit@maxscale-02' ...
[{pid,12251},
@ -57,13 +57,13 @@ Example output:
Listing bindings ...
x1 exchange q1 queue k1 []
...done.
```
Interaction with the server may require stop & reset at some point:
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app
```
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app
```
## Step 3 - Install and test the client libraries
The selected library for MaxScale integration of RabbitMQ is:
@ -72,13 +72,13 @@ The selected library for MaxScale integration of RabbitMQ is:
### Manual software compilation
To compile the RabbitMQ-C libraries manually:
git clone https://github.com/alanxz/rabbitmq-c.git
cd rabbitmq-c
cmake -DCMAKE_INSTALL_PREFIX=/usr .
make
make install
```
git clone https://github.com/alanxz/rabbitmq-c.git
cd rabbitmq-c
cmake -DCMAKE_INSTALL_PREFIX=/usr .
make
make install
```
Please note, this will install the packages to /usr. If you do not wish to install them to this location, provide a different value for the CMAKE_INSTALL_PREFIX variable.
@ -87,19 +87,17 @@ Please note, this will install the packages to /usr. If you do not wish to insta
Check how to configure your distribution for the EPEL repository: [https://fedoraproject.org/wiki/EPEL](https://fedoraproject.org/wiki/EPEL EPEL)
Configure your repositories and install the software:
yum install librabbitmq.x86_64
```
yum install librabbitmq.x86_64
```
you might also like to install:
librabbitmq-tools.x86_64, librabbitmq-devel.x86_64
```
librabbitmq-tools.x86_64, librabbitmq-devel.x86_64
```
Please note you may also install the rabbitmq server from the EPEL repository:
yum install rabbitmq-server
```
yum install rabbitmq-server
```
### Basic tests with library
@ -108,150 +106,146 @@ The required library librabbitmq-c is now installed and we continue with basic o
Please note, those example applications may not be included in the RPM library packages.
#### Test 1 - create the exchange
[root@maxscale-02 examples]# ./amqp_exchange_declare
Usage: amqp_exchange_declare host port exchange exchangetype
```
[root@maxscale-02 examples]# ./amqp_exchange_declare
Usage: amqp_exchange_declare host port exchange exchangetype
```
Declare the exchange:
[root@maxscale-02 examples]# ./amqp_exchange_declare 127.0.0.1 5672 foo direct
```
[root@maxscale-02 examples]# ./amqp_exchange_declare 127.0.0.1 5672 foo direct
```
#### Test 2 - Listen to exchange with selected binding key
[root@maxscale-02 examples]# ./amqp_listen
Usage: amqp_listen host port exchange bindingkey
```
[root@maxscale-02 examples]# ./amqp_listen
Usage: amqp_listen host port exchange bindingkey
```
Start the listener:
[root@maxscale-02 examples]# ./amqp_listen 127.0.0.1 5672 foo k1 &
```
[root@maxscale-02 examples]# ./amqp_listen 127.0.0.1 5672 foo k1 &
```
#### Test 3 - Send a message …
[root@maxscale-02 examples]# ./amqp_sendstring
Usage: amqp_sendstring host port exchange routingkey messagebody
[root@maxscale-02 examples]# ./amqp_sendstring 127.0.0.1 5672 foo k1 “This is a new message”
```
[root@maxscale-02 examples]# ./amqp_sendstring
Usage: amqp_sendstring host port exchange routingkey messagebody
```
[root@maxscale-02 examples]# ./amqp_sendstring 127.0.0.1 5672 foo k1 “This is a new message”
```
... and watch the listener output
Delivery 1, exchange foo routingkey k1
Content-type: text/plain
```
Delivery 1, exchange foo routingkey k1
Content-type: text/plain
```
## Step 4 - MaxScale integration with librabbitmq-c
A new filter (mqfilter.c) is implemented in order to send messages to the rabbitmq server and a message consumer (rabbitmq_consumer/consumer.c) program will get messages and store them into a MySQL/MariaDB database.
A quick way to install MaxScale with the RabbitMQ filter is to go to the MaxScale source directory and run the following commands:
mkdir build
cd build
cmake .. -DBUILD_RABBITMQ=Y
make
make install
```
mkdir build
cd build
cmake .. -DBUILD_RABBITMQ=Y
make
make install
```
To build the RabbitMQ filter CMake needs an additional parameter:
-DBUILD_RABBITMQ=Y
```
-DBUILD_RABBITMQ=Y
```
If the librabbitmq-c library is manually compiled it may be necessary to manually pass the location of the libraries and header files to CMake.
Libraries:
-DRABBITMQ_LIBRARIES=<path to RabbitMQ-c libraries>
```
-DRABBITMQ_LIBRARIES=<path to RabbitMQ-c libraries>
```
Headers:
-DRABBITMQ_HEADERS=<path to RabbitMQ-c headers>
```
-DRABBITMQ_HEADERS=<path to RabbitMQ-c headers>
```
Please note, Message Queue Consumer (consumer.c) also needs to be compiled with MySQL/MariaDB client libraries in addition to the RabbitMQ-c libraries. If you have your MySQL/MariaDB client libraries and headers in non-standard locations, you can pass them manually to CMake:
Libraries:
-DMYSQLCLIENT_LIBRARIES=<path to libraries>
```
-DMYSQLCLIENT_LIBRARIES=<path to libraries>
```
Headers:
-DMYSQLCLIENT_HEADERS=<path to headers>
```
-DMYSQLCLIENT_HEADERS=<path to headers>
```
The message queue consumer must be also built as a separate task, it’s not built as part of MaxScale build system. To build it, run the following commands in the rabbitmq_consumer directory in the MaxScale source folder:
mkdir build
cd build
cmake ..
make
```
mkdir build
cd build
cmake ..
make
```
To install it:
make install
```
make install
```
To build packages:
make package
```
make package
```
This generates RPM or DEB packages based on your system. These packages can then be installed on remote systems for easy access to the data generated by the consumer client.
## Step 5 - Configure new applications
The new filter needs to be configured in maxscale.cnf.
```
[Test Service]
type=service
router=readconnroute
router_options=slave
servers=server1,server2,server3,server5,server4
user=massi
passwd=massi
filters=MQ
[Test Service]
type=service
router=readconnroute
router_options=slave
servers=server1,server2,server3,server5,server4
user=massi
passwd=massi
filters=MQ
[MQ]
type=filter
module=mqfilter
exchange=x1
key=k1
queue=q1
hostname=127.0.0.1
port=5672
logging_trigger=all
[MQ]
type=filter
module=mqfilter
exchange=x1
key=k1
queue=q1
hostname=127.0.0.1
port=5672
logging_trigger=all
```
Logging triggers define whether to log all or a subset of the incoming queries using these options:
```
# log only some elements or all
logging_trigger=[all,source,schema,object]
# log only some elements or all
logging_trigger=[all,source,schema,object]
# Whether to log only SELECT, UPDATE, INSERT and DELETE queries or all possible queries
logging_log_all=true|false
# Whether to log only SELECT, UPDATE, INSERT and DELETE queries or all possible queries
logging_log_all=true|false
# Log only when any of the trigger parameters match or only if all parameters match
logging_strict=true|false
# specify objects
logging_object=mytable,another_table
# specify logged users
logging_source_user=testuser,testuser
# Log only when any of the trigger parameters match or only if all parameters match
logging_strict=true|false
# specify objects
logging_object=mytable,another_table
# specify logged users
logging_source_user=testuser,testuser
# specify source addresses
logging_source_host=127.0.0.1,192.168.10.14
# specify schemas
logging_schema=employees,orders,catalog
# specify source addresses
logging_source_host=127.0.0.1,192.168.10.14
# specify schemas
logging_schema=employees,orders,catalog
```
Example:
logging_trigger=object,schema,source
logging_strict=false
logging_log_all=false
logging_object=my1
logging_schema=test
logging_source_user=maxtest
```
logging_trigger=object,schema,source
logging_strict=false
logging_log_all=false
logging_object=my1
logging_schema=test
logging_source_user=maxtest
```
@ -259,117 +253,118 @@ Example:
The logging result of the example is:
if user maxtest does something, it's logged
and all queries in test schema are logged
anything targeting my1 table is logged
SELECT NOW(), SELECT MD5(“xyz)” are not logged
```
if user maxtest does something, it's logged
and all queries in test schema are logged
anything targeting my1 table is logged
SELECT NOW(), SELECT MD5(“xyz)” are not logged
```
Please note that if we want to log only the user ‘maxtest’ accessing the schema ‘test’ with target ‘my1’ the option logging_strict must be set to TRUE and if we want to include those selects without schema name the option logging_log_all must be set to TRUE.
The mqfilter logs into the MaxScale TRACE log information about the matched logging triggers and the message delivering:
2014 09/03 06:22:04 Trigger is TRG_SOURCE: user: testuser = testuser
2014 09/03 06:22:04 Trigger is TRG_SCHEMA: test = test
2014 09/03 06:22:04 Trigger is TRG_OBJECT: test.t1 = t1
2014 09/03 06:22:04 Routing message to: 127.0.0.1:5672 / as guest/guest, exchange: x1<direct> key:k1 queue:q1
```
2014 09/03 06:22:04 Trigger is TRG_SOURCE: user: testuser = testuser
2014 09/03 06:22:04 Trigger is TRG_SCHEMA: test = test
2014 09/03 06:22:04 Trigger is TRG_OBJECT: test.t1 = t1
2014 09/03 06:22:04 Routing message to: 127.0.0.1:5672 / as guest/guest, exchange: x1<direct> key:k1 queue:q1
```
The consumer application needs to be configured as well:
```
#The options for the consumer are:
#hostname RabbitMQ hostname
#port RabbitMQ port
#vhost RabbitMQ virtual host
#user RabbitMQ username
#passwd RabbitMQ password
#The options for the consumer are:
#hostname RabbitMQ hostname
#port RabbitMQ port
#vhost RabbitMQ virtual host
#user RabbitMQ username
#passwd RabbitMQ password
#queue Name of the queue to use
#dbserver SQL server name
#dbport SQL server port
#dbname Name of the database to use
#dbuser SQL server username
#dbpasswd SQL server password
#logfile Message log filename
[consumer]
hostname=127.0.0.1
port=5672
vhost=/
user=guest
passwd=guest
queue=q1
dbserver=127.0.0.1
dbport=3308
dbname=mqpairs
dbuser=xxx
dbpasswd=yyy
#queue Name of the queue to use
#dbserver SQL server name
#dbport SQL server port
#dbname Name of the database to use
#dbuser SQL server username
#dbpasswd SQL server password
#logfile Message log filename
[consumer]
hostname=127.0.0.1
port=5672
vhost=/
user=guest
passwd=guest
queue=q1
dbserver=127.0.0.1
dbport=3308
dbname=mqpairs
dbuser=xxx
dbpasswd=yyy
```
We may probably need to modify LD_LIBRARY_PATH before launching ‘consumer’:
# export LD_LIBRARY_PATH=/packages/rabbitmq-c/rabbitmq-c/librabbitmq:/packages/mariadb_client-2.0.0-Linux/lib/mariadb:/usr/lib64
```
# export LD_LIBRARY_PATH=/packages/rabbitmq-c/rabbitmq-c/librabbitmq:/packages/mariadb_client-2.0.0-Linux/lib/mariadb:/usr/lib64
```
and finally we can launch it:
# ./consumer
```
# ./consumer
```
If the consumer.cnf file is not in the same directory as the binary file is, you can provide the location of the folder that it is in by passing it the -c flag followed by the path:
# ./consumer -c path/to/file
# ./consumer -c path/to/file
and start maxScale as well
## Step 6 - Test the filter and check collected data
Assuming that MaxScale and the message consumer are successfully running let’s connect to the service with an active mqfilter:
```
[root@maxscale-02 MaxScale]# mysql -h 127.0.0.1 -P 4506 -uxxx -pyyy
...
MariaDB [(none)]> select RAND(3), RAND(5);
+--------------------+---------------------+
| RAND(3) | RAND(5) |
+--------------------+---------------------+
| 0.9057697559760601 | 0.40613597483014313 |
+--------------------+---------------------+
1 row in set (0.01 sec)
MariaDB [(none)]> select RAND(3544), RAND(11);
```
[root@maxscale-02 MaxScale]# mysql -h 127.0.0.1 -P 4506 -uxxx -pyyy
...
MariaDB [(none)]> select RAND(3), RAND(5);
+--------------------+---------------------+
| RAND(3) | RAND(5) |
+--------------------+---------------------+
| 0.9057697559760601 | 0.40613597483014313 |
+--------------------+---------------------+
1 row in set (0.01 sec)
MariaDB [(none)]> select RAND(3544), RAND(11);
we can check the consumer output in the terminal where it was started:
--------------------------------------------------------------
Received: 1409671452|select @@version_comment limit ?
Received: 1409671452|Columns: 1
...
Received: 1409671477|select RAND(?), RAND(?)
Received: 1409671477|Columns: 2
We query now the database for the content collected so far:
MariaDB [(none)]> use mqpairs;
Database changed
```
--------------------------------------------------------------
Received: 1409671452|select @@version_comment limit ?
Received: 1409671452|Columns: 1
...
Received: 1409671477|select RAND(?), RAND(?)
Received: 1409671477|Columns: 2
We query now the database for the content collected so far:
MariaDB [(none)]> use mqpairs;
Database changed
MariaDB [mqpairs]> select * from pairs;
+-------------------------------------+----------------------------------+------------+---------------------+---------------------+---------+
| tag | query | reply | date_in | date_out | counter |
+-------------------------------------+----------------------------------+------------+---------------------+---------------------+---------+
| 006c006d006e006f007000710072007374 | select @@version_comment limit ? | Columns: 1 | 2014-09-02 11:14:51 | 2014-09-02 11:26:38 | 3 |
| 00750076007700780079007a007b007c7d | SELECT DATABASE() | Columns: 1 | 2014-09-02 11:14:56 | 2014-09-02 11:27:06 | 3 |
| 007e007f00800081008200830084008586 | show databases | Columns: 1 | 2014-09-02 11:14:56 | 2014-09-02 11:27:06 | 3 |
| 008700880089008a008b008c008d008e8f | show tables | Columns: 1 | 2014-09-02 11:14:56 | 2014-09-02 11:27:06 | 3 |
| 0090009100920093009400950096009798 | select * from mqpairs.pairs | Columns: 6 | 2014-09-02 11:15:00 | 2014-09-02 11:27:00 | 12 |
| 00fc00fd00fe00ff0100010101020103104 | select NOW() | Columns: 1 | 2014-09-02 11:24:23 | 2014-09-02 11:24:23 | 1 |
| 01050106010701080109010a010b010c10d | select RAND(?), RAND(?) | Columns: 2 | 2014-09-02 11:24:37 | 2014-09-02 11:24:37 | 1 |
+-------------------------------------+----------------------------------+------------+---------------------+---------------------+---------+
7 rows in set (0.01 sec)
MariaDB [mqpairs]> select * from pairs;
+-------------------------------------+----------------------------------+------------+---------------------+---------------------+---------+
| tag | query | reply | date_in | date_out | counter |
+-------------------------------------+----------------------------------+------------+---------------------+---------------------+---------+
| 006c006d006e006f007000710072007374 | select @@version_comment limit ? | Columns: 1 | 2014-09-02 11:14:51 | 2014-09-02 11:26:38 | 3 |
| 00750076007700780079007a007b007c7d | SELECT DATABASE() | Columns: 1 | 2014-09-02 11:14:56 | 2014-09-02 11:27:06 | 3 |
| 007e007f00800081008200830084008586 | show databases | Columns: 1 | 2014-09-02 11:14:56 | 2014-09-02 11:27:06 | 3 |
| 008700880089008a008b008c008d008e8f | show tables | Columns: 1 | 2014-09-02 11:14:56 | 2014-09-02 11:27:06 | 3 |
| 0090009100920093009400950096009798 | select * from mqpairs.pairs | Columns: 6 | 2014-09-02 11:15:00 | 2014-09-02 11:27:00 | 12 |
| 00fc00fd00fe00ff0100010101020103104 | select NOW() | Columns: 1 | 2014-09-02 11:24:23 | 2014-09-02 11:24:23 | 1 |
| 01050106010701080109010a010b010c10d | select RAND(?), RAND(?) | Columns: 2 | 2014-09-02 11:24:37 | 2014-09-02 11:24:37 | 1 |
+-------------------------------------+----------------------------------+------------+---------------------+---------------------+---------+
7 rows in set (0.01 sec)
```
The filter send queries to the RabbitMQ server in the canonical format, i.e select RAND(?), RAND(?).
The queries Message Queue Consumer application gets from the server are stored with a counter that quickly shows how many times that normalized query was received:
| 01050106010701080109010a010b010c10d | select RAND(?), RAND(?) | Columns: 2 | 2014-09-02 11:24:37 | 2014-09-02 11:29:15 | 3 |
```
| 01050106010701080109010a010b010c10d | select RAND(?), RAND(?) | Columns: 2 | 2014-09-02 11:24:37 | 2014-09-02 11:29:15 | 3 |
```

View File

@ -29,22 +29,22 @@ Using MaxScale as a replication proxy is much the same as using MaxScale as a pr
## Service Configuration
As with any MaxScale configuration a good starting point is with the service definition with the maxscale.cnf file. The service requires a name which is the section name in the ini file, a type parameter with a value of service and the name of the router plugin that should be loaded. In the case of replication proxies this router name is binlogrouter.
```
[Replication]
type=service
router=binlogrouter
[Replication]
type=service
router=binlogrouter
```
Other standard service parameters need to be given in the configuration section that are used to retrieve the set of users from the backend (master) database, also a version string can be given such that the MaxScale instance will report this version string to the slave servers that connect to MaxScale. The master server entry must also be given. In the current implementation of the router only a single server can be given.
[Replication]
type=service
router=binlogrouter
servers=masterdb
version_string=5.6.17-log
user=maxscale
passwd=Mhu87p2D
```
[Replication]
type=service
router=binlogrouter
servers=masterdb
version_string=5.6.17-log
user=maxscale
passwd=Mhu87p2D
```
The user and passwd entries in the above example are used in order for MaxScale to populate the credential information that is required to allow the slaves to connect to MaxScale. This user should be configured in exactly the same way a for any other MaxScale service, i.e. the user needs access to the mysql.user table and the mysql.db table as well as having the ability to perform a SHOW DATABASES command.
The final configuration requirement is the router specific options. The binlog router requires a set of parameters to be passed, these are passed in the router_options parameter of the service definition as a comma separated list of name value pairs.
@ -62,10 +62,10 @@ As with uuid, MaxScale must have a unique server-id for the connection it makes
This is the user name that MaxScale uses when it connects to the master. This user name must have the rights required for replication as with any other user that a slave uses for replication purposes. If the user parameter is not given in the router options then the same user as is used to retrieve the credential information will be used for the replication connection, i.e. the user in the service entry.
The user that is used for replication, either defined using the user= option in the router options or using the username and password defined of the service must be granted replication privileges on the database server.
MariaDB> CREATE USER 'repl'@'maxscalehost' IDENTIFIED by 'password';
MariaDB> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'maxscalehost';
```
MariaDB> CREATE USER 'repl'@'maxscalehost' IDENTIFIED by 'password';
MariaDB> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'maxscalehost';
```
### password
The password of the above user. If the password is not explicitly given then the password in the service entry will be used. For compatibility with other username and password definitions within the MaxScale configuration file it is also possible to use the parameter passwd=.
@ -95,45 +95,45 @@ This defines the value of the heartbeat interval in seconds for the connection t
This parameter is used to define the maximum amount of data that will be sent to a slave by MaxScale when that slave is lagging behind the master. In this situation the slave is said to be in "catchup mode", this parameter is designed to both prevent flooding of that slave and also to prevent threads within MaxScale spending disproportionate amounts of time with slaves that are lagging behind the master. The burst size can be defined in Kb, Mb or Gb by adding the qualifier K, M or G to the number given. The default value of burstsize is 1Mb and will be used if burstsize is not given in the router options.
A complete example of a service entry for a binlog router service would be as follows.
[Replication]
type=service
router=binlogrouter
servers=masterdb
version_string=5.6.17-log
router_options=uuid=f12fcb7f-b97b-11e3-bc5e-0401152c4c22,server-id=3,user=repl,password=slavepass,master-id=1,filestem=mybin,heartbeat=30,binlogdir=/var/binlogs
user=maxscale
passwd=Mhu87p2D
```
[Replication]
type=service
router=binlogrouter
servers=masterdb
version_string=5.6.17-log
router_options=uuid=f12fcb7f-b97b-11e3-bc5e-0401152c4c22,server-id=3,user=repl,password=slavepass,master-id=1,filestem=mybin,heartbeat=30,binlogdir=/var/binlogs
user=maxscale
passwd=Mhu87p2D
```
The minimum set of router options that must be given in the configuration are are server-id and aster-id, default values may be used for all other options.
## Listener Section
As per any service in MaxScale a listener section is required to define the address, port and protocol that is used to listen for incoming connections. In this case those incoming connections will originate from the slave servers.
[Replication Listener]
type=listener
service=Replication
protocol=MySQLClient
port=5308
```
[Replication Listener]
type=listener
service=Replication
protocol=MySQLClient
port=5308
```
The protocol used by slaves for connection to MaxScale is the same MySQLClient protocol that is used for client applications to connect to databases, therefore the same MaxScale protocol module can be used.
## Master Server Section
The master server is defined in a section within the MaxScale configuration file in the same way as any other server. The protocol that is used is the same backend protocol as is used in other configurations.
[masterdb]
type=server
address=178.62.50.70
port=3306
protocol=MySQLBackend
```
[masterdb]
type=server
address=178.62.50.70
port=3306
protocol=MySQLBackend
```
# MaxScale replication diagnostics
The binlog router module of MaxScale produces diagnostic output that can be viewed via the `maxadmin` client application. Running the maxadmin command and issuing a show service command will produce a considerable amount of output that will show both the master connection status and statistics and also a block for each of the slaves currently connected.
-bash-4.1$ maxadmin show service Replication
```
-bash-4.1$ maxadmin show service Replication
Service 0x1567ef0
Service: Replication
Router: binlogrouter (0x7f4ceb96a820)
@ -207,9 +207,8 @@ The binlog router module of MaxScale produces diagnostic output that can be view
Users data: 0x156c030
Total connections: 2
Currently connected: 2
-bash-4.1$
-bash-4.1$
```
# Binlog router compatibility
@ -224,13 +223,13 @@ Binlog Router currently does not work for MySQL 5.5 due to missing @@global.binl
# Slave servers setup
Examples of CHANGE MASTER TO command issued on a slave server that wants to gets replication events from MaxScale binlog router:
```
CHANGE MASTER TO MASTER_HOST=‘$maxscale_IP’, MASTER_PORT=5308, MASTER_USER='repl', MASTER_PASSWORD=‘somepasswd’,
MASTER_LOG_FILE=‘mysql-bin.000001'
CHANGE MASTER TO MASTER_HOST=‘$maxscale_IP’, MASTER_PORT=5308, MASTER_USER='repl', MASTER_PASSWORD=‘somepasswd’,
MASTER_LOG_FILE=‘mysql-bin.000001'
CHANGE MASTER TO MASTER_HOST=‘$maxscale_IP’, MASTER_PORT=5308, MASTER_USER='repl', MASTER_PASSWORD=‘somepasswd’,
MASTER_LOG_FILE=‘mysql-bin.000159', MASTER_LOG_POS=245
CHANGE MASTER TO MASTER_HOST=‘$maxscale_IP’, MASTER_PORT=5308, MASTER_USER='repl', MASTER_PASSWORD=‘somepasswd’,
MASTER_LOG_FILE=‘mysql-bin.000159', MASTER_LOG_POS=245
```
The latter example specifies a MASTER_LOG_POS for the selected MASTER_LOG_FILE
Note:
@ -242,31 +241,31 @@ Note:
- Latest binlog file name and pos in MaxScale could be find via maxadmin output or from mysql client connected to MaxScale:
Example:
-bash-4.1$ mysql -h 127.0.0.1 -P 5308 -u$user -p$pass
```
-bash-4.1$ mysql -h 127.0.0.1 -P 5308 -u$user -p$pass
MySQL [(none)]> show master status\G
*************************** 1. row ***************************
File: mysql-bin.000181
Position: 2569
```
# Enabling MariaDB 10 compatibility
MariaDB 10 has different slave registration phase so an option is required:
router_options=...., mariadb10-compatibility=1
```
router_options=...., mariadb10-compatibility=1
```
version_string should be modified in order to present MariaDB 10 version when MaxScale sends server handshake packet.
version_string=10.0.17-log
```
version_string=10.0.17-log
```
# New MariaDB events in Diagnostics
With a MariaDB 10 setups new events are displayed when master server is MariaDB 10.
MariaDB 10 Annotate Rows Event 0
MariaDB 10 Binlog Checkpoint Event 0
MariaDB 10 GTID Event 0
MariaDB 10 GTID List Event 0
```
MariaDB 10 Annotate Rows Event 0
MariaDB 10 Binlog Checkpoint Event 0
MariaDB 10 GTID Event 0
MariaDB 10 GTID List Event 0
```