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 ## 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. 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] [MyFilter]
type=filter type=filter
module=xxxfilter 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. 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. 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] [Split Service]
type=service type=service
router=readwritesplit router=readwritesplit
servers=dbserver1,dbserver2,dbserver3,dbserver4 servers=dbserver1,dbserver2,dbserver3,dbserver4
user=massi user=massi
passwd=6628C50E07CCE1F0392EDEEB9D1203F3 passwd=6628C50E07CCE1F0392EDEEB9D1203F3
filters=hints | top10 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. 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 ## 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 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. 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] [top30]
type=filter type=filter
module=topfilter module=topfilter
count=30 count=30
filebase=/var/log/DBSessions/top30 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. 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. 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. 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 Filter: top30
State: Session ready for routing Report size 30
Service: Split Service (0x719f60) Logging to file /var/log/DBSessions/top30.1.
Client DCB: 0x7361a0 Current Top 30:
Client Address: 127.0.0.1
Connected: Thu Jun 26 10:10:44 2014
Filter: top30 1 place:
Report size 30 Execution time: 23.826 seconds
Logging to file /var/log/DBSessions/top30.1. 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?
Current Top 30:
1 place: 2 place:
Execution time: 23.826 seconds Execution time: 5.251 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? 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: 3 place:
Execution time: 5.251 seconds Execution time: 2.903 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 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; 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 ### 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 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] [BubbleGame]
type=service type=service
router=readwritesplit router=readwritesplit
servers=dbbubble1,dbbubble2,dbbubble3,dbbubble4,dbbubble5 servers=dbbubble1,dbbubble2,dbbubble3,dbbubble4,dbbubble5
user=maxscale user=maxscale
passwd=6628C50E07CCE1F0392EDEEB9D1203F3 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. 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] [CassandraDB]
type=server type=server
address=192.168.4.28 address=192.168.4.28
port=3306 port=3306
protocol=MySQLBackend protocol=MySQLBackend
[Cassandra] [Cassandra]
type=service type=service
router=readconnrouter router=readconnrouter
router_options=running router_options=running
servers=CassandraDB servers=CassandraDB
user=maxscale user=maxscale
passwd=6628C50E07CCE1F0392EDEEB9D1203F3 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. 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] [HighScores]
type=filter type=filter
module=teefilter module=teefilter
match=insert.*HighScore.*values match=insert.*HighScore.*values
service=Cassandra 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 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. The final step is to add the filter to the BubbleGame service to enable the use of the filter.
```
[BubbleGame] [BubbleGame]
type=service type=service
router=readwritesplit router=readwritesplit
servers=dbbubble1,dbbubble2,dbbubble3,dbbubble4,dbbubble5 servers=dbbubble1,dbbubble2,dbbubble3,dbbubble4,dbbubble5
user=maxscale user=maxscale
passwd=6628C50E07CCE1F0392EDEEB9D1203F3 passwd=6628C50E07CCE1F0392EDEEB9D1203F3
filters=HighScores 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. 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. 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] [maxscale]
threads=4 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. 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] [Splitter Service]
type=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. 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] [Splitter Service]
type=service type=service
router=readwritesplit router=readwritesplit
servers=dbserv1, dbserv2, dbserv3 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. 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. Once the keys have been created the maxpasswd command can be used to generate the encrypted password.
```
% maxpasswd plainpassword % maxpasswd plainpassword
96F99AA1315BDC3604B006F427DD9484 96F99AA1315BDC3604B006F427DD9484
% %
```
The username and password, either encrypted or plain text, are stored in the service section using the user and passwd parameters. The username and password, either encrypted or plain text, are stored in the service section using the user and passwd parameters.
```
[Splitter Service] [Splitter Service]
type=service type=service
router=readwritesplit router=readwritesplit
servers=dbserv1, dbserv2, dbserv3 servers=dbserv1, dbserv2, dbserv3
user=maxscale user=maxscale
passwd=96F99AA1315BDC3604B006F427DD9484 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. 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] [Splitter Listener]
type=listener type=listener
service=Splitter Service 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. 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] [Splitter Listener]
type=listener type=listener
service=Splitter Service service=Splitter Service
protocol=MySQLClient protocol=MySQLClient
port=3306 port=3306
socket=/tmp/ClusterMaster 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. 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. 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] [dbserv2]
type=server type=server
address=192.168.2.1 address=192.168.2.2
port=3306 port=3306
protocol=MySQLBackend 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
[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. 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] [Galera Monitor]
type=monitor type=monitor
module=galeramon module=galeramon
servers=dbserv1, dbserv2, dbserv3 servers=dbserv1, dbserv2, dbserv3
user=maxscale user=maxscale
passwd=96F99AA1315BDC3604B006F427DD9484 passwd=96F99AA1315BDC3604B006F427DD9484
```
As with the password definition in the server either plain text or encrypted passwords may be used. 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. 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] [Galera Monitor]
type=monitor type=monitor
module=galeramon module=galeramon
diable_master_failback=1 diable_master_failback=1
servers=dbserv1, dbserv2, dbserv3 servers=dbserv1, dbserv2, dbserv3
user=maxscale user=maxscale
passwd=96F99AA1315BDC3604B006F427DD9484 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. 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. 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] [CLI Listener]
type=service type=listener
router=cli service=CLI
[CLI Listener] protocol=maxscaled
type=listener address=localhost
service=CLI port=6603
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. 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 ## 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. 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 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. 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.
--------------------------+----------------------+--------+---------------
Services. Service Name | Router Module | #Users | Total Sessions
--------------------------+----------------------+--------+--------------- --------------------------+----------------------+--------+---------------
Service Name | Router Module | #Users | Total Sessions Splitter Service | readwritesplit | 1 | 1
--------------------------+----------------------+--------+--------------- CLI | cli | 2 | 2
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
-------------------+-----------------+-------+-------------+--------------------
% 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. 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.
---------------------+--------------------+-----------------+-------+--------
Listeners. Service Name | Protocol Module | Address | Port | State
---------------------+--------------------+-----------------+-------+-------- ---------------------+--------------------+-----------------+-------+--------
Service Name | Protocol Module | Address | Port | State Splitter Service | MySQLClient | * | 3306 | Running
---------------------+--------------------+-----------------+-------+-------- CLI | maxscaled | localhost | 6603 | Running
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". 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. Currently the user can connect to maxinfo from any remote IP and to localhost as well.
``` ```
[MaxInfo] [MaxInfo]
type=service type=service
router=maxinfo router=maxinfo
user=monitor user=monitor
passwd=EBD2F49C3B375812A8CDEBA632ED8BBC 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. 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] [MaxInfo Listener]
type=listener type=listener
service=MaxInfo service=MaxInfo
protocol=MySQLClient protocol=MySQLClient
port=9003 port=9003
``` ```
To listen with the HTTP protocol and hence return JSON documents a section as should below is required. To listen with the HTTP protocol and hence return JSON documents a section as should below is required.
``` ```
[MaxInfo JSON Listener] [MaxInfo JSON Listener]
type=listener type=listener
service=MaxInfo service=MaxInfo
protocol=HTTPD protocol=HTTPD
port=8003 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. 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] [MaxInfo Listener]
type=listener type=listener
service=MaxInfo service=MaxInfo
protocol=MySQLClient protocol=MySQLClient
address=localhost address=localhost
port=9003 port=9003
``` ```
# MySQL Interface to maxinfo # 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. 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 % mysqladmin -hmaxscale.mariadb.com -P9003 -umonitor -pxyz ping
mysqld is alive mysqld is alive
% mysqladmin -hmaxscale.mariadb.com -P9003 -umonitor -pxyz status % mysqladmin -hmaxscale.mariadb.com -P9003 -umonitor -pxyz status
Uptime: 72 Threads: 1 Sessions: 11 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. 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. The show variables command will display a set of name and value pairs for a number of MaxScale system variables.
``` ```
mysql> show variables; mysql> show variables;
+--------------------+-------------------------+ +--------------------+-------------------------+
| Variable_name | Value | | Variable_name | Value |
+--------------------+-------------------------+ +--------------------+-------------------------+
| version | 1.0.6-unstable | | version | 1.0.6-unstable |
| version_comment | MariaDB MaxScale | | version_comment | MariaDB MaxScale |
| basedir | /home/mriddoch/skygate2 | | basedir | /home/mriddoch/skygate2 |
| MAXSCALE_VERSION | 1.0.6-unstable | | MAXSCALE_VERSION | 1.0.6-unstable |
| MAXSCALE_THREADS | 1 | | MAXSCALE_THREADS | 1 |
| MAXSCALE_NBPOLLS | 3 | | MAXSCALE_NBPOLLS | 3 |
| MAXSCALE_POLLSLEEP | 1000 | | MAXSCALE_POLLSLEEP | 1000 |
| MAXSCALE_UPTIME | 223 | | MAXSCALE_UPTIME | 223 |
| MAXSCALE_SESSIONS | 11 | | MAXSCALE_SESSIONS | 11 |
+--------------------+-------------------------+ +--------------------+-------------------------+
9 rows in set (0.02 sec) 9 rows in set (0.02 sec)
mysql> 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. 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'; mysql> show variables like 'version';
+---------------+----------------+ +---------------+----------------+
| Variable_name | Value | | Variable_name | Value |
+---------------+----------------+ +---------------+----------------+
| version | 1.0.6-unstable | | version | 1.0.6-unstable |
+---------------+----------------+ +---------------+----------------+
1 row in set (0.02 sec) 1 row in set (0.02 sec)
mysql> show variables like 'version%'; mysql> show variables like 'version%';
+-----------------+------------------+ +-----------------+------------------+
| Variable_name | Value | | Variable_name | Value |
+-----------------+------------------+ +-----------------+------------------+
| version | 1.0.6-unstable | | version | 1.0.6-unstable |
| version_comment | MariaDB MaxScale | | version_comment | MariaDB MaxScale |
+-----------------+------------------+ +-----------------+------------------+
2 rows in set (0.02 sec) 2 rows in set (0.02 sec)
mysql> show variables like '%comment'; mysql> show variables like '%comment';
+-----------------+------------------+ +-----------------+------------------+
| Variable_name | Value | | Variable_name | Value |
+-----------------+------------------+ +-----------------+------------------+
| version_comment | MariaDB MaxScale | | version_comment | MariaDB MaxScale |
+-----------------+------------------+ +-----------------+------------------+
1 row in set (0.02 sec) 1 row in set (0.02 sec)
mysql> show variables like '%ers%'; mysql> show variables like '%ers%';
+------------------+------------------+ +------------------+------------------+
| Variable_name | Value | | Variable_name | Value |
+------------------+------------------+ +------------------+------------------+
| version | 1.0.6-unstable | | version | 1.0.6-unstable |
| version_comment | MariaDB MaxScale | | version_comment | MariaDB MaxScale |
| MAXSCALE_VERSION | 1.0.6-unstable | | MAXSCALE_VERSION | 1.0.6-unstable |
+------------------+------------------+ +------------------+------------------+
3 rows in set (0.02 sec) 3 rows in set (0.02 sec)
mysql> mysql>
``` ```
## Show status ## 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. 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; mysql> show status;
+---------------------------+-------+ +---------------------------+-------+
| Variable_name | Value | | Variable_name | Value |
+---------------------------+-------+ +---------------------------+-------+
| Uptime | 156 | | Uptime | 156 |
| Uptime_since_flush_status | 156 | | Uptime_since_flush_status | 156 |
| Threads_created | 1 | | Threads_created | 1 |
| Threads_running | 1 | | Threads_running | 1 |
| Threadpool_threads | 1 | | Threadpool_threads | 1 |
| Threads_connected | 11 | | Threads_connected | 11 |
| Connections | 11 | | Connections | 11 |
| Client_connections | 2 | | Client_connections | 2 |
| Backend_connections | 0 | | Backend_connections | 0 |
| Listeners | 9 | | Listeners | 9 |
| Zombie_connections | 0 | | Zombie_connections | 0 |
| Internal_descriptors | 2 | | Internal_descriptors | 2 |
| Read_events | 22 | | Read_events | 22 |
| Write_events | 24 | | Write_events | 24 |
| Hangup_events | 0 | | Hangup_events | 0 |
| Error_events | 0 | | Error_events | 0 |
| Accept_events | 2 | | Accept_events | 2 |
| Event_queue_length | 1 | | Event_queue_length | 1 |
| Pending_events | 0 | | Pending_events | 0 |
| Max_event_queue_length | 1 | | Max_event_queue_length | 1 |
| Max_event_queue_time | 0 | | Max_event_queue_time | 0 |
| Max_event_execution_time | 0 | | Max_event_execution_time | 0 |
+---------------------------+-------+ +---------------------------+-------+
22 rows in set (0.02 sec) 22 rows in set (0.02 sec)
mysql> mysql>
``` ```
## Show services ## 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. The show services command will return a set of basic statistics regarding each of the configured services within MaxScale.
``` ```
mysql> show services; mysql> show services;
+----------------+----------------+--------------+----------------+ +----------------+----------------+--------------+----------------+
| Service Name | Router Module | No. Sessions | Total Sessions | | Service Name | Router Module | No. Sessions | Total Sessions |
+----------------+----------------+--------------+----------------+ +----------------+----------------+--------------+----------------+
| Test Service | readconnroute | 1 | 1 | | Test Service | readconnroute | 1 | 1 |
| Split Service | readwritesplit | 1 | 1 | | Split Service | readwritesplit | 1 | 1 |
| Filter Service | readconnroute | 1 | 1 | | Filter Service | readconnroute | 1 | 1 |
| Named Service | readwritesplit | 1 | 1 | | Named Service | readwritesplit | 1 | 1 |
| QLA Service | readconnroute | 1 | 1 | | QLA Service | readconnroute | 1 | 1 |
| Debug Service | debugcli | 1 | 1 | | Debug Service | debugcli | 1 | 1 |
| CLI | cli | 1 | 1 | | CLI | cli | 1 | 1 |
| MaxInfo | maxinfo | 4 | 4 | | MaxInfo | maxinfo | 4 | 4 |
+----------------+----------------+--------------+----------------+ +----------------+----------------+--------------+----------------+
8 rows in set (0.02 sec) 8 rows in set (0.02 sec)
mysql> mysql>
``` ```
The show services command does not accept a like clause and will ignore any like clause that is given. 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. The show listeners command will return a set of status information for every listener defined within the MaxScale configuration file.
``` ```
mysql> show listeners; mysql> show listeners;
+----------------+-----------------+-----------+------+---------+ +----------------+-----------------+-----------+------+---------+
| Service Name | Protocol Module | Address | Port | State | | Service Name | Protocol Module | Address | Port | State |
+----------------+-----------------+-----------+------+---------+ +----------------+-----------------+-----------+------+---------+
| Test Service | MySQLClient | * | 4006 | Running | | Test Service | MySQLClient | * | 4006 | Running |
| Split Service | MySQLClient | * | 4007 | Running | | Split Service | MySQLClient | * | 4007 | Running |
| Filter Service | MySQLClient | * | 4008 | Running | | Filter Service | MySQLClient | * | 4008 | Running |
| Named Service | MySQLClient | * | 4010 | Running | | Named Service | MySQLClient | * | 4010 | Running |
| QLA Service | MySQLClient | * | 4009 | Running | | QLA Service | MySQLClient | * | 4009 | Running |
| Debug Service | telnetd | localhost | 4242 | Running | | Debug Service | telnetd | localhost | 4242 | Running |
| CLI | maxscaled | localhost | 6603 | Running | | CLI | maxscaled | localhost | 6603 | Running |
| MaxInfo | MySQLClient | * | 9003 | Running | | MaxInfo | MySQLClient | * | 9003 | Running |
| MaxInfo | HTTPD | * | 8003 | Running | | MaxInfo | HTTPD | * | 8003 | Running |
+----------------+-----------------+-----------+------+---------+ +----------------+-----------------+-----------+------+---------+
9 rows in set (0.02 sec) 9 rows in set (0.02 sec)
mysql> mysql>
``` ```
The show listeners command will ignore any like clause passed to it. 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. The show sessions command returns information on every active session within MaxScale. It will ignore any like clause passed to it.
``` ```
mysql> show sessions; mysql> show sessions;
+-----------+---------------+----------------+---------------------------+ +-----------+---------------+----------------+---------------------------+
| Session | Client | Service | State | | Session | Client | Service | State |
+-----------+---------------+----------------+---------------------------+ +-----------+---------------+----------------+---------------------------+
| 0x1a92a60 | 127.0.0.1 | MaxInfo | Session ready for routing | | 0x1a92a60 | 127.0.0.1 | MaxInfo | Session ready for routing |
| 0x1a92100 | 80.240.130.35 | MaxInfo | Session ready for routing | | 0x1a92100 | 80.240.130.35 | MaxInfo | Session ready for routing |
| 0x1a76a00 | | MaxInfo | Listener Session | | 0x1a76a00 | | MaxInfo | Listener Session |
| 0x1a76020 | | MaxInfo | Listener Session | | 0x1a76020 | | MaxInfo | Listener Session |
| 0x1a75d40 | | CLI | Listener Session | | 0x1a75d40 | | CLI | Listener Session |
| 0x1a75220 | | Debug Service | Listener Session | | 0x1a75220 | | Debug Service | Listener Session |
| 0x1a774b0 | | QLA Service | Listener Session | | 0x1a774b0 | | QLA Service | Listener Session |
| 0x1a78630 | | Named Service | Listener Session | | 0x1a78630 | | Named Service | Listener Session |
| 0x1a60270 | | Filter Service | Listener Session | | 0x1a60270 | | Filter Service | Listener Session |
| 0x1a606f0 | | Split Service | Listener Session | | 0x1a606f0 | | Split Service | Listener Session |
| 0x19b0380 | | Test Service | Listener Session | | 0x19b0380 | | Test Service | Listener Session |
+-----------+---------------+----------------+---------------------------+ +-----------+---------------+----------------+---------------------------+
11 rows in set (0.02 sec) 11 rows in set (0.02 sec)
mysql> mysql>
``` ```
## Show clients ## 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. 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; mysql> show clients;
+-----------+---------------+---------+---------------------------+ +-----------+---------------+---------+---------------------------+
| Session | Client | Service | State | | Session | Client | Service | State |
+-----------+---------------+---------+---------------------------+ +-----------+---------------+---------+---------------------------+
| 0x1a92a60 | 127.0.0.1 | MaxInfo | Session ready for routing | | 0x1a92a60 | 127.0.0.1 | MaxInfo | Session ready for routing |
| 0x1a92100 | 80.240.130.35 | MaxInfo | Session ready for routing | | 0x1a92100 | 80.240.130.35 | MaxInfo | Session ready for routing |
+-----------+---------------+---------+---------------------------+ +-----------+---------------+---------+---------------------------+
2 rows in set (0.02 sec) 2 rows in set (0.02 sec)
mysql> mysql>
``` ```
## Show servers ## 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. 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; mysql> show servers;
+---------+-----------+------+-------------+---------+ +---------+-----------+------+-------------+---------+
| Server | Address | Port | Connections | Status | | Server | Address | Port | Connections | Status |
+---------+-----------+------+-------------+---------+ +---------+-----------+------+-------------+---------+
| server1 | 127.0.0.1 | 3306 | 0 | Running | | server1 | 127.0.0.1 | 3306 | 0 | Running |
| server2 | 127.0.0.1 | 3307 | 0 | Down | | server2 | 127.0.0.1 | 3307 | 0 | Down |
| server3 | 127.0.0.1 | 3308 | 0 | Down | | server3 | 127.0.0.1 | 3308 | 0 | Down |
| server4 | 127.0.0.1 | 3309 | 0 | Down | | server4 | 127.0.0.1 | 3309 | 0 | Down |
+---------+-----------+------+-------------+---------+ +---------+-----------+------+-------------+---------+
4 rows in set (0.02 sec) 4 rows in set (0.02 sec)
mysql> mysql>
``` ```
## Show modules ## 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. 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; mysql> show modules;
+----------------+-------------+---------+-------------+----------------+ +----------------+-------------+---------+-------------+----------------+
| Module Name | Module Type | Version | API Version | Status | | Module Name | Module Type | Version | API Version | Status |
+----------------+-------------+---------+-------------+----------------+ +----------------+-------------+---------+-------------+----------------+
| HTTPD | Protocol | V1.0.1 | 1.0.0 | In Development | | HTTPD | Protocol | V1.0.1 | 1.0.0 | In Development |
| maxscaled | Protocol | V1.0.0 | 1.0.0 | GA | | maxscaled | Protocol | V1.0.0 | 1.0.0 | GA |
| telnetd | Protocol | V1.0.1 | 1.0.0 | GA | | telnetd | Protocol | V1.0.1 | 1.0.0 | GA |
| MySQLClient | Protocol | V1.0.0 | 1.0.0 | GA | | MySQLClient | Protocol | V1.0.0 | 1.0.0 | GA |
| mysqlmon | Monitor | V1.4.0 | 1.0.0 | GA | | mysqlmon | Monitor | V1.4.0 | 1.0.0 | GA |
| readwritesplit | Router | V1.0.2 | 1.0.0 | GA | | readwritesplit | Router | V1.0.2 | 1.0.0 | GA |
| readconnroute | Router | V1.1.0 | 1.0.0 | GA | | readconnroute | Router | V1.1.0 | 1.0.0 | GA |
| debugcli | Router | V1.1.1 | 1.0.0 | GA | | debugcli | Router | V1.1.1 | 1.0.0 | GA |
| cli | Router | V1.0.0 | 1.0.0 | GA | | cli | Router | V1.0.0 | 1.0.0 | GA |
| maxinfo | Router | V1.0.0 | 1.0.0 | Alpha | | maxinfo | Router | V1.0.0 | 1.0.0 | Alpha |
+----------------+-------------+---------+-------------+----------------+ +----------------+-------------+---------+-------------+----------------+
10 rows in set (0.02 sec) 10 rows in set (0.02 sec)
mysql> mysql>
``` ```
## Show monitors ## 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. The show monitors command reports each monitor configured within the system and the state of that monitor.
``` ```
mysql> show monitors; mysql> show monitors;
+---------------+---------+ +---------------+---------+
| Monitor | Status | | Monitor | Status |
+---------------+---------+ +---------------+---------+
| MySQL Monitor | Running | | MySQL Monitor | Running |
+---------------+---------+ +---------------+---------+
1 row in set (0.02 sec) 1 row in set (0.02 sec)
mysql> mysql>
``` ```
## Show eventTimes ## 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. 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; mysql> show eventTimes;
+---------------+-------------------+---------------------+ +---------------+-------------------+---------------------+
| Duration | No. Events Queued | No. Events Executed | | Duration | No. Events Queued | No. Events Executed |
+---------------+-------------------+---------------------+ +---------------+-------------------+---------------------+
| < 100ms | 460 | 456 | | < 100ms | 460 | 456 |
| 100 - 200ms | 0 | 3 | | 100 - 200ms | 0 | 3 |
| 200 - 300ms | 0 | 0 | | 200 - 300ms | 0 | 0 |
| 300 - 400ms | 0 | 0 | | 300 - 400ms | 0 | 0 |
| 400 - 500ms | 0 | 0 | | 400 - 500ms | 0 | 0 |
| 500 - 600ms | 0 | 0 | | 500 - 600ms | 0 | 0 |
| 600 - 700ms | 0 | 0 | | 600 - 700ms | 0 | 0 |
| 700 - 800ms | 0 | 0 | | 700 - 800ms | 0 | 0 |
| 800 - 900ms | 0 | 0 | | 800 - 900ms | 0 | 0 |
| 900 - 1000ms | 0 | 0 | | 900 - 1000ms | 0 | 0 |
| 1000 - 1100ms | 0 | 0 | | 1000 - 1100ms | 0 | 0 |
| 1100 - 1200ms | 0 | 0 | | 1100 - 1200ms | 0 | 0 |
| 1200 - 1300ms | 0 | 0 | | 1200 - 1300ms | 0 | 0 |
| 1300 - 1400ms | 0 | 0 | | 1300 - 1400ms | 0 | 0 |
| 1400 - 1500ms | 0 | 0 | | 1400 - 1500ms | 0 | 0 |
| 1500 - 1600ms | 0 | 0 | | 1500 - 1600ms | 0 | 0 |
| 1600 - 1700ms | 0 | 0 | | 1600 - 1700ms | 0 | 0 |
| 1700 - 1800ms | 0 | 0 | | 1700 - 1800ms | 0 | 0 |
| 1800 - 1900ms | 0 | 0 | | 1800 - 1900ms | 0 | 0 |
| 1900 - 2000ms | 0 | 0 | | 1900 - 2000ms | 0 | 0 |
| 2000 - 2100ms | 0 | 0 | | 2000 - 2100ms | 0 | 0 |
| 2100 - 2200ms | 0 | 0 | | 2100 - 2200ms | 0 | 0 |
| 2200 - 2300ms | 0 | 0 | | 2200 - 2300ms | 0 | 0 |
| 2300 - 2400ms | 0 | 0 | | 2300 - 2400ms | 0 | 0 |
| 2400 - 2500ms | 0 | 0 | | 2400 - 2500ms | 0 | 0 |
| 2500 - 2600ms | 0 | 0 | | 2500 - 2600ms | 0 | 0 |
| 2600 - 2700ms | 0 | 0 | | 2600 - 2700ms | 0 | 0 |
| 2700 - 2800ms | 0 | 0 | | 2700 - 2800ms | 0 | 0 |
| 2800 - 2900ms | 0 | 0 | | 2800 - 2900ms | 0 | 0 |
| > 3000ms | 0 | 0 | | > 3000ms | 0 | 0 |
+---------------+-------------------+---------------------+ +---------------+-------------------+---------------------+
30 rows in set (0.02 sec) 30 rows in set (0.02 sec)
mysql> 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. 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. The /variables URL will return the MaxScale variables, these variables can not be filtered via this interface.
``` ```
$ curl http://maxscale.mariadb.com:8003/variables $ curl http://maxscale.mariadb.com:8003/variables
[ { "Variable_name" : "version", "Value" : "1.0.6-unstable"}, [ { "Variable_name" : "version", "Value" : "1.0.6-unstable"},
{ "Variable_name" : "version_comment", "Value" : "MariaDB MaxScale"}, { "Variable_name" : "version_comment", "Value" : "MariaDB MaxScale"},
{ "Variable_name" : "basedir", "Value" : "/home/mriddoch/skygate2"}, { "Variable_name" : "basedir", "Value" : "/home/mriddoch/skygate2"},
{ "Variable_name" : "MAXSCALE_VERSION", "Value" : "1.0.6-unstable"}, { "Variable_name" : "MAXSCALE_VERSION", "Value" : "1.0.6-unstable"},
{ "Variable_name" : "MAXSCALE_THREADS", "Value" : 1}, { "Variable_name" : "MAXSCALE_THREADS", "Value" : 1},
{ "Variable_name" : "MAXSCALE_NBPOLLS", "Value" : 3}, { "Variable_name" : "MAXSCALE_NBPOLLS", "Value" : 3},
{ "Variable_name" : "MAXSCALE_POLLSLEEP", "Value" : 1000}, { "Variable_name" : "MAXSCALE_POLLSLEEP", "Value" : 1000},
{ "Variable_name" : "MAXSCALE_UPTIME", "Value" : 3948}, { "Variable_name" : "MAXSCALE_UPTIME", "Value" : 3948},
{ "Variable_name" : "MAXSCALE_SESSIONS", "Value" : 12}] { "Variable_name" : "MAXSCALE_SESSIONS", "Value" : 12}]
$ $
``` ```
## Status ## Status
@ -397,30 +397,30 @@ 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 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 $ curl http://maxscale.mariadb.com:8003/status
[ { "Variable_name" : "Uptime", "Value" : 3831}, [ { "Variable_name" : "Uptime", "Value" : 3831},
{ "Variable_name" : "Uptime_since_flush_status", "Value" : 3831}, { "Variable_name" : "Uptime_since_flush_status", "Value" : 3831},
{ "Variable_name" : "Threads_created", "Value" : 1}, { "Variable_name" : "Threads_created", "Value" : 1},
{ "Variable_name" : "Threads_running", "Value" : 1}, { "Variable_name" : "Threads_running", "Value" : 1},
{ "Variable_name" : "Threadpool_threads", "Value" : 1}, { "Variable_name" : "Threadpool_threads", "Value" : 1},
{ "Variable_name" : "Threads_connected", "Value" : 12}, { "Variable_name" : "Threads_connected", "Value" : 12},
{ "Variable_name" : "Connections", "Value" : 12}, { "Variable_name" : "Connections", "Value" : 12},
{ "Variable_name" : "Client_connections", "Value" : 3}, { "Variable_name" : "Client_connections", "Value" : 3},
{ "Variable_name" : "Backend_connections", "Value" : 0}, { "Variable_name" : "Backend_connections", "Value" : 0},
{ "Variable_name" : "Listeners", "Value" : 9}, { "Variable_name" : "Listeners", "Value" : 9},
{ "Variable_name" : "Zombie_connections", "Value" : 0}, { "Variable_name" : "Zombie_connections", "Value" : 0},
{ "Variable_name" : "Internal_descriptors", "Value" : 3}, { "Variable_name" : "Internal_descriptors", "Value" : 3},
{ "Variable_name" : "Read_events", "Value" : 469}, { "Variable_name" : "Read_events", "Value" : 469},
{ "Variable_name" : "Write_events", "Value" : 479}, { "Variable_name" : "Write_events", "Value" : 479},
{ "Variable_name" : "Hangup_events", "Value" : 12}, { "Variable_name" : "Hangup_events", "Value" : 12},
{ "Variable_name" : "Error_events", "Value" : 0}, { "Variable_name" : "Error_events", "Value" : 0},
{ "Variable_name" : "Accept_events", "Value" : 15}, { "Variable_name" : "Accept_events", "Value" : 15},
{ "Variable_name" : "Event_queue_length", "Value" : 1}, { "Variable_name" : "Event_queue_length", "Value" : 1},
{ "Variable_name" : "Pending_events", "Value" : 0}, { "Variable_name" : "Pending_events", "Value" : 0},
{ "Variable_name" : "Max_event_queue_length", "Value" : 1}, { "Variable_name" : "Max_event_queue_length", "Value" : 1},
{ "Variable_name" : "Max_event_queue_time", "Value" : 0}, { "Variable_name" : "Max_event_queue_time", "Value" : 0},
{ "Variable_name" : "Max_event_execution_time", "Value" : 1}] { "Variable_name" : "Max_event_execution_time", "Value" : 1}]
$ $
``` ```
## Services ## Services
@ -428,16 +428,16 @@ Use of the /status URI will return the status information that would normally be
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. 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 $ curl http://maxscale.mariadb.com:8003/services
[ { "Service Name" : "Test Service", "Router Module" : "readconnroute", "No. Sessions" : 1, "Total Sessions" : 1}, [ { "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" : "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" : "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" : "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" : "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" : "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" : "CLI", "Router Module" : "cli", "No. Sessions" : 1, "Total Sessions" : 1},
{ "Service Name" : "MaxInfo", "Router Module" : "maxinfo", "No. Sessions" : 5, "Total Sessions" : 20}] { "Service Name" : "MaxInfo", "Router Module" : "maxinfo", "No. Sessions" : 5, "Total Sessions" : 20}]
$ $
``` ```
## Listeners ## 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. 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 $ curl http://maxscale.mariadb.com:8003/listeners
[ { "Service Name" : "Test Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4006, "State" : "Running"}, [ { "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" : "Split Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4007, "State" : "Running"},
{ "Service Name" : "Filter Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4008, "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" : "Named Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4010, "State" : "Running"},
{ "Service Name" : "QLA Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4009, "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" : "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" : "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" : "MySQLClient", "Address" : "*", "Port" : 9003, "State" : "Running"},
{ "Service Name" : "MaxInfo", "Protocol Module" : "HTTPD", "Address" : "*", "Port" : 8003, "State" : "Running"}] { "Service Name" : "MaxInfo", "Protocol Module" : "HTTPD", "Address" : "*", "Port" : 8003, "State" : "Running"}]
$ $
``` ```
## Modules ## 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. 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 $ 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" : "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" : "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" : "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" : "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" : "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" : "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" : "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" : "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" : "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"}] { "Module Name" : "maxinfo", "Module Type" : "Router", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "Alpha"}]
$ $
``` ```
## Sessions ## Sessions
@ -482,19 +482,19 @@ 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. The /sessions URI returns a JSON array with an object for each active session within MaxScale.
``` ```
$ curl http://maxscale.mariadb.com:8003/sessions $ curl http://maxscale.mariadb.com:8003/sessions
[ { "Session" : "0x1a8e9a0", "Client" : "80.176.79.245", "Service" : "MaxInfo", "State" : "Session ready for routing"}, [ { "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" : "0x1a8e6d0", "Client" : "80.240.130.35", "Service" : "MaxInfo", "State" : "Session ready for routing"},
{ "Session" : "0x1a8ddd0", "Client" : , "Service" : "MaxInfo", "State" : "Listener Session"}, { "Session" : "0x1a8ddd0", "Client" : , "Service" : "MaxInfo", "State" : "Listener Session"},
{ "Session" : "0x1a92da0", "Client" : , "Service" : "MaxInfo", "State" : "Listener Session"}, { "Session" : "0x1a92da0", "Client" : , "Service" : "MaxInfo", "State" : "Listener Session"},
{ "Session" : "0x1a92ac0", "Client" : , "Service" : "CLI", "State" : "Listener Session"}, { "Session" : "0x1a92ac0", "Client" : , "Service" : "CLI", "State" : "Listener Session"},
{ "Session" : "0x1a70e90", "Client" : , "Service" : "Debug Service", "State" : "Listener Session"}, { "Session" : "0x1a70e90", "Client" : , "Service" : "Debug Service", "State" : "Listener Session"},
{ "Session" : "0x1a758d0", "Client" : , "Service" : "QLA Service", "State" : "Listener Session"}, { "Session" : "0x1a758d0", "Client" : , "Service" : "QLA Service", "State" : "Listener Session"},
{ "Session" : "0x1a73a90", "Client" : , "Service" : "Named Service", "State" : "Listener Session"}, { "Session" : "0x1a73a90", "Client" : , "Service" : "Named Service", "State" : "Listener Session"},
{ "Session" : "0x1a5c0b0", "Client" : , "Service" : "Filter Service", "State" : "Listener Session"}, { "Session" : "0x1a5c0b0", "Client" : , "Service" : "Filter Service", "State" : "Listener Session"},
{ "Session" : "0x1a5c530", "Client" : , "Service" : "Split Service", "State" : "Listener Session"}, { "Session" : "0x1a5c530", "Client" : , "Service" : "Split Service", "State" : "Listener Session"},
{ "Session" : "0x19ac1c0", "Client" : , "Service" : "Test Service", "State" : "Listener Session"}] { "Session" : "0x19ac1c0", "Client" : , "Service" : "Test Service", "State" : "Listener Session"}]
$ $
``` ```
## Clients ## Clients
@ -502,11 +502,11 @@ The /sessions URI returns a JSON array with an object for each active session wi
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. 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 $ curl http://maxscale.mariadb.com:8003/clients
[ { "Session" : "0x1a90be0", "Client" : "80.176.79.245", "Service" : "MaxInfo", "State" : "Session ready for routing"}, [ { "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" : "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"}] { "Session" : "0x1a8e6d0", "Client" : "80.240.130.35", "Service" : "MaxInfo", "State" : "Session ready for routing"}]
$ $
``` ```
## Servers ## 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. 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 $ curl http://maxscale.mariadb.com:8003/servers
[ { "Server" : "server1", "Address" : "127.0.0.1", "Port" : 3306, "Connections" : 0, "Status" : "Running"}, [ { "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" : "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" : "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"}] { "Server" : "server4", "Address" : "127.0.0.1", "Port" : 3309, "Connections" : 0, "Status" : "Down"}]
$ $
``` ```
## Event Times ## 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. 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 $ curl http://maxscale.mariadb.com:8003/event/times
[ { "Duration" : "< 100ms", "No. Events Queued" : 64, "No. Events Executed" : 63}, [ { "Duration" : "< 100ms", "No. Events Queued" : 64, "No. Events Executed" : 63},
{ "Duration" : " 100 - 200ms", "No. Events Queued" : 0, "No. Events Executed" : 0}, { "Duration" : " 100 - 200ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 200 - 300ms", "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" : " 300 - 400ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 400 - 500ms", "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" : " 500 - 600ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 600 - 700ms", "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" : " 700 - 800ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : " 800 - 900ms", "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" : " 900 - 1000ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1000 - 1100ms", "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" : "1100 - 1200ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1200 - 1300ms", "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" : "1300 - 1400ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1400 - 1500ms", "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" : "1500 - 1600ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1600 - 1700ms", "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" : "1700 - 1800ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "1800 - 1900ms", "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" : "1900 - 2000ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2000 - 2100ms", "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" : "2100 - 2200ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2200 - 2300ms", "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" : "2300 - 2400ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2400 - 2500ms", "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" : "2500 - 2600ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2600 - 2700ms", "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" : "2700 - 2800ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
{ "Duration" : "2800 - 2900ms", "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}] { "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 Cluster configuration file is /var/lib/mysql-cluster/config.ini, copied on all servers
[ndbd default] ```
NoOfReplicas=2 [ndbd default]
DataMemory=60M NoOfReplicas=2
IndexMemory=16M DataMemory=60M
IndexMemory=16M
[ndb_mgmd] [ndb_mgmd]
hostname=178.62.38.199 hostname=178.62.38.199
id=21 id=21
datadir=/var/lib/mysql-cluster datadir=/var/lib/mysql-cluster
[mysqld] [mysqld]
hostname=178.62.38.199 hostname=178.62.38.199
[mysqld] [mysqld]
hostname=162.243.90.81 hostname=162.243.90.81
[ndbd] [ndbd]
hostname=178.62.38.199 hostname=178.62.38.199
[ndbd] [ndbd]
hostname=162.243.90.81 hostname=162.243.90.81
```
Note, it’s possible to specify all node ids and datadir as well for each cluster component Note, it’s possible to specify all node ids and datadir as well for each cluster component
Example: Example:
[ndbd] ```
hostname=162.243.90.81 [ndbd]
id=43 hostname=162.243.90.81
datadir=/usr/local/mysql/data id=43
datadir=/usr/local/mysql/data
```
and /etc/my.cnf, copied as well in all servers and /etc/my.cnf, copied as well in all servers
[mysqld] ```
ndbcluster [mysqld]
ndb-connectstring=178.62.38.199 ndbcluster
innodb_buffer_pool_size=16M ndb-connectstring=178.62.38.199
innodb_buffer_pool_size=16M
[mysql_cluster] [mysql_cluster]
ndb-connectstring=178.62.38.199 ndb-connectstring=178.62.38.199
```
## Startup of MySQL Cluster ## 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: 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: - 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: - 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: - 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 ## Check the cluster status
If all has gone well, and the cluster has been set up correctly, the cluster should now be operational. 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. 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: 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 [root@server1 ~]# ndb_mgm
-- NDB Cluster -- Management Client -- -- 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=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) id=25 @162.243.90.81 (mysql-5.5.38 ndb-7.2.17, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s) [ndb_mgmd(MGM)] 1 node(s)
id=21 @178.62.38.199 (mysql-5.5.38 ndb-7.2.17) id=21 @178.62.38.199 (mysql-5.5.38 ndb-7.2.17)
[mysqld(API)] 2 node(s) [mysqld(API)] 2 node(s)
id=22 @178.62.38.199 (mysql-5.5.38 ndb-7.2.17) 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) id=23 @162.243.90.81 (mysql-5.5.38 ndb-7.2.17)
ndb_mgm> 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. 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 ## Working with NDBCLUSTER engine in MySQL
- First create a table with NDBCLUSTER engine: - First create a table with NDBCLUSTER engine:
```
[root@server1 ~]# mysql [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` ( | t1 | CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL `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); +----------+
| count(1) |
Query OK, 1 row affected (0.15 sec) +----------+
| 1 |
- Select the current number of rows: +----------+
mysql> select count(1) from t1;
+----------+
| count(1) |
+----------+
| 1 |
+----------+
1 row in set (0.07 sec)
1 row in set (0.07 sec)
```
- The same from the MySQL client pointing to SQL node on server2 - The same from the MySQL client pointing to SQL node on server2
```
[root@server2 ~]# mysql [root@server2 ~]# mysql
mysql> select count(1) from test.t1; mysql> select count(1) from test.t1;
+----------+ +----------+
| count(1) | | count(1) |
+----------+ +----------+
| 1 | | 1 |
+----------+ +----------+
1 row in set (0.08 sec)
1 row in set (0.08 sec)
```
## Configuring MaxScale for connection load balancing of SQL nodes ## Configuring MaxScale for connection load balancing of SQL nodes
Add these sections in maxscale.cnf config file: 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] [Cluster Listener]
type=service type=listener
router=readconnroute service=Cluster Service
router_options=ndb protocol=MySQLClient
servers=server1,server2 port=4906
user=test
passwd=test
version_string=5.5.37-CLUSTER
[Cluster Listener] [NDB Cluster Monitor]
type=listener type=monitor
service=Cluster Service module=ndbclustermon
protocol=MySQLClient servers=server1,server2
port=4906 user=monitor
passwd=monitor
monitor_interval=8000
[NDB Cluster Monitor] [server1]
type=monitor
module=ndbclustermon
servers=server1,server2
user=monitor
passwd=monitor
monitor_interval=8000
[server1] #SQL node1
type=server
#SQL node1 address=127.0.0.1
type=server port=3306
address=127.0.0.1 protocol=MySQLBackend
port=3306
protocol=MySQLBackend
[server2]
#SQL node2
type=server
address=162.243.90.81
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 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 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 MaxScale> show servers
Monitor running
Sampling interval: 8000 milliseconds
Monitored servers: 127.0.0.1:3306, 162.243.90.81:3306
MaxScale> show servers Server 0x3873b40 (server1)
Server 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 Server 0x3873a40 (server2)
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: 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 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: (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 |
+---------------------+-------+
+---------------------+-------+ [root@server1 ~]# mysql -h 127.0.0.1 -P 4906 -u test -ptest -e "SHOW STATUS LIKE 'Ndb_cluster_node_id'"
| Variable_name | Value |
+---------------------+-------+
| Ndb_cluster_node_id | 23 |
+---------------------+-------+
[root@server1 ~]# mysql -h 127.0.0.1 -P 4906 -u test -ptest -e "SHOW STATUS LIKE 'Ndb_cluster_node_id'"
+---------------------+-------+
| Variable_name | Value |
+---------------------+-------+
| Ndb_cluster_node_id | 22 |
+---------------------+-------+
+---------------------+-------+
| Variable_name | Value |
+---------------------+-------+
| Ndb_cluster_node_id | 22 |
+---------------------+-------+
```
The MaxScale connection load balancing is working. The MaxScale connection load balancing is working.
(2) test a select statement on an NBDBCLUSTER table, database test and table t1 created before: (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) |
+----------+ +----------+
| COUNT(1) | | 1 |
+----------+ +----------+
| 1 | ```
+----------+
(3) test an insert statement (3) test an insert statement
```
mysql -h 127.0.0.1 -P 4906 -utest -ptest -e "INSERT INTO test.t1 VALUES (19)" 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 (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" ```
[root@server1 ~] mysql -h 127.0.0.1 -P 4906 -utest -ptest -e "SELECT COUNT(1) FROM test.t1"
+----------+
| COUNT(1) |
+----------+
| 2 |
+----------+
+----------+
| 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 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*'; MariaDB [(none)]> create user '*username*'@'*maxscalehost*' identified by '*password*';
**Query OK, 0 rows affected (0.00 sec)** **Query OK, 0 rows affected (0.00 sec)**
```
3. Grant select privileges on the mysql.user table. 3. Grant select privileges on the mysql.user table.
```
MariaDB [(none)]> grant SELECT on mysql.user to '*username*'@'*maxscalehost*'; MariaDB [(none)]> grant SELECT on mysql.user to '*username*'@'*maxscalehost*';
**Query OK, 0 rows affected (0.03 sec)** **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. 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'; MariaDB [(none)]> GRANT SELECT ON mysql.db TO 'username'@'maxscalehost';
**Query OK, 0 rows affected (0.00 sec)** **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)** **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 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*'; MariaDB [(none)]> grant REPLICATION SLAVE on *.* to '*username*'@'*maxscalehost*';
**Query OK, 0 rows affected (0.00 sec)** **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)** **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. 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 ## 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. 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] [maxscale]
threads=4 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. 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] [Splitter Service]
type=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. 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] [Splitter Service]
type=service type=service
router=readwritesplit router=readwritesplit
servers=dbserv1, dbserv2, dbserv3 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. 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. Once the keys have been created the maxpasswd command can be used to generate the encrypted password.
% maxpasswd plainpassword ```
maxpasswd plainpassword
96F99AA1315BDC3604B006F427DD9484 96F99AA1315BDC3604B006F427DD9484
% ```
The username and password, either encrypted or plain text, are stored in the service section using the user and passwd parameters. The username and password, either encrypted or plain text, are stored in the service section using the user and passwd parameters.
```
[Splitter Service] [Splitter Service]
type=service type=service
router=readwritesplit router=readwritesplit
servers=dbserv1, dbserv2, dbserv3 servers=dbserv1, dbserv2, dbserv3
user=maxscale user=maxscale
passwd=96F99AA1315BDC3604B006F427DD9484 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. 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] [Splitter Listener]
type=listener type=listener
service=Splitter Service 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. 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] [Splitter Listener]
type=listener type=listener
service=Splitter Service service=Splitter Service
protocol=MySQLClient protocol=MySQLClient
port=3306 port=3306
socket=/tmp/ClusterMaster 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. 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. 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] [dbserv1]
type=server type=server
address=192.168.2.1 address=192.168.2.1
port=3306 port=3306
protocol=MySQLBackend protocol=MySQLBackend
[dbserv2] [dbserv2]
type=server type=server
address=192.168.2.2 address=192.168.2.2
port=3306 port=3306
protocol=MySQLBackend protocol=MySQLBackend
[dbserv3] [dbserv3]
type=server type=server
address=192.168.2.3 address=192.168.2.3
port=3306 port=3306
protocol=MySQLBackend 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. 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] [Replication Monitor]
type=monitor type=monitor
module=mysqlmon module=mysqlmon
servers=dbserv1, dbserv2, dbserv3 servers=dbserv1, dbserv2, dbserv3
user=maxscale user=maxscale
passwd=96F99AA1315BDC3604B006F427DD9484 passwd=96F99AA1315BDC3604B006F427DD9484
```
As with the password definition in the server either plain text or encrypted passwords may be used. 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. 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] [CLI]
type=service type=service
router=cli router=cli
[CLI Listener] [CLI Listener]
type=listener type=listener
service=CLI service=CLI
protocol=maxscaled protocol=maxscaled
address=localhost address=localhost
port=6603 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. 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 # 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. 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 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. 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. Services.
@ -277,8 +264,8 @@ Splitter Service | MySQLClient | * | 3306 | Running
CLI | maxscaled | localhost | 6603 | 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". 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: MaxScale must be configured with 'maxscaled' protocol for the administration interface:
Example of maxscale.cnf file: Example of maxscale.cnf file:
```
[AdminInterface]
type=service
router=cli
[AdminInterface] [AdminListener]
type=service type=listener
router=cli service=AdminInterface
protocol=maxscaled
[AdminListener] port=6603
type=listener ```
service=AdminInterface
protocol=maxscaled
port=6603
## Prepare Nagios configuration files. ## 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: 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) 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: ### Please note:
- modify server IP address in server1.cfg, pointing to MaxScale server - 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. 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 In this example we are using the check_maxscale_resource as the check command
```
#Check MaxScale sessions, on the remote machine. #Check MaxScale sessions, on the remote machine.
define service{ define service{
use local-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 check_command check_maxscale_resource!6603!admin!mariadb!sessions!/path_to/maxadmin
notifications_enabled 0 notifications_enabled 0
} }
```
### Check new running monitors ### Check new running monitors
* Restart Nagios and check new monitors are running in HTTP Interface "Current Status -> Services" on Nagios Server * 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: # Output description:
Example for 'services' 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 OK and the number of services
Returns CRITICAL if no services are found Returns CRITICAL if no services are found
The data after | char are so called performance data and may be collected by Nagios The data after | char are so called performance data and may be collected by Nagios
output format is: 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: This feature is not enabled by default: MaxScale must be configured in [feedback] section:
```
[feedback] [feedback]
feedback_enable=1 feedback_enable=1
feedback_url=https://enterprise.mariadb.com/feedback/post feedback_url=https://enterprise.mariadb.com/feedback/post
feedback_user_info=x-y-z-w 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. 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 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 MaxScale>show feedbackreport
```
Report could be saved to report.txt file: Report could be saved to report.txt file:
```
maxadmin -uxxx -pyyy show feedbackreport > ./report.txt maxadmin -uxxx -pyyy show feedbackreport > ./report.txt
curl -F data=@./report.txt https://mariadb.org/feedback_plugin/post curl -F data=@./report.txt https://mariadb.org/feedback_plugin/post
```
Report Example: Report Example:
```
FEEDBACK_SERVER_UID 6B5C44AEA73137D049B02E6D1C7629EF431A350F FEEDBACK_SERVER_UID 6B5C44AEA73137D049B02E6D1C7629EF431A350F
FEEDBACK_USER_INFO 0467009f-b04d-45b1-a77b-b6b2ec9c6cf4 FEEDBACK_USER_INFO 0467009f-b04d-45b1-a77b-b6b2ec9c6cf4
VERSION 1.0.6-unstable VERSION 1.0.6-unstable
NOW 1425914890 NOW 1425914890
PRODUCT maxscale PRODUCT maxscale
Uname_sysname Linux Uname_sysname Linux
Uname_distribution CentOS release 6.5 (Final) Uname_distribution CentOS release 6.5 (Final)
module_maxscaled_type Protocol module_maxscaled_type Protocol
module_maxscaled_version V1.0.0 module_maxscaled_version V1.0.0
module_maxscaled_api 1.0.0 module_maxscaled_api 1.0.0
module_maxscaled_releasestatus GA module_maxscaled_releasestatus GA
module_telnetd_type Protocol module_telnetd_type Protocol
module_telnetd_version V1.0.1 module_telnetd_version V1.0.1
module_telnetd_api 1.0.0 module_telnetd_api 1.0.0
module_telnetd_releasestatus GA 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") 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. Please note, before installing RabbitMQ, you must install Erlang.
Example: Example:
yum install erlang yum install erlang
Package erlang-R14B-04.3.el6.x86_64 already installed and latest version Package erlang-R14B-04.3.el6.x86_64 already installed and latest version
## Step 2 - Install and Start the Server ## Step 2 - Install and Start the Server
Install the packages using your distribution's package manager 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 yum install rabbitmq-server-3.3.4-1.noarch.rpm
systemctl start rabbitmq-server.service 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). 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 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
rabbitmqctl list_queues | list_exchanges| cluster_status | list_bindings | list_connections | list_consumers | status rabbitmqctl list_queues | list_exchanges| cluster_status | list_bindings | list_connections | list_consumers | status
```
Example output: Example output:
```
[root@maxscale-02 MaxScale]# rabbitmqctl status [root@maxscale-02 MaxScale]# rabbitmqctl status
Status of node 'rabbit@maxscale-02' ... Status of node 'rabbit@maxscale-02' ...
[{pid,12251}, [{pid,12251},
@ -57,13 +57,13 @@ Example output:
Listing bindings ... Listing bindings ...
x1 exchange q1 queue k1 [] x1 exchange q1 queue k1 []
...done. ...done.
```
Interaction with the server may require stop & reset at some point: Interaction with the server may require stop & reset at some point:
```
rabbitmqctl stop_app rabbitmqctl stop_app
rabbitmqctl reset rabbitmqctl reset
rabbitmqctl start_app rabbitmqctl start_app
```
## Step 3 - Install and test the client libraries ## Step 3 - Install and test the client libraries
The selected library for MaxScale integration of RabbitMQ is: 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 ### Manual software compilation
To compile the RabbitMQ-C libraries manually: To compile the RabbitMQ-C libraries manually:
```
git clone https://github.com/alanxz/rabbitmq-c.git git clone https://github.com/alanxz/rabbitmq-c.git
cd rabbitmq-c cd rabbitmq-c
cmake -DCMAKE_INSTALL_PREFIX=/usr . cmake -DCMAKE_INSTALL_PREFIX=/usr .
make make
make install 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. 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) 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: Configure your repositories and install the software:
```
yum install librabbitmq.x86_64 yum install librabbitmq.x86_64
```
you might also like to install: 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: 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 ### 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. Please note, those example applications may not be included in the RPM library packages.
#### Test 1 - create the exchange #### Test 1 - create the exchange
```
[root@maxscale-02 examples]# ./amqp_exchange_declare [root@maxscale-02 examples]# ./amqp_exchange_declare
Usage: amqp_exchange_declare host port exchange exchangetype Usage: amqp_exchange_declare host port exchange exchangetype
```
Declare the exchange: 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 #### Test 2 - Listen to exchange with selected binding key
```
[root@maxscale-02 examples]# ./amqp_listen [root@maxscale-02 examples]# ./amqp_listen
Usage: amqp_listen host port exchange bindingkey Usage: amqp_listen host port exchange bindingkey
```
Start the listener: 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 … #### Test 3 - Send a message …
```
[root@maxscale-02 examples]# ./amqp_sendstring [root@maxscale-02 examples]# ./amqp_sendstring
Usage: amqp_sendstring host port exchange routingkey messagebody 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 127.0.0.1 5672 foo k1 “This is a new message”
```
... and watch the listener output ... and watch the listener output
```
Delivery 1, exchange foo routingkey k1 Delivery 1, exchange foo routingkey k1
Content-type: text/plain Content-type: text/plain
```
## Step 4 - MaxScale integration with librabbitmq-c ## 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 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: 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 mkdir build
cd build cd build
cmake .. -DBUILD_RABBITMQ=Y cmake .. -DBUILD_RABBITMQ=Y
make make
make install make install
```
To build the RabbitMQ filter CMake needs an additional parameter: 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. 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: Libraries:
```
-DRABBITMQ_LIBRARIES=<path to RabbitMQ-c libraries> -DRABBITMQ_LIBRARIES=<path to RabbitMQ-c libraries>
```
Headers: 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: 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: Libraries:
```
-DMYSQLCLIENT_LIBRARIES=<path to libraries> -DMYSQLCLIENT_LIBRARIES=<path to libraries>
```
Headers: 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: 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 mkdir build
cd build cd build
cmake .. cmake ..
make make
```
To install it: To install it:
```
make install make install
```
To build packages: 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. 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 ## Step 5 - Configure new applications
The new filter needs to be configured in maxscale.cnf. 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] [MQ]
type=service type=filter
router=readconnroute module=mqfilter
router_options=slave exchange=x1
servers=server1,server2,server3,server5,server4 key=k1
user=massi queue=q1
passwd=massi hostname=127.0.0.1
filters=MQ 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: 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 # Whether to log only SELECT, UPDATE, INSERT and DELETE queries or all possible queries
logging_trigger=[all,source,schema,object] logging_log_all=true|false
# Whether to log only SELECT, UPDATE, INSERT and DELETE queries or all possible queries # Log only when any of the trigger parameters match or only if all parameters match
logging_log_all=true|false 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 # specify source addresses
logging_strict=true|false logging_source_host=127.0.0.1,192.168.10.14
# 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 schemas
logging_schema=employees,orders,catalog
```
Example: Example:
```
logging_trigger=object,schema,source logging_trigger=object,schema,source
logging_strict=false logging_strict=false
logging_log_all=false logging_log_all=false
logging_object=my1 logging_object=my1
logging_schema=test logging_schema=test
logging_source_user=maxtest logging_source_user=maxtest
```
@ -259,117 +253,118 @@ Example:
The logging result of the example is: The logging result of the example is:
```
if user maxtest does something, it's logged if user maxtest does something, it's logged
and all queries in test schema are logged and all queries in test schema are logged
anything targeting my1 table is logged anything targeting my1 table is logged
SELECT NOW(), SELECT MD5(“xyz)” are not 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. 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: 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_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_SCHEMA: test = test
2014 09/03 06:22:04 Trigger is TRG_OBJECT: test.t1 = t1 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 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 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: #queue Name of the queue to use
#hostname RabbitMQ hostname #dbserver SQL server name
#port RabbitMQ port #dbport SQL server port
#vhost RabbitMQ virtual host #dbname Name of the database to use
#user RabbitMQ username #dbuser SQL server username
#passwd RabbitMQ password #dbpasswd SQL server password
#logfile Message log filename
#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
[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’: 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: 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: 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 and start maxScale as well
## Step 6 - Test the filter and check collected data ## 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: 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)
[root@maxscale-02 MaxScale]# mysql -h 127.0.0.1 -P 4506 -uxxx -pyyy
... MariaDB [(none)]> select RAND(3544), RAND(11);
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: 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:
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 [(none)]> use mqpairs;
Database changed
MariaDB [mqpairs]> select * from pairs; 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)
+-------------------------------------+----------------------------------+------------+---------------------+---------------------+---------+
| 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 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: 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 ## 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. 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]
[Replication] type=service
type=service router=binlogrouter
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. 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] [Replication]
type=service type=service
router=binlogrouter router=binlogrouter
servers=masterdb servers=masterdb
version_string=5.6.17-log version_string=5.6.17-log
user=maxscale user=maxscale
passwd=Mhu87p2D 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 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. 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. 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. 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> CREATE USER 'repl'@'maxscalehost' IDENTIFIED by 'password';
MariaDB> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'maxscalehost'; MariaDB> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'maxscalehost';
```
### password ### 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=. 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. 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. A complete example of a service entry for a binlog router service would be as follows.
```
[Replication] [Replication]
type=service type=service
router=binlogrouter router=binlogrouter
servers=masterdb servers=masterdb
version_string=5.6.17-log 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 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 user=maxscale
passwd=Mhu87p2D 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. 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 ## 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. 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] [Replication Listener]
type=listener type=listener
service=Replication service=Replication
protocol=MySQLClient protocol=MySQLClient
port=5308 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. 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 ## 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. 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] [masterdb]
type=server type=server
address=178.62.50.70 address=178.62.50.70
port=3306 port=3306
protocol=MySQLBackend protocol=MySQLBackend
```
# MaxScale replication diagnostics # 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. 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 0x1567ef0
Service: Replication Service: Replication
Router: binlogrouter (0x7f4ceb96a820) Router: binlogrouter (0x7f4ceb96a820)
@ -207,9 +207,8 @@ The binlog router module of MaxScale produces diagnostic output that can be view
Users data: 0x156c030 Users data: 0x156c030
Total connections: 2 Total connections: 2
Currently connected: 2 Currently connected: 2
-bash-4.1$ -bash-4.1$
```
# Binlog router compatibility # 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 # Slave servers setup
Examples of CHANGE MASTER TO command issued on a slave server that wants to gets replication events from MaxScale binlog router: 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’, CHANGE MASTER TO MASTER_HOST=‘$maxscale_IP’, MASTER_PORT=5308, MASTER_USER='repl', MASTER_PASSWORD=‘somepasswd’,
MASTER_LOG_FILE=‘mysql-bin.000001' 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 The latter example specifies a MASTER_LOG_POS for the selected MASTER_LOG_FILE
Note: 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: - Latest binlog file name and pos in MaxScale could be find via maxadmin output or from mysql client connected to MaxScale:
Example: 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 MySQL [(none)]> show master status\G
*************************** 1. row *************************** *************************** 1. row ***************************
File: mysql-bin.000181 File: mysql-bin.000181
Position: 2569 Position: 2569
```
# Enabling MariaDB 10 compatibility # Enabling MariaDB 10 compatibility
MariaDB 10 has different slave registration phase so an option is required: 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 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 # New MariaDB events in Diagnostics
With a MariaDB 10 setups new events are displayed when master server is MariaDB 10. With a MariaDB 10 setups new events are displayed when master server is MariaDB 10.
```
MariaDB 10 Annotate Rows Event 0 MariaDB 10 Annotate Rows Event 0
MariaDB 10 Binlog Checkpoint Event 0 MariaDB 10 Binlog Checkpoint Event 0
MariaDB 10 GTID Event 0 MariaDB 10 GTID Event 0
MariaDB 10 GTID List Event 0 MariaDB 10 GTID List Event 0
```