973b983 Merge branch 'release-2.0.0' into develop 255dd23 Make spinlock functions take const argument 6e23bab Fix bitmask reallocation 338c189 Rename and clean up slavelag filter 3ea8f28 Fix possible NULL pointer dereference bfe6738 MXS-830: Add module information to logged messages 1fad962 Fix strncat usage d38997a Adjust log throttling policy 0be4e4b Add hashtable_item_strcasecmp 726100e Take hashtable convenience functions into use 5e7744a Fix typo in maxadmin.md c5778c8 Merge branch 'release-2.0.0' into develop b5762af Move from tmpnam to mkstemp d6f2c71 Add convenience functions to hashtable 359058a MXS-825: Add support for --execdir 636347c Enable runtime reconfiguration of log throttling ef9fba9 Improve log throttling documentation aef917a Implement log throttling e3a5349 Remove shardrouter.c 8051e80 Remove custom qc_sqlite allocation functions fd34d60 Initial implementation of the learning firewall a8752a8 Removed "filestem option" from example 1ef2519 Removed "filestem option" from example 0815cc8 Cleanup spinlock.h ab4dc99 Clean up hashtable.h ef2c078 Add prototypes for hashtable copy and free functions fb5cfaf Add 'log_throttling' configuration entry 300d823 Add proper prototypes for hashtable hash and cmp functions 1c649aa qc_mysqlembedded: Include skygw_...h without path. d276160 Add missing RPM scripts e70e644 Fix HTTPAuth installation 1b2b389 Combine utils into the server directory 3ff9913 Add missing utils headers to devel package 407efb2 Fix minor packaging problems 99aa6ad Split MaxScale into core, experimental and devel packages 1290386 Merge branch 'develop' of ssh://github.com/mariadb-corporation/maxscale-new into develop e59f148 Make scripts POSIX sh compatible 7319266 Fixed SHOW SLAVE STATUS in bonlog router f8d760a Update Binlogrouter.md 0a904ed Update Replication-Proxy-Binlog-Router-Tutorial.md 75d4202 Update Replication-Proxy-Binlog-Router-Tutorial.md b8651fc Add missing newline in listmanager.h c7ad047 Add note about user data caches to release notes 70ccc2b Merge branch 'release-2.0.0' into develop 575d1b6 Mistake - dummy session needs list markers set. 8364508 Merge branch 'develop' into binlog_server_semisync 868b902 Update MaxScale limitations 2c8b327 Store listener caches in separate directories 6e183ec Create unique user data caches for each listeners f643685 Don't free orphaned tee filter sessions 4179afa Allow binlogrouter to be used without a listener 7ad79af Add function for freeing a listener 677a0a2 Move authentication data from services to listeners 4f12af7 Merge remote-tracking branch 'origin/MXS-677' into develop 1419b81 Semi-Sync support to binlog server: code review updtate 0ea0f01 Semi-Sync support to binlog server: added missing routine 4aad909 Semi-Sync support to binlog server b824e1e Add authenticator support to httpd.c 705a688 Change tabs to spaces d0c419e Change method of adding list fields to e.g. DCB 25504fc Document the changed routing priority of hints 41666d1 Remove use_ssl_if_enabled global option a3584e9 Make routing hints have highest priority 34a1d24 Updated document with new binlog router option 01eedc5 Updated documentation with SSL usage 8a4c0f6 Update Replication-Proxy-Binlog-Router-Tutorial.md 4e374aa Update Replication-Proxy-Binlog-Router-Tutorial.md f3f3c57 Update Replication-Proxy-Binlog-Router-Tutorial.md 617b79f Binlog Server: error messages typo fix fa8dfae Binlog Server: error messages review 1b8819c Fix freeing of schemarouter session memory 07f49e1 MXS-788: new code review fix 1fd3b09 MXS-788: show services now displays SSL info 6ca2584 MXS-788 code review fix ae6a7d0 MXS-788 code review 43d3474 Master server SSL connection 90b2377 Use correct variable in listmanager pre-allocation 9a5b238 Fix listmanager pre-allocation 9c78625 Fix a memory leak when backend authentication fails e59a966 Fix hang in list_find_free ff30223 Fix freeing of shared data in schemarouter fc8f9d3 Add missing include in luafilter ecf7f53 Add missing NULL value to filter parameter array 636d849 Update memory allocation approach f0d1d38 Add new allocation functions 97d00a0 Fix writing of uninitialized data to logs e72c9b2 Merge branch 'release-2.0.0' into develop cf2b712 Merge branch 'release-2.0.0' into develop 8917c5c Change the logic behind valid list entry checks c10deff Improve documentation about version_string f59f1f7 Merge branch 'develop' of ssh://github.com/mariadb-corporation/maxscale-new into develop c88edb3 Backend authentication failure improvement abd5bee Revert "Backend authentication failure improvement" 5bb3107 Backend authentication failure improvement b7f434a Add new allocation functions 3f022fa Fix stupid mistake 99c4317 Merge remote-tracking branch 'origin/MXS-677' into develop 3c1ded6 Added connection/authentication failure error reporting in SHOW SLAVE STATUS 0a60f7b Tidy up and deal with review points. ba103ff blr_slave.c: Update strncpy usage 467331e blr_master.c: Strncpy usage updates d2b7c0c Merge remote-tracking branch 'origin/develop-nullauth-merge' into develop 5a8c1d0 qc: Measure execution time at the right place. bccdb93 Merge branch 'NullAuthDeny' into develop 2e6511c Add 5.5.5 prefix to all version strings that lack it 314655a Improve DCB and session initialization and list handling e1c43f0 MXS-655: Make MaxScale logging logrotate(8) compatible ce36afd MXS-626: Don't log a header unless maxlog enabled dcd47a7 blr_file.c: Replace uses of strncpy 6b8f576 bls_slave.c: Replace strncpy with memcpy 68a0039 Add list preallocation, tidy up, simplify init. cb37d1b Fix copyright etc headers. 11a400d Tidy; comment; fix bad copies and mistakes. 7e36ec4 Add list manager files. c4794e3 Initial code for list manager. 1b42e25 Merge remote-tracking branch 'origin/MXS-765' into develop d50f617 Fix problems, extend tests, respond to review. dcb4a91 Filter test folder removed 0b60dbe Add a couple of comments. 83cdba0 Fix overwriting problem. ba5d353 Fix overwriting problem. 53671cb Small fixes in response to review. 173d049 blr.c: Review strncpy usage 4ff6ef2 binlog_common.c: Replace strncpy with memcpy f238e03 maxbinlogcheck.s: Replace strncpy 9807f8d harness: Replace unnecessary use of strncpy 8c7fe6a avro: Modify strncpy usage 9b8008e Small improvements. b7f784f Fix mistakes in testqueuemanager.c cc26962 Restore missing poll.c code; add testqueuemanager.c. 2e91806 Format the filter harness 22059e6 Initial implementation connection queueing. c604dc2 readwritesplit.c: Improve COM_INIT_DB handling 454d920 schemarouter.c: Replace strncpy with strcpy 8e85d66 sharding_common.c: Too long a database name handled explicitly 77f4446 Astyle schemarouter 491f7c2 maxinfo.c: Replace strncpy with memcpy 6b98105 maxinfo: Reformat with astyle c1dbf08 Handle oversize user and database names 5fa4a0f Merge branch 'develop' of ssh://github.com/mariadb-corporation/maxscale-new into develop 706963b BLR_DBUSERS_TAIL new var in blr.h d75b9af Tweak comments, remove trailing blanks. ab2400a Optimise statistics gathering by inline & simpler fns. fb59ddc Remove unnecessary strncpy/strncat usage in Binlog Server bdcd551 resultset.c: Change strncpy to memcpy c6b1c5e Reject rather than cut too long a path 6d8f112 Remove unnecessary strncpy/strncat usage 18bf5ed Remove unnecessary strncpy usage dc0e2db Make maxpasswd more userfriendly c9c8695 Fix calculation of padded_len in encryptPassword 2cfd2c6 dbusers.c: Check strncpy usage 7ab9342 Make more thorough checks in secrets_readKeys be7d593 Format cli.c debugcli.c testroute.c webserver.c 1ee5efb config.c: Check usage of strncpy 3043b12 gq_utils.c: Unnecessary use of strncpy removed 77874ac Add help to maxkeys 38392a3 Update secrets_writeKeys documentation 2d1325c Make SSL optional in MaxScale's own communication bda00da Fix avro build failures b2cb31a Add more OOM macros 41ccf17 Fix strdup usage a48f732 Fix realloc calls 20771f6 Add forgotten extern "C" block 8faf35a Add maxscale allocation functions bb47890 Add macros for OOM logging afea388 Fix silly mistakes. 6dafd22 Make deny default for null auth; move code from common to auth.
50 KiB
Maxadmin
The Maxscale Administrative & Monitoring Client Application
- Overview
- Running MaxAdmin
- Working With Administration Interface Users
- Getting Help
- Working with Services
- Working with Servers
- Working with Sessions
- Descriptor Control Blocks
- Working with Filters
- Working with Monitors
- MariaDB MaxScale Status Commands
- Administration Commands
- Configuring MariaDB MaxScale to Accept MaxAdmin Connections
- Tuning MariaDB MaxScale
Overview
MaxAdmin is a simple client interface that can be used to interact with the MariaDB MaxScale server, it allows the display of internal MariaDB MaxScale statistics, status and control of MariaDB MaxScale operations.
MaxAdmin supports
-
Interactive user sessions
-
Execution of one-off commands via command line arguments
-
Execution of command scripts
Running MaxAdmin
The MaxAdmin client application may be run in two different modes, either as an interactive command shell for executing commands against MariaDB MaxScale or by passing commands on the MaxAdmin command line itself.
Working With Administration Interface Users
MaxScale communicates with MariaDB MaxScale using UNIX domain sockets, which means that it can only be used on the very host where MariaDB MaxScale is running. Initially MaxAdmin can connect only when run as root. Other Linux users can subsequently be allowed access.
NOTE: Remote access with -h and -P options is no longer supported.
What Users Have Been Defined?
In order to see the current users (UNIX users) that have been defined for the administration interface use the command show users.
MaxScale> show users
Administration interface users:
User names: vilho, dba, massi, mark
MaxScale>
Please note root will not be shown.
MaxScale> show users
Administration interface users:
No administration users have been defined.
MaxScale>
Add A New User
To add a new administrative user to the MariaDB MaxScale server use the command add user. This command is passed a user name, which should be the same as that of an existing Linux user.
MaxScale> add user maria
User maria has been successfully added.
MaxScale>
Note that a user that is given the rights to use MaxAdmin, has the very same rights root has, including adding and removing users.
Delete A User
To remove a user the command remove user is used and it is simply invoked with the user to be removed.
MaxScale> remove user maria
User maria has been successfully removed.
MaxScale>
Note that it is possible to remove the current user, but that will only affect the next attempt to use MaxAdmin. root cannot be removed.
Command Line Switches
The MaxAdmin command accepts a number of switches
| Switch | Long Option | Description |
| -S socket path | --socket=... | The UNIX domain socket path that MaxAdmin will use to connect to the MariaDB MaxScale server. If no -S option is given then the default socket path /tmp/maxadmin.sock will be used. |
| -? | --help | Print usage information regarding MaxAdmin |
| -v | --version | Print the maxadmin version information and exit |
When a switch takes a value, this may either be as the next argument on the command line or maybe as part of the switch itself, e.g. -S path and -Spath are treated in the same way.
Interactive Operation
If no arguments other than the command line switches are passed to MaxAdmin it will enter its interactive mode of operation. Users will be prompted to enter commands with a MaxScale> prompt. The commands themselves are documented in the sections later in this document. A help system is available that will give some minimal details of the commands available.
Command history is available on platforms that support the libedit library. This allows the use of the up and down arrow keys to recall previous commands that have been executed by MaxAdmin. The default edit mode for the history is to emulate the vi commands, the behavior of libedit may however be customized using the .editrc file. To obtain the history of commands that have been executed use the inbuilt history command.
In interactive mode it is possible to execute a set of commands stored in an external file by using the source command. The command takes the argument of a filename which should contain a set of MariaDB MaxScale commands, one per line. These will be executed in the order they appear in the file.
Command Line Operation
MaxAdmin can also be used to execute commands that are passed on the command line, e.g.
-bash-4.1$ maxadmin -S /tmp/maxadmin.sock list services
Password:
Services.
--------------------------+----------------------+--------+---------------
Service Name | Router Module | #Users | Total Sessions
--------------------------+----------------------+--------+---------------
Test Service | readconnroute | 1 | 1
Split Service | readwritesplit | 1 | 1
Filter Service | readconnroute | 1 | 1
QLA Service | readconnroute | 1 | 1
Debug Service | debugcli | 1 | 1
CLI | cli | 2 | 27
--------------------------+----------------------+--------+---------------
-bash-4.1$
The single command is executed and MaxAdmin then terminates. If the -p option is not given then MaxAdmin will prompt for a password. If a MariaDB MaxScale command requires an argument which contains whitespace, for example a service name, that name should be quoted. The quotes will be preserved and used in the execution of the MariaDB MaxScale command.
-bash-4.1$ maxadmin show service "QLA Service"
Password:
Service 0x70c6a0
Service: QLA Service
Router: readconnroute (0x7ffff0f7ae60)
Number of router sessions: 0
Current no. of router sessions: 0
Number of queries forwarded: 0
Started: Wed Jun 25 10:08:23 2014
Backend databases
127.0.0.1:3309 Protocol: MySQLBackend
127.0.0.1:3308 Protocol: MySQLBackend
127.0.0.1:3307 Protocol: MySQLBackend
127.0.0.1:3306 Protocol: MySQLBackend
Users data: 0x724340
Total connections: 1
Currently connected: 1
-bash-4.1$
Command files may be executed by either calling MaxAdmin with the name of the file that contains the commands
maxadmin listall.ms
Or by using the #! mechanism to make the command file executable from the shell. To do this add a line at the start of your command file that contains the #! directive with the path of the MaxAdmin executable. Command options may also be given in this line. For example to create a script file that runs a set of list commands
#!/usr/local/bin/maxadmin
list modules
list servers
list services
list listeners
list dcbs
list sessions
list filters
Then simply set this file to have execute permissions and it may be run like any other command in the Linux shell.
The .maxadmin file
MaxAdmin supports a mechanism to set defaults for all the command line switches via a file in the home directory of the user. If a file named .maxadmin exists it will be read and parameters set according to the lies in this files. The parameter that can be set is: socket. An example of a .maxadmin file that will alter the default password and user name arguments would be
socket=/somepath/maxadmin.socket
This mechanism can be used to provide a means of passwords entry into maxadmin or to override any of the command line option defaults. If a command line option is given that will still override the value in the .maxadmin file.
The .maxadmin file may be made read only to protect any passwords written to that file.
Getting Help
A help system is available that describes the commands available via the administration interface. To obtain a list of all commands available simply type the command help.
MaxScale> help
Available commands:
add user
clear server
disable [heartbeat|log|root]
enable [heartbeat|log|root]
list [clients|dcbs|filters|listeners|modules|monitors|services|servers|sessions]
reload [config|dbusers]
remove user
restart [monitor|service]
set server
show [dcbs|dcb|dbusers|epoll|filter|filters|modules|monitor|monitors|server|servers|services|service|session|sessions|users]
shutdown [maxscale|monitor|service]
Type help command to see details of each command.
Where commands require names as arguments and these names contain
whitespace either the \ character may be used to escape the whitespace
or the name may be enclosed in double quotes ".
MaxScale>
To see more detail on a particular command, and a list of the sub commands of the command, type help followed by the command name.
MaxScale> help list
Available options to the list command:
clients List all the client connections to MaxScale
dcbs List all the DCBs active within MaxScale
filters List all the filters defined within MaxScale
listeners List all the listeners defined within MaxScale
modules List all currently loaded modules
monitors List all monitors
services List all the services defined within MaxScale
servers List all the servers defined within MaxScale
sessions List all the active sessions within MaxScale
MaxScale>
Working With Services
A service is a very important concept in MariaDB MaxScale as it defines the mechanism by which clients interact with MariaDB MaxScale and can attached to the backend databases. A number of commands exist that allow interaction with the services.
What Services Are Available?
The list services command can be used to discover what services are currently available within your MariaDB MaxScale configuration.
MaxScale> list services
Services.
--------------------------+----------------------+--------+---------------
Service Name | Router Module | #Users | Total Sessions
--------------------------+----------------------+--------+---------------
Test Service | readconnroute | 1 | 1
Split Service | readwritesplit | 1 | 1
Filter Service | readconnroute | 1 | 1
QLA Service | readconnroute | 1 | 1
Debug Service | debugcli | 1 | 1
CLI | cli | 2 | 24
--------------------------+----------------------+--------+---------------
MaxScale>
In order to determine which ports services are using then the list listeners command can be used.
MaxScale> list listeners
Listeners.
---------------------+--------------------+-----------------+-------+--------
Service Name | Protocol Module | Address | Port | State
---------------------+--------------------+-----------------+-------+--------
Test Service | MySQLClient | * | 4006 | Running
Split Service | MySQLClient | * | 4007 | Running
Filter Service | MySQLClient | * | 4008 | Running
QLA Service | MySQLClient | * | 4009 | Running
Debug Service | telnetd | localhost | 4242 | Running
CLI | maxscaled | localhost | 6603 | Running
---------------------+--------------------+-----------------+-------+--------
MaxScale>
See Service Details
It is possible to see the details of an individual service using the show service command. This command should be passed the name of the service you wish to examine as an argument. Where a service name contains spaces characters there should either be escaped or the name placed in quotes.
MaxScale> show service "QLA Service"
Service 0x70c6a0
Service: QLA Service
Router: readconnroute (0x7ffff0f7ae60)
Number of router sessions: 0
Current no. of router sessions: 0
Number of queries forwarded: 0
Started: Wed Jun 25 10:08:23 2014
Backend databases
127.0.0.1:3309 Protocol: MySQLBackend
127.0.0.1:3308 Protocol: MySQLBackend
127.0.0.1:3307 Protocol: MySQLBackend
127.0.0.1:3306 Protocol: MySQLBackend
Users data: 0x724340
Total connections: 1
Currently connected: 1
MaxScale>
This allows the set of backend servers defined by the service to be seen along with the service statistics and other information.
Examining Service Users
MariaDB MaxScale provides an authentication model by which the client application authenticates with MariaDB MaxScale using the credentials they would normally use to with the database itself. MariaDB MaxScale loads the user data from one of the backend databases defined for the service. The show dbusers command can be used to examine the user data held by MariaDB MaxScale.
MaxScale> show dbusers "Filter Service"
User names: pappo@%, rana@%, new_control@%, new_nuovo@%, uno@192.168.56.1, nuovo@192.168.56.1, pesce@%, tryme@192.168.1.199, repluser@%, seven@%, due@%, pippo@%, mmm@%, daka@127.0.0.1, timour@%, ivan@%, prova@%, changeme@127.0.0.1, uno@%, massimiliano@127.0.0.1, massim@127.0.0.1, massi@127.0.0.1, masssi@127.0.0.1, pappo@127.0.0.1, rana@127.0.0.1, newadded@127.0.0.1, newaded@127.0.0.1, pesce@127.0.0.1, repluser@127.0.0.1, seven@127.0.0.1, pippo@127.0.0.1, due@127.0.0.1, nopwd@127.0.0.1, timour@127.0.0.1, controlla@192.168.56.1, ivan@127.0.0.1, ppp@127.0.0.1, daka@%, nuovo@127.0.0.1, uno@127.0.0.1, repluser@192.168.56.1, havoc@%, tekka@192.168.1.19, due@192.168.56.1, qwerty@127.0.0.1, massimiliano@%, massi@%, massim@%
MaxScale>
Reloading Service User Data
MariaDB MaxScale will automatically reload user data if there are failed authentication requests from client applications. This reloading is rate limited and triggered by missing entries in the MariaDB MaxScale table. If a user is removed from the backend database user table it will not trigger removal from the MariaDB MaxScale internal table. The reload dbusers command can be used to force the reloading of the user table within MariaDB MaxScale.
MaxScale> reload dbusers "Split Service"
Loaded 34 database users for service Split Service.
MaxScale>
Stopping A Service
It is possible to stop a service from accepting new connections by using the shutdown service command. This will not affect the connections that are already in place for a service, but will stop any new connections from being accepted.
MaxScale> shutdown service "Split Service"
MaxScale>
Restart A Stopped Service
A stopped service may be restarted by using the restart service command.
MaxScale> restart service "Split Service"
MaxScale>
Working With Servers
The server represents each of the instances of MySQL or MariaDB that a service may use.
What Servers Are Configured?
The command list servers can be used to display a list of all the servers configured within MariaDB MaxScale.
MaxScale> list servers
Servers.
-------------------+-----------------+-------+----------------------+------------
Server | Address | Port | Status | Connections
-------------------+-----------------+-------+----------------------+------------
server1 | 127.0.0.1 | 3306 | Running | 0
server2 | 127.0.0.1 | 3307 | Master, Running | 0
server3 | 127.0.0.1 | 3308 | Running | 0
server4 | 127.0.0.1 | 3309 | Slave, Running | 0
-------------------+-----------------+-------+----------------------+------------
MaxScale>
Server Details
It is possible to see more details regarding a given server using the show server command.
MaxScale> show server server2
Server 0x70d460 (server2)
Server: 127.0.0.1
Status: Master, Running
Protocol: MySQLBackend
Port: 3307
Server Version: 5.5.25-MariaDB-log
Node Id: 124
Number of connections: 0
Current no. of conns: 0
Current no. of operations: 0
MaxScale>
If the server has a non-zero value set for the server configuration item "persistpoolmax", then additional information will be shown:
Persistent pool size: 1
Persistent measured pool size: 1
Persistent pool max size: 10
Persistent max time (secs): 3660
The distinction between pool size and measured pool size is that the first is a counter that is updated when operations affect the persistent connections pool, whereas the measured size is the result of checking how many persistent connections are currently in the pool. It can be slightly different, since any expired connections are removed during the check.
Setting The State Of A Server
MariaDB MaxScale maintains a number of status bits for each server that is configured, these status bits are normally maintained by the monitors, there are two commands in the user interface that are used to manually maintain these bits also; the set server and clear server commands.
The status bit that can be controlled are
| Bit Name | Description |
| running | The server is responding to requests, accepting connections and executing database commands |
| master | The server is a master in a replication setup or should be considered as a destination for database updates. |
| slave | The server is a replication slave or is considered as a read only database. |
| synced | The server is a fully fledged member of a Galera cluster |
| maintenance | The server is in maintenance mode. In this mode no new connections will be established to the server. The monitors will also not monitor servers that are in maintenance mode. |
All status bits, with the exception of the maintenance bit, will be set by the monitors that are monitoring the server. If manual control is required the monitor should be stopped.
MaxScale> set server server3 maintenance
MaxScale> clear server server3 maintenance
MaxScale>
Viewing the persistent pool of DCB
The DCBs that are in the pool for a particular server can be displayed (in the format described below in the DCB section) with a command like:
MaxScale> show persistent server1
Working With Sessions
The MariaDB MaxScale session represents the state within MariaDB MaxScale. Sessions are dynamic entities and not named in the configuration file, this means that sessions can not be easily named within the user interface. The sessions are referenced using ID values, these are actually memory address, however the important thing is that no two session have the same ID.
What Sessions Are Active in MariaDB MaxScale?
There are a number of ways to find out what sessions are active, the most comprehensive being the list sessions command.
MaxScale> list sessions
Sessions.
-----------------+-----------------+----------------+--------------------------
Session | Client | Service | State
-----------------+-----------------+----------------+--------------------------
0x7267a0 | 127.0.0.1 | CLI | Session ready for routing
0x726340 | | CLI | Listener Session
0x725720 | | Debug Service | Listener Session
0x724720 | | QLA Service | Listener Session
0x72a750 | | Filter Service | Listener Session
0x709500 | | Split Service | Listener Session
0x7092d0 | | Test Service | Listener Session
-----------------+-----------------+----------------+--------------------------
MaxScale>
This lists all the sessions for both user connections and for the service listeners.
The list clients command will give just the subset of sessions that originate from a client connection.
MaxScale> list clients
Client Connections
-----------------+------------+----------------------+------------
Client | DCB | Service | Session
-----------------+------------+----------------------+------------
127.0.0.1 | 0x7274b0 | CLI | 0x727700
127.0.0.1 | 0x727900 | QLA Service | 0x727da0
-----------------+------------+----------------------+------------
MaxScale>
Display Session Details
Once the session ID has been determined using one of the above method it is possible to determine more detail regarding a session by using the show session command.
MaxScale> show session 0x727da0
Session 0x727da0
State: Session ready for routing
Service: QLA Service (0x70d6a0)
Client DCB: 0x727900
Client Address: 127.0.0.1
Connected: Wed Jun 25 15:27:21 2014
MaxScale>
Descriptor Control Blocks
The Descriptor Control Block or DCB is a very important entity within MariaDB MaxScale, it represents the state of each connection within MariaDB MaxScale. A DCB is allocated for every connection from a client, every network listener and every connection to a backend database. Statistics for each of these connections are maintained within these DCB’s.
As with session above the DCB’s are not named and are therefore referred to by the use of a unique ID, the memory address of the DCB.
Finding DCB’s
There are several ways to determine what DCB’s are active within a MariaDB MaxScale server, the most straightforward being the list dcbs command.
MaxScale> list dcbs
Descriptor Control Blocks
------------+----------------------------+----------------------+----------
DCB | State | Service | Remote
------------+----------------------------+----------------------+----------
0x667170 | DCB for listening socket | Test Service |
0x71a350 | DCB for listening socket | Split Service |
0x724b40 | DCB for listening socket | Filter Service |
0x7250d0 | DCB for listening socket | QLA Service |
0x725740 | DCB for listening socket | Debug Service |
0x726740 | DCB for listening socket | CLI |
0x7274b0 | DCB in the polling loop | CLI | 127.0.0.1
0x727900 | DCB in the polling loop | QLA Service | 127.0.0.1
0x72e880 | DCB in the polling loop | QLA Service |
------------+----------------------------+----------------------+----------
MaxScale>
A MariaDB MaxScale server that has activity on it will however have many more DCB’s than in the example above, making it hard to find the DCB that you require. The DCB ID is also included in a number of other command outputs, depending on the information you have it may be easier to use other methods to locate a particular DCB.
DCB Of A Client Connection
To find the DCB for a particular client connection it may be best to start with the list clients command and then look at each DCB for a particular client address to determine the one of interest.
DCB Details
The details of an individual DCB can be obtained by use of the show dcb command
MaxScale> show dcb 0x727900
DCB: 0x727900
DCB state: DCB in the polling loop
Username: somename
Protocol: MySQLBackend
Server Status: Master, running
Role: Request Handler
Connected to: 127.0.0.1
Owning Session: 0x727da0
Statistics:
No. of Reads: 4
No. of Writes: 3
No. of Buffered Writes: 0
No. of Accepts: 0
No. of High Water Events: 0
No. of Low Water Events: 0
Added to persistent pool: Jun 24 09:09:56
MaxScale>
The information Username, Protocol, Server Status are not always relevant, and will not be shown when they are null. The time the DCB was added to the persistent pool is only shown for a DCB that is in a persistent pool.
Working with Filters
Filters allow the request contents and result sets from a database to be modified for a client connection, pipelines of filters can be created between the client connection and MariaDB MaxScale router modules.
What Filters Are Configured?
Filters are configured in the configuration file for MariaDB MaxScale, they are given names and may be included in the definition of a service. The list filters command can be used to determine which filters are defined.
MaxScale> list filters
Filters
--------------------+-----------------+----------------------------------------
Filter | Module | Options
--------------------+-----------------+----------------------------------------
counter | testfilter |
QLA | qlafilter | /tmp/QueryLog
Replicate | tee |
QLA_BLR | qlafilter | /tmp/QueryLog.blr0
regex | regexfilter |
MySQL5.1 | regexfilter |
top10 | topfilter |
--------------------+-----------------+----------------------------------------
MaxScale>
Retrieve Details Of A Filter Configuration
The command show filter can be used to display information related to a particular filter.
MaxScale> show filter QLA
Filter 0x719460 (QLA)
Module: qlafilter
Options: /tmp/QueryLog
Limit logging to connections from 127.0.0.1
Include queries that match select.*from.*user.*where
MaxScale>
Filter Usage
The show session command will include details for each of the filters in use within a session. First use list sessions or list clients to find the session of interest and then run the show session command
MaxScale> list clients
Client Connections
-----------------+------------+----------------------+------------
Client | DCB | Service | Session
-----------------+------------+----------------------+------------
127.0.0.1 | 0x7361a0 | Split Service | 0x736680
127.0.0.1 | 0x737ec0 | Plumbing | 0x7382b0
127.0.0.1 | 0x73ab20 | DigitalOcean | 0x73ad90
127.0.0.1 | 0x7219e0 | CLI | 0x721bd0
-----------------+------------+----------------------+------------
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
Filter: top10
Report size 10
Logging to file /tmp/Query.top10.1.
Current Top 10:
1 place:
Execution time: 23.826 seconds
SQL: select sum(salary), year(from_date) from salaries s, (select distinct year(from_date) as y1 from salaries) y where (makedate(y.y1, 1) between s.from_date and s.to_date) group by y.y1 ("1988-08-01?
2 place:
Execution time: 5.251 seconds
SQL: select d.dept_name as "Department", y.y1 as "Year", count(*) as "Count" from departments d, dept_emp de, (select distinct year(from_date) as y1 from dept_emp order by 1) y where d.dept_no = de.dept_no and (makedate(y.y1, 1) between de.from_date and de.to_date) group by y.y1, d.dept_name order by 1, 2
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
4 place:
Execution time: 2.138 seconds
SQL: select dept_name as "Department", sum(salary) / 12 as "Salary Bill" from employees e, departments d, dept_emp de, salaries s where e.emp_no = de.emp_no and de.dept_no = d.dept_no and ("1988-08-01" between de.from_date AND de.to_date) and ("1988-08-01" between s.from_date AND s.to_date) and s.emp_no = e.emp_no group by dept_name order by 1
5 place:
Execution time: 0.839 seconds
SQL: select dept_name as "Department", avg(year(now()) - year(birth_date)) as "Average Age", gender from employees e, departments d, dept_emp de where e.emp_no = de.emp_no and de.dept_no = d.dept_no and ("1988-08-01" between from_date AND to_date) group by dept_name, gender
6 place:
Execution time: 0.662 seconds
SQL: select year(hire_date) as "Hired", d.dept_name, count(*) as "Count" from employees e, departments d, dept_emp de where de.emp_no = e.emp_no and de.dept_no = d.dept_no group by d.dept_name, year(hire_date)
7 place:
Execution time: 0.286 seconds
SQL: select moves.n_depts As "No. of Departments", count(moves.emp_no) as "No. of Employees" from (select de1.emp_no as emp_no, count(de1.emp_no) as n_depts from dept_emp de1 group by de1.emp_no) as moves group by moves.n_depts order by 1
8 place:
Execution time: 0.248 seconds
SQL: select year(now()) - year(birth_date) as age, gender, count(*) as "Count" from employees group by year(now()) - year(birth_date), gender order by 1,2@
9 place:
Execution time: 0.182 seconds
SQL: select year(hire_date) as "Hired", count(*) as "Count" from employees group by year(hire_date)
10 place:
Execution time: 0.169 seconds
SQL: select year(hire_date) - year(birth_date) as "Age", count(*) as Count from employees group by year(hire_date) - year(birth_date) order by 1
MaxScale>
The data displayed varies from filter to filter, the example above is the top filter. This filter prints a report of the current top queries at the time the show session command is run.
Working With Monitors
Monitors are used to monitor the state of databases within MariaDB MaxScale in order to supply information to other modules, specifically the routers within MariaDB MaxScale.
What Monitors Are Running?
To see what monitors are running within MariaDB MaxScale use the list monitors command.
MaxScale> list monitors
+----------------------+---------------------
| Monitor | Status
+----------------------+---------------------
| MySQL Monitor | Running
+----------------------+---------------------
MaxScale>
Details Of A Particular Monitor
To see the details of a particular monitor use the show monitor command.
MaxScale> show monitor "MySQL Monitor"
Monitor: 0x71c370
Name: MySQL Monitor
Monitor running
Sampling interval: 10000 milliseconds
MaxScale MonitorId: 24209641
Replication lag: disabled
Monitored servers: 127.0.0.1:3306, 127.0.0.1:3307, 127.0.0.1:3308, 127.0.0.1:3309
MaxScale>
Controlling Replication Heartbeat
Some monitors provide a replication heartbeat mechanism that monitors the delay for data that is replicated from a master to slaves in a tree structured replication environment. This can be enabled or disabled using the commands enable heartbeat and disable heartbeat.
MaxScale> disable heartbeat "MySQL Monitor"
MaxScale> enable heartbeat "MySQL Monitor"
MaxScale>
Please note that changes made via this interface will not persist across restarts of MariaDB MaxScale. To make a permanent change edit the maxscale.cnf file.
Enabling the replication heartbeat mechanism will add the display of heartbeat information in the show server output
MaxScale> show server server4
Server 0x719800 (server4)
Server: 127.0.0.1
Status: Slave, Running
Protocol: MySQLBackend
Port: 3309
Server Version: 5.5.25-MariaDB-log
Node Id: 4
Number of connections: 0
Current no. of conns: 0
MaxScale> enable heartbeat "MySQL Monitor"
MaxScale> show server server4
Server 0x719800 (server4)
Server: 127.0.0.1
Status: Slave, Running
Protocol: MySQLBackend
Port: 3309
Server Version: 5.5.25-MariaDB-log
Node Id: 4
Slave delay: 0
Last Repl Heartbeat: Thu Jun 26 17:04:58 2014
Number of connections: 0
Current no. of conns: 0
MaxScale>
Shutting Down A Monitor
A monitor may be shutdown using the shutdown monitor command. This allows for manual control of the status of servers using the set server and clear server commands.
MaxScale> shutdown monitor "MySQL Monitor"
MaxScale> list monitors
+----------------------+---------------------
| Monitor | Status
+----------------------+---------------------
| MySQL Monitor | Stopped
+----------------------+---------------------
MaxScale>
Restarting A Monitor
A monitor that has been shutdown may be restarted using the restart monitor command.
MaxScale> restart monitor "MySQL Monitor"
MaxScale> show monitor "MySQL Monitor"
Monitor: 0x71a310
Name: MySQL Monitor
Monitor running
Sampling interval: 10000 milliseconds
MaxScale MonitorId: 24201552
Replication lag: enabled
Monitored servers: 127.0.0.1:3306, 127.0.0.1:3307, 127.0.0.1:3308, 127.0.0.1:3309
MaxScale>
MaxScale Status Commands
A number of commands exists that enable the internal MariaDB MaxScale status to be revealed, these commands give an insight to how MariaDB MaxScale is using resource internally and are used to allow the tuning process to take place.
MariaDB MaxScale Thread Usage
MariaDB MaxScale uses a number of threads, as defined in the MariaDB MaxScale configuration file, to execute the processing of requests received from clients and the handling of responses. The show threads command can be used to determine what each thread is currently being used for.
MaxScale> show threads
Polling Threads.
Historic Thread Load Average: 1.00.
Current Thread Load Average: 1.00.
15 Minute Average: 0.48, 5 Minute Average: 1.00, 1 Minute Average: 1.00
Pending event queue length averages:
15 Minute Average: 0.90, 5 Minute Average: 1.83, 1 Minute Average: 2.00
ID | State | # fds | Descriptor | Running | Event
----+------------+--------+------------------+----------+---------------
0 | Processing | 1 | 0xf55a70 | < 100ms | IN|OUT
1 | Processing | 1 | 0xf49ba0 | < 100ms | IN|OUT
2 | Processing | 1 | 0x7f54c0030d00 | < 100ms | IN|OUT
MaxScale>
The resultant output returns data as to the average thread utilization for the past minutes 5 minutes and 15 minutes. It also gives a table, with a row per thread that shows what DCB that thread is currently processing events for, the events it is processing and how long, to the nearest 100ms has been send processing these events.
The Event Queue
At the core of MariaDB MaxScale is an event driven engine that is processing network events for the network connections between MariaDB MaxScale and client applications and MariaDB MaxScale and the backend servers. It is possible to see the event queue using the show eventq command. This will show the events currently being executed and those that are queued for execution.
MaxScale> show eventq
Event Queue.
DCB | Status | Processing Events | Pending Events
-----------------+------------+--------------------+-------------------
0x1e22f10 | Processing | IN|OUT |
MaxScale>
The output of this command gives the DCB’s that are currently in the event queue, the events queued for that DCB, and events that are being processed for that DCB.
The Housekeeper Tasks
Internally MariaDB MaxScale has a housekeeper thread that is used to perform periodic tasks, it is possible to use the command show tasks to see what tasks are outstanding within the housekeeper.
MaxScale> show tasks
Name | Type | Frequency | Next Due
--------------------------+----------+-----------+-------------------------
Load Average | Repeated | 10 | Wed Nov 19 15:10:51 2014
MaxScale>
Administration Commands
What Modules Are In use?
In order to determine what modules are in use, and the version and status of those modules the list modules command can be used.
MaxScale> list modules
Modules.
----------------+-------------+---------+-------+-------------------------
Module Name | Module Type | Version | API | Status
----------------+-------------+---------+-------+-------------------------
tee | Filter | V1.0.0 | 1.1.0 | Alpha
qlafilter | Filter | V1.1.1 | 1.1.0 | Alpha
topfilter | Filter | V1.0.1 | 1.1.0 | Alpha
MySQLBackend | Protocol | V2.0.0 | 1.0.0 | Alpha
maxscaled | Protocol | V1.0.0 | 1.0.0 | Alpha
telnetd | Protocol | V1.0.1 | 1.0.0 | Alpha
MySQLClient | Protocol | V1.0.0 | 1.0.0 | Alpha
mysqlmon | Monitor | V1.2.0 | 1.0.0 | Alpha
readconnroute | Router | V1.0.2 | 1.0.0 | Alpha
readwritesplit | Router | V1.0.2 | 1.0.0 | Alpha
debugcli | Router | V1.1.1 | 1.0.0 | Alpha
cli | Router | V1.0.0 | 1.0.0 | Alpha
----------------+-------------+---------+-------+-------------------------
MaxScale>
This command provides important version information for the module. Each module has two versions; the version of the module itself and the version of the module API that it supports. Also included in the output is the status of the module, this may be "In Development", “Alpha”, “Beta”, “GA” or “Experimental”.
Enabling syslog and maxlog logging
MariaDB MaxScale can log messages to syslog, to a log file or to both. The approach can be set in the config file, but can also be changed from maxadmin. Syslog logging is identified by syslog and file logging by maxlog.
MaxScale> enable syslog
MaxScale> disable maxlog
NOTE If you disable both, then you will see no messages at all.
Rotating the log file
MariaDB MaxScale logs messages to a log file in the log directory of MariaDB MaxScale. As the log file grows continuously, it is recommended to periodically rotate it. When rotated, the current log file will be closed and a new one with the same name opened.
To retain the ealier log entries, you need to first rename the log file and then instruct MaxScale to rotate it.
$ mv maxscale.log maxscale1.log
$ # MaxScale continues to write to maxscale1.log
$ kill -SIGUSR1 <maxscale-pid>
$ # MaxScale closes the file (i.e. maxscale1.log) and reopens maxscale.log
There are two ways for rotating the log - flush log maxscale and flush logs - and the result is identical. The two alternatives are due to historical reasons; earlier MariaDB MaxScale had several different log files.
MaxScale> flush log maxscale
MaxScale>
The flush logs command may be used to rotate all logs with a single command.
MaxScale> flush logs
MaxScale>
Change MariaDB MaxScale Logging Options
From version 1.3 onwards, MariaDB MaxScale has a single log file where messages of various priority (aka severity) are logged. Consequently, you no longer enable or disable log files but log priorities. The priorities are the same as those of syslog and the ones that can be enabled or disabled are debug, info, notice and warning. Error and any more severe messages can not be disabled.
MaxScale> enable log-priority info
MaxScale> disable log-priority notice
MaxScale>
Please note that changes made via this interface will not persist across restarts of MariaDB MaxScale. To make a permanent change edit the maxscale.cnf file.
Adjusting the Log Throttling
From 2.0 onwards, MariaDB MaxScale will throttle messages that are logged too frequently, which typically is a sign that MaxScale encounters some error that just keeps on repeating. The aim is to prevent the log from flooding. The configuration specifies how many times a particular error may be logged during a period of a specified length, before it is suppressed for a period of a specified other length.
The current log throttling configuration can be queried with
MaxScale> show log_throttling
10 1000 100000
where the numbers are the count, the length (in milliseconds) of the period during which the counting is made, and the length (in milliseconds) of the period the message is subsequently suppressed.
The configuration can be set with
MaxScale> set log_throttling 10 1000 10000
where numbers are specified in the same order as in the show case. Setting any of the values to 0, disables the throttling.
Reloading The Configuration
A command, reload config, is available that will cause MariaDB MaxScale to reload the maxscale.cnf configuration file.
Shutting Down MariaDB MaxScale
The MariaDB MaxScale server may be shutdown using the shutdown maxscale command.
Configuring MariaDB MaxScale to Accept MaxAdmin Connections
In order to enable the use of MaxAdmin, the service CLI with an accompanying listener must be added to the MariaDB MaxScale configuration file.
The default entries required are shown below.
[CLI]
type=service
router=cli
[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
socket=default
#socket=/somepath/maxadmin.socket
NOTE: As the protocol maxscaled only supports UNIX domain sockets it is thus not possible to connect remotely to MariaDB MaxScale.
In the example, the default socket path (/tmp/maxadmin.sock) is used. It can be changed to an specific path and in that case MaxAdmin must be invoked with the -S option.
Tuning MariaDB MaxScale
The way that MariaDB MaxScale does it’s polling is that each of the polling threads, as defined by the threads parameter in the configuration file, will call epoll_wait to obtain the events that are to be processed. The events are then added to a queue for execution. Any thread can read from this queue, not just the thread that added the event.
Once the thread has done an epoll call with no timeout it will either do an epoll_wait call with a timeout or it will take an event from the queue if there is one. These two new parameters affect this behavior.
The first parameter, which may be set by using the non_blocking_polls option in the configuration file, controls the number of epoll_wait calls that will be issued without a timeout before MariaDB MaxScale will make a call with a timeout value. The advantage of performing a call without a timeout is that the kernel treats this case as different and will not rescheduled the process in this case. If a timeout is passed then the system call will cause the MariaDB MaxScale thread to be put back in the scheduling queue and may result in lost CPU time to MariaDB MaxScale. Setting the value of this parameter too high will cause MariaDB MaxScale to consume a lot of CPU when there is infrequent work to be done. The default value of this parameter is 3.
This parameter may also be set via the maxadmin client using the command set nbpolls .
The second parameter is the maximum sleep value that MariaDB MaxScale will pass to epoll_wait. What normally happens is that MariaDB MaxScale will do an epoll_wait call with a sleep value that is 10% of the maximum, each time the returns and there is no more work to be done MariaDB MaxScale will increase this percentage by 10%. This will continue until the maximum value is reached or until there is some work to be done. Once the thread finds some work to be done it will reset the sleep time it uses to 10% of the maximum.
The maximum sleep time is set in milliseconds and can be placed in the [maxscale] section of the configuration file with the poll_sleep parameter. Alternatively it may be set in the maxadmin client using the command set pollsleep . The default value of this parameter is 1000.
Setting this value too high means that if a thread collects a large number of events and adds to the event queue, the other threads might not return from the epoll_wait calls they are running for some time resulting in less overall performance. Setting the sleep time too low will cause MariaDB MaxScale to wake up too often and consume CPU time when there is no work to be done.
The show epoll command can be used to see how often we actually poll with a timeout, the first two values output are significant. Also the "Number of wake with pending events" is a good measure. This is the count of the number of times a blocking call returned to find there was some work waiting from another thread. If the value is increasing rapidly reducing the maximum sleep value and increasing the number of non-blocking polls should help the situation.
MaxScale> show epoll
Number of epoll cycles: 534
Number of epoll cycles with wait: 10447
Number of read events: 35
Number of write events: 1988
Number of error events: 0
Number of hangup events: 1
Number of accept events: 3
Number of times no threads polling: 5
Current event queue length: 1
Maximum event queue length: 2
Number of DCBs with pending events: 0
Number of wakeups with pending queue: 0
No of poll completions with descriptors
No. of descriptors No. of poll completions.
1 534
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
>= 10 0
MaxScale>
If the "Number of DCBs with pending events" grows rapidly it is an indication that MariaDB MaxScale needs more threads to be able to keep up with the load it is under.
The show threads command can be used to see the historic average for the pending events queue, it gives 15 minute, 5 minute and 1 minute averages. The load average it displays is the event count per poll cycle data. An idea load is 1, in this case MariaDB MaxScale threads and fully occupied but nothing is waiting for threads to become available for processing.
The show eventstats command can be used to see statistics about how long events have been queued before processing takes place and also how long the events took to execute once they have been allocated a thread to run on.
MaxScale> show eventstats
Event statistics.
Maximum queue time: 2600ms
Maximum execution time: 1600ms
Maximum event queue length: 3
Current event queue length: 3
| Number of events
Duration | Queued | Executed
---------------+------------+-----------
< 100ms | 107 | 461
100 - 200ms | 958 | 22830
200 - 300ms | 20716 | 2545
300 - 400ms | 3284 | 253
400 - 500ms | 505 | 45
500 - 600ms | 66 | 73
600 - 700ms | 116 | 169
700 - 800ms | 319 | 185
800 - 900ms | 382 | 42
900 - 1000ms | 95 | 31
1000 - 1100ms | 63 | 7
1100 - 1200ms | 18 | 4
1200 - 1300ms | 8 | 2
1300 - 1400ms | 6 | 0
1400 - 1500ms | 1 | 1
1500 - 1600ms | 3 | 1
1600 - 1700ms | 2 | 1
1700 - 1800ms | 2 | 0
1800 - 1900ms | 0 | 0
1900 - 2000ms | 1 | 0
2000 - 2100ms | 0 | 0
2100 - 2200ms | 0 | 0
2200 - 2300ms | 0 | 0
2300 - 2400ms | 0 | 0
2400 - 2500ms | 0 | 0
2500 - 2600ms | 0 | 0
2600 - 2700ms | 1 | 0
2700 - 2800ms | 0 | 0
2800 - 2900ms | 0 | 0
2900 - 3000ms | 0 | 0
> 3000ms | 0 | 0
MaxScale>
The statics are defined in 100ms buckets, with the count of the events that fell into that bucket being recorded.