Merge remote-tracking branch 'origin/develop' into MXS-329
Conflicts: server/core/session.c
This commit is contained in:
commit
cfeaf7d6e9
@ -38,6 +38,7 @@ find_package(MySQL)
|
||||
find_package(Pandoc)
|
||||
find_package(TCMalloc)
|
||||
find_package(Jemalloc)
|
||||
find_package(Git)
|
||||
find_package(CURL)
|
||||
# You can find the variables set by this in the FindCURL.cmake file
|
||||
# which is a default module in CMake.
|
||||
@ -56,6 +57,26 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(GIT_FOUND)
|
||||
message(STATUS "Found git ${GIT_VERSION_STRING}")
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-list --max-count=1 HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMIT
|
||||
ERROR_VARIABLE GIT_ERROR
|
||||
RESULT_VARIABLE GIT_RVAL)
|
||||
if(${GIT_RVAL} EQUAL 0)
|
||||
string(REPLACE "\n" "" MAXSCALE_COMMIT ${GIT_COMMIT})
|
||||
message(STATUS "Commit ID: ${MAXSCALE_COMMIT}")
|
||||
else()
|
||||
message(STATUS "Git exited with non-zero value: ${GIT_ERROR}")
|
||||
message(STATUS "Could not find repository in source folder, MaxScale commit ID will not be resolved. Will use 'source-build' for commit ID.")
|
||||
set(MAXSCALE_COMMIT "source-build")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "Could not find git, MaxScale commit ID will not be resolved. Will use 'source-build' for commit ID.")
|
||||
set(MAXSCALE_COMMIT "source-build")
|
||||
endif()
|
||||
|
||||
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/${MAXSCALE_LIBDIR})
|
||||
|
||||
# Make sure the release notes for this release are present if it is a stable one
|
||||
@ -172,7 +193,7 @@ install(FILES ${CMAKE_BINARY_DIR}/ReleaseNotes.txt DESTINATION ${MAXSCALE_SHARED
|
||||
install(FILES ${CMAKE_BINARY_DIR}/UpgradingToMaxScale120.txt DESTINATION ${MAXSCALE_SHAREDIR})
|
||||
install(FILES server/maxscale_template.cnf DESTINATION ${MAXSCALE_SHAREDIR})
|
||||
if(WITH_MAXSCALE_CNF)
|
||||
install(FILES server/maxscale_template.cnf DESTINATION ${MAXSCALE_CONFDIR} RENAME maxscale.cnf)
|
||||
install(FILES server/maxscale_template.cnf DESTINATION ${MAXSCALE_CONFDIR} RENAME maxscale.cnf.template)
|
||||
endif()
|
||||
install(FILES server/maxscale_binlogserver_template.cnf DESTINATION ${MAXSCALE_SHAREDIR})
|
||||
install(FILES ${ERRMSG} DESTINATION ${MAXSCALE_VARDIR}/lib/maxscale
|
||||
|
@ -75,12 +75,12 @@ There is a possibility for misbehavior; if `USE mytable` was executed in one of
|
||||
The above-mentioned behavior can be partially controller with the `use_sql_variables_in` configuration parameter.
|
||||
|
||||
```
|
||||
use_sql_variables_in=[master|all] (master)
|
||||
use_sql_variables_in=[master|all] (default: all)
|
||||
```
|
||||
|
||||
Server-side session variables are called as SQL variables. If "master" or no value is set, SQL variables are read and written in master only. Autocommit values and prepared statements are routed to all nodes always.
|
||||
Server-side session variables are called as SQL variables. If "master" is set, SQL variables are read and written in master only. Autocommit values and prepared statements are routed to all nodes always.
|
||||
|
||||
**NOTE**: If variable is written as a part of write query, it is treated like write query and not routed to all servers. For example, `INSERT INTO test.t1 VALUES (@myvar:= 7)` will be routed to the master and an error in the error log will be written.
|
||||
**NOTE**: If variable is written as a part of write query, it is treated like write query and not routed to all servers. For example, `INSERT INTO test.t1 VALUES (@myvar:= 7)` will not be routed and an error in the error log will be written. Add the `use_sql_variables_in=master` to the service definition to allow these queries.
|
||||
|
||||
#### Examples of session command limitations
|
||||
|
||||
|
@ -33,7 +33,18 @@ The MaxScale configuration is read from a file which can be located in a number
|
||||
|
||||
An explicit path to a configuration file can be passed by using the `-f` option to MaxScale.
|
||||
|
||||
The configuration file itself is based on the ".ini" file format and consists of various sections that are used to build the configuration, these sections define services, servers, listeners, monitors and global settings.
|
||||
The configuration file itself is based on the ".ini" file format and consists of various sections that are used to build the configuration, these sections define services, servers, listeners, monitors and global settings. Parameters which expect a comma-separated list of values can be defined on multiple lines. The following is an example of a multi-line definition.
|
||||
|
||||
```
|
||||
[MyService]
|
||||
type=service
|
||||
router=readconnroute
|
||||
servers=server1,
|
||||
server2,
|
||||
server3
|
||||
```
|
||||
|
||||
The values of the parameter that are not on the first line need to have at least one whitespace character before them in order for them to be recognized as a part of the multi-line parameter.
|
||||
|
||||
Please see the section about [Protocol Modules](#protocol-modules) for more details about MaxScale and the default directories where modules will be searched for.
|
||||
|
||||
@ -55,6 +66,18 @@ threads=1
|
||||
|
||||
It should be noted that additional threads will be created to execute other internal services within MaxScale. This setting is used to configure the number of threads that will be used to manage the user connections.
|
||||
|
||||
#### `auth_connect_timeout`
|
||||
|
||||
The connection timeout in seconds for the MySQL connections to the backend server when user authentication data is fetched. Increasing the value of this parameter will cause MaxScale to wait longer for a response from the backend server before aborting the authentication process.
|
||||
|
||||
#### `auth_read_timeout`
|
||||
|
||||
The read timeout in seconds for the MySQL connection to the backend database when user authentication data is fetched. Increasing the value of this parameter will cause MaxScale to wait longer for a response from the backend server when user data is being actively fetched. If the authentication is failing and you either have a large number of database users and grants or the connection to the backend servers is slow, it is a good idea to increase this value.
|
||||
|
||||
#### `auth_write_timeout`
|
||||
|
||||
The write timeout in seconds for the MySQL connection to the backend database when user authentication data is fetched. Currently MaxScale does not write or modify the data in the backend server.
|
||||
|
||||
#### `ms_timestamp`
|
||||
|
||||
Enable or disable the high precision timestamps in logfiles. Enabling this adds millisecond precision to all logfile timestamps.
|
||||
|
@ -8,22 +8,22 @@ Mark Riddoch
|
||||
|
||||
Last Updated: 24th June 2015
|
||||
|
||||
[Overview](#overview)
|
||||
[Running MaxAdmin](#running)
|
||||
[Getting Help](#help)
|
||||
[Working with Services](#services)
|
||||
[Working with Servers](#servers)
|
||||
[Working with Sessions](#sessions)
|
||||
[Descriptor Control Blocks](#dcbs)
|
||||
[Working with Filters](#filters)
|
||||
[Working with Monitors](#monitors)
|
||||
[Working With Administration Interface Users](#interface)
|
||||
[MaxScale Status Commands](#statuscommands)
|
||||
[Administration Commands](#admincommands)
|
||||
[Configuring MaxScale to Accept MaxAdmin Connections](#connections)
|
||||
[Tuning MaxScale](#tuning)
|
||||
[Overview](#overview)
|
||||
[Running MaxAdmin](#running)
|
||||
[Working With Administration Interface Users](#interface)
|
||||
[Getting Help](#help)
|
||||
[Working with Services](#services)
|
||||
[Working with Servers](#servers)
|
||||
[Working with Sessions](#sessions)
|
||||
[Descriptor Control Blocks](#dcbs)
|
||||
[Working with Filters](#filters)
|
||||
[Working with Monitors](#monitors)
|
||||
[MaxScale Status Commands](#statuscommands)
|
||||
[Administration Commands](#admincommands)
|
||||
[Configuring MaxScale to Accept MaxAdmin Connections](#connections)
|
||||
[Tuning MaxScale](#tuning)
|
||||
|
||||
<a name="overview"></a>
|
||||
<a name="overview"></a>
|
||||
# Overview
|
||||
|
||||
MaxAdmin is a simple client interface that can be used to interact with the MaxScale server, it allows the display of internal MaxScale statistics, status and control of MaxScale operations.
|
||||
@ -36,12 +36,57 @@ MaxAdmin supports
|
||||
|
||||
* Execution of command scripts
|
||||
|
||||
<a name="running"></a>
|
||||
<a name="running"></a>
|
||||
# Running MaxAdmin
|
||||
|
||||
The MaxAdmin client application may be run in two different modes, either as an interactive command shell for executing commands against MaxScale or by passing commands on the MaxAdmin command line itself.
|
||||
|
||||
## Command Line Switches
|
||||
<a name="interface"></a>
|
||||
# Working With Administration Interface Users
|
||||
|
||||
A default installation of MaxScale allows connection to the administration interface using the username of `admin` and the password `mariadb`. This username and password stay in effect as long as no other users have been created for the administration interface. As soon as the first user is added the use of `admin/mariadb` as login credentials will be disabled.
|
||||
|
||||
|
||||
## What Users Have Been Defined?
|
||||
|
||||
In order to see the current users that have been defined for the administration interface use the command show users.
|
||||
|
||||
MaxScale> show users
|
||||
Administration interface users:
|
||||
Users table data
|
||||
Hashtable: 0x734470, size 52
|
||||
No. of entries: 5
|
||||
Average chain length: 0.1
|
||||
Longest chain length: 2
|
||||
User names: vilho, root, dba, massi, mark
|
||||
MaxScale>
|
||||
|
||||
Please note that if no users have been configured the default admin/mariadb user 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 MaxScale server use the command add user. This command is passed a user name and a password.
|
||||
|
||||
MaxScale> add user maria dtbse243
|
||||
User maria has been successfully added.
|
||||
MaxScale>
|
||||
|
||||
## Delete A User
|
||||
|
||||
To remove a user the command remove user is used, it must also be called with the username and password of the user. The password will be checked.
|
||||
|
||||
MaxScale> remove user maria des
|
||||
Failed to remove user maria. Authentication failed
|
||||
MaxScale> remove user maria dtbse243
|
||||
User maria has been successfully removed.
|
||||
MaxScale>
|
||||
|
||||
# Command Line Switches
|
||||
|
||||
The MaxAdmin command accepts a number of switches
|
||||
|
||||
@ -703,50 +748,6 @@ A monitor that has been shutdown may be restarted using the restart monitor comm
|
||||
Monitored servers: 127.0.0.1:3306, 127.0.0.1:3307, 127.0.0.1:3308, 127.0.0.1:3309
|
||||
MaxScale>
|
||||
|
||||
<a name="interface"></a>
|
||||
# Working With Administration Interface Users
|
||||
|
||||
A default installation of MaxScale allows connection to the administration interface using the username of admin and the password mariadb. This username and password stay in effect as long as no other users have been created for the administration interface. As soon as the first user is added the use of admin/mariadb as login credentials will be disabled.
|
||||
|
||||
## What Users Have Been Defined?
|
||||
|
||||
In order to see the current users that have been defined for the administration interface use the command show users.
|
||||
|
||||
MaxScale> show users
|
||||
Administration interface users:
|
||||
Users table data
|
||||
Hashtable: 0x734470, size 52
|
||||
No. of entries: 5
|
||||
Average chain length: 0.1
|
||||
Longest chain length: 2
|
||||
User names: vilho, root, dba, massi, mark
|
||||
MaxScale>
|
||||
|
||||
Please note that if no users have been configured the default admin/mariadb user 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 MaxScale server use the command add user. This command is passed a user name and a password.
|
||||
|
||||
MaxScale> add user maria dtbse243
|
||||
User maria has been successfully added.
|
||||
MaxScale>
|
||||
|
||||
## Delete A User
|
||||
|
||||
To remove a user the command remove user is used, it must also be called with the username and password of the user. The password will be checked.
|
||||
|
||||
MaxScale> remove user maria des
|
||||
Failed to remove user maria. Authentication failed
|
||||
MaxScale> remove user maria dtbse243
|
||||
User maria has been successfully removed.
|
||||
MaxScale>
|
||||
|
||||
<a name="statuscommands"></a>
|
||||
# MaxScale Status Commands
|
||||
|
||||
|
@ -1,32 +1,4 @@
|
||||
How to make MaxScale High Available
|
||||
|
||||
Corosync/Pacemaker setup
|
||||
|
||||
& MaxScale init script
|
||||
|
||||
Massimiliano Pinto
|
||||
|
||||
Last Updated: 4th August 2014
|
||||
|
||||
# Contents
|
||||
|
||||
[Contents](#heading=h.myvf4p2ngdc5)
|
||||
|
||||
[Overview](#heading=h.92d1rpk8nyx4)
|
||||
|
||||
[Clustering Software installation](#heading=h.c1l0xy6aynl7)
|
||||
|
||||
[MaxScale init script](#heading=h.cfb6xvv8fu1n)
|
||||
|
||||
[Configure MaxScale for HA](#heading=h.qk4cgmtiugm0)
|
||||
|
||||
[Use case: failed resource is restarted](#heading=h.3fszf28iz3m5)
|
||||
|
||||
[Use case: failed resource migration on a node is started in another one](#heading=h.erqw535ttk7l)
|
||||
|
||||
[Add a Virtual IP (VIP) to the cluster](#heading=h.vzslsgvxjyug)
|
||||
|
||||
# Overview
|
||||
# How to make MaxScale High Available
|
||||
|
||||
The document shows an example of a Pacemaker / Corosync setup with MaxScale based on Linux Centos 6.5, using three virtual servers and unicast heartbeat mode with the following minimum requirements:
|
||||
|
||||
@ -38,71 +10,65 @@ The document shows an example of a Pacemaker / Corosync setup with MaxScale base
|
||||
|
||||
Please note the solution is a quick setup example that may not be suited for all production environments.
|
||||
|
||||
# Clustering Software installation
|
||||
## Clustering Software installation
|
||||
|
||||
On each node in the cluster do the following steps:
|
||||
|
||||
(1) Add clustering repos to yum
|
||||
|
||||
```
|
||||
# vi /etc/yum.repos.d/ha-clustering.repo
|
||||
```
|
||||
|
||||
Add the following to the file
|
||||
|
||||
```
|
||||
[haclustering]
|
||||
|
||||
name=HA Clustering
|
||||
|
||||
baseurl=http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/
|
||||
|
||||
enabled=1
|
||||
|
||||
gpgcheck=0
|
||||
```
|
||||
|
||||
(2) Install the software
|
||||
|
||||
```
|
||||
# yum install pacemaker corosync crmsh
|
||||
```
|
||||
|
||||
Package versions used
|
||||
|
||||
Package** pacemake**r-1.1.10-14.el6_5.3.x86_64
|
||||
|
||||
Package **corosync**-1.4.5-2.4.x86_64
|
||||
|
||||
Package **crmsh**-2.0+git46-1.1.x86_64
|
||||
```
|
||||
Package pacemaker-1.1.10-14.el6_5.3.x86_64
|
||||
Package corosync-1.4.5-2.4.x86_64
|
||||
Package crmsh-2.0+git46-1.1.x86_64
|
||||
```
|
||||
|
||||
(3) Assign hostname on each node
|
||||
|
||||
|
||||
|
||||
In this example the three names used for the nodes are:
|
||||
|
||||
**node1,node,node3**
|
||||
|
||||
# hostname **node1**
|
||||
In this example the three names used for the nodes are: node1,node,node3
|
||||
|
||||
```
|
||||
[root@server1 ~]# hostname node1
|
||||
...
|
||||
|
||||
# hostname nodeN
|
||||
[root@server2 ~]# hostname node2
|
||||
...
|
||||
[root@server3 ~]# hostname node3
|
||||
```
|
||||
|
||||
(4) For each node add server names in /etc/hosts
|
||||
|
||||
```
|
||||
[root@node3 ~]# vi /etc/hosts
|
||||
|
||||
10.74.14.39 node1
|
||||
|
||||
10.228.103.72 node2
|
||||
|
||||
10.35.15.26 node3 current-node
|
||||
|
||||
[root@node1 ~]# vi /etc/hosts
|
||||
|
||||
10.74.14.39 node1 current-node
|
||||
|
||||
10.228.103.72 node2
|
||||
|
||||
10.35.15.26 node3
|
||||
|
||||
...
|
||||
[root@node1 ~]# vi /etc/hosts
|
||||
10.74.14.39 node1 current-node
|
||||
10.228.103.72 node2
|
||||
10.35.15.26 node3
|
||||
```
|
||||
|
||||
**Please note**: add **current-node** as an alias for the current node in each of the /etc/hosts files.
|
||||
|
||||
@ -110,97 +76,70 @@ In this example the three names used for the nodes are:
|
||||
|
||||
On one of the nodes, say node2 run the corosync-keygen utility and follow
|
||||
|
||||
```
|
||||
[root@node2 ~]# corosync-keygen
|
||||
|
||||
Corosync Cluster Engine Authentication key generator.
Gathering 1024 bits for key from /dev/random.
Press keys on your keyboard to generate entropy.
|
||||
|
||||
After completion the key will be found in /etc/corosync/authkey.
|
||||
```
|
||||
|
||||
(6) Prepare the corosync configuration file
|
||||
|
||||
Using node2 as an example:
|
||||
|
||||
```
|
||||
[root@node2 ~]# vi /etc/corosync/corosync.conf
|
||||
```
|
||||
|
||||
Add the following to the file:
|
||||
|
||||
```
|
||||
# Please read the corosync.conf.5 manual page
|
||||
|
||||
compatibility: whitetank
|
||||
|
||||
totem {
|
||||
|
||||
version: 2
|
||||
|
||||
secauth: off
|
||||
|
||||
interface {
|
||||
|
||||
member {
|
||||
|
||||
memberaddr: node1
|
||||
|
||||
}
|
||||
|
||||
member {
|
||||
|
||||
memberaddr: node2
|
||||
|
||||
}
|
||||
|
||||
member {
|
||||
|
||||
memberaddr: node3
|
||||
|
||||
}
|
||||
|
||||
ringnumber: 0
|
||||
|
||||
bindnetaddr: current-node
|
||||
|
||||
mcastport: 5405
|
||||
|
||||
ttl: 1
|
||||
|
||||
}
|
||||
|
||||
transport: udpu
|
||||
|
||||
}
|
||||
|
||||
logging {
|
||||
|
||||
fileline: off
|
||||
|
||||
to_logfile: yes
|
||||
|
||||
to_syslog: yes
|
||||
|
||||
logfile: /var/log/cluster/corosync.log
|
||||
|
||||
debug: off
|
||||
|
||||
timestamp: on
|
||||
|
||||
logger_subsys {
|
||||
|
||||
subsys: AMF
|
||||
|
||||
debug: off
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# this will start Pacemaker processes
|
||||
|
||||
service {
|
||||
|
||||
ver: 0
|
||||
|
||||
name: pacemaker
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
**Please note **in this example:
|
||||
|
||||
@ -212,11 +151,11 @@ name: pacemaker
|
||||
|
||||
(7) copy configuration files and auth key on each of the other nodes
|
||||
|
||||
```
|
||||
[root@node2 ~]# scp /etc/corosync/* root@node1:/etc/corosync/
|
||||
|
||||
[root@node2 ~]# scp /etc/corosync/* root@nodeN:/etc/corosync/
|
||||
|
||||
...
|
||||
[root@node2 ~]# scp /etc/corosync/* root@nodeN:/etc/corosync/
|
||||
```
|
||||
|
||||
(8) Corosync needs port *5*405 to be opened:
|
||||
|
||||
@ -224,39 +163,36 @@ name: pacemaker
|
||||
|
||||
For a quick start just disable iptables on each nodes:
|
||||
|
||||
```
|
||||
[root@node2 ~]# service iptables stop
|
||||
|
||||
…
|
||||
|
||||
...
|
||||
[root@nodeN ~]# service iptables stop
|
||||
```
|
||||
|
||||
(9) Start Corosyn on each node:
|
||||
|
||||
```
|
||||
[root@node2 ~] #/etc/init.d/corosync start
|
||||
|
||||
…
|
||||
|
||||
...
|
||||
[root@nodeN ~] #/etc/init.d/corosync start
|
||||
```
|
||||
|
||||
and check the corosync daemon is successfully bound to port 5405:
|
||||
|
||||
```
|
||||
[root@node2 ~] #netstat -na | grep 5405
|
||||
|
||||
udp 0 0 10.228.103.72:5405 0.0.0.0:*
|
||||
```
|
||||
|
||||
Check if other nodes are reachable with nc utility and option UDP (-u):
|
||||
|
||||
```
|
||||
[root@node2 ~] #echo "check ..." | nc -u node1 5405
|
||||
|
||||
[root@node2 ~] #echo "check ..." | nc -u node3 5405
|
||||
|
||||
...
|
||||
|
||||
[root@node1 ~] #echo "check ..." | nc -u node2 5405
|
||||
|
||||
[root@node1 ~] #echo "check ..." | nc -u node3 5405
|
||||
|
||||
…
|
||||
```
|
||||
|
||||
If the following message is displayed
|
||||
|
||||
@ -266,27 +202,25 @@ There is an issue with communication between the nodes, this is most likely to b
|
||||
|
||||
(10) Check the cluster status, from any node
|
||||
|
||||
```
|
||||
[root@node3 ~]# crm status
|
||||
```
|
||||
|
||||
After a while this will be the output:
|
||||
|
||||
```
|
||||
[root@node3 ~]# crm status
|
||||
|
||||
Last updated: Mon Jun 30 12:47:53 2014
|
||||
|
||||
Last change: Mon Jun 30 12:47:39 2014 via crmd on node2
|
||||
|
||||
Stack: classic openais (with plugin)
|
||||
|
||||
Current DC: node2 - partition with quorum
|
||||
|
||||
Version: 1.1.10-14.el6_5.3-368c726
|
||||
|
||||
3 Nodes configured, 3 expected votes
|
||||
|
||||
0 Resources configured
|
||||
|
||||
Online: [ node1 node2 node3 ]
|
||||
```
|
||||
|
||||
For the basic setup disable the following properties:
|
||||
|
||||
@ -294,11 +228,12 @@ For the basic setup disable the following properties:
|
||||
|
||||
- quorum policy
|
||||
|
||||
```
|
||||
[root@node3 ~]# crm configure property 'stonith-enabled'='false'
|
||||
|
||||
[root@node3 ~]# crm configure property 'no-quorum-policy'='ignore'
|
||||
```
|
||||
|
||||
For more information see:
|
||||
For additional information see:
|
||||
|
||||
[http://www.clusterlabs.org/doc/crm_fencing.html](http://www.clusterlabs.org/doc/crm_fencing.html)
|
||||
|
||||
@ -308,156 +243,131 @@ The configuration is automatically updated on every node:
|
||||
|
||||
Check it from another node, say node1
|
||||
|
||||
```
|
||||
[root@node1 ~]# crm configure show
|
||||
|
||||
node node1
|
||||
|
||||
node node2
|
||||
|
||||
node node3
|
||||
|
||||
property cib-bootstrap-options: \
|
||||
|
||||
dc-version=1.1.10-14.el6_5.3-368c726 \
|
||||
|
||||
cluster-infrastructure="classic openais (with plugin)" \
|
||||
|
||||
expected-quorum-votes=3 \
|
||||
|
||||
stonith-enabled=false \
|
||||
|
||||
no-quorum-policy=ignore \
|
||||
|
||||
placement-strategy=balanced \
|
||||
|
||||
default-resource-stickiness=infinity
|
||||
```
|
||||
|
||||
The Corosync / Pacemaker cluster is ready to be configured to manage resources.
|
||||
|
||||
# MaxScale init script /etc/init.d/maxscale
|
||||
## MaxScale init script /etc/init.d/maxscale
|
||||
|
||||
The MaxScale /etc/init.d./maxscale script allows to start/stop/restart and monitor MaxScale process running in the system.
|
||||
|
||||
Edit it and modify the **MAXSCALE_BASEDIR** to match the installation directory you choose when you installed MaxScale.
|
||||
|
||||
**Note**:
|
||||
|
||||
It could be necessary to modify other variables, such as
|
||||
|
||||
MAXSCALE_BIN, MAXSCALE_HOME, MAXSCALE_PIDFILE and LD_LIBRARY_PATH for a non standard setup.
|
||||
|
||||
```
|
||||
[root@node1 ~]# /etc/init.d/maxscale
|
||||
|
||||
Usage: /etc/init.d/maxscale {start|stop|status|restart|condrestart|reload}
|
||||
```
|
||||
|
||||
- Start
|
||||
|
||||
```
|
||||
[root@node1 ~]# /etc/init.d/maxscale start
|
||||
|
||||
Starting MaxScale: maxscale (pid 25892) is running... [ OK ]
|
||||
```
|
||||
|
||||
- Start again
|
||||
|
||||
```
|
||||
[root@node1 ~]# /etc/init.d/maxscale start
|
||||
|
||||
Starting MaxScale: found maxscale (pid 25892) is running.[ OK ]
|
||||
```
|
||||
|
||||
- Stop
|
||||
|
||||
```
|
||||
[root@node1 ~]# /etc/init.d/maxscale stop
|
||||
|
||||
Stopping MaxScale: [ OK ]
|
||||
```
|
||||
|
||||
- Stop again
|
||||
|
||||
```
|
||||
[root@node1 ~]# /etc/init.d/maxscale stop
|
||||
|
||||
Stopping MaxScale: [FAILED]
|
||||
```
|
||||
|
||||
- Status (MaxScale not running)
|
||||
|
||||
```
|
||||
[root@node1 ~]# /etc/init.d/maxscale status
|
||||
|
||||
MaxScale is stopped [FAILED]
|
||||
```
|
||||
|
||||
The script exit code for "status" is 3
|
||||
|
||||
- Status (MaxScale is running)
|
||||
|
||||
```
|
||||
[root@node1 ~]# /etc/init.d/maxscale status
|
||||
|
||||
Checking MaxScale status: MaxScale (pid 25953) is running.[ OK ]
|
||||
```
|
||||
|
||||
The script exit code for "status" is 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Note: the MaxScale script is LSB compatible and returns the proper exit code for each action:
|
||||
|
||||
For more informations;
|
||||
For additional informations;
|
||||
|
||||
[http://www.linux-ha.org/wiki/LSB_Resource_Agents](http://www.linux-ha.org/wiki/LSB_Resource_Agents)
|
||||
[http://www.linux-ha.org/wiki/LSB_Resource_Agents](http://www.linux-ha.org/wiki/LSB_Resource_Agents)
|
||||
|
||||
After checking MaxScale is well managed by the /etc/init.d/script is possible to configure the MaxScale HA via Pacemaker.
|
||||
|
||||
# Configure MaxScale for HA with Pacemaker
|
||||
|
||||
```
|
||||
[root@node2 ~]# crm configure primitive MaxScale lsb:maxscale \
|
||||
|
||||
op monitor interval="10s” timeout=”15s” \
|
||||
|
||||
op start interval="0” timeout=”15s” \
|
||||
|
||||
op stop interval="0” timeout=”30s”
|
||||
```
|
||||
|
||||
MaxScale resource will be started:
|
||||
|
||||
```
|
||||
[root@node2 ~]# crm status
|
||||
|
||||
Last updated: Mon Jun 30 13:15:34 2014
|
||||
|
||||
Last change: Mon Jun 30 13:15:28 2014 via cibadmin on node2
|
||||
|
||||
Stack: classic openais (with plugin)
|
||||
|
||||
Current DC: node2 - partition with quorum
|
||||
|
||||
Version: 1.1.10-14.el6_5.3-368c726
|
||||
|
||||
3 Nodes configured, 3 expected votes
|
||||
|
||||
1 Resources configured
|
||||
|
||||
Online: [ node1 node2 node3 ]
|
||||
|
||||
MaxScale (lsb:maxscale): Started node1
|
||||
```
|
||||
|
||||
Basic use cases:
|
||||
##Basic use cases:
|
||||
|
||||
# 1. Resource restarted after a failure:
|
||||
### 1. Resource restarted after a failure:
|
||||
|
||||
MaxScale Pid is, $MAXSCALE_PIDFILE=$MAXSCALE_HOME/log/maxscale.pid
|
||||
|
||||
In the example is 26114, kill the process immediately:
|
||||
In the example MaxScale PID is 26114, kill the process immediately:
|
||||
|
||||
```
|
||||
[root@node2 ~]# kill -9 26114
|
||||
|
||||
...
|
||||
[root@node2 ~]# crm status
|
||||
|
||||
Last updated: Mon Jun 30 13:16:11 2014
|
||||
|
||||
Last change: Mon Jun 30 13:15:28 2014 via cibadmin on node2
|
||||
|
||||
Stack: classic openais (with plugin)
|
||||
|
||||
Current DC: node2 - partition with quorum
|
||||
|
||||
Version: 1.1.10-14.el6_5.3-368c726
|
||||
|
||||
3 Nodes configured, 3 expected votes
|
||||
|
||||
1 Resources configured
|
||||
|
||||
Online: [ node1 node2 node3 ]
|
||||
@ -465,37 +375,34 @@ Online: [ node1 node2 node3 ]
|
||||
Failed actions:
|
||||
|
||||
MaxScale_monitor_15000 on node1 'not running' (7): call=19, status=complete, last-rc-change='Mon Jun 30 13:16:14 2014', queued=0ms, exec=0ms
|
||||
```
|
||||
|
||||
**Note** the **MaxScale_monitor** failed action
|
||||
|
||||
After a few seconds it will be started again:
|
||||
|
||||
```
|
||||
[root@node2 ~]# crm status
|
||||
|
||||
Last updated: Mon Jun 30 13:21:12 2014
|
||||
|
||||
Last change: Mon Jun 30 13:15:28 2014 via cibadmin on node1
|
||||
|
||||
Stack: classic openais (with plugin)
|
||||
|
||||
Current DC: node2 - partition with quorum
|
||||
|
||||
Version: 1.1.10-14.el6_5.3-368c726
|
||||
|
||||
3 Nodes configured, 3 expected votes
|
||||
|
||||
1 Resources configured
|
||||
|
||||
Online: [ node1 node2 node3 ]
|
||||
|
||||
MaxScale (lsb:maxscale): Started node1
|
||||
```
|
||||
|
||||
# 2. The resource cannot be migrated to node1 for a failure:
|
||||
### 2. The resource cannot be migrated to node1 for a failure:
|
||||
|
||||
First, migrate the the resource to another node, say node3
|
||||
|
||||
```
|
||||
[root@node1 ~]# crm resource migrate MaxScale node3
|
||||
|
||||
...
|
||||
|
||||
Online: [ node1 node2 node3 ]
|
||||
@ -503,23 +410,19 @@ Online: [ node1 node2 node3 ]
|
||||
Failed actions:
|
||||
|
||||
MaxScale_start_0 on node1 'not running' (7): call=76, status=complete, last-rc-change='Mon Jun 30 13:31:17 2014', queued=2015ms, exec=0ms
|
||||
```
|
||||
|
||||
Note the **MaxScale_start** failed action on node1, and after a few seconds
|
||||
|
||||
```
|
||||
[root@node3 ~]# crm status
|
||||
|
||||
Last updated: Mon Jun 30 13:35:00 2014
|
||||
|
||||
Last change: Mon Jun 30 13:31:13 2014 via crm_resource on node3
|
||||
|
||||
Stack: classic openais (with plugin)
|
||||
|
||||
Current DC: node2 - partition with quorum
|
||||
|
||||
Version: 1.1.10-14.el6_5.3-368c726
|
||||
|
||||
3 Nodes configured, 3 expected votes
|
||||
|
||||
1 Resources configured
|
||||
|
||||
Online: [ node1 node2 node3 ]
|
||||
@ -529,6 +432,7 @@ Online: [ node1 node2 node3 ]
|
||||
Failed actions:
|
||||
|
||||
MaxScale_start_0 on node1 'not running' (7): call=76, status=complete, last-rc-change='Mon Jun 30 13:31:17 2014', queued=2015ms, exec=0ms
|
||||
```
|
||||
|
||||
Successfully, MaxScale has been started on a new node: node2.
|
||||
|
||||
@ -536,37 +440,32 @@ Successfully, MaxScale has been started on a new node: node2.
|
||||
|
||||
With "crm resource cleanup MaxScale" is possible to cleanup the messages:
|
||||
|
||||
```
|
||||
[root@node1 ~]# crm resource cleanup MaxScale
|
||||
|
||||
Cleaning up MaxScale on node1
|
||||
|
||||
Cleaning up MaxScale on node2
|
||||
|
||||
Cleaning up MaxScale on node3
|
||||
```
|
||||
|
||||
The cleaned status is visible from other nodes as well:
|
||||
|
||||
```
|
||||
[root@node2 ~]# crm status
|
||||
|
||||
Last updated: Mon Jun 30 13:38:18 2014
|
||||
|
||||
Last change: Mon Jun 30 13:38:17 2014 via crmd on node3
|
||||
|
||||
Stack: classic openais (with plugin)
|
||||
|
||||
Current DC: node2 - partition with quorum
|
||||
|
||||
Version: 1.1.10-14.el6_5.3-368c726
|
||||
|
||||
3 Nodes configured, 3 expected votes
|
||||
|
||||
1 Resources configured
|
||||
|
||||
Online: [ node1 node2 node3 ]
|
||||
|
||||
MaxScale (lsb:maxscale): Started node2
|
||||
```
|
||||
|
||||
# Add a Virtual IP (VIP) to the cluster
|
||||
## Add a Virtual IP (VIP) to the cluster
|
||||
|
||||
It’s possible to add a virtual IP to the cluster:
|
||||
|
||||
@ -576,74 +475,53 @@ Setup is very easy:
|
||||
|
||||
assuming an addition IP address is available and can be added to one of the nodes, this i the new configuration to add:
|
||||
|
||||
```
|
||||
[root@node2 ~]# crm configure primitive maxscale_vip ocf:heartbeat:IPaddr2 params ip=192.168.122.125 op monitor interval=10s
|
||||
|
||||
|
||||
```
|
||||
|
||||
MaxScale process and the VIP must be run in the same node, so it’s mandatory to add to the configuration the group ‘maxscale_service’.
|
||||
|
||||
```
|
||||
[root@node2 ~]# crm configure group maxscale_service maxscale_vip MaxScale
|
||||
```
|
||||
|
||||
The final configuration is, from another node:
|
||||
|
||||
```
|
||||
[root@node3 ~]# crm configure show
|
||||
|
||||
node node1
|
||||
|
||||
node node2
|
||||
|
||||
node node3
|
||||
|
||||
primitive MaxScale lsb:maxscale \
|
||||
|
||||
op monitor interval=15s timeout=10s \
|
||||
|
||||
op start interval=0 timeout=15s \
|
||||
|
||||
op stop interval=0 timeout=30s
|
||||
|
||||
primitive maxscale_vip IPaddr2 \
|
||||
|
||||
params ip=192.168.122.125 \
|
||||
|
||||
op monitor interval=10s
|
||||
|
||||
group maxscale_service maxscale_vip MaxScale \
|
||||
|
||||
meta target-role=Started
|
||||
|
||||
property cib-bootstrap-options: \
|
||||
|
||||
dc-version=1.1.10-14.el6_5.3-368c726 \
|
||||
|
||||
cluster-infrastructure="classic openais (with plugin)" \
|
||||
|
||||
expected-quorum-votes=3 \
|
||||
|
||||
stonith-enabled=false \
|
||||
|
||||
no-quorum-policy=ignore \
|
||||
|
||||
placement-strategy=balanced \
|
||||
|
||||
last-lrm-refresh=1404125486
|
||||
```
|
||||
|
||||
Check the resource status:
|
||||
|
||||
```
|
||||
[root@node1 ~]# crm status
|
||||
|
||||
Last updated: Mon Jun 30 13:51:29 2014
|
||||
|
||||
Last change: Mon Jun 30 13:51:27 2014 via crmd on node1
|
||||
|
||||
Stack: classic openais (with plugin)
|
||||
|
||||
Current DC: node2 - partition with quorum
|
||||
|
||||
Version: 1.1.10-14.el6_5.3-368c726
|
||||
|
||||
3 Nodes configured, 3 expected votes
|
||||
|
||||
2 Resources configured
|
||||
|
||||
Online: [ node1 node2 node3 ]
|
||||
@ -653,6 +531,7 @@ Online: [ node1 node2 node3 ]
|
||||
maxscale_vip (ocf::heartbeat:IPaddr2): Started node2
|
||||
|
||||
MaxScale (lsb:maxscale): Started node2
|
||||
```
|
||||
|
||||
With both resources on node2, now MaxScale service will be reachable via the configured VIP address 192.168.122.125
|
||||
|
||||
|
@ -65,7 +65,7 @@ where *<criteria>* is one of the following:
|
||||
|
||||
**`use_sql_variables_in`** specifies where should queries, which read session variable, be routed. The syntax for `use_sql_variable_in` is:
|
||||
|
||||
use_sql_variables_in=[master|all]
|
||||
use_sql_variables_in=[master|all] (default: all)
|
||||
|
||||
When value all is used, queries reading session variables can be routed to any available slave (depending on selection criteria). Note, that queries modifying session variables are routed to all backend servers by default, excluding write queries with embedded session variable modifications, such as:
|
||||
|
||||
|
@ -44,6 +44,7 @@ Switch|Long Option|Description
|
||||
`-s [yes no]`|`--syslog=[yes no]`|log messages to syslog (default:yes)
|
||||
`-S [yes no]`|`--maxscalelog=[yes no]`|log messages to MaxScale log (default: yes)
|
||||
`-v`|`--version`|print version info and exit
|
||||
`-V`|`--version-full`|print version info and the commit ID the binary was built from
|
||||
`-?`|`--help`|show this help
|
||||
|
||||
<a name="stopping"></a>
|
||||
|
@ -47,23 +47,23 @@ The MaxScale 1.0 GA release contains an implementation of a tee filter that allo
|
||||
## Filter Definition
|
||||
|
||||
Filters are defined in the configuration file, MaxScale.ini, using a section for each filter instance. The content of the filter sections in the configuration file various from filter to filter, however there are always to entries present for every filter, the type and module.
|
||||
|
||||
[MyFilter]
|
||||
type=filter
|
||||
module=xxxfilter
|
||||
|
||||
```
|
||||
[MyFilter]
|
||||
type=filter
|
||||
module=xxxfilter
|
||||
```
|
||||
The type is used by the configuration manager within MaxScale to determine what this section is defining and the module is the name of the plugin that implements the filter.
|
||||
|
||||
When a filter is used within a service in MaxScale the entry filters= is added to the service definition in the ini file section for the service. Multiple filters can be defined using a syntax akin to the Linux shell pipe syntax.
|
||||
|
||||
[Split Service]
|
||||
type=service
|
||||
router=readwritesplit
|
||||
servers=dbserver1,dbserver2,dbserver3,dbserver4
|
||||
user=massi
|
||||
passwd=6628C50E07CCE1F0392EDEEB9D1203F3
|
||||
filters=hints | top10
|
||||
|
||||
```
|
||||
[Split Service]
|
||||
type=service
|
||||
router=readwritesplit
|
||||
servers=dbserver1,dbserver2,dbserver3,dbserver4
|
||||
user=massi
|
||||
passwd=6628C50E07CCE1F0392EDEEB9D1203F3
|
||||
filters=hints | top10
|
||||
```
|
||||
The names used in the filters= parameter are the names of the filter definition sections in the ini file. The same filter definition can be used in multiple services and the same filter module can have multiple instances, each with its own section in the ini file.
|
||||
|
||||
## Filter Examples
|
||||
@ -75,46 +75,45 @@ The filters that are bundled with the MaxScale 1.0 GA release are documented sep
|
||||
The top filter can be used to measure the execution time of every statement within a connection and log the details of the longest running statements.
|
||||
|
||||
The first thing to do is to define a filter entry in the ini file for the top filter. In this case we will call it "top30". The type is filter and the module that implements the filter is called topfilter.
|
||||
|
||||
[top30]
|
||||
type=filter
|
||||
module=topfilter
|
||||
count=30
|
||||
filebase=/var/log/DBSessions/top30
|
||||
|
||||
```
|
||||
[top30]
|
||||
type=filter
|
||||
module=topfilter
|
||||
count=30
|
||||
filebase=/var/log/DBSessions/top30
|
||||
```
|
||||
In the definition above we have defined two filter specific parameters, the count of the number of statement to be logged and a filebase that is used to define where to log the information. This filename is a stem to which a session id is added for each new connection that uses the filter.
|
||||
|
||||
The filter keeps track of every statement that is executed, monitors the time it takes for a response to come back and uses this as the measure of execution time for the statement. If the time is longer than the other statements that have been recorded, then this is added to the ordered list within the filter. Once 30 statements have been recorded those statements that have been recorded with the least time are discarded from the list. The result is that at any time the filter has a list of the 30 longest running statements in each session.
|
||||
|
||||
It is possible to see what is in the current list by using the maxadmin tool to view the state of the filter by looking at the session data. First you need to find the session id for the session of interest, this can be done using commands such as list sessions. You can then use the show session command to see the details for a particular session.
|
||||
```
|
||||
MaxScale> show session 0x736680
|
||||
|
||||
MaxScale> show session 0x736680
|
||||
Session 0x736680
|
||||
State: Session ready for routing
|
||||
Service: Split Service (0x719f60)
|
||||
Client DCB: 0x7361a0
|
||||
Client Address: 127.0.0.1
|
||||
Connected: Thu Jun 26 10:10:44 2014
|
||||
|
||||
Session 0x736680
|
||||
State: Session ready for routing
|
||||
Service: Split Service (0x719f60)
|
||||
Client DCB: 0x7361a0
|
||||
Client Address: 127.0.0.1
|
||||
Connected: Thu Jun 26 10:10:44 2014
|
||||
Filter: top30
|
||||
Report size 30
|
||||
Logging to file /var/log/DBSessions/top30.1.
|
||||
Current Top 30:
|
||||
|
||||
Filter: top30
|
||||
Report size 30
|
||||
Logging to file /var/log/DBSessions/top30.1.
|
||||
Current Top 30:
|
||||
1 place:
|
||||
Execution time: 23.826 seconds
|
||||
SQL: select sum(salary), year(from_date) from salaries s, (select distinct year(from_date) as y1 from salaries) y where (makedate(y.y1, 1) between s.from_date and s.to_date) group by y.y1 ("1988-08-01?
|
||||
|
||||
1 place:
|
||||
Execution time: 23.826 seconds
|
||||
SQL: select sum(salary), year(from_date) from salaries s, (select distinct year(from_date) as y1 from salaries) y where (makedate(y.y1, 1) between s.from_date and s.to_date) group by y.y1 ("1988-08-01?
|
||||
2 place:
|
||||
Execution time: 5.251 seconds
|
||||
SQL: select d.dept_name as "Department", y.y1 as "Year", count(*) as "Count" from departments d, dept_emp de, (select distinct year(from_date) as y1 from dept_emp order by 1) y where d.dept_no = de.dept_no and (makedate(y.y1, 1) between de.from_date and de.to_date) group by y.y1, d.dept_name order by 1, 2
|
||||
|
||||
2 place:
|
||||
Execution time: 5.251 seconds
|
||||
SQL: select d.dept_name as "Department", y.y1 as "Year", count(*) as "Count" from departments d, dept_emp de, (select distinct year(from_date) as y1 from dept_emp order by 1) y where d.dept_no = de.dept_no and (makedate(y.y1, 1) between de.from_date and de.to_date) group by y.y1, d.dept_name order by 1, 2
|
||||
|
||||
3 place:
|
||||
Execution time: 2.903 seconds
|
||||
SQL: select year(now()) - year(birth_date) as age, gender, avg(salary) as "Average Salary" from employees e, salaries s where e.emp_no = s.emp_no and ("1988-08-01" between from_date AND to_date) group by year(now()) - year(birth_date), gender order by 1,2
|
||||
|
||||
...
|
||||
3 place:
|
||||
Execution time: 2.903 seconds
|
||||
SQL: select year(now()) - year(birth_date) as age, gender, avg(salary) as "Average Salary" from employees e, salaries s where e.emp_no = s.emp_no and ("1988-08-01" between from_date AND to_date) group by year(now()) - year(birth_date), gender order by 1,2
|
||||
```
|
||||
|
||||
When the session ends a report will be written for the session into the logfile defined. That report will include the top 30 longest running statements, plus summary data for the session;
|
||||
|
||||
@ -133,46 +132,46 @@ When the session ends a report will be written for the session into the logfile
|
||||
### Duplicate Data From Your Application Into Cassandra
|
||||
|
||||
The scenario we are using in this example is one in which you have an online gaming application that is designed to work with a MariaDB/MySQL database. The database schema includes a high score table which you would like to have access to in a Cassandra cluster. The application is already using MaxScale to connect to a MariaDB Galera cluster, using a service names BubbleGame. The definition of that service is as follows
|
||||
|
||||
[BubbleGame]
|
||||
type=service
|
||||
router=readwritesplit
|
||||
servers=dbbubble1,dbbubble2,dbbubble3,dbbubble4,dbbubble5
|
||||
user=maxscale
|
||||
passwd=6628C50E07CCE1F0392EDEEB9D1203F3
|
||||
|
||||
```
|
||||
[BubbleGame]
|
||||
type=service
|
||||
router=readwritesplit
|
||||
servers=dbbubble1,dbbubble2,dbbubble3,dbbubble4,dbbubble5
|
||||
user=maxscale
|
||||
passwd=6628C50E07CCE1F0392EDEEB9D1203F3
|
||||
```
|
||||
The table you wish to store in Cassandra in called HighScore and will contain the same columns in both the MariaDB table and the Cassandra table. The first step is to install a MariaDB instance with the Cassandra storage engine to act as a bridge server between the relational database and Cassandra. In this bridge server add a table definition for the HighScore table with the engine type set to cassandra. Add this server into the MaxScale configuration and create a service that will connect to this server.
|
||||
|
||||
[CassandraDB]
|
||||
type=server
|
||||
address=192.168.4.28
|
||||
port=3306
|
||||
protocol=MySQLBackend
|
||||
[Cassandra]
|
||||
type=service
|
||||
router=readconnrouter
|
||||
router_options=running
|
||||
servers=CassandraDB
|
||||
user=maxscale
|
||||
passwd=6628C50E07CCE1F0392EDEEB9D1203F3
|
||||
|
||||
```
|
||||
[CassandraDB]
|
||||
type=server
|
||||
address=192.168.4.28
|
||||
port=3306
|
||||
protocol=MySQLBackend
|
||||
[Cassandra]
|
||||
type=service
|
||||
router=readconnrouter
|
||||
router_options=running
|
||||
servers=CassandraDB
|
||||
user=maxscale
|
||||
passwd=6628C50E07CCE1F0392EDEEB9D1203F3
|
||||
```
|
||||
Next add a filter definition for the tee filter that will duplication insert statements that are destined for the HighScore table to this new service.
|
||||
|
||||
[HighScores]
|
||||
type=filter
|
||||
module=teefilter
|
||||
match=insert.*HighScore.*values
|
||||
service=Cassandra
|
||||
|
||||
```
|
||||
[HighScores]
|
||||
type=filter
|
||||
module=teefilter
|
||||
match=insert.*HighScore.*values
|
||||
service=Cassandra
|
||||
```
|
||||
The above filter definition will cause all statements that match the regular expression inset.*HighScore.*values to be duplication and sent not just to the original destination, via the router but also to the service named Cassandra.
|
||||
|
||||
The final step is to add the filter to the BubbleGame service to enable the use of the filter.
|
||||
|
||||
[BubbleGame]
|
||||
type=service
|
||||
router=readwritesplit
|
||||
servers=dbbubble1,dbbubble2,dbbubble3,dbbubble4,dbbubble5
|
||||
user=maxscale
|
||||
passwd=6628C50E07CCE1F0392EDEEB9D1203F3
|
||||
filters=HighScores
|
||||
|
||||
```
|
||||
[BubbleGame]
|
||||
type=service
|
||||
router=readwritesplit
|
||||
servers=dbbubble1,dbbubble2,dbbubble3,dbbubble4,dbbubble5
|
||||
user=maxscale
|
||||
passwd=6628C50E07CCE1F0392EDEEB9D1203F3
|
||||
filters=HighScores
|
||||
```
|
||||
|
@ -65,158 +65,159 @@ If you wish to use two different usernames for the two different roles of monito
|
||||
MaxScale configuration is held in an ini file that is located in the file maxscale.cnf in the directory /etc, if you have installed in the default location then this file is available in /etc/maxscale.cnf. This is not created as part of the installation process and must be manually created. A template file does exist within the /usr/share/maxscale directory that may be use as a basis for your configuration.
|
||||
|
||||
A global, maxscale, section is included within every MaxScale configuration file; this is used to set the values of various MaxScale wide parameters, perhaps the most important of these is the number of threads that MaxScale will use to execute the code that forwards requests and handles responses for clients.
|
||||
|
||||
[maxscale]
|
||||
threads=4
|
||||
|
||||
```
|
||||
[maxscale]
|
||||
threads=4
|
||||
```
|
||||
The first step is to create a service for our Read/Write Splitter. Create a section in your MaxScale.ini file and set the type to service, the section names are the names of the services themselves and should be meaningful to the administrator. Names may contain whitespace.
|
||||
|
||||
[Splitter Service]
|
||||
type=service
|
||||
|
||||
```
|
||||
[Splitter Service]
|
||||
type=service
|
||||
```
|
||||
The router for we need to use for this configuration is the readwritesplit module, also the services should be provided with the list of servers that will be part of the cluster. The server names given here are actually the names of server sections in the configuration file and not the physical hostnames or addresses of the servers.
|
||||
|
||||
[Splitter Service]
|
||||
type=service
|
||||
router=readwritesplit
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
|
||||
```
|
||||
[Splitter Service]
|
||||
type=service
|
||||
router=readwritesplit
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
```
|
||||
The final step in the service sections is to add the username and password that will be used to populate the user data from the database cluster. There are two options for representing the password, either plain text or encrypted passwords may be used. In order to use encrypted passwords a set of keys must be generated that will be used by the encryption and decryption process. To generate the keys use the maxkeys command and pass the name of the secrets file in which the keys are stored.
|
||||
|
||||
% maxkeys /var/lib/maxscale/.secrets
|
||||
%
|
||||
|
||||
```
|
||||
% maxkeys /var/lib/maxscale/.secrets
|
||||
%
|
||||
```
|
||||
Once the keys have been created the maxpasswd command can be used to generate the encrypted password.
|
||||
|
||||
% maxpasswd plainpassword
|
||||
96F99AA1315BDC3604B006F427DD9484
|
||||
%
|
||||
|
||||
```
|
||||
% maxpasswd plainpassword
|
||||
96F99AA1315BDC3604B006F427DD9484
|
||||
%
|
||||
```
|
||||
The username and password, either encrypted or plain text, are stored in the service section using the user and passwd parameters.
|
||||
|
||||
[Splitter Service]
|
||||
type=service
|
||||
router=readwritesplit
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
user=maxscale
|
||||
passwd=96F99AA1315BDC3604B006F427DD9484
|
||||
|
||||
```
|
||||
[Splitter Service]
|
||||
type=service
|
||||
router=readwritesplit
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
user=maxscale
|
||||
passwd=96F99AA1315BDC3604B006F427DD9484
|
||||
```
|
||||
This completes the definitions required by the service, however listening ports must be associated with the service in order to allow network connections. This is done by creating a series of listener sections. This section again is named for the convenience of the administrator and should be of type listener with an entry labeled service which contains the name of the service to associate the listener with. A service may have multiple listeners.
|
||||
|
||||
[Splitter Listener]
|
||||
type=listener
|
||||
service=Splitter Service
|
||||
|
||||
```
|
||||
[Splitter Listener]
|
||||
type=listener
|
||||
service=Splitter Service
|
||||
```
|
||||
A listener must also define the protocol module it will use for the incoming network protocol, currently this should be the MySQLClient protocol for all database listeners. The listener may then supply a network port to listen on and/or a socket within the file system.
|
||||
|
||||
[Splitter Listener]
|
||||
type=listener
|
||||
service=Splitter Service
|
||||
protocol=MySQLClient
|
||||
port=3306
|
||||
socket=/tmp/ClusterMaster
|
||||
|
||||
```
|
||||
[Splitter Listener]
|
||||
type=listener
|
||||
service=Splitter Service
|
||||
protocol=MySQLClient
|
||||
port=3306
|
||||
socket=/tmp/ClusterMaster
|
||||
```
|
||||
An address parameter may be given if the listener is required to bind to a particular network address when using hosts with multiple network addresses. The default behavior is to listen on all network interfaces.
|
||||
|
||||
The next stage is the configuration is to define the server information. This defines how to connect to each of the servers within the cluster, again a section is created for each server, with the type set to server, the network address and port to connect to and the protocol to use to connect to the server. Currently the protocol module for all database connections in MySQLBackend.
|
||||
```
|
||||
[dbserv1]
|
||||
type=server
|
||||
address=192.168.2.1
|
||||
port=3306
|
||||
protocol=MySQLBackend
|
||||
|
||||
[dbserv1]
|
||||
type=server
|
||||
address=192.168.2.1
|
||||
port=3306
|
||||
protocol=MySQLBackend
|
||||
[dbserv2]
|
||||
type=server
|
||||
address=192.168.2.2
|
||||
port=3306
|
||||
protocol=MySQLBackend
|
||||
[dbserv3]
|
||||
type=server
|
||||
address=192.168.2.3
|
||||
port=3306
|
||||
protocol=MySQLBackend
|
||||
[dbserv2]
|
||||
type=server
|
||||
address=192.168.2.2
|
||||
port=3306
|
||||
protocol=MySQLBackend
|
||||
|
||||
[dbserv3]
|
||||
type=server
|
||||
address=192.168.2.3
|
||||
port=3306
|
||||
protocol=MySQLBackend
|
||||
```
|
||||
In order for MaxScale to monitor the servers using the correct monitoring mechanisms a section should be provided that defines the monitor to use and the servers to monitor. Once again a section is created with a symbolic name for the monitor, with the type set to monitor. Parameters are added for the module to use, the list of servers to monitor and the username and password to use when connecting to the the servers with the monitor.
|
||||
|
||||
[Galera Monitor]
|
||||
type=monitor
|
||||
module=galeramon
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
user=maxscale
|
||||
passwd=96F99AA1315BDC3604B006F427DD9484
|
||||
|
||||
```
|
||||
[Galera Monitor]
|
||||
type=monitor
|
||||
module=galeramon
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
user=maxscale
|
||||
passwd=96F99AA1315BDC3604B006F427DD9484
|
||||
```
|
||||
As with the password definition in the server either plain text or encrypted passwords may be used.
|
||||
|
||||
This monitor module will assign one node within the Galera Cluster as the current master and other nodes as slave. Only those nodes that are active members of the cluster are considered when making the choice of master node. Normally the master node will be the node with the lowest value of the status variable, WSREP_LOCAL_INDEX. When cluster membership changes a new master may be elected. In order to prevent changes of the node that is currently master, a parameter can be added to the monitor that will result in the current master remaining as master even if a node with a lower value of WSREP_LOCAL_INDEX joins the cluster. This parameter is called disable_master_failback.
|
||||
|
||||
[Galera Monitor]
|
||||
type=monitor
|
||||
module=galeramon
|
||||
diable_master_failback=1
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
user=maxscale
|
||||
passwd=96F99AA1315BDC3604B006F427DD9484
|
||||
|
||||
```
|
||||
[Galera Monitor]
|
||||
type=monitor
|
||||
module=galeramon
|
||||
diable_master_failback=1
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
user=maxscale
|
||||
passwd=96F99AA1315BDC3604B006F427DD9484
|
||||
```
|
||||
Using this option the master node will only change if there is a problem with the current master and never because other nodes have joined the cluster.
|
||||
|
||||
The final stage in the configuration is to add the option service which is used by the maxadmin command to connect to MaxScale for monitoring and administration purposes. This creates a service section and a listener section.
|
||||
```
|
||||
[CLI]
|
||||
type=service
|
||||
router=cli
|
||||
|
||||
[CLI]
|
||||
type=service
|
||||
router=cli
|
||||
[CLI Listener]
|
||||
type=listener
|
||||
service=CLI
|
||||
protocol=maxscaled
|
||||
address=localhost
|
||||
port=6603
|
||||
|
||||
[CLI Listener]
|
||||
type=listener
|
||||
service=CLI
|
||||
protocol=maxscaled
|
||||
address=localhost
|
||||
port=6603
|
||||
```
|
||||
In the case of the example above it should be noted that an address parameter has been given to the listener, this limits connections to maxadmin commands that are executed on the same machine that hosts MaxScale.
|
||||
|
||||
## Starting MaxScale
|
||||
|
||||
Upon completion of the configuration process MaxScale is ready to be started for the first time. This may either be done manually by running the maxscale command or via the service interface.
|
||||
|
||||
% maxscale
|
||||
|
||||
```
|
||||
% maxscale
|
||||
```
|
||||
or
|
||||
|
||||
% service maxscale start
|
||||
|
||||
```
|
||||
% service maxscale start
|
||||
```
|
||||
Check the error log in /var/log/maxscale to see if any errors are detected in the configuration file and to confirm MaxScale has been started. Also the maxadmin command may be used to confirm that MaxScale is running and the services, listeners etc have been correctly configured.
|
||||
```
|
||||
% maxadmin -pmariadb list services
|
||||
|
||||
% maxadmin -pmariadb list services
|
||||
|
||||
Services.
|
||||
--------------------------+----------------------+--------+---------------
|
||||
Service Name | Router Module | #Users | Total Sessions
|
||||
--------------------------+----------------------+--------+---------------
|
||||
Splitter Service | readwritesplit | 1 | 1
|
||||
CLI | cli | 2 | 2
|
||||
--------------------------+----------------------+--------+---------------
|
||||
|
||||
% maxadmin -pmariadb list servers
|
||||
Servers.
|
||||
-------------------+-----------------+-------+-------------+--------------------
|
||||
Server | Address | Port | Connections | Status
|
||||
-------------------+-----------------+-------+-------------+--------------------
|
||||
dbserv1 | 192.168.2.1 | 3306 | 0 | Running, Synced, Master
|
||||
dbserv2 | 192.168.2.2 | 3306 | 0 | Running, Synced, Slave
|
||||
dbserv3 | 192.168.2.3 | 3306 | 0 | Running, Synced, Slave
|
||||
-------------------+-----------------+-------+-------------+--------------------
|
||||
Services.
|
||||
--------------------------+----------------------+--------+---------------
|
||||
Service Name | Router Module | #Users | Total Sessions
|
||||
--------------------------+----------------------+--------+---------------
|
||||
Splitter Service | readwritesplit | 1 | 1
|
||||
CLI | cli | 2 | 2
|
||||
--------------------------+----------------------+--------+---------------
|
||||
|
||||
% maxadmin -pmariadb list servers
|
||||
Servers.
|
||||
-------------------+-----------------+-------+-------------+--------------------
|
||||
Server | Address | Port | Connections | Status
|
||||
-------------------+-----------------+-------+-------------+--------------------
|
||||
dbserv1 | 192.168.2.1 | 3306 | 0 | Running, Synced, Master
|
||||
dbserv2 | 192.168.2.2 | 3306 | 0 | Running, Synced, Slave
|
||||
dbserv3 | 192.168.2.3 | 3306 | 0 | Running, Synced, Slave
|
||||
-------------------+-----------------+-------+-------------+--------------------
|
||||
```
|
||||
A Galera Cluster is a multi-master clustering technology, however the monitor is able to impose false notions of master and slave roles within a Galera Cluster in order to facilitate the use of Galera as if it were a standard MySQL Replication setup. This is merely an internal MaxScale convenience and has no impact on the behavior of the cluster but does allow the monitor to create these pseudo roles which are utilized by the Read/Write Splitter.
|
||||
```
|
||||
% maxadmin -pmariadb list listeners
|
||||
|
||||
% maxadmin -pmariadb list listeners
|
||||
|
||||
Listeners.
|
||||
---------------------+--------------------+-----------------+-------+--------
|
||||
Service Name | Protocol Module | Address | Port | State
|
||||
---------------------+--------------------+-----------------+-------+--------
|
||||
Splitter Service | MySQLClient | * | 3306 | Running
|
||||
CLI | maxscaled | localhost | 6603 | Running
|
||||
---------------------+--------------------+-----------------+-------+--------
|
||||
%
|
||||
|
||||
Listeners.
|
||||
---------------------+--------------------+-----------------+-------+--------
|
||||
Service Name | Protocol Module | Address | Port | State
|
||||
---------------------+--------------------+-----------------+-------+--------
|
||||
Splitter Service | MySQLClient | * | 3306 | Running
|
||||
CLI | maxscaled | localhost | 6603 | Running
|
||||
---------------------+--------------------+-----------------+-------+--------
|
||||
```
|
||||
MaxScale is now ready to start accepting client connections and routing them to the master or slaves within your cluster. Other configuration options are available that can alter the criteria used for routing, these include monitoring the replication lag within the cluster and routing only to slaves that are within a predetermined delay from the current master or using weights to obtain unequal balancing operations. These options may be found in the MaxScale Configuration Guide. More detail on the use of maxadmin can be found in the document "MaxAdmin - The MaxScale Administration & Monitoring Client Application".
|
||||
|
||||
|
@ -12,31 +12,31 @@ The specified user, with the password (plain or encrypted via maxpassword utilit
|
||||
Currently the user can connect to maxinfo from any remote IP and to localhost as well.
|
||||
|
||||
```
|
||||
[MaxInfo]
|
||||
type=service
|
||||
router=maxinfo
|
||||
user=monitor
|
||||
passwd=EBD2F49C3B375812A8CDEBA632ED8BBC
|
||||
[MaxInfo]
|
||||
type=service
|
||||
router=maxinfo
|
||||
user=monitor
|
||||
passwd=EBD2F49C3B375812A8CDEBA632ED8BBC
|
||||
```
|
||||
|
||||
The listener section defines the protocol, port and other information needed to create a listener for the service. To listen on a port using the MySQL protocol a section as shown below should be added to the configuration file.
|
||||
|
||||
```
|
||||
[MaxInfo Listener]
|
||||
type=listener
|
||||
service=MaxInfo
|
||||
protocol=MySQLClient
|
||||
port=9003
|
||||
[MaxInfo Listener]
|
||||
type=listener
|
||||
service=MaxInfo
|
||||
protocol=MySQLClient
|
||||
port=9003
|
||||
```
|
||||
|
||||
To listen with the HTTP protocol and hence return JSON documents a section as should below is required.
|
||||
|
||||
```
|
||||
[MaxInfo JSON Listener]
|
||||
type=listener
|
||||
service=MaxInfo
|
||||
protocol=HTTPD
|
||||
port=8003
|
||||
[MaxInfo JSON Listener]
|
||||
type=listener
|
||||
service=MaxInfo
|
||||
protocol=HTTPD
|
||||
port=8003
|
||||
|
||||
```
|
||||
|
||||
@ -45,12 +45,12 @@ If both the MySQL and JSON responses are required then a single service can be c
|
||||
As with any other listeners within MaxScale the listeners can be bound to a particular interface by use of the address= parameter. This allows the access to the maxinfo data to be limited to the localhost by adding an address=localhost parameter in the configuration file.
|
||||
|
||||
```
|
||||
[MaxInfo Listener]
|
||||
type=listener
|
||||
service=MaxInfo
|
||||
protocol=MySQLClient
|
||||
address=localhost
|
||||
port=9003
|
||||
[MaxInfo Listener]
|
||||
type=listener
|
||||
service=MaxInfo
|
||||
protocol=MySQLClient
|
||||
address=localhost
|
||||
port=9003
|
||||
```
|
||||
|
||||
# MySQL Interface to maxinfo
|
||||
@ -58,11 +58,11 @@ As with any other listeners within MaxScale the listeners can be bound to a part
|
||||
The maxinfo supports a small subset of SQL statements in addition to the MySQL status and ping requests. These may be used for simple monitoring of MaxScale.
|
||||
|
||||
```
|
||||
% mysqladmin -hmaxscale.mariadb.com -P9003 -umonitor -pxyz ping
|
||||
mysqld is alive
|
||||
% mysqladmin -hmaxscale.mariadb.com -P9003 -umonitor -pxyz status
|
||||
Uptime: 72 Threads: 1 Sessions: 11
|
||||
%
|
||||
% mysqladmin -hmaxscale.mariadb.com -P9003 -umonitor -pxyz ping
|
||||
mysqld is alive
|
||||
% mysqladmin -hmaxscale.mariadb.com -P9003 -umonitor -pxyz status
|
||||
Uptime: 72 Threads: 1 Sessions: 11
|
||||
%
|
||||
```
|
||||
|
||||
The SQL command used to interact with maxinfo is the show command, a variety of show commands are available and will be described in the following sections.
|
||||
@ -72,64 +72,64 @@ The SQL command used to interact with maxinfo is the show command, a variety of
|
||||
The show variables command will display a set of name and value pairs for a number of MaxScale system variables.
|
||||
|
||||
```
|
||||
mysql> show variables;
|
||||
+--------------------+-------------------------+
|
||||
| Variable_name | Value |
|
||||
+--------------------+-------------------------+
|
||||
| version | 1.0.6-unstable |
|
||||
| version_comment | MariaDB MaxScale |
|
||||
| basedir | /home/mriddoch/skygate2 |
|
||||
| MAXSCALE_VERSION | 1.0.6-unstable |
|
||||
| MAXSCALE_THREADS | 1 |
|
||||
| MAXSCALE_NBPOLLS | 3 |
|
||||
| MAXSCALE_POLLSLEEP | 1000 |
|
||||
| MAXSCALE_UPTIME | 223 |
|
||||
| MAXSCALE_SESSIONS | 11 |
|
||||
+--------------------+-------------------------+
|
||||
9 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
mysql> show variables;
|
||||
+--------------------+-------------------------+
|
||||
| Variable_name | Value |
|
||||
+--------------------+-------------------------+
|
||||
| version | 1.0.6-unstable |
|
||||
| version_comment | MariaDB MaxScale |
|
||||
| basedir | /home/mriddoch/skygate2 |
|
||||
| MAXSCALE_VERSION | 1.0.6-unstable |
|
||||
| MAXSCALE_THREADS | 1 |
|
||||
| MAXSCALE_NBPOLLS | 3 |
|
||||
| MAXSCALE_POLLSLEEP | 1000 |
|
||||
| MAXSCALE_UPTIME | 223 |
|
||||
| MAXSCALE_SESSIONS | 11 |
|
||||
+--------------------+-------------------------+
|
||||
9 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
The show variables command can also accept a limited like clause. This like clause must either be a literal string to match, a pattern starting with a %, a pattern ending with a % or a string with a % at both the start and the end.
|
||||
|
||||
```
|
||||
mysql> show variables like 'version';
|
||||
+---------------+----------------+
|
||||
| Variable_name | Value |
|
||||
+---------------+----------------+
|
||||
| version | 1.0.6-unstable |
|
||||
+---------------+----------------+
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
mysql> show variables like 'version%';
|
||||
+-----------------+------------------+
|
||||
| Variable_name | Value |
|
||||
+-----------------+------------------+
|
||||
| version | 1.0.6-unstable |
|
||||
| version_comment | MariaDB MaxScale |
|
||||
+-----------------+------------------+
|
||||
2 rows in set (0.02 sec)
|
||||
|
||||
mysql> show variables like '%comment';
|
||||
+-----------------+------------------+
|
||||
| Variable_name | Value |
|
||||
+-----------------+------------------+
|
||||
| version_comment | MariaDB MaxScale |
|
||||
+-----------------+------------------+
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
mysql> show variables like '%ers%';
|
||||
+------------------+------------------+
|
||||
| Variable_name | Value |
|
||||
+------------------+------------------+
|
||||
| version | 1.0.6-unstable |
|
||||
| version_comment | MariaDB MaxScale |
|
||||
| MAXSCALE_VERSION | 1.0.6-unstable |
|
||||
+------------------+------------------+
|
||||
3 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
mysql> show variables like 'version';
|
||||
+---------------+----------------+
|
||||
| Variable_name | Value |
|
||||
+---------------+----------------+
|
||||
| version | 1.0.6-unstable |
|
||||
+---------------+----------------+
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
mysql> show variables like 'version%';
|
||||
+-----------------+------------------+
|
||||
| Variable_name | Value |
|
||||
+-----------------+------------------+
|
||||
| version | 1.0.6-unstable |
|
||||
| version_comment | MariaDB MaxScale |
|
||||
+-----------------+------------------+
|
||||
2 rows in set (0.02 sec)
|
||||
|
||||
mysql> show variables like '%comment';
|
||||
+-----------------+------------------+
|
||||
| Variable_name | Value |
|
||||
+-----------------+------------------+
|
||||
| version_comment | MariaDB MaxScale |
|
||||
+-----------------+------------------+
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
mysql> show variables like '%ers%';
|
||||
+------------------+------------------+
|
||||
| Variable_name | Value |
|
||||
+------------------+------------------+
|
||||
| version | 1.0.6-unstable |
|
||||
| version_comment | MariaDB MaxScale |
|
||||
| MAXSCALE_VERSION | 1.0.6-unstable |
|
||||
+------------------+------------------+
|
||||
3 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
## Show status
|
||||
@ -137,36 +137,36 @@ The show variables command can also accept a limited like clause. This like clau
|
||||
The show status command displays a set of status counters, as with show variables the show status command can be passed a simplified like clause to limit the values returned.
|
||||
|
||||
```
|
||||
mysql> show status;
|
||||
+---------------------------+-------+
|
||||
| Variable_name | Value |
|
||||
+---------------------------+-------+
|
||||
| Uptime | 156 |
|
||||
| Uptime_since_flush_status | 156 |
|
||||
| Threads_created | 1 |
|
||||
| Threads_running | 1 |
|
||||
| Threadpool_threads | 1 |
|
||||
| Threads_connected | 11 |
|
||||
| Connections | 11 |
|
||||
| Client_connections | 2 |
|
||||
| Backend_connections | 0 |
|
||||
| Listeners | 9 |
|
||||
| Zombie_connections | 0 |
|
||||
| Internal_descriptors | 2 |
|
||||
| Read_events | 22 |
|
||||
| Write_events | 24 |
|
||||
| Hangup_events | 0 |
|
||||
| Error_events | 0 |
|
||||
| Accept_events | 2 |
|
||||
| Event_queue_length | 1 |
|
||||
| Pending_events | 0 |
|
||||
| Max_event_queue_length | 1 |
|
||||
| Max_event_queue_time | 0 |
|
||||
| Max_event_execution_time | 0 |
|
||||
+---------------------------+-------+
|
||||
22 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
mysql> show status;
|
||||
+---------------------------+-------+
|
||||
| Variable_name | Value |
|
||||
+---------------------------+-------+
|
||||
| Uptime | 156 |
|
||||
| Uptime_since_flush_status | 156 |
|
||||
| Threads_created | 1 |
|
||||
| Threads_running | 1 |
|
||||
| Threadpool_threads | 1 |
|
||||
| Threads_connected | 11 |
|
||||
| Connections | 11 |
|
||||
| Client_connections | 2 |
|
||||
| Backend_connections | 0 |
|
||||
| Listeners | 9 |
|
||||
| Zombie_connections | 0 |
|
||||
| Internal_descriptors | 2 |
|
||||
| Read_events | 22 |
|
||||
| Write_events | 24 |
|
||||
| Hangup_events | 0 |
|
||||
| Error_events | 0 |
|
||||
| Accept_events | 2 |
|
||||
| Event_queue_length | 1 |
|
||||
| Pending_events | 0 |
|
||||
| Max_event_queue_length | 1 |
|
||||
| Max_event_queue_time | 0 |
|
||||
| Max_event_execution_time | 0 |
|
||||
+---------------------------+-------+
|
||||
22 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
## Show services
|
||||
@ -174,22 +174,22 @@ The show status command displays a set of status counters, as with show variable
|
||||
The show services command will return a set of basic statistics regarding each of the configured services within MaxScale.
|
||||
|
||||
```
|
||||
mysql> show services;
|
||||
+----------------+----------------+--------------+----------------+
|
||||
| Service Name | Router Module | No. Sessions | Total Sessions |
|
||||
+----------------+----------------+--------------+----------------+
|
||||
| Test Service | readconnroute | 1 | 1 |
|
||||
| Split Service | readwritesplit | 1 | 1 |
|
||||
| Filter Service | readconnroute | 1 | 1 |
|
||||
| Named Service | readwritesplit | 1 | 1 |
|
||||
| QLA Service | readconnroute | 1 | 1 |
|
||||
| Debug Service | debugcli | 1 | 1 |
|
||||
| CLI | cli | 1 | 1 |
|
||||
| MaxInfo | maxinfo | 4 | 4 |
|
||||
+----------------+----------------+--------------+----------------+
|
||||
8 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
mysql> show services;
|
||||
+----------------+----------------+--------------+----------------+
|
||||
| Service Name | Router Module | No. Sessions | Total Sessions |
|
||||
+----------------+----------------+--------------+----------------+
|
||||
| Test Service | readconnroute | 1 | 1 |
|
||||
| Split Service | readwritesplit | 1 | 1 |
|
||||
| Filter Service | readconnroute | 1 | 1 |
|
||||
| Named Service | readwritesplit | 1 | 1 |
|
||||
| QLA Service | readconnroute | 1 | 1 |
|
||||
| Debug Service | debugcli | 1 | 1 |
|
||||
| CLI | cli | 1 | 1 |
|
||||
| MaxInfo | maxinfo | 4 | 4 |
|
||||
+----------------+----------------+--------------+----------------+
|
||||
8 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
The show services command does not accept a like clause and will ignore any like clause that is given.
|
||||
@ -199,23 +199,23 @@ The show services command does not accept a like clause and will ignore any like
|
||||
The show listeners command will return a set of status information for every listener defined within the MaxScale configuration file.
|
||||
|
||||
```
|
||||
mysql> show listeners;
|
||||
+----------------+-----------------+-----------+------+---------+
|
||||
| Service Name | Protocol Module | Address | Port | State |
|
||||
+----------------+-----------------+-----------+------+---------+
|
||||
| Test Service | MySQLClient | * | 4006 | Running |
|
||||
| Split Service | MySQLClient | * | 4007 | Running |
|
||||
| Filter Service | MySQLClient | * | 4008 | Running |
|
||||
| Named Service | MySQLClient | * | 4010 | Running |
|
||||
| QLA Service | MySQLClient | * | 4009 | Running |
|
||||
| Debug Service | telnetd | localhost | 4242 | Running |
|
||||
| CLI | maxscaled | localhost | 6603 | Running |
|
||||
| MaxInfo | MySQLClient | * | 9003 | Running |
|
||||
| MaxInfo | HTTPD | * | 8003 | Running |
|
||||
+----------------+-----------------+-----------+------+---------+
|
||||
9 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
mysql> show listeners;
|
||||
+----------------+-----------------+-----------+------+---------+
|
||||
| Service Name | Protocol Module | Address | Port | State |
|
||||
+----------------+-----------------+-----------+------+---------+
|
||||
| Test Service | MySQLClient | * | 4006 | Running |
|
||||
| Split Service | MySQLClient | * | 4007 | Running |
|
||||
| Filter Service | MySQLClient | * | 4008 | Running |
|
||||
| Named Service | MySQLClient | * | 4010 | Running |
|
||||
| QLA Service | MySQLClient | * | 4009 | Running |
|
||||
| Debug Service | telnetd | localhost | 4242 | Running |
|
||||
| CLI | maxscaled | localhost | 6603 | Running |
|
||||
| MaxInfo | MySQLClient | * | 9003 | Running |
|
||||
| MaxInfo | HTTPD | * | 8003 | Running |
|
||||
+----------------+-----------------+-----------+------+---------+
|
||||
9 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
The show listeners command will ignore any like clause passed to it.
|
||||
@ -225,25 +225,25 @@ The show listeners command will ignore any like clause passed to it.
|
||||
The show sessions command returns information on every active session within MaxScale. It will ignore any like clause passed to it.
|
||||
|
||||
```
|
||||
mysql> show sessions;
|
||||
+-----------+---------------+----------------+---------------------------+
|
||||
| Session | Client | Service | State |
|
||||
+-----------+---------------+----------------+---------------------------+
|
||||
| 0x1a92a60 | 127.0.0.1 | MaxInfo | Session ready for routing |
|
||||
| 0x1a92100 | 80.240.130.35 | MaxInfo | Session ready for routing |
|
||||
| 0x1a76a00 | | MaxInfo | Listener Session |
|
||||
| 0x1a76020 | | MaxInfo | Listener Session |
|
||||
| 0x1a75d40 | | CLI | Listener Session |
|
||||
| 0x1a75220 | | Debug Service | Listener Session |
|
||||
| 0x1a774b0 | | QLA Service | Listener Session |
|
||||
| 0x1a78630 | | Named Service | Listener Session |
|
||||
| 0x1a60270 | | Filter Service | Listener Session |
|
||||
| 0x1a606f0 | | Split Service | Listener Session |
|
||||
| 0x19b0380 | | Test Service | Listener Session |
|
||||
+-----------+---------------+----------------+---------------------------+
|
||||
11 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
mysql> show sessions;
|
||||
+-----------+---------------+----------------+---------------------------+
|
||||
| Session | Client | Service | State |
|
||||
+-----------+---------------+----------------+---------------------------+
|
||||
| 0x1a92a60 | 127.0.0.1 | MaxInfo | Session ready for routing |
|
||||
| 0x1a92100 | 80.240.130.35 | MaxInfo | Session ready for routing |
|
||||
| 0x1a76a00 | | MaxInfo | Listener Session |
|
||||
| 0x1a76020 | | MaxInfo | Listener Session |
|
||||
| 0x1a75d40 | | CLI | Listener Session |
|
||||
| 0x1a75220 | | Debug Service | Listener Session |
|
||||
| 0x1a774b0 | | QLA Service | Listener Session |
|
||||
| 0x1a78630 | | Named Service | Listener Session |
|
||||
| 0x1a60270 | | Filter Service | Listener Session |
|
||||
| 0x1a606f0 | | Split Service | Listener Session |
|
||||
| 0x19b0380 | | Test Service | Listener Session |
|
||||
+-----------+---------------+----------------+---------------------------+
|
||||
11 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
## Show clients
|
||||
@ -251,16 +251,16 @@ The show sessions command returns information on every active session within Max
|
||||
The show clients command reports a row for every client application connected to MaxScale. Like clauses are not available of the show clients command.
|
||||
|
||||
```
|
||||
mysql> show clients;
|
||||
+-----------+---------------+---------+---------------------------+
|
||||
| Session | Client | Service | State |
|
||||
+-----------+---------------+---------+---------------------------+
|
||||
| 0x1a92a60 | 127.0.0.1 | MaxInfo | Session ready for routing |
|
||||
| 0x1a92100 | 80.240.130.35 | MaxInfo | Session ready for routing |
|
||||
+-----------+---------------+---------+---------------------------+
|
||||
2 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
mysql> show clients;
|
||||
+-----------+---------------+---------+---------------------------+
|
||||
| Session | Client | Service | State |
|
||||
+-----------+---------------+---------+---------------------------+
|
||||
| 0x1a92a60 | 127.0.0.1 | MaxInfo | Session ready for routing |
|
||||
| 0x1a92100 | 80.240.130.35 | MaxInfo | Session ready for routing |
|
||||
+-----------+---------------+---------+---------------------------+
|
||||
2 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
## Show servers
|
||||
@ -268,18 +268,18 @@ The show clients command reports a row for every client application connected to
|
||||
The show servers command returns data for each backend server configured within the MaxScale configuration file. This data includes the current number of connections MaxScale has to that server and the state of that server as monitored by MaxScale.
|
||||
|
||||
```
|
||||
mysql> show servers;
|
||||
+---------+-----------+------+-------------+---------+
|
||||
| Server | Address | Port | Connections | Status |
|
||||
+---------+-----------+------+-------------+---------+
|
||||
| server1 | 127.0.0.1 | 3306 | 0 | Running |
|
||||
| server2 | 127.0.0.1 | 3307 | 0 | Down |
|
||||
| server3 | 127.0.0.1 | 3308 | 0 | Down |
|
||||
| server4 | 127.0.0.1 | 3309 | 0 | Down |
|
||||
+---------+-----------+------+-------------+---------+
|
||||
4 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
mysql> show servers;
|
||||
+---------+-----------+------+-------------+---------+
|
||||
| Server | Address | Port | Connections | Status |
|
||||
+---------+-----------+------+-------------+---------+
|
||||
| server1 | 127.0.0.1 | 3306 | 0 | Running |
|
||||
| server2 | 127.0.0.1 | 3307 | 0 | Down |
|
||||
| server3 | 127.0.0.1 | 3308 | 0 | Down |
|
||||
| server4 | 127.0.0.1 | 3309 | 0 | Down |
|
||||
+---------+-----------+------+-------------+---------+
|
||||
4 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
## Show modules
|
||||
@ -287,24 +287,24 @@ The show servers command returns data for each backend server configured within
|
||||
The show modules command reports the information on the modules currently loaded into MaxScale. This includes the name type and version of each module. It also includes the API version the module has been written against and the current release status of the module.
|
||||
|
||||
```
|
||||
mysql> show modules;
|
||||
+----------------+-------------+---------+-------------+----------------+
|
||||
| Module Name | Module Type | Version | API Version | Status |
|
||||
+----------------+-------------+---------+-------------+----------------+
|
||||
| HTTPD | Protocol | V1.0.1 | 1.0.0 | In Development |
|
||||
| maxscaled | Protocol | V1.0.0 | 1.0.0 | GA |
|
||||
| telnetd | Protocol | V1.0.1 | 1.0.0 | GA |
|
||||
| MySQLClient | Protocol | V1.0.0 | 1.0.0 | GA |
|
||||
| mysqlmon | Monitor | V1.4.0 | 1.0.0 | GA |
|
||||
| readwritesplit | Router | V1.0.2 | 1.0.0 | GA |
|
||||
| readconnroute | Router | V1.1.0 | 1.0.0 | GA |
|
||||
| debugcli | Router | V1.1.1 | 1.0.0 | GA |
|
||||
| cli | Router | V1.0.0 | 1.0.0 | GA |
|
||||
| maxinfo | Router | V1.0.0 | 1.0.0 | Alpha |
|
||||
+----------------+-------------+---------+-------------+----------------+
|
||||
10 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
mysql> show modules;
|
||||
+----------------+-------------+---------+-------------+----------------+
|
||||
| Module Name | Module Type | Version | API Version | Status |
|
||||
+----------------+-------------+---------+-------------+----------------+
|
||||
| HTTPD | Protocol | V1.0.1 | 1.0.0 | In Development |
|
||||
| maxscaled | Protocol | V1.0.0 | 1.0.0 | GA |
|
||||
| telnetd | Protocol | V1.0.1 | 1.0.0 | GA |
|
||||
| MySQLClient | Protocol | V1.0.0 | 1.0.0 | GA |
|
||||
| mysqlmon | Monitor | V1.4.0 | 1.0.0 | GA |
|
||||
| readwritesplit | Router | V1.0.2 | 1.0.0 | GA |
|
||||
| readconnroute | Router | V1.1.0 | 1.0.0 | GA |
|
||||
| debugcli | Router | V1.1.1 | 1.0.0 | GA |
|
||||
| cli | Router | V1.0.0 | 1.0.0 | GA |
|
||||
| maxinfo | Router | V1.0.0 | 1.0.0 | Alpha |
|
||||
+----------------+-------------+---------+-------------+----------------+
|
||||
10 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
## Show monitors
|
||||
@ -312,15 +312,15 @@ The show modules command reports the information on the modules currently loaded
|
||||
The show monitors command reports each monitor configured within the system and the state of that monitor.
|
||||
|
||||
```
|
||||
mysql> show monitors;
|
||||
+---------------+---------+
|
||||
| Monitor | Status |
|
||||
+---------------+---------+
|
||||
| MySQL Monitor | Running |
|
||||
+---------------+---------+
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
mysql> show monitors;
|
||||
+---------------+---------+
|
||||
| Monitor | Status |
|
||||
+---------------+---------+
|
||||
| MySQL Monitor | Running |
|
||||
+---------------+---------+
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
## Show eventTimes
|
||||
@ -328,44 +328,44 @@ The show monitors command reports each monitor configured within the system and
|
||||
The show eventTimes command returns a table of statistics that reflect the performance of the event queuing and execution portion of the MaxScale core.
|
||||
|
||||
```
|
||||
mysql> show eventTimes;
|
||||
+---------------+-------------------+---------------------+
|
||||
| Duration | No. Events Queued | No. Events Executed |
|
||||
+---------------+-------------------+---------------------+
|
||||
| < 100ms | 460 | 456 |
|
||||
| 100 - 200ms | 0 | 3 |
|
||||
| 200 - 300ms | 0 | 0 |
|
||||
| 300 - 400ms | 0 | 0 |
|
||||
| 400 - 500ms | 0 | 0 |
|
||||
| 500 - 600ms | 0 | 0 |
|
||||
| 600 - 700ms | 0 | 0 |
|
||||
| 700 - 800ms | 0 | 0 |
|
||||
| 800 - 900ms | 0 | 0 |
|
||||
| 900 - 1000ms | 0 | 0 |
|
||||
| 1000 - 1100ms | 0 | 0 |
|
||||
| 1100 - 1200ms | 0 | 0 |
|
||||
| 1200 - 1300ms | 0 | 0 |
|
||||
| 1300 - 1400ms | 0 | 0 |
|
||||
| 1400 - 1500ms | 0 | 0 |
|
||||
| 1500 - 1600ms | 0 | 0 |
|
||||
| 1600 - 1700ms | 0 | 0 |
|
||||
| 1700 - 1800ms | 0 | 0 |
|
||||
| 1800 - 1900ms | 0 | 0 |
|
||||
| 1900 - 2000ms | 0 | 0 |
|
||||
| 2000 - 2100ms | 0 | 0 |
|
||||
| 2100 - 2200ms | 0 | 0 |
|
||||
| 2200 - 2300ms | 0 | 0 |
|
||||
| 2300 - 2400ms | 0 | 0 |
|
||||
| 2400 - 2500ms | 0 | 0 |
|
||||
| 2500 - 2600ms | 0 | 0 |
|
||||
| 2600 - 2700ms | 0 | 0 |
|
||||
| 2700 - 2800ms | 0 | 0 |
|
||||
| 2800 - 2900ms | 0 | 0 |
|
||||
| > 3000ms | 0 | 0 |
|
||||
+---------------+-------------------+---------------------+
|
||||
30 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
mysql> show eventTimes;
|
||||
+---------------+-------------------+---------------------+
|
||||
| Duration | No. Events Queued | No. Events Executed |
|
||||
+---------------+-------------------+---------------------+
|
||||
| < 100ms | 460 | 456 |
|
||||
| 100 - 200ms | 0 | 3 |
|
||||
| 200 - 300ms | 0 | 0 |
|
||||
| 300 - 400ms | 0 | 0 |
|
||||
| 400 - 500ms | 0 | 0 |
|
||||
| 500 - 600ms | 0 | 0 |
|
||||
| 600 - 700ms | 0 | 0 |
|
||||
| 700 - 800ms | 0 | 0 |
|
||||
| 800 - 900ms | 0 | 0 |
|
||||
| 900 - 1000ms | 0 | 0 |
|
||||
| 1000 - 1100ms | 0 | 0 |
|
||||
| 1100 - 1200ms | 0 | 0 |
|
||||
| 1200 - 1300ms | 0 | 0 |
|
||||
| 1300 - 1400ms | 0 | 0 |
|
||||
| 1400 - 1500ms | 0 | 0 |
|
||||
| 1500 - 1600ms | 0 | 0 |
|
||||
| 1600 - 1700ms | 0 | 0 |
|
||||
| 1700 - 1800ms | 0 | 0 |
|
||||
| 1800 - 1900ms | 0 | 0 |
|
||||
| 1900 - 2000ms | 0 | 0 |
|
||||
| 2000 - 2100ms | 0 | 0 |
|
||||
| 2100 - 2200ms | 0 | 0 |
|
||||
| 2200 - 2300ms | 0 | 0 |
|
||||
| 2300 - 2400ms | 0 | 0 |
|
||||
| 2400 - 2500ms | 0 | 0 |
|
||||
| 2500 - 2600ms | 0 | 0 |
|
||||
| 2600 - 2700ms | 0 | 0 |
|
||||
| 2700 - 2800ms | 0 | 0 |
|
||||
| 2800 - 2900ms | 0 | 0 |
|
||||
| > 3000ms | 0 | 0 |
|
||||
+---------------+-------------------+---------------------+
|
||||
30 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
Each row represents a time interval, in 100ms increments, with the counts representing the number of events that were in the event queue for the length of time that row represents and the number of events that were executing of the time indicated by the row.
|
||||
@ -379,17 +379,17 @@ The simplified JSON interface takes the URL of the request made to maxinfo and m
|
||||
The /variables URL will return the MaxScale variables, these variables can not be filtered via this interface.
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/variables
|
||||
[ { "Variable_name" : "version", "Value" : "1.0.6-unstable"},
|
||||
{ "Variable_name" : "version_comment", "Value" : "MariaDB MaxScale"},
|
||||
{ "Variable_name" : "basedir", "Value" : "/home/mriddoch/skygate2"},
|
||||
{ "Variable_name" : "MAXSCALE_VERSION", "Value" : "1.0.6-unstable"},
|
||||
{ "Variable_name" : "MAXSCALE_THREADS", "Value" : 1},
|
||||
{ "Variable_name" : "MAXSCALE_NBPOLLS", "Value" : 3},
|
||||
{ "Variable_name" : "MAXSCALE_POLLSLEEP", "Value" : 1000},
|
||||
{ "Variable_name" : "MAXSCALE_UPTIME", "Value" : 3948},
|
||||
{ "Variable_name" : "MAXSCALE_SESSIONS", "Value" : 12}]
|
||||
$
|
||||
$ curl http://maxscale.mariadb.com:8003/variables
|
||||
[ { "Variable_name" : "version", "Value" : "1.0.6-unstable"},
|
||||
{ "Variable_name" : "version_comment", "Value" : "MariaDB MaxScale"},
|
||||
{ "Variable_name" : "basedir", "Value" : "/home/mriddoch/skygate2"},
|
||||
{ "Variable_name" : "MAXSCALE_VERSION", "Value" : "1.0.6-unstable"},
|
||||
{ "Variable_name" : "MAXSCALE_THREADS", "Value" : 1},
|
||||
{ "Variable_name" : "MAXSCALE_NBPOLLS", "Value" : 3},
|
||||
{ "Variable_name" : "MAXSCALE_POLLSLEEP", "Value" : 1000},
|
||||
{ "Variable_name" : "MAXSCALE_UPTIME", "Value" : 3948},
|
||||
{ "Variable_name" : "MAXSCALE_SESSIONS", "Value" : 12}]
|
||||
$
|
||||
```
|
||||
|
||||
## Status
|
||||
@ -397,47 +397,47 @@ The /variables URL will return the MaxScale variables, these variables can not b
|
||||
Use of the /status URI will return the status information that would normally be returned by the show status command. No filtering of the status information is available via this interface
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/status
|
||||
[ { "Variable_name" : "Uptime", "Value" : 3831},
|
||||
{ "Variable_name" : "Uptime_since_flush_status", "Value" : 3831},
|
||||
{ "Variable_name" : "Threads_created", "Value" : 1},
|
||||
{ "Variable_name" : "Threads_running", "Value" : 1},
|
||||
{ "Variable_name" : "Threadpool_threads", "Value" : 1},
|
||||
{ "Variable_name" : "Threads_connected", "Value" : 12},
|
||||
{ "Variable_name" : "Connections", "Value" : 12},
|
||||
{ "Variable_name" : "Client_connections", "Value" : 3},
|
||||
{ "Variable_name" : "Backend_connections", "Value" : 0},
|
||||
{ "Variable_name" : "Listeners", "Value" : 9},
|
||||
{ "Variable_name" : "Zombie_connections", "Value" : 0},
|
||||
{ "Variable_name" : "Internal_descriptors", "Value" : 3},
|
||||
{ "Variable_name" : "Read_events", "Value" : 469},
|
||||
{ "Variable_name" : "Write_events", "Value" : 479},
|
||||
{ "Variable_name" : "Hangup_events", "Value" : 12},
|
||||
{ "Variable_name" : "Error_events", "Value" : 0},
|
||||
{ "Variable_name" : "Accept_events", "Value" : 15},
|
||||
{ "Variable_name" : "Event_queue_length", "Value" : 1},
|
||||
{ "Variable_name" : "Pending_events", "Value" : 0},
|
||||
{ "Variable_name" : "Max_event_queue_length", "Value" : 1},
|
||||
{ "Variable_name" : "Max_event_queue_time", "Value" : 0},
|
||||
{ "Variable_name" : "Max_event_execution_time", "Value" : 1}]
|
||||
$
|
||||
$ curl http://maxscale.mariadb.com:8003/status
|
||||
[ { "Variable_name" : "Uptime", "Value" : 3831},
|
||||
{ "Variable_name" : "Uptime_since_flush_status", "Value" : 3831},
|
||||
{ "Variable_name" : "Threads_created", "Value" : 1},
|
||||
{ "Variable_name" : "Threads_running", "Value" : 1},
|
||||
{ "Variable_name" : "Threadpool_threads", "Value" : 1},
|
||||
{ "Variable_name" : "Threads_connected", "Value" : 12},
|
||||
{ "Variable_name" : "Connections", "Value" : 12},
|
||||
{ "Variable_name" : "Client_connections", "Value" : 3},
|
||||
{ "Variable_name" : "Backend_connections", "Value" : 0},
|
||||
{ "Variable_name" : "Listeners", "Value" : 9},
|
||||
{ "Variable_name" : "Zombie_connections", "Value" : 0},
|
||||
{ "Variable_name" : "Internal_descriptors", "Value" : 3},
|
||||
{ "Variable_name" : "Read_events", "Value" : 469},
|
||||
{ "Variable_name" : "Write_events", "Value" : 479},
|
||||
{ "Variable_name" : "Hangup_events", "Value" : 12},
|
||||
{ "Variable_name" : "Error_events", "Value" : 0},
|
||||
{ "Variable_name" : "Accept_events", "Value" : 15},
|
||||
{ "Variable_name" : "Event_queue_length", "Value" : 1},
|
||||
{ "Variable_name" : "Pending_events", "Value" : 0},
|
||||
{ "Variable_name" : "Max_event_queue_length", "Value" : 1},
|
||||
{ "Variable_name" : "Max_event_queue_time", "Value" : 0},
|
||||
{ "Variable_name" : "Max_event_execution_time", "Value" : 1}]
|
||||
$
|
||||
```
|
||||
|
||||
|
||||
## Services
|
||||
|
||||
The /services URI returns the data regarding the services defined within the configuration of MaxScale. Two counters are returned, the current number of sessions attached to this service and the total number connected since the service started.
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/services
|
||||
[ { "Service Name" : "Test Service", "Router Module" : "readconnroute", "No. Sessions" : 1, "Total Sessions" : 1},
|
||||
{ "Service Name" : "Split Service", "Router Module" : "readwritesplit", "No. Sessions" : 1, "Total Sessions" : 1},
|
||||
{ "Service Name" : "Filter Service", "Router Module" : "readconnroute", "No. Sessions" : 1, "Total Sessions" : 1},
|
||||
{ "Service Name" : "Named Service", "Router Module" : "readwritesplit", "No. Sessions" : 1, "Total Sessions" : 1},
|
||||
{ "Service Name" : "QLA Service", "Router Module" : "readconnroute", "No. Sessions" : 1, "Total Sessions" : 1},
|
||||
{ "Service Name" : "Debug Service", "Router Module" : "debugcli", "No. Sessions" : 1, "Total Sessions" : 1},
|
||||
{ "Service Name" : "CLI", "Router Module" : "cli", "No. Sessions" : 1, "Total Sessions" : 1},
|
||||
{ "Service Name" : "MaxInfo", "Router Module" : "maxinfo", "No. Sessions" : 5, "Total Sessions" : 20}]
|
||||
$
|
||||
$ curl http://maxscale.mariadb.com:8003/services
|
||||
[ { "Service Name" : "Test Service", "Router Module" : "readconnroute", "No. Sessions" : 1, "Total Sessions" : 1},
|
||||
{ "Service Name" : "Split Service", "Router Module" : "readwritesplit", "No. Sessions" : 1, "Total Sessions" : 1},
|
||||
{ "Service Name" : "Filter Service", "Router Module" : "readconnroute", "No. Sessions" : 1, "Total Sessions" : 1},
|
||||
{ "Service Name" : "Named Service", "Router Module" : "readwritesplit", "No. Sessions" : 1, "Total Sessions" : 1},
|
||||
{ "Service Name" : "QLA Service", "Router Module" : "readconnroute", "No. Sessions" : 1, "Total Sessions" : 1},
|
||||
{ "Service Name" : "Debug Service", "Router Module" : "debugcli", "No. Sessions" : 1, "Total Sessions" : 1},
|
||||
{ "Service Name" : "CLI", "Router Module" : "cli", "No. Sessions" : 1, "Total Sessions" : 1},
|
||||
{ "Service Name" : "MaxInfo", "Router Module" : "maxinfo", "No. Sessions" : 5, "Total Sessions" : 20}]
|
||||
$
|
||||
```
|
||||
|
||||
## Listeners
|
||||
@ -445,17 +445,17 @@ The /services URI returns the data regarding the services defined within the con
|
||||
The /listeners URI will return a JSON array with one entry per listener, each entry is a JSON object that describes the configuration and state of that listener.
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/listeners
|
||||
[ { "Service Name" : "Test Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4006, "State" : "Running"},
|
||||
{ "Service Name" : "Split Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4007, "State" : "Running"},
|
||||
{ "Service Name" : "Filter Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4008, "State" : "Running"},
|
||||
{ "Service Name" : "Named Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4010, "State" : "Running"},
|
||||
{ "Service Name" : "QLA Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4009, "State" : "Running"},
|
||||
{ "Service Name" : "Debug Service", "Protocol Module" : "telnetd", "Address" : "localhost", "Port" : 4242, "State" : "Running"},
|
||||
{ "Service Name" : "CLI", "Protocol Module" : "maxscaled", "Address" : "localhost", "Port" : 6603, "State" : "Running"},
|
||||
{ "Service Name" : "MaxInfo", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 9003, "State" : "Running"},
|
||||
{ "Service Name" : "MaxInfo", "Protocol Module" : "HTTPD", "Address" : "*", "Port" : 8003, "State" : "Running"}]
|
||||
$
|
||||
$ curl http://maxscale.mariadb.com:8003/listeners
|
||||
[ { "Service Name" : "Test Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4006, "State" : "Running"},
|
||||
{ "Service Name" : "Split Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4007, "State" : "Running"},
|
||||
{ "Service Name" : "Filter Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4008, "State" : "Running"},
|
||||
{ "Service Name" : "Named Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4010, "State" : "Running"},
|
||||
{ "Service Name" : "QLA Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4009, "State" : "Running"},
|
||||
{ "Service Name" : "Debug Service", "Protocol Module" : "telnetd", "Address" : "localhost", "Port" : 4242, "State" : "Running"},
|
||||
{ "Service Name" : "CLI", "Protocol Module" : "maxscaled", "Address" : "localhost", "Port" : 6603, "State" : "Running"},
|
||||
{ "Service Name" : "MaxInfo", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 9003, "State" : "Running"},
|
||||
{ "Service Name" : "MaxInfo", "Protocol Module" : "HTTPD", "Address" : "*", "Port" : 8003, "State" : "Running"}]
|
||||
$
|
||||
```
|
||||
|
||||
## Modules
|
||||
@ -463,18 +463,18 @@ The /listeners URI will return a JSON array with one entry per listener, each en
|
||||
The /modules URI returns data for each plugin that has been loaded into MaxScale. The plugin name, type and version are returned as is the version of the plugin API that the plugin was built against and the release status of the plugin.
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/modules
|
||||
[ { "Module Name" : "HTTPD", "Module Type" : "Protocol", "Version" : "V1.0.1", "API Version" : "1.0.0", "Status" : "In Development"},
|
||||
{ "Module Name" : "maxscaled", "Module Type" : "Protocol", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
{ "Module Name" : "telnetd", "Module Type" : "Protocol", "Version" : "V1.0.1", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
{ "Module Name" : "MySQLClient", "Module Type" : "Protocol", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
{ "Module Name" : "mysqlmon", "Module Type" : "Monitor", "Version" : "V1.4.0", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
{ "Module Name" : "readwritesplit", "Module Type" : "Router", "Version" : "V1.0.2", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
{ "Module Name" : "readconnroute", "Module Type" : "Router", "Version" : "V1.1.0", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
{ "Module Name" : "debugcli", "Module Type" : "Router", "Version" : "V1.1.1", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
{ "Module Name" : "cli", "Module Type" : "Router", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
{ "Module Name" : "maxinfo", "Module Type" : "Router", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "Alpha"}]
|
||||
$
|
||||
$ curl http://maxscale.mariadb.com:8003/modules
|
||||
[ { "Module Name" : "HTTPD", "Module Type" : "Protocol", "Version" : "V1.0.1", "API Version" : "1.0.0", "Status" : "In Development"},
|
||||
{ "Module Name" : "maxscaled", "Module Type" : "Protocol", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
{ "Module Name" : "telnetd", "Module Type" : "Protocol", "Version" : "V1.0.1", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
{ "Module Name" : "MySQLClient", "Module Type" : "Protocol", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
{ "Module Name" : "mysqlmon", "Module Type" : "Monitor", "Version" : "V1.4.0", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
{ "Module Name" : "readwritesplit", "Module Type" : "Router", "Version" : "V1.0.2", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
{ "Module Name" : "readconnroute", "Module Type" : "Router", "Version" : "V1.1.0", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
{ "Module Name" : "debugcli", "Module Type" : "Router", "Version" : "V1.1.1", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
{ "Module Name" : "cli", "Module Type" : "Router", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
{ "Module Name" : "maxinfo", "Module Type" : "Router", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "Alpha"}]
|
||||
$
|
||||
```
|
||||
|
||||
## Sessions
|
||||
@ -482,31 +482,31 @@ The /modules URI returns data for each plugin that has been loaded into MaxScale
|
||||
The /sessions URI returns a JSON array with an object for each active session within MaxScale.
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/sessions
|
||||
[ { "Session" : "0x1a8e9a0", "Client" : "80.176.79.245", "Service" : "MaxInfo", "State" : "Session ready for routing"},
|
||||
{ "Session" : "0x1a8e6d0", "Client" : "80.240.130.35", "Service" : "MaxInfo", "State" : "Session ready for routing"},
|
||||
{ "Session" : "0x1a8ddd0", "Client" : , "Service" : "MaxInfo", "State" : "Listener Session"},
|
||||
{ "Session" : "0x1a92da0", "Client" : , "Service" : "MaxInfo", "State" : "Listener Session"},
|
||||
{ "Session" : "0x1a92ac0", "Client" : , "Service" : "CLI", "State" : "Listener Session"},
|
||||
{ "Session" : "0x1a70e90", "Client" : , "Service" : "Debug Service", "State" : "Listener Session"},
|
||||
{ "Session" : "0x1a758d0", "Client" : , "Service" : "QLA Service", "State" : "Listener Session"},
|
||||
{ "Session" : "0x1a73a90", "Client" : , "Service" : "Named Service", "State" : "Listener Session"},
|
||||
{ "Session" : "0x1a5c0b0", "Client" : , "Service" : "Filter Service", "State" : "Listener Session"},
|
||||
{ "Session" : "0x1a5c530", "Client" : , "Service" : "Split Service", "State" : "Listener Session"},
|
||||
{ "Session" : "0x19ac1c0", "Client" : , "Service" : "Test Service", "State" : "Listener Session"}]
|
||||
$
|
||||
$ curl http://maxscale.mariadb.com:8003/sessions
|
||||
[ { "Session" : "0x1a8e9a0", "Client" : "80.176.79.245", "Service" : "MaxInfo", "State" : "Session ready for routing"},
|
||||
{ "Session" : "0x1a8e6d0", "Client" : "80.240.130.35", "Service" : "MaxInfo", "State" : "Session ready for routing"},
|
||||
{ "Session" : "0x1a8ddd0", "Client" : , "Service" : "MaxInfo", "State" : "Listener Session"},
|
||||
{ "Session" : "0x1a92da0", "Client" : , "Service" : "MaxInfo", "State" : "Listener Session"},
|
||||
{ "Session" : "0x1a92ac0", "Client" : , "Service" : "CLI", "State" : "Listener Session"},
|
||||
{ "Session" : "0x1a70e90", "Client" : , "Service" : "Debug Service", "State" : "Listener Session"},
|
||||
{ "Session" : "0x1a758d0", "Client" : , "Service" : "QLA Service", "State" : "Listener Session"},
|
||||
{ "Session" : "0x1a73a90", "Client" : , "Service" : "Named Service", "State" : "Listener Session"},
|
||||
{ "Session" : "0x1a5c0b0", "Client" : , "Service" : "Filter Service", "State" : "Listener Session"},
|
||||
{ "Session" : "0x1a5c530", "Client" : , "Service" : "Split Service", "State" : "Listener Session"},
|
||||
{ "Session" : "0x19ac1c0", "Client" : , "Service" : "Test Service", "State" : "Listener Session"}]
|
||||
$
|
||||
```
|
||||
|
||||
|
||||
## Clients
|
||||
|
||||
The /clients URI is a limited version of the /sessions, in this case it only returns an entry for a session that represents a client connection.
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/clients
|
||||
[ { "Session" : "0x1a90be0", "Client" : "80.176.79.245", "Service" : "MaxInfo", "State" : "Session ready for routing"},
|
||||
{ "Session" : "0x1a8e9a0", "Client" : "127.0.0.1", "Service" : "MaxInfo", "State" : "Session ready for routing"},
|
||||
{ "Session" : "0x1a8e6d0", "Client" : "80.240.130.35", "Service" : "MaxInfo", "State" : "Session ready for routing"}]
|
||||
$
|
||||
$ curl http://maxscale.mariadb.com:8003/clients
|
||||
[ { "Session" : "0x1a90be0", "Client" : "80.176.79.245", "Service" : "MaxInfo", "State" : "Session ready for routing"},
|
||||
{ "Session" : "0x1a8e9a0", "Client" : "127.0.0.1", "Service" : "MaxInfo", "State" : "Session ready for routing"},
|
||||
{ "Session" : "0x1a8e6d0", "Client" : "80.240.130.35", "Service" : "MaxInfo", "State" : "Session ready for routing"}]
|
||||
$
|
||||
```
|
||||
|
||||
## Servers
|
||||
@ -514,12 +514,12 @@ The /clients URI is a limited version of the /sessions, in this case it only ret
|
||||
The /servers URI is used to retrieve information for each of the servers defined within the MaxScale configuration. This information includes the connection count and the current status as monitored by MaxScale. The connection count is only those connections made by MaxScale to those servers.
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/servers
|
||||
[ { "Server" : "server1", "Address" : "127.0.0.1", "Port" : 3306, "Connections" : 0, "Status" : "Running"},
|
||||
{ "Server" : "server2", "Address" : "127.0.0.1", "Port" : 3307, "Connections" : 0, "Status" : "Down"},
|
||||
{ "Server" : "server3", "Address" : "127.0.0.1", "Port" : 3308, "Connections" : 0, "Status" : "Down"},
|
||||
{ "Server" : "server4", "Address" : "127.0.0.1", "Port" : 3309, "Connections" : 0, "Status" : "Down"}]
|
||||
$
|
||||
$ curl http://maxscale.mariadb.com:8003/servers
|
||||
[ { "Server" : "server1", "Address" : "127.0.0.1", "Port" : 3306, "Connections" : 0, "Status" : "Running"},
|
||||
{ "Server" : "server2", "Address" : "127.0.0.1", "Port" : 3307, "Connections" : 0, "Status" : "Down"},
|
||||
{ "Server" : "server3", "Address" : "127.0.0.1", "Port" : 3308, "Connections" : 0, "Status" : "Down"},
|
||||
{ "Server" : "server4", "Address" : "127.0.0.1", "Port" : 3309, "Connections" : 0, "Status" : "Down"}]
|
||||
$
|
||||
```
|
||||
|
||||
## Event Times
|
||||
@ -527,35 +527,35 @@ The /servers URI is used to retrieve information for each of the servers defined
|
||||
The /event/times URI returns an array of statistics that reflect the performance of the event queuing and execution portion of the MaxScale core. Each element is an object that represents a time bucket, in 100ms increments, with the counts representing the number of events that were in the event queue for the length of time that row represents and the number of events that were executing of the time indicated by the object.
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/event/times
|
||||
[ { "Duration" : "< 100ms", "No. Events Queued" : 64, "No. Events Executed" : 63},
|
||||
{ "Duration" : " 100 - 200ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : " 200 - 300ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : " 300 - 400ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : " 400 - 500ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : " 500 - 600ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : " 600 - 700ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : " 700 - 800ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : " 800 - 900ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : " 900 - 1000ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1000 - 1100ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1100 - 1200ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1200 - 1300ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1300 - 1400ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1400 - 1500ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1500 - 1600ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1600 - 1700ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1700 - 1800ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1800 - 1900ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1900 - 2000ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2000 - 2100ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2100 - 2200ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2200 - 2300ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2300 - 2400ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2400 - 2500ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2500 - 2600ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2600 - 2700ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2700 - 2800ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2800 - 2900ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "> 3000ms", "No. Events Queued" : 0, "No. Events Executed" : 0}]
|
||||
$ curl http://maxscale.mariadb.com:8003/event/times
|
||||
[ { "Duration" : "< 100ms", "No. Events Queued" : 64, "No. Events Executed" : 63},
|
||||
{ "Duration" : " 100 - 200ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : " 200 - 300ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : " 300 - 400ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : " 400 - 500ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : " 500 - 600ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : " 600 - 700ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : " 700 - 800ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : " 800 - 900ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : " 900 - 1000ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1000 - 1100ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1100 - 1200ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1200 - 1300ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1300 - 1400ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1400 - 1500ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1500 - 1600ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1600 - 1700ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1700 - 1800ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1800 - 1900ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "1900 - 2000ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2000 - 2100ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2100 - 2200ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2200 - 2300ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2300 - 2400ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2400 - 2500ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2500 - 2600ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2600 - 2700ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2700 - 2800ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2800 - 2900ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "> 3000ms", "No. Events Queued" : 0, "No. Events Executed" : 0}]
|
||||
```
|
||||
|
@ -46,67 +46,73 @@ MySQL 5.5.38 as SQL node2
|
||||
|
||||
Cluster configuration file is /var/lib/mysql-cluster/config.ini, copied on all servers
|
||||
|
||||
[ndbd default]
|
||||
NoOfReplicas=2
|
||||
DataMemory=60M
|
||||
IndexMemory=16M
|
||||
```
|
||||
[ndbd default]
|
||||
NoOfReplicas=2
|
||||
DataMemory=60M
|
||||
IndexMemory=16M
|
||||
|
||||
[ndb_mgmd]
|
||||
hostname=178.62.38.199
|
||||
id=21
|
||||
datadir=/var/lib/mysql-cluster
|
||||
|
||||
[mysqld]
|
||||
hostname=178.62.38.199
|
||||
|
||||
[mysqld]
|
||||
hostname=162.243.90.81
|
||||
[ndb_mgmd]
|
||||
hostname=178.62.38.199
|
||||
id=21
|
||||
datadir=/var/lib/mysql-cluster
|
||||
|
||||
[ndbd]
|
||||
hostname=178.62.38.199
|
||||
[mysqld]
|
||||
hostname=178.62.38.199
|
||||
|
||||
[ndbd]
|
||||
hostname=162.243.90.81
|
||||
[mysqld]
|
||||
hostname=162.243.90.81
|
||||
|
||||
[ndbd]
|
||||
hostname=178.62.38.199
|
||||
|
||||
[ndbd]
|
||||
hostname=162.243.90.81
|
||||
```
|
||||
|
||||
Note, it’s possible to specify all node ids and datadir as well for each cluster component
|
||||
|
||||
Example:
|
||||
|
||||
[ndbd]
|
||||
hostname=162.243.90.81
|
||||
id=43
|
||||
datadir=/usr/local/mysql/data
|
||||
```
|
||||
[ndbd]
|
||||
hostname=162.243.90.81
|
||||
id=43
|
||||
datadir=/usr/local/mysql/data
|
||||
```
|
||||
|
||||
and /etc/my.cnf, copied as well in all servers
|
||||
|
||||
[mysqld]
|
||||
ndbcluster
|
||||
ndb-connectstring=178.62.38.199
|
||||
innodb_buffer_pool_size=16M
|
||||
```
|
||||
[mysqld]
|
||||
ndbcluster
|
||||
ndb-connectstring=178.62.38.199
|
||||
innodb_buffer_pool_size=16M
|
||||
|
||||
[mysql_cluster]
|
||||
ndb-connectstring=178.62.38.199
|
||||
[mysql_cluster]
|
||||
ndb-connectstring=178.62.38.199
|
||||
```
|
||||
|
||||
## Startup of MySQL Cluster
|
||||
|
||||
Each cluster node process must be started separately, and on the host where it resides. The management node should be started first, followed by the data nodes, and then finally by any SQL nodes:
|
||||
|
||||
- On the management host, server1, issue the following command from the system shell to start the management node process:
|
||||
|
||||
[root@server1 ~]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini
|
||||
|
||||
```
|
||||
[root@server1 ~]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini
|
||||
```
|
||||
- On each of the data node hosts, run this command to start the ndbd process:
|
||||
```
|
||||
[root@server1 ~]# ndbd —-initial -—initial-start
|
||||
|
||||
[root@server1 ~]# ndbd —-initial -—initial-start
|
||||
|
||||
[root@server2 ~]# ndbd —-initial -—initial-start
|
||||
|
||||
[root@server2 ~]# ndbd —-initial -—initial-start
|
||||
```
|
||||
- On each SQL node start the MySQL server process:
|
||||
```
|
||||
[root@server1 ~]# /etc/init.d/mysql start
|
||||
|
||||
[root@server1 ~]# /etc/init.d/mysql start
|
||||
|
||||
[root@server2 ~]# /etc/init.d/mysql start
|
||||
|
||||
[root@server2 ~]# /etc/init.d/mysql start
|
||||
```
|
||||
## Check the cluster status
|
||||
|
||||
If all has gone well, and the cluster has been set up correctly, the cluster should now be operational.
|
||||
@ -114,7 +120,7 @@ If all has gone well, and the cluster has been set up correctly, the cluster sho
|
||||
It’s possible to test this by invoking the ndb_mgm management node client.
|
||||
|
||||
The output should look like that shown here, although you might see some slight differences in the output depending upon the exact version of MySQL that you are using:
|
||||
|
||||
```
|
||||
[root@server1 ~]# ndb_mgm
|
||||
|
||||
-- NDB Cluster -- Management Client --
|
||||
@ -127,216 +133,217 @@ Cluster Configuration
|
||||
|
||||
---------------------
|
||||
|
||||
[ndbd(NDB)] 2 node(s)
|
||||
[ndbd(NDB)] 2 node(s)
|
||||
|
||||
id=24 @178.62.38.199 (mysql-5.5.38 ndb-7.2.17, Nodegroup: 0, *)
|
||||
|
||||
id=25 @162.243.90.81 (mysql-5.5.38 ndb-7.2.17, Nodegroup: 0)
|
||||
|
||||
[ndb_mgmd(MGM)] 1 node(s)
|
||||
|
||||
id=21 @178.62.38.199 (mysql-5.5.38 ndb-7.2.17)
|
||||
|
||||
[mysqld(API)] 2 node(s)
|
||||
id=24 @178.62.38.199 (mysql-5.5.38 ndb-7.2.17, Nodegroup: 0, *)
|
||||
|
||||
id=22 @178.62.38.199 (mysql-5.5.38 ndb-7.2.17)
|
||||
id=25 @162.243.90.81 (mysql-5.5.38 ndb-7.2.17, Nodegroup: 0)
|
||||
|
||||
id=23 @162.243.90.81 (mysql-5.5.38 ndb-7.2.17)
|
||||
[ndb_mgmd(MGM)] 1 node(s)
|
||||
|
||||
id=21 @178.62.38.199 (mysql-5.5.38 ndb-7.2.17)
|
||||
|
||||
[mysqld(API)] 2 node(s)
|
||||
|
||||
id=22 @178.62.38.199 (mysql-5.5.38 ndb-7.2.17)
|
||||
|
||||
id=23 @162.243.90.81 (mysql-5.5.38 ndb-7.2.17)
|
||||
|
||||
ndb_mgm>
|
||||
|
||||
```
|
||||
The SQL node is referenced here as [mysqld(API)], which reflects the fact that the mysqld process is acting as a MySQL Cluster API node.
|
||||
|
||||
## Working with NDBCLUSTER engine in MySQL
|
||||
|
||||
- First create a table with NDBCLUSTER engine:
|
||||
|
||||
- First create a table with NDBCLUSTER engine:
|
||||
```
|
||||
[root@server1 ~]# mysql
|
||||
|
||||
mysql> CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) ENGINE=NDBCLUSTER;
|
||||
mysql> CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) ENGINE=NDBCLUSTER;
|
||||
|
||||
Query OK, 0 rows affected (3.28 sec)
|
||||
Query OK, 0 rows affected (3.28 sec)
|
||||
|
||||
mysql> show create table t1;
|
||||
mysql> show create table t1;
|
||||
|
||||
+------- +-------------------------------------------------------------------------------------------+
|
||||
| Table | Create Table |
|
||||
+------- +-------------------------------------------------------------------------------------------+
|
||||
| Table | Create Table |
|
||||
|
||||
+-------+-------------------------------------------------------------------------------------------+
|
||||
+-------+-------------------------------------------------------------------------------------------+
|
||||
|
||||
| t1 | CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
| t1 | CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 |
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 |
|
||||
|
||||
+-------+-------------------------------------------------------------------------------------------+
|
||||
+-------+-------------------------------------------------------------------------------------------+
|
||||
|
||||
1 row in set (0.01 sec)
|
||||
1 row in set (0.01 sec)
|
||||
```
|
||||
- Just add a row in the table:
|
||||
```
|
||||
mysql> insert into test.t1 values(11);
|
||||
|
||||
- Just add a row in the table:
|
||||
Query OK, 1 row affected (0.15 sec)
|
||||
```
|
||||
- Select the current number of rows:
|
||||
```
|
||||
mysql> select count(1) from t1;
|
||||
|
||||
mysql> insert into test.t1 values(11);
|
||||
|
||||
Query OK, 1 row affected (0.15 sec)
|
||||
|
||||
- Select the current number of rows:
|
||||
|
||||
mysql> select count(1) from t1;
|
||||
|
||||
+----------+
|
||||
| count(1) |
|
||||
+----------+
|
||||
| 1 |
|
||||
+----------+
|
||||
|
||||
1 row in set (0.07 sec)
|
||||
+----------+
|
||||
| count(1) |
|
||||
+----------+
|
||||
| 1 |
|
||||
+----------+
|
||||
|
||||
1 row in set (0.07 sec)
|
||||
```
|
||||
- The same from the MySQL client pointing to SQL node on server2
|
||||
|
||||
```
|
||||
[root@server2 ~]# mysql
|
||||
|
||||
mysql> select count(1) from test.t1;
|
||||
mysql> select count(1) from test.t1;
|
||||
|
||||
+----------+
|
||||
| count(1) |
|
||||
+----------+
|
||||
| 1 |
|
||||
+----------+
|
||||
|
||||
1 row in set (0.08 sec)
|
||||
+----------+
|
||||
| count(1) |
|
||||
+----------+
|
||||
| 1 |
|
||||
+----------+
|
||||
|
||||
1 row in set (0.08 sec)
|
||||
```
|
||||
## Configuring MaxScale for connection load balancing of SQL nodes
|
||||
|
||||
Add these sections in maxscale.cnf config file:
|
||||
```
|
||||
[Cluster Service]
|
||||
type=service
|
||||
router=readconnroute
|
||||
router_options=ndb
|
||||
servers=server1,server2
|
||||
user=test
|
||||
passwd=test
|
||||
version_string=5.5.37-CLUSTER
|
||||
|
||||
[Cluster Service]
|
||||
type=service
|
||||
router=readconnroute
|
||||
router_options=ndb
|
||||
servers=server1,server2
|
||||
user=test
|
||||
passwd=test
|
||||
version_string=5.5.37-CLUSTER
|
||||
|
||||
[Cluster Listener]
|
||||
type=listener
|
||||
service=Cluster Service
|
||||
protocol=MySQLClient
|
||||
port=4906
|
||||
[Cluster Listener]
|
||||
type=listener
|
||||
service=Cluster Service
|
||||
protocol=MySQLClient
|
||||
port=4906
|
||||
|
||||
[NDB Cluster Monitor]
|
||||
type=monitor
|
||||
module=ndbclustermon
|
||||
servers=server1,server2
|
||||
user=monitor
|
||||
passwd=monitor
|
||||
monitor_interval=8000
|
||||
[NDB Cluster Monitor]
|
||||
type=monitor
|
||||
module=ndbclustermon
|
||||
servers=server1,server2
|
||||
user=monitor
|
||||
passwd=monitor
|
||||
monitor_interval=8000
|
||||
|
||||
[server1]
|
||||
[server1]
|
||||
|
||||
#SQL node1
|
||||
type=server
|
||||
address=127.0.0.1
|
||||
port=3306
|
||||
protocol=MySQLBackend
|
||||
|
||||
[server2]
|
||||
#SQL node2
|
||||
type=server
|
||||
address=162.243.90.81
|
||||
port=3306
|
||||
protocol=MySQLBackend
|
||||
#SQL node1
|
||||
type=server
|
||||
address=127.0.0.1
|
||||
port=3306
|
||||
protocol=MySQLBackend
|
||||
|
||||
[server2]
|
||||
#SQL node2
|
||||
type=server
|
||||
address=162.243.90.81
|
||||
port=3306
|
||||
protocol=MySQLBackend
|
||||
```
|
||||
Assuming MaxScale is installed in server1, start it
|
||||
```
|
||||
[root@server1 ~]# cd /usr/bin
|
||||
|
||||
[root@server1 ~]# cd /usr/bin
|
||||
|
||||
[root@server1 bin]# ./maxscale -c ../
|
||||
|
||||
[root@server1 bin]# ./maxscale -c ../
|
||||
```
|
||||
Using the debug interface it’s possible to check the status of monitored servers
|
||||
```
|
||||
MaxScale> show monitors
|
||||
|
||||
MaxScale> show monitors
|
||||
Monitor: 0x387b880
|
||||
|
||||
Monitor: 0x387b880
|
||||
Name: NDB Cluster Monitor
|
||||
Monitor running
|
||||
Sampling interval: 8000 milliseconds
|
||||
Monitored servers: 127.0.0.1:3306, 162.243.90.81:3306
|
||||
|
||||
Name: NDB Cluster Monitor
|
||||
Monitor running
|
||||
Sampling interval: 8000 milliseconds
|
||||
Monitored servers: 127.0.0.1:3306, 162.243.90.81:3306
|
||||
MaxScale> show servers
|
||||
|
||||
MaxScale> show servers
|
||||
Server 0x3873b40 (server1)
|
||||
|
||||
Server 0x3873b40 (server1)
|
||||
Server: 127.0.0.1
|
||||
Status: NDB, Running
|
||||
Protocol: MySQLBackend
|
||||
Port: 3306
|
||||
Server Version: 5.5.38-ndb-7.2.17-cluster-gpl
|
||||
Node Id: 22
|
||||
Master Id: -1
|
||||
Repl Depth: 0
|
||||
Number of connections: 0
|
||||
Current no. of conns: 0
|
||||
Current no. of operations: 0
|
||||
|
||||
Server: 127.0.0.1
|
||||
Status: NDB, Running
|
||||
Protocol: MySQLBackend
|
||||
Port: 3306
|
||||
Server Version: 5.5.38-ndb-7.2.17-cluster-gpl
|
||||
Node Id: 22
|
||||
Master Id: -1
|
||||
Repl Depth: 0
|
||||
Number of connections: 0
|
||||
Current no. of conns: 0
|
||||
Current no. of operations: 0
|
||||
|
||||
Server 0x3873a40 (server2)
|
||||
|
||||
Server: 162.243.90.81
|
||||
Status: NDB, Running
|
||||
Protocol: MySQLBackend
|
||||
Port: 3306
|
||||
Server Version: 5.5.38-ndb-7.2.17-cluster-gpl
|
||||
Node Id: 23
|
||||
Master Id: -1
|
||||
Repl Depth: 0
|
||||
Number of connections: 0
|
||||
Current no. of conns: 0
|
||||
Current no. of operations: 0
|
||||
Server 0x3873a40 (server2)
|
||||
|
||||
Server: 162.243.90.81
|
||||
Status: NDB, Running
|
||||
Protocol: MySQLBackend
|
||||
Port: 3306
|
||||
Server Version: 5.5.38-ndb-7.2.17-cluster-gpl
|
||||
Node Id: 23
|
||||
Master Id: -1
|
||||
Repl Depth: 0
|
||||
Number of connections: 0
|
||||
Current no. of conns: 0
|
||||
Current no. of operations: 0
|
||||
```
|
||||
It’s now possible to run basic tests with the read connection load balancing for the two configured SQL nodes
|
||||
|
||||
(1) test MaxScale load balancing requesting the Ndb_cluster_node_id variable:
|
||||
```
|
||||
[root@server1 ~]# mysql -h 127.0.0.1 -P 4906 -u test -ptest -e "SHOW STATUS LIKE 'Ndb_cluster_node_id'"
|
||||
|
||||
[root@server1 ~]# mysql -h 127.0.0.1 -P 4906 -u test -ptest -e "SHOW STATUS LIKE 'Ndb_cluster_node_id'"
|
||||
+---------------------+-------+
|
||||
| Variable_name | Value |
|
||||
+---------------------+-------+
|
||||
| Ndb_cluster_node_id | 23 |
|
||||
+---------------------+-------+
|
||||
|
||||
+---------------------+-------+
|
||||
| Variable_name | Value |
|
||||
+---------------------+-------+
|
||||
| Ndb_cluster_node_id | 23 |
|
||||
+---------------------+-------+
|
||||
|
||||
[root@server1 ~]# mysql -h 127.0.0.1 -P 4906 -u test -ptest -e "SHOW STATUS LIKE 'Ndb_cluster_node_id'"
|
||||
|
||||
+---------------------+-------+
|
||||
| Variable_name | Value |
|
||||
+---------------------+-------+
|
||||
| Ndb_cluster_node_id | 22 |
|
||||
+---------------------+-------+
|
||||
[root@server1 ~]# mysql -h 127.0.0.1 -P 4906 -u test -ptest -e "SHOW STATUS LIKE 'Ndb_cluster_node_id'"
|
||||
|
||||
+---------------------+-------+
|
||||
| Variable_name | Value |
|
||||
+---------------------+-------+
|
||||
| Ndb_cluster_node_id | 22 |
|
||||
+---------------------+-------+
|
||||
```
|
||||
The MaxScale connection load balancing is working.
|
||||
|
||||
(2) test a select statement on an NBDBCLUSTER table, database test and table t1 created before:
|
||||
```
|
||||
[root@server1 ~] mysql -h 127.0.0.1 -P 4906 -utest -ptest -e "SELECT COUNT(1) FROM test.t1"
|
||||
|
||||
[root@server1 ~] mysql -h 127.0.0.1 -P 4906 -utest -ptest -e "SELECT COUNT(1) FROM test.t1"
|
||||
|
||||
+----------+
|
||||
| COUNT(1) |
|
||||
+----------+
|
||||
| 1 |
|
||||
+----------+
|
||||
|
||||
+----------+
|
||||
| COUNT(1) |
|
||||
+----------+
|
||||
| 1 |
|
||||
+----------+
|
||||
```
|
||||
(3) test an insert statement
|
||||
|
||||
```
|
||||
mysql -h 127.0.0.1 -P 4906 -utest -ptest -e "INSERT INTO test.t1 VALUES (19)"
|
||||
|
||||
```
|
||||
(4) test again the select and check the number of rows
|
||||
|
||||
[root@server1 ~] mysql -h 127.0.0.1 -P 4906 -utest -ptest -e "SELECT COUNT(1) FROM test.t1"
|
||||
|
||||
+----------+
|
||||
| COUNT(1) |
|
||||
+----------+
|
||||
| 2 |
|
||||
+----------+
|
||||
```
|
||||
[root@server1 ~] mysql -h 127.0.0.1 -P 4906 -utest -ptest -e "SELECT COUNT(1) FROM test.t1"
|
||||
|
||||
+----------+
|
||||
| COUNT(1) |
|
||||
+----------+
|
||||
| 2 |
|
||||
+----------+
|
||||
```
|
||||
|
@ -36,18 +36,23 @@ The first user required must be able to select data from the table mysql.user, t
|
||||
|
||||
2. Create the user, substituting the username, password and host on which maxscale runs within your environment
|
||||
|
||||
```
|
||||
MariaDB [(none)]> create user '*username*'@'*maxscalehost*' identified by '*password*';
|
||||
|
||||
**Query OK, 0 rows affected (0.00 sec)**
|
||||
|
||||
```
|
||||
3. Grant select privileges on the mysql.user table.
|
||||
|
||||
```
|
||||
MariaDB [(none)]> grant SELECT on mysql.user to '*username*'@'*maxscalehost*';
|
||||
|
||||
**Query OK, 0 rows affected (0.03 sec)**
|
||||
|
||||
```
|
||||
Additionally, GRANT SELECT on the mysql.db table and SHOW DATABASES privileges are required in order to load databases name and grants suitable for database name authorization.
|
||||
|
||||
```
|
||||
MariaDB [(none)]> GRANT SELECT ON mysql.db TO 'username'@'maxscalehost';
|
||||
|
||||
**Query OK, 0 rows affected (0.00 sec)**
|
||||
@ -56,8 +61,10 @@ MariaDB [(none)]> GRANT SHOW DATABASES ON *.* TO 'username'@'maxscalehost';
|
||||
|
||||
**Query OK, 0 rows affected (0.00 sec)**
|
||||
|
||||
```
|
||||
The second user is used to monitored the state of the cluster. This user, which may be the same username as the first, requires permissions to access the various sources of monitoring data. In order to monitor a replication cluster this user must be granted the roles REPLICATION SLAVE and REPLICATION CLIENT
|
||||
|
||||
```
|
||||
MariaDB [(none)]> grant REPLICATION SLAVE on *.* to '*username*'@'*maxscalehost*';
|
||||
|
||||
**Query OK, 0 rows affected (0.00 sec)**
|
||||
@ -66,6 +73,7 @@ MariaDB [(none)]> grant REPLICATION CLIENT on *.* to '*username*'@'*maxscalehost
|
||||
|
||||
**Query OK, 0 rows affected (0.00 sec)**
|
||||
|
||||
```
|
||||
If you wish to use two different usernames for the two different roles of monitoring and collecting user information then create a different username using the first two steps from above.
|
||||
|
||||
## Creating Your MaxScale Configuration
|
||||
@ -74,160 +82,139 @@ MaxScale configuration is held in an ini file that is located in the file maxsca
|
||||
|
||||
A global, maxscale, section is included within every MaxScale configuration file; this is used to set the values of various MaxScale wide parameters, perhaps the most important of these is the number of threads that MaxScale will use to execute the code that forwards requests and handles responses for clients.
|
||||
|
||||
```
|
||||
[maxscale]
|
||||
|
||||
threads=4
|
||||
|
||||
```
|
||||
|
||||
The first step is to create a service for our Read/Write Splitter. Create a section in your MaxScale.ini file and set the type to service, the section names are the names of the services themselves and should be meaningful to the administrator. Names may contain whitespace.
|
||||
|
||||
```
|
||||
[Splitter Service]
|
||||
|
||||
type=service
|
||||
```
|
||||
|
||||
The router for we need to use for this configuration is the readwritesplit module, also the services should be provided with the list of servers that will be part of the cluster. The server names given here are actually the names of server sections in the configuration file and not the physical hostnames or addresses of the servers.
|
||||
|
||||
```
|
||||
[Splitter Service]
|
||||
|
||||
type=service
|
||||
|
||||
router=readwritesplit
|
||||
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
```
|
||||
|
||||
The final step in the service sections is to add the username and password that will be used to populate the user data from the database cluster. There are two options for representing the password, either plain text or encrypted passwords may be used. In order to use encrypted passwords a set of keys must be generated that will be used by the encryption and decryption process. To generate the keys use the maxkeys command and pass the name of the secrets file in which the keys are stored.
|
||||
|
||||
% maxkeys /var/lib/maxscale/.secrets
|
||||
```
|
||||
maxkeys /var/lib/maxscale/.secrets
|
||||
|
||||
%
|
||||
```
|
||||
|
||||
Once the keys have been created the maxpasswd command can be used to generate the encrypted password.
|
||||
|
||||
% maxpasswd plainpassword
|
||||
```
|
||||
maxpasswd plainpassword
|
||||
|
||||
96F99AA1315BDC3604B006F427DD9484
|
||||
|
||||
%
|
||||
```
|
||||
|
||||
The username and password, either encrypted or plain text, are stored in the service section using the user and passwd parameters.
|
||||
|
||||
```
|
||||
[Splitter Service]
|
||||
|
||||
type=service
|
||||
|
||||
router=readwritesplit
|
||||
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
|
||||
user=maxscale
|
||||
|
||||
passwd=96F99AA1315BDC3604B006F427DD9484
|
||||
```
|
||||
|
||||
This completes the definitions required by the service, however listening ports must be associated with the service in order to allow network connections. This is done by creating a series of listener sections. This section again is named for the convenience of the administrator and should be of type listener with an entry labeled service which contains the name of the service to associate the listener with. A service may have multiple listeners.
|
||||
|
||||
```
|
||||
[Splitter Listener]
|
||||
|
||||
type=listener
|
||||
|
||||
service=Splitter Service
|
||||
```
|
||||
|
||||
A listener must also define the protocol module it will use for the incoming network protocol, currently this should be the MySQLClient protocol for all database listeners. The listener may then supply a network port to listen on and/or a socket within the file system.
|
||||
|
||||
```
|
||||
[Splitter Listener]
|
||||
|
||||
type=listener
|
||||
|
||||
service=Splitter Service
|
||||
|
||||
protocol=MySQLClient
|
||||
|
||||
port=3306
|
||||
|
||||
socket=/tmp/ClusterMaster
|
||||
```
|
||||
|
||||
An address parameter may be given if the listener is required to bind to a particular network address when using hosts with multiple network addresses. The default behaviour is to listen on all network interfaces.
|
||||
|
||||
The next stage is the configuration is to define the server information. This defines how to connect to each of the servers within the cluster, again a section is created for each server, with the type set to server, the network address and port to connect to and the protocol to use to connect to the server. Currently the protocol module for all database connections in MySQLBackend.
|
||||
|
||||
```
|
||||
[dbserv1]
|
||||
|
||||
type=server
|
||||
|
||||
address=192.168.2.1
|
||||
|
||||
port=3306
|
||||
|
||||
protocol=MySQLBackend
|
||||
|
||||
[dbserv2]
|
||||
|
||||
type=server
|
||||
|
||||
address=192.168.2.2
|
||||
|
||||
port=3306
|
||||
|
||||
protocol=MySQLBackend
|
||||
|
||||
[dbserv3]
|
||||
|
||||
type=server
|
||||
|
||||
address=192.168.2.3
|
||||
|
||||
port=3306
|
||||
|
||||
protocol=MySQLBackend
|
||||
```
|
||||
|
||||
In order for MaxScale to monitor the servers using the correct monitoring mechanisms a section should be provided that defines the monitor to use and the servers to monitor. Once again a section is created with a symbolic name for the monitor, with the type set to monitor. Parameters are added for the module to use, the list of servers to monitor and the username and password to use when connecting to the the servers with the monitor.
|
||||
|
||||
```
|
||||
[Replication Monitor]
|
||||
|
||||
type=monitor
|
||||
|
||||
module=mysqlmon
|
||||
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
|
||||
user=maxscale
|
||||
|
||||
passwd=96F99AA1315BDC3604B006F427DD9484
|
||||
```
|
||||
|
||||
As with the password definition in the server either plain text or encrypted passwords may be used.
|
||||
|
||||
The final stage in the configuration is to add the option service which is used by the maxadmin command to connect to MaxScale for monitoring and administration purposes. This creates a service section and a listener section.
|
||||
|
||||
```
|
||||
[CLI]
|
||||
|
||||
type=service
|
||||
|
||||
router=cli
|
||||
|
||||
[CLI Listener]
|
||||
|
||||
type=listener
|
||||
|
||||
service=CLI
|
||||
|
||||
protocol=maxscaled
|
||||
|
||||
address=localhost
|
||||
|
||||
port=6603
|
||||
```
|
||||
|
||||
In the case of the example above it should be noted that an address parameter has been given to the listener, this limits connections to maxadmin commands that are executed on the same machine that hosts MaxScale.
|
||||
|
||||
# Starting MaxScale
|
||||
|
||||
Upon completion of the configuration process MaxScale is ready to be started for the first time. This may either be done manually by running the maxscale command or via the service interface.
|
||||
|
||||
```
|
||||
% maxscale
|
||||
|
||||
```
|
||||
or
|
||||
|
||||
```
|
||||
% service maxscale start
|
||||
|
||||
```
|
||||
Check the error log in /var/log/maxscale to see if any errors are detected in the configuration file and to confirm MaxScale has been started. Also the maxadmin command may be used to confirm that MaxScale is running and the services, listeners etc have been correctly configured.
|
||||
|
||||
```
|
||||
% maxadmin -pmariadb list services
|
||||
|
||||
Services.
|
||||
@ -277,8 +264,8 @@ Splitter Service | MySQLClient | * | 3306 | Running
|
||||
CLI | maxscaled | localhost | 6603 | Running
|
||||
|
||||
---------------------+--------------------+-----------------+-------+--------
|
||||
```
|
||||
|
||||
%
|
||||
|
||||
MaxScale is now ready to start accepting client connections and routing them to the master or slaves within your cluster. Other configuration options are available that can alter the criteria used for routing, these include monitoring the replication lag within the cluster and routing only to slaves that are within a predetermined delay from the current master or using weights to obtain unequal balancing operations. These options may be found in the MaxScale Configuration Guide. More detail on the use of maxadmin can be found in the document "MaxAdmin - The MaxScale Administration & Monitoring Client Application".
|
||||
|
||||
|
@ -45,17 +45,17 @@ In order to use these scripts on your Nagios Server, you need to copy them from
|
||||
MaxScale must be configured with 'maxscaled' protocol for the administration interface:
|
||||
|
||||
Example of maxscale.cnf file:
|
||||
```
|
||||
[AdminInterface]
|
||||
type=service
|
||||
router=cli
|
||||
|
||||
[AdminInterface]
|
||||
type=service
|
||||
router=cli
|
||||
|
||||
[AdminListener]
|
||||
type=listener
|
||||
service=AdminInterface
|
||||
protocol=maxscaled
|
||||
port=6603
|
||||
|
||||
[AdminListener]
|
||||
type=listener
|
||||
service=AdminInterface
|
||||
protocol=maxscaled
|
||||
port=6603
|
||||
```
|
||||
## Prepare Nagios configuration files.
|
||||
|
||||
Assuming Nagios installed on a separated server and the plugins are in /usr/lib64/nagios/plugins and configuration files are in /etc/nagios:
|
||||
@ -66,8 +66,10 @@ Assuming Nagios installed on a separated server and the plugins are in /usr/lib6
|
||||
|
||||
and add (just after localhost.cfg or commnads.cfg)
|
||||
|
||||
cfg_file=/etc/nagios/objects/maxscale_commands.cfg
|
||||
cfg_file=/etc/nagios/objects/server1.cfg
|
||||
```
|
||||
cfg_file=/etc/nagios/objects/maxscale_commands.cfg
|
||||
cfg_file=/etc/nagios/objects/server1.cfg
|
||||
```
|
||||
|
||||
### Please note:
|
||||
- modify server IP address in server1.cfg, pointing to MaxScale server
|
||||
@ -80,6 +82,7 @@ and add (just after localhost.cfg or commnads.cfg)
|
||||
This example shows configuration that needs to be done on Nagios server in order to communicate to MaxScale server that is running on host server1.
|
||||
In this example we are using the check_maxscale_resource as the check command
|
||||
|
||||
```
|
||||
#Check MaxScale sessions, on the remote machine.
|
||||
define service{
|
||||
use local-service
|
||||
@ -88,6 +91,7 @@ In this example we are using the check_maxscale_resource as the check command
|
||||
check_command check_maxscale_resource!6603!admin!mariadb!sessions!/path_to/maxadmin
|
||||
notifications_enabled 0
|
||||
}
|
||||
```
|
||||
|
||||
### Check new running monitors
|
||||
* Restart Nagios and check new monitors are running in HTTP Interface "Current Status -> Services" on Nagios Server
|
||||
@ -143,15 +147,17 @@ In this example we are using the check_maxscale_resource as the check command
|
||||
# Output description:
|
||||
|
||||
Example for 'services'
|
||||
```
|
||||
#./check_maxscale_resources.pl -r resources
|
||||
|
||||
#./check_maxscale_resources.pl -r resources
|
||||
|
||||
OK: 7 services found | services1=RW_Router;readwritesplit;1;1 services2=RW_Split;readwritesplit;1;1 services3=Test Service;readconnroute;1;1 services4=Master Service;readconnroute;2;2 services5=Debug Service;debugcli;1;1 services6=CLI;cli;2;145 services7=MaxInfo;maxinfo;2;2
|
||||
|
||||
OK: 7 services found | services1=RW_Router;readwritesplit;1;1 services2=RW_Split;readwritesplit;1;1 services3=Test Service;readconnroute;1;1 services4=Master Service;readconnroute;2;2 services5=Debug Service;debugcli;1;1 services6=CLI;cli;2;145 services7=MaxInfo;maxinfo;2;2
|
||||
```
|
||||
Returns OK and the number of services
|
||||
|
||||
Returns CRITICAL if no services are found
|
||||
|
||||
The data after | char are so called performance data and may be collected by Nagios
|
||||
output format is:
|
||||
servicex=Name;router_module;NumUsers;TotalSessions
|
||||
```
|
||||
servicex=Name;router_module;NumUsers;TotalSessions
|
||||
```
|
||||
|
@ -34,11 +34,12 @@ It tries to send data and if there is any failure (timeout, server is down, etc)
|
||||
|
||||
This feature is not enabled by default: MaxScale must be configured in [feedback] section:
|
||||
|
||||
|
||||
[feedback]
|
||||
feedback_enable=1
|
||||
feedback_url=https://enterprise.mariadb.com/feedback/post
|
||||
feedback_user_info=x-y-z-w
|
||||
```
|
||||
[feedback]
|
||||
feedback_enable=1
|
||||
feedback_url=https://enterprise.mariadb.com/feedback/post
|
||||
feedback_user_info=x-y-z-w
|
||||
```
|
||||
|
||||
The activation code that will be provided by MariaDB corp upon request by the customer and it should be put in feedback_user_info.
|
||||
|
||||
@ -63,32 +64,33 @@ MaxScale shall send the generated feedback report to a feedback server specified
|
||||
|
||||
If it’s not possible to send data due to firewall or security settings the report could be generated manually (feedback_user_info is required) via MaxAdmin
|
||||
|
||||
|
||||
```
|
||||
MaxScale>show feedbackreport
|
||||
|
||||
```
|
||||
|
||||
Report could be saved to report.txt file:
|
||||
|
||||
|
||||
```
|
||||
maxadmin -uxxx -pyyy show feedbackreport > ./report.txt
|
||||
|
||||
curl -F data=@./report.txt https://mariadb.org/feedback_plugin/post
|
||||
|
||||
```
|
||||
|
||||
Report Example:
|
||||
|
||||
FEEDBACK_SERVER_UID 6B5C44AEA73137D049B02E6D1C7629EF431A350F
|
||||
FEEDBACK_USER_INFO 0467009f-b04d-45b1-a77b-b6b2ec9c6cf4
|
||||
VERSION 1.0.6-unstable
|
||||
NOW 1425914890
|
||||
PRODUCT maxscale
|
||||
Uname_sysname Linux
|
||||
Uname_distribution CentOS release 6.5 (Final)
|
||||
module_maxscaled_type Protocol
|
||||
module_maxscaled_version V1.0.0
|
||||
module_maxscaled_api 1.0.0
|
||||
module_maxscaled_releasestatus GA
|
||||
module_telnetd_type Protocol
|
||||
module_telnetd_version V1.0.1
|
||||
module_telnetd_api 1.0.0
|
||||
module_telnetd_releasestatus GA
|
||||
```
|
||||
FEEDBACK_SERVER_UID 6B5C44AEA73137D049B02E6D1C7629EF431A350F
|
||||
FEEDBACK_USER_INFO 0467009f-b04d-45b1-a77b-b6b2ec9c6cf4
|
||||
VERSION 1.0.6-unstable
|
||||
NOW 1425914890
|
||||
PRODUCT maxscale
|
||||
Uname_sysname Linux
|
||||
Uname_distribution CentOS release 6.5 (Final)
|
||||
module_maxscaled_type Protocol
|
||||
module_maxscaled_version V1.0.0
|
||||
module_maxscaled_api 1.0.0
|
||||
module_maxscaled_releasestatus GA
|
||||
module_telnetd_type Protocol
|
||||
module_telnetd_version V1.0.1
|
||||
module_telnetd_api 1.0.0
|
||||
module_telnetd_releasestatus GA
|
||||
```
|
||||
|
@ -10,31 +10,34 @@ The software install setup provides RPM and DEB packaging and traditional compil
|
||||
|
||||
On Centos 6.5 using fedora / RHEL rpm get the rpm from [http://www.rabbitmq.com/](http://www.rabbitmq.com/ "RabbitMQ")
|
||||
|
||||
rabbitmq-server-3.3.4-1.noarch.rpm
|
||||
rabbitmq-server-3.3.4-1.noarch.rpm
|
||||
|
||||
Please note, before installing RabbitMQ, you must install Erlang.
|
||||
|
||||
Example:
|
||||
|
||||
yum install erlang
|
||||
Package erlang-R14B-04.3.el6.x86_64 already installed and latest version
|
||||
yum install erlang
|
||||
Package erlang-R14B-04.3.el6.x86_64 already installed and latest version
|
||||
|
||||
## Step 2 - Install and Start the Server
|
||||
|
||||
Install the packages using your distribution's package manager and start the server:
|
||||
|
||||
yum install rabbitmq-server-3.3.4-1.noarch.rpm
|
||||
systemctl start rabbitmq-server.service
|
||||
yum install rabbitmq-server-3.3.4-1.noarch.rpm
|
||||
systemctl start rabbitmq-server.service
|
||||
|
||||
To configure your RabbitMQ server, please refer to the RabbitMQ website: [http://www.rabbitmq.com/](http://www.rabbitmq.com/ RabbitMQ website).
|
||||
|
||||
rabbitmqctl is a command line tool for managing a RabbitMQ broker. It performs all actions by connecting to one of the broker's nodes.
|
||||
|
||||
rabbitmqctl list_queues
|
||||
rabbitmqctl list_queues | list_exchanges| cluster_status | list_bindings | list_connections | list_consumers | status
|
||||
```
|
||||
rabbitmqctl list_queues
|
||||
rabbitmqctl list_queues | list_exchanges| cluster_status | list_bindings | list_connections | list_consumers | status
|
||||
```
|
||||
|
||||
Example output:
|
||||
|
||||
```
|
||||
[root@maxscale-02 MaxScale]# rabbitmqctl status
|
||||
Status of node 'rabbit@maxscale-02' ...
|
||||
[{pid,12251},
|
||||
@ -57,12 +60,15 @@ Example output:
|
||||
Listing bindings ...
|
||||
x1 exchange q1 queue k1 []
|
||||
...done.
|
||||
```
|
||||
|
||||
Interaction with the server may require stop & reset at some point:
|
||||
|
||||
rabbitmqctl stop_app
|
||||
rabbitmqctl reset
|
||||
rabbitmqctl start_app
|
||||
```
|
||||
rabbitmqctl stop_app
|
||||
rabbitmqctl reset
|
||||
rabbitmqctl start_app
|
||||
```
|
||||
|
||||
## Step 3 - Install and test the client libraries
|
||||
|
||||
@ -73,11 +79,13 @@ The selected library for MaxScale integration of RabbitMQ is:
|
||||
|
||||
To compile the RabbitMQ-C libraries manually:
|
||||
|
||||
git clone https://github.com/alanxz/rabbitmq-c.git
|
||||
cd rabbitmq-c
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr .
|
||||
make
|
||||
make install
|
||||
```
|
||||
git clone https://github.com/alanxz/rabbitmq-c.git
|
||||
cd rabbitmq-c
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr .
|
||||
make
|
||||
make install
|
||||
```
|
||||
|
||||
Please note, this will install the packages to /usr. If you do not wish to install them to this location, provide a different value for the CMAKE_INSTALL_PREFIX variable.
|
||||
|
||||
@ -88,18 +96,21 @@ Check how to configure your distribution for the EPEL repository: [https://fedor
|
||||
|
||||
Configure your repositories and install the software:
|
||||
|
||||
yum install librabbitmq.x86_64
|
||||
```
|
||||
yum install librabbitmq.x86_64
|
||||
```
|
||||
|
||||
you might also like to install:
|
||||
|
||||
librabbitmq-tools.x86_64, librabbitmq-devel.x86_64
|
||||
```
|
||||
librabbitmq-tools.x86_64, librabbitmq-devel.x86_64
|
||||
```
|
||||
|
||||
Please note you may also install the rabbitmq server from the EPEL repository:
|
||||
|
||||
yum install rabbitmq-server
|
||||
|
||||
|
||||
|
||||
```
|
||||
yum install rabbitmq-server
|
||||
```
|
||||
|
||||
### Basic tests with library
|
||||
|
||||
@ -109,85 +120,113 @@ Please note, those example applications may not be included in the RPM library p
|
||||
|
||||
#### Test 1 - create the exchange
|
||||
|
||||
[root@maxscale-02 examples]# ./amqp_exchange_declare
|
||||
Usage: amqp_exchange_declare host port exchange exchangetype
|
||||
```
|
||||
[root@maxscale-02 examples]# ./amqp_exchange_declare
|
||||
Usage: amqp_exchange_declare host port exchange exchangetype
|
||||
```
|
||||
|
||||
Declare the exchange:
|
||||
|
||||
[root@maxscale-02 examples]# ./amqp_exchange_declare 127.0.0.1 5672 foo direct
|
||||
```
|
||||
[root@maxscale-02 examples]# ./amqp_exchange_declare 127.0.0.1 5672 foo direct
|
||||
```
|
||||
|
||||
#### Test 2 - Listen to exchange with selected binding key
|
||||
|
||||
[root@maxscale-02 examples]# ./amqp_listen
|
||||
Usage: amqp_listen host port exchange bindingkey
|
||||
```
|
||||
[root@maxscale-02 examples]# ./amqp_listen
|
||||
Usage: amqp_listen host port exchange bindingkey
|
||||
```
|
||||
|
||||
Start the listener:
|
||||
|
||||
[root@maxscale-02 examples]# ./amqp_listen 127.0.0.1 5672 foo k1 &
|
||||
```
|
||||
[root@maxscale-02 examples]# ./amqp_listen 127.0.0.1 5672 foo k1 &
|
||||
```
|
||||
|
||||
#### Test 3 - Send a message …
|
||||
|
||||
[root@maxscale-02 examples]# ./amqp_sendstring
|
||||
Usage: amqp_sendstring host port exchange routingkey messagebody
|
||||
```
|
||||
[root@maxscale-02 examples]# ./amqp_sendstring
|
||||
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
|
||||
|
||||
Delivery 1, exchange foo routingkey k1
|
||||
Content-type: text/plain
|
||||
|
||||
```
|
||||
Delivery 1, exchange foo routingkey k1
|
||||
Content-type: text/plain
|
||||
```
|
||||
|
||||
## Step 4 - MaxScale integration with librabbitmq-c
|
||||
|
||||
A new filter (mqfilter.c) is implemented in order to send messages to the rabbitmq server and a message consumer (rabbitmq_consumer/consumer.c) program will get messages and store them into a MySQL/MariaDB database.
|
||||
A quick way to install MaxScale with the RabbitMQ filter is to go to the MaxScale source directory and run the following commands:
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DBUILD_RABBITMQ=Y
|
||||
make
|
||||
make install
|
||||
|
||||
```
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DBUILD_RABBITMQ=Y
|
||||
make
|
||||
make install
|
||||
```
|
||||
|
||||
To build the RabbitMQ filter CMake needs an additional parameter:
|
||||
|
||||
-DBUILD_RABBITMQ=Y
|
||||
```
|
||||
-DBUILD_RABBITMQ=Y
|
||||
```
|
||||
|
||||
If the librabbitmq-c library is manually compiled it may be necessary to manually pass the location of the libraries and header files to CMake.
|
||||
|
||||
Libraries:
|
||||
|
||||
-DRABBITMQ_LIBRARIES=<path to RabbitMQ-c libraries>
|
||||
```
|
||||
-DRABBITMQ_LIBRARIES=<path to RabbitMQ-c libraries>
|
||||
```
|
||||
|
||||
Headers:
|
||||
|
||||
-DRABBITMQ_HEADERS=<path to RabbitMQ-c headers>
|
||||
|
||||
```
|
||||
-DRABBITMQ_HEADERS=<path to RabbitMQ-c headers>
|
||||
```
|
||||
|
||||
Please note, Message Queue Consumer (consumer.c) also needs to be compiled with MySQL/MariaDB client libraries in addition to the RabbitMQ-c libraries. If you have your MySQL/MariaDB client libraries and headers in non-standard locations, you can pass them manually to CMake:
|
||||
|
||||
Libraries:
|
||||
|
||||
-DMYSQLCLIENT_LIBRARIES=<path to libraries>
|
||||
```
|
||||
-DMYSQLCLIENT_LIBRARIES=<path to libraries>
|
||||
```
|
||||
|
||||
Headers:
|
||||
|
||||
-DMYSQLCLIENT_HEADERS=<path to headers>
|
||||
```
|
||||
-DMYSQLCLIENT_HEADERS=<path to headers>
|
||||
```
|
||||
|
||||
The message queue consumer must be also built as a separate task, it’s not built as part of MaxScale build system. To build it, run the following commands in the rabbitmq_consumer directory in the MaxScale source folder:
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
|
||||
To install it:
|
||||
|
||||
make install
|
||||
```
|
||||
make install
|
||||
```
|
||||
|
||||
To build packages:
|
||||
|
||||
make package
|
||||
```
|
||||
make package
|
||||
```
|
||||
|
||||
This generates RPM or DEB packages based on your system. These packages can then be installed on remote systems for easy access to the data generated by the consumer client.
|
||||
|
||||
@ -195,181 +234,192 @@ This generates RPM or DEB packages based on your system. These packages can then
|
||||
|
||||
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
|
||||
|
||||
[MQ]
|
||||
type=filter
|
||||
module=mqfilter
|
||||
exchange=x1
|
||||
key=k1
|
||||
queue=q1
|
||||
hostname=127.0.0.1
|
||||
port=5672
|
||||
logging_trigger=all
|
||||
|
||||
```
|
||||
[Test Service]
|
||||
type=service
|
||||
router=readconnroute
|
||||
router_options=slave
|
||||
servers=server1,server2,server3,server5,server4
|
||||
user=massi
|
||||
passwd=massi
|
||||
filters=MQ
|
||||
|
||||
[MQ]
|
||||
type=filter
|
||||
module=mqfilter
|
||||
exchange=x1
|
||||
key=k1
|
||||
queue=q1
|
||||
hostname=127.0.0.1
|
||||
port=5672
|
||||
logging_trigger=all
|
||||
```
|
||||
|
||||
Logging triggers define whether to log all or a subset of the incoming queries using these options:
|
||||
|
||||
# log only some elements or all
|
||||
logging_trigger=[all,source,schema,object]
|
||||
```
|
||||
# log only some elements or all
|
||||
logging_trigger=[all,source,schema,object]
|
||||
|
||||
# Whether to log only SELECT, UPDATE, INSERT and DELETE queries or all possible queries
|
||||
logging_log_all=true|false
|
||||
# Whether to log only SELECT, UPDATE, INSERT and DELETE queries or all possible queries
|
||||
logging_log_all=true|false
|
||||
|
||||
# Log only when any of the trigger parameters match or only if all parameters match
|
||||
logging_strict=true|false
|
||||
|
||||
# specify objects
|
||||
logging_object=mytable,another_table
|
||||
|
||||
# Log only when any of the trigger parameters match or only if all parameters match
|
||||
logging_strict=true|false
|
||||
# specify logged users
|
||||
logging_source_user=testuser,testuser
|
||||
|
||||
# specify objects
|
||||
logging_object=mytable,another_table
|
||||
|
||||
# specify logged users
|
||||
logging_source_user=testuser,testuser
|
||||
|
||||
|
||||
# specify source addresses
|
||||
logging_source_host=127.0.0.1,192.168.10.14
|
||||
|
||||
# specify schemas
|
||||
logging_schema=employees,orders,catalog
|
||||
# specify source addresses
|
||||
logging_source_host=127.0.0.1,192.168.10.14
|
||||
|
||||
# specify schemas
|
||||
logging_schema=employees,orders,catalog
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
logging_trigger=object,schema,source
|
||||
logging_strict=false
|
||||
logging_log_all=false
|
||||
logging_object=my1
|
||||
logging_schema=test
|
||||
logging_source_user=maxtest
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```
|
||||
logging_trigger=object,schema,source
|
||||
logging_strict=false
|
||||
logging_log_all=false
|
||||
logging_object=my1
|
||||
logging_schema=test
|
||||
logging_source_user=maxtest
|
||||
```
|
||||
|
||||
The logging result of the example is:
|
||||
|
||||
if user maxtest does something, it's logged
|
||||
and all queries in test schema are logged
|
||||
anything targeting my1 table is logged
|
||||
SELECT NOW(), SELECT MD5(“xyz)” are not logged
|
||||
```
|
||||
if user maxtest does something, it's logged
|
||||
and all queries in test schema are logged
|
||||
anything targeting my1 table is logged
|
||||
SELECT NOW(), SELECT MD5(“xyz)” are not logged
|
||||
```
|
||||
|
||||
Please note that if we want to log only the user ‘maxtest’ accessing the schema ‘test’ with target ‘my1’ the option logging_strict must be set to TRUE and if we want to include those selects without schema name the option logging_log_all must be set to TRUE.
|
||||
|
||||
The mqfilter logs into the MaxScale TRACE log information about the matched logging triggers and the message delivering:
|
||||
|
||||
2014 09/03 06:22:04 Trigger is TRG_SOURCE: user: testuser = testuser
|
||||
2014 09/03 06:22:04 Trigger is TRG_SCHEMA: test = test
|
||||
2014 09/03 06:22:04 Trigger is TRG_OBJECT: test.t1 = t1
|
||||
2014 09/03 06:22:04 Routing message to: 127.0.0.1:5672 / as guest/guest, exchange: x1<direct> key:k1 queue:q1
|
||||
```
|
||||
2014 09/03 06:22:04 Trigger is TRG_SOURCE: user: testuser = testuser
|
||||
2014 09/03 06:22:04 Trigger is TRG_SCHEMA: test = test
|
||||
2014 09/03 06:22:04 Trigger is TRG_OBJECT: test.t1 = t1
|
||||
2014 09/03 06:22:04 Routing message to: 127.0.0.1:5672 / as guest/guest, exchange: x1<direct> key:k1 queue:q1
|
||||
|
||||
```
|
||||
|
||||
The consumer application needs to be configured as well:
|
||||
|
||||
```
|
||||
|
||||
#The options for the consumer are:
|
||||
#hostname RabbitMQ hostname
|
||||
#port RabbitMQ port
|
||||
#vhost RabbitMQ virtual host
|
||||
#user RabbitMQ username
|
||||
#passwd RabbitMQ password
|
||||
|
||||
|
||||
#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
|
||||
#The options for the consumer are:
|
||||
#hostname RabbitMQ hostname
|
||||
#port RabbitMQ port
|
||||
#vhost RabbitMQ virtual host
|
||||
#user RabbitMQ username
|
||||
#passwd RabbitMQ password
|
||||
|
||||
|
||||
#queue Name of the queue to use
|
||||
#dbserver SQL server name
|
||||
#dbport SQL server port
|
||||
#dbname Name of the database to use
|
||||
#dbuser SQL server username
|
||||
#dbpasswd SQL server password
|
||||
#logfile Message log filename
|
||||
|
||||
[consumer]
|
||||
hostname=127.0.0.1
|
||||
port=5672
|
||||
vhost=/
|
||||
user=guest
|
||||
passwd=guest
|
||||
queue=q1
|
||||
dbserver=127.0.0.1
|
||||
dbport=3308
|
||||
dbname=mqpairs
|
||||
dbuser=xxx
|
||||
dbpasswd=yyy
|
||||
```
|
||||
|
||||
We may probably need to modify LD_LIBRARY_PATH before launching ‘consumer’:
|
||||
|
||||
# export LD_LIBRARY_PATH=/packages/rabbitmq-c/rabbitmq-c/librabbitmq:/packages/mariadb_client-2.0.0-Linux/lib/mariadb:/usr/lib64
|
||||
```
|
||||
# export LD_LIBRARY_PATH=/packages/rabbitmq-c/rabbitmq-c/librabbitmq:/packages/mariadb_client-2.0.0-Linux/lib/mariadb:/usr/lib64
|
||||
```
|
||||
|
||||
and finally we can launch it:
|
||||
|
||||
# ./consumer
|
||||
```
|
||||
# ./consumer
|
||||
```
|
||||
|
||||
If the consumer.cnf file is not in the same directory as the binary file is, you can provide the location of the folder that it is in by passing it the -c flag followed by the path:
|
||||
|
||||
# ./consumer -c path/to/file
|
||||
```
|
||||
# ./consumer -c path/to/file
|
||||
```
|
||||
|
||||
and start maxScale as well
|
||||
|
||||
## Step 6 - Test the filter and check collected data
|
||||
|
||||
Assuming that MaxScale and the message consumer are successfully running let’s connect to the service with an active mqfilter:
|
||||
|
||||
[root@maxscale-02 MaxScale]# mysql -h 127.0.0.1 -P 4506 -uxxx -pyyy
|
||||
...
|
||||
MariaDB [(none)]> select RAND(3), RAND(5);
|
||||
+--------------------+---------------------+
|
||||
| RAND(3) | RAND(5) |
|
||||
+--------------------+---------------------+
|
||||
| 0.9057697559760601 | 0.40613597483014313 |
|
||||
+--------------------+---------------------+
|
||||
1 row in set (0.01 sec)
|
||||
|
||||
…
|
||||
MariaDB [(none)]> select RAND(3544), RAND(11);
|
||||
|
||||
|
||||
|
||||
```
|
||||
[root@maxscale-02 MaxScale]# mysql -h 127.0.0.1 -P 4506 -uxxx -pyyy
|
||||
...
|
||||
MariaDB [(none)]> select RAND(3), RAND(5);
|
||||
+--------------------+---------------------+
|
||||
| RAND(3) | RAND(5) |
|
||||
+--------------------+---------------------+
|
||||
| 0.9057697559760601 | 0.40613597483014313 |
|
||||
+--------------------+---------------------+
|
||||
1 row in set (0.01 sec)
|
||||
…
|
||||
MariaDB [(none)]> select RAND(3544), RAND(11);
|
||||
```
|
||||
|
||||
we can check the consumer output in the terminal where it was started:
|
||||
|
||||
--------------------------------------------------------------
|
||||
Received: 1409671452|select @@version_comment limit ?
|
||||
Received: 1409671452|Columns: 1
|
||||
...
|
||||
Received: 1409671477|select RAND(?), RAND(?)
|
||||
Received: 1409671477|Columns: 2
|
||||
|
||||
We query now the database for the content collected so far:
|
||||
|
||||
MariaDB [(none)]> use mqpairs;
|
||||
Database changed
|
||||
|
||||
```
|
||||
--------------------------------------------------------------
|
||||
Received: 1409671452|select @@version_comment limit ?
|
||||
Received: 1409671452|Columns: 1
|
||||
...
|
||||
Received: 1409671477|select RAND(?), RAND(?)
|
||||
Received: 1409671477|Columns: 2
|
||||
|
||||
We query now the database for the content collected so far:
|
||||
|
||||
MariaDB [(none)]> use mqpairs;
|
||||
Database changed
|
||||
|
||||
|
||||
|
||||
MariaDB [mqpairs]> select * from pairs;
|
||||
|
||||
+-------------------------------------+----------------------------------+------------+---------------------+---------------------+---------+
|
||||
| tag | query | reply | date_in | date_out | counter |
|
||||
+-------------------------------------+----------------------------------+------------+---------------------+---------------------+---------+
|
||||
| 006c006d006e006f007000710072007374 | select @@version_comment limit ? | Columns: 1 | 2014-09-02 11:14:51 | 2014-09-02 11:26:38 | 3 |
|
||||
| 00750076007700780079007a007b007c7d | SELECT DATABASE() | Columns: 1 | 2014-09-02 11:14:56 | 2014-09-02 11:27:06 | 3 |
|
||||
| 007e007f00800081008200830084008586 | show databases | Columns: 1 | 2014-09-02 11:14:56 | 2014-09-02 11:27:06 | 3 |
|
||||
| 008700880089008a008b008c008d008e8f | show tables | Columns: 1 | 2014-09-02 11:14:56 | 2014-09-02 11:27:06 | 3 |
|
||||
| 0090009100920093009400950096009798 | select * from mqpairs.pairs | Columns: 6 | 2014-09-02 11:15:00 | 2014-09-02 11:27:00 | 12 |
|
||||
| 00fc00fd00fe00ff0100010101020103104 | select NOW() | Columns: 1 | 2014-09-02 11:24:23 | 2014-09-02 11:24:23 | 1 |
|
||||
| 01050106010701080109010a010b010c10d | select RAND(?), RAND(?) | Columns: 2 | 2014-09-02 11:24:37 | 2014-09-02 11:24:37 | 1 |
|
||||
+-------------------------------------+----------------------------------+------------+---------------------+---------------------+---------+
|
||||
7 rows in set (0.01 sec)
|
||||
|
||||
|
||||
MariaDB [mqpairs]> select * from pairs;
|
||||
|
||||
+-------------------------------------+----------------------------------+------------+---------------------+---------------------+---------+
|
||||
| tag | query | reply | date_in | date_out | counter |
|
||||
+-------------------------------------+----------------------------------+------------+---------------------+---------------------+---------+
|
||||
| 006c006d006e006f007000710072007374 | select @@version_comment limit ? | Columns: 1 | 2014-09-02 11:14:51 | 2014-09-02 11:26:38 | 3 |
|
||||
| 00750076007700780079007a007b007c7d | SELECT DATABASE() | Columns: 1 | 2014-09-02 11:14:56 | 2014-09-02 11:27:06 | 3 |
|
||||
| 007e007f00800081008200830084008586 | show databases | Columns: 1 | 2014-09-02 11:14:56 | 2014-09-02 11:27:06 | 3 |
|
||||
| 008700880089008a008b008c008d008e8f | show tables | Columns: 1 | 2014-09-02 11:14:56 | 2014-09-02 11:27:06 | 3 |
|
||||
| 0090009100920093009400950096009798 | select * from mqpairs.pairs | Columns: 6 | 2014-09-02 11:15:00 | 2014-09-02 11:27:00 | 12 |
|
||||
| 00fc00fd00fe00ff0100010101020103104 | select NOW() | Columns: 1 | 2014-09-02 11:24:23 | 2014-09-02 11:24:23 | 1 |
|
||||
| 01050106010701080109010a010b010c10d | select RAND(?), RAND(?) | Columns: 2 | 2014-09-02 11:24:37 | 2014-09-02 11:24:37 | 1 |
|
||||
+-------------------------------------+----------------------------------+------------+---------------------+---------------------+---------+
|
||||
7 rows in set (0.01 sec)
|
||||
```
|
||||
|
||||
The filter send queries to the RabbitMQ server in the canonical format, i.e select RAND(?), RAND(?).
|
||||
The queries Message Queue Consumer application gets from the server are stored with a counter that quickly shows how many times that normalized query was received:
|
||||
|
||||
| 01050106010701080109010a010b010c10d | select RAND(?), RAND(?) | Columns: 2 | 2014-09-02 11:24:37 | 2014-09-02 11:29:15 | 3 |
|
||||
```
|
||||
| 01050106010701080109010a010b010c10d | select RAND(?), RAND(?) | Columns: 2 | 2014-09-02 11:24:37 | 2014-09-02 11:29:15 | 3 |
|
||||
```
|
||||
|
@ -29,22 +29,22 @@ Using MaxScale as a replication proxy is much the same as using MaxScale as a pr
|
||||
## Service Configuration
|
||||
|
||||
As with any MaxScale configuration a good starting point is with the service definition with the maxscale.cnf file. The service requires a name which is the section name in the ini file, a type parameter with a value of service and the name of the router plugin that should be loaded. In the case of replication proxies this router name is binlogrouter.
|
||||
```
|
||||
|
||||
|
||||
[Replication]
|
||||
type=service
|
||||
router=binlogrouter
|
||||
|
||||
[Replication]
|
||||
type=service
|
||||
router=binlogrouter
|
||||
```
|
||||
Other standard service parameters need to be given in the configuration section that are used to retrieve the set of users from the backend (master) database, also a version string can be given such that the MaxScale instance will report this version string to the slave servers that connect to MaxScale. The master server entry must also be given. In the current implementation of the router only a single server can be given.
|
||||
|
||||
[Replication]
|
||||
type=service
|
||||
router=binlogrouter
|
||||
servers=masterdb
|
||||
version_string=5.6.17-log
|
||||
user=maxscale
|
||||
passwd=Mhu87p2D
|
||||
|
||||
```
|
||||
[Replication]
|
||||
type=service
|
||||
router=binlogrouter
|
||||
servers=masterdb
|
||||
version_string=5.6.17-log
|
||||
user=maxscale
|
||||
passwd=Mhu87p2D
|
||||
```
|
||||
The user and passwd entries in the above example are used in order for MaxScale to populate the credential information that is required to allow the slaves to connect to MaxScale. This user should be configured in exactly the same way a for any other MaxScale service, i.e. the user needs access to the mysql.user table and the mysql.db table as well as having the ability to perform a SHOW DATABASES command.
|
||||
|
||||
The final configuration requirement is the router specific options. The binlog router requires a set of parameters to be passed, these are passed in the router_options parameter of the service definition as a comma separated list of name value pairs.
|
||||
@ -62,10 +62,10 @@ As with uuid, MaxScale must have a unique server-id for the connection it makes
|
||||
This is the user name that MaxScale uses when it connects to the master. This user name must have the rights required for replication as with any other user that a slave uses for replication purposes. If the user parameter is not given in the router options then the same user as is used to retrieve the credential information will be used for the replication connection, i.e. the user in the service entry.
|
||||
|
||||
The user that is used for replication, either defined using the user= option in the router options or using the username and password defined of the service must be granted replication privileges on the database server.
|
||||
|
||||
MariaDB> CREATE USER 'repl'@'maxscalehost' IDENTIFIED by 'password';
|
||||
MariaDB> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'maxscalehost';
|
||||
|
||||
```
|
||||
MariaDB> CREATE USER 'repl'@'maxscalehost' IDENTIFIED by 'password';
|
||||
MariaDB> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'maxscalehost';
|
||||
```
|
||||
### password
|
||||
|
||||
The password of the above user. If the password is not explicitly given then the password in the service entry will be used. For compatibility with other username and password definitions within the MaxScale configuration file it is also possible to use the parameter passwd=.
|
||||
@ -95,45 +95,45 @@ This defines the value of the heartbeat interval in seconds for the connection t
|
||||
This parameter is used to define the maximum amount of data that will be sent to a slave by MaxScale when that slave is lagging behind the master. In this situation the slave is said to be in "catchup mode", this parameter is designed to both prevent flooding of that slave and also to prevent threads within MaxScale spending disproportionate amounts of time with slaves that are lagging behind the master. The burst size can be defined in Kb, Mb or Gb by adding the qualifier K, M or G to the number given. The default value of burstsize is 1Mb and will be used if burstsize is not given in the router options.
|
||||
|
||||
A complete example of a service entry for a binlog router service would be as follows.
|
||||
|
||||
[Replication]
|
||||
type=service
|
||||
router=binlogrouter
|
||||
servers=masterdb
|
||||
version_string=5.6.17-log
|
||||
router_options=uuid=f12fcb7f-b97b-11e3-bc5e-0401152c4c22,server-id=3,user=repl,password=slavepass,master-id=1,filestem=mybin,heartbeat=30,binlogdir=/var/binlogs
|
||||
user=maxscale
|
||||
passwd=Mhu87p2D
|
||||
|
||||
```
|
||||
[Replication]
|
||||
type=service
|
||||
router=binlogrouter
|
||||
servers=masterdb
|
||||
version_string=5.6.17-log
|
||||
router_options=uuid=f12fcb7f-b97b-11e3-bc5e-0401152c4c22,server-id=3,user=repl,password=slavepass,master-id=1,filestem=mybin,heartbeat=30,binlogdir=/var/binlogs
|
||||
user=maxscale
|
||||
passwd=Mhu87p2D
|
||||
```
|
||||
The minimum set of router options that must be given in the configuration are are server-id and aster-id, default values may be used for all other options.
|
||||
|
||||
## Listener Section
|
||||
|
||||
As per any service in MaxScale a listener section is required to define the address, port and protocol that is used to listen for incoming connections. In this case those incoming connections will originate from the slave servers.
|
||||
|
||||
[Replication Listener]
|
||||
type=listener
|
||||
service=Replication
|
||||
protocol=MySQLClient
|
||||
port=5308
|
||||
|
||||
```
|
||||
[Replication Listener]
|
||||
type=listener
|
||||
service=Replication
|
||||
protocol=MySQLClient
|
||||
port=5308
|
||||
```
|
||||
The protocol used by slaves for connection to MaxScale is the same MySQLClient protocol that is used for client applications to connect to databases, therefore the same MaxScale protocol module can be used.
|
||||
|
||||
## Master Server Section
|
||||
|
||||
The master server is defined in a section within the MaxScale configuration file in the same way as any other server. The protocol that is used is the same backend protocol as is used in other configurations.
|
||||
|
||||
[masterdb]
|
||||
type=server
|
||||
address=178.62.50.70
|
||||
port=3306
|
||||
protocol=MySQLBackend
|
||||
|
||||
```
|
||||
[masterdb]
|
||||
type=server
|
||||
address=178.62.50.70
|
||||
port=3306
|
||||
protocol=MySQLBackend
|
||||
```
|
||||
# MaxScale replication diagnostics
|
||||
|
||||
The binlog router module of MaxScale produces diagnostic output that can be viewed via the `maxadmin` client application. Running the maxadmin command and issuing a show service command will produce a considerable amount of output that will show both the master connection status and statistics and also a block for each of the slaves currently connected.
|
||||
|
||||
-bash-4.1$ maxadmin show service Replication
|
||||
```
|
||||
-bash-4.1$ maxadmin show service Replication
|
||||
Service 0x1567ef0
|
||||
Service: Replication
|
||||
Router: binlogrouter (0x7f4ceb96a820)
|
||||
@ -207,9 +207,8 @@ The binlog router module of MaxScale produces diagnostic output that can be view
|
||||
Users data: 0x156c030
|
||||
Total connections: 2
|
||||
Currently connected: 2
|
||||
-bash-4.1$
|
||||
|
||||
|
||||
-bash-4.1$
|
||||
```
|
||||
|
||||
# Binlog router compatibility
|
||||
|
||||
@ -224,13 +223,13 @@ Binlog Router currently does not work for MySQL 5.5 due to missing @@global.binl
|
||||
# Slave servers setup
|
||||
|
||||
Examples of CHANGE MASTER TO command issued on a slave server that wants to gets replication events from MaxScale binlog router:
|
||||
```
|
||||
CHANGE MASTER TO MASTER_HOST=‘$maxscale_IP’, MASTER_PORT=5308, MASTER_USER='repl', MASTER_PASSWORD=‘somepasswd’,
|
||||
MASTER_LOG_FILE=‘mysql-bin.000001'
|
||||
|
||||
CHANGE MASTER TO MASTER_HOST=‘$maxscale_IP’, MASTER_PORT=5308, MASTER_USER='repl', MASTER_PASSWORD=‘somepasswd’,
|
||||
MASTER_LOG_FILE=‘mysql-bin.000001'
|
||||
|
||||
CHANGE MASTER TO MASTER_HOST=‘$maxscale_IP’, MASTER_PORT=5308, MASTER_USER='repl', MASTER_PASSWORD=‘somepasswd’,
|
||||
MASTER_LOG_FILE=‘mysql-bin.000159', MASTER_LOG_POS=245
|
||||
|
||||
CHANGE MASTER TO MASTER_HOST=‘$maxscale_IP’, MASTER_PORT=5308, MASTER_USER='repl', MASTER_PASSWORD=‘somepasswd’,
|
||||
MASTER_LOG_FILE=‘mysql-bin.000159', MASTER_LOG_POS=245
|
||||
```
|
||||
The latter example specifies a MASTER_LOG_POS for the selected MASTER_LOG_FILE
|
||||
|
||||
Note:
|
||||
@ -242,31 +241,31 @@ Note:
|
||||
- Latest binlog file name and pos in MaxScale could be find via maxadmin output or from mysql client connected to MaxScale:
|
||||
|
||||
Example:
|
||||
|
||||
-bash-4.1$ mysql -h 127.0.0.1 -P 5308 -u$user -p$pass
|
||||
```
|
||||
-bash-4.1$ mysql -h 127.0.0.1 -P 5308 -u$user -p$pass
|
||||
|
||||
MySQL [(none)]> show master status\G
|
||||
*************************** 1. row ***************************
|
||||
File: mysql-bin.000181
|
||||
Position: 2569
|
||||
|
||||
```
|
||||
# Enabling MariaDB 10 compatibility
|
||||
|
||||
MariaDB 10 has different slave registration phase so an option is required:
|
||||
|
||||
router_options=...., mariadb10-compatibility=1
|
||||
|
||||
```
|
||||
router_options=...., mariadb10-compatibility=1
|
||||
```
|
||||
version_string should be modified in order to present MariaDB 10 version when MaxScale sends server handshake packet.
|
||||
|
||||
version_string=10.0.17-log
|
||||
|
||||
```
|
||||
version_string=10.0.17-log
|
||||
```
|
||||
|
||||
# New MariaDB events in Diagnostics
|
||||
|
||||
With a MariaDB 10 setups new events are displayed when master server is MariaDB 10.
|
||||
|
||||
MariaDB 10 Annotate Rows Event 0
|
||||
MariaDB 10 Binlog Checkpoint Event 0
|
||||
MariaDB 10 GTID Event 0
|
||||
MariaDB 10 GTID List Event 0
|
||||
|
||||
```
|
||||
MariaDB 10 Annotate Rows Event 0
|
||||
MariaDB 10 Binlog Checkpoint Event 0
|
||||
MariaDB 10 GTID Event 0
|
||||
MariaDB 10 GTID List Event 0
|
||||
```
|
||||
|
@ -56,6 +56,9 @@ Log messages to MaxScale's own log files.
|
||||
.BR "-v, --version"
|
||||
Print version information and exit.
|
||||
.TP
|
||||
.BR "-V, --version-full"
|
||||
Print full version information including the Git commit the binary was built from and exit.
|
||||
.TP
|
||||
.BR "-?, --help"
|
||||
Show the help information for MaxScale and exit.
|
||||
|
||||
|
@ -55,6 +55,13 @@
|
||||
#include <histedit.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We need a common.h file that is included by every component.
|
||||
*/
|
||||
#if !defined(STRERROR_BUFLEN)
|
||||
#define STRERROR_BUFLEN 512
|
||||
#endif
|
||||
|
||||
static int connectMaxScale(char *hostname, char *port);
|
||||
static int setipaddress(struct in_addr *a, char *p);
|
||||
static int authMaxScale(int so, char *user, char *password);
|
||||
@ -329,8 +336,9 @@ int keepalive = 1;
|
||||
|
||||
if ((so = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr, "Unable to create socket: %s\n",
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
return -1;
|
||||
}
|
||||
memset(&addr, 0, sizeof addr);
|
||||
@ -339,8 +347,9 @@ int keepalive = 1;
|
||||
addr.sin_port = htons(atoi(port));
|
||||
if (connect(so, (struct sockaddr *)&addr, sizeof(addr)) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr, "Unable to connect to MaxScale at %s, %s: %s\n",
|
||||
hostname, port, strerror(errno));
|
||||
hostname, port, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
close(so);
|
||||
return -1;
|
||||
}
|
||||
|
@ -58,6 +58,35 @@ start() {
|
||||
CHECK_RET=$?
|
||||
[ $CHECK_RET -eq 0 ] && echo -n " found $my_check" && success && CHECK_RET=0
|
||||
|
||||
if [ ! -d @MAXSCALE_VARDIR@/log/maxscale ]
|
||||
then
|
||||
mkdir -p @MAXSCALE_VARDIR@/log/maxscale
|
||||
fi
|
||||
|
||||
if [ ! -d @MAXSCALE_VARDIR@/cache/maxscale ]
|
||||
then
|
||||
mkdir -p @MAXSCALE_VARDIR@/cache/maxscale
|
||||
fi
|
||||
|
||||
if [ ! -d @MAXSCALE_VARDIR@/lib/maxscale ]
|
||||
then
|
||||
mkdir -p @MAXSCALE_VARDIR@/lib/maxscale
|
||||
fi
|
||||
|
||||
if [ ! -d @MAXSCALE_VARDIR@/run/maxscale ]
|
||||
then
|
||||
mkdir -p @MAXSCALE_VARDIR@/run/maxscale
|
||||
fi
|
||||
|
||||
chown maxscale:maxscale @MAXSCALE_VARDIR@/log/maxscale
|
||||
chown maxscale:maxscale @MAXSCALE_VARDIR@/lib/maxscale
|
||||
chown maxscale:maxscale @MAXSCALE_VARDIR@/cache/maxscale
|
||||
chown maxscale:maxscale @MAXSCALE_VARDIR@/run/maxscale
|
||||
chmod 0755 @MAXSCALE_VARDIR@/log/maxscale
|
||||
chmod 0755 @MAXSCALE_VARDIR@/lib/maxscale
|
||||
chmod 0755 @MAXSCALE_VARDIR@/cache/maxscale
|
||||
chmod 0755 @MAXSCALE_VARDIR@/run/maxscale
|
||||
|
||||
daemon --pidfile $MAXSCALE_PIDFILE @CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@/maxscale --user=maxscale >& /dev/null
|
||||
|
||||
RETVAL=$?
|
||||
|
@ -45,7 +45,7 @@ _RETVAL_STATUS_NOT_RUNNING=3
|
||||
#################################
|
||||
NAME=maxscale
|
||||
DAEMON=@CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@/maxscale
|
||||
DAEMON_OPTS=--user=maxscale
|
||||
DAEMON_OPTS='--user=maxscale'
|
||||
# Source function library.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
@ -56,6 +56,36 @@ servicename=maxscale
|
||||
RETVAL=0
|
||||
|
||||
start() {
|
||||
|
||||
if [ ! -d @MAXSCALE_VARDIR@/log/maxscale ]
|
||||
then
|
||||
mkdir -p @MAXSCALE_VARDIR@/log/maxscale
|
||||
fi
|
||||
|
||||
if [ ! -d @MAXSCALE_VARDIR@/cache/maxscale ]
|
||||
then
|
||||
mkdir -p @MAXSCALE_VARDIR@/cache/maxscale
|
||||
fi
|
||||
|
||||
if [ ! -d @MAXSCALE_VARDIR@/lib/maxscale ]
|
||||
then
|
||||
mkdir -p @MAXSCALE_VARDIR@/lib/maxscale
|
||||
fi
|
||||
|
||||
if [ ! -d @MAXSCALE_VARDIR@/run/maxscale ]
|
||||
then
|
||||
mkdir -p @MAXSCALE_VARDIR@/run/maxscale
|
||||
fi
|
||||
|
||||
chown maxscale:maxscale @MAXSCALE_VARDIR@/log/maxscale
|
||||
chown maxscale:maxscale @MAXSCALE_VARDIR@/lib/maxscale
|
||||
chown maxscale:maxscale @MAXSCALE_VARDIR@/cache/maxscale
|
||||
chown maxscale:maxscale @MAXSCALE_VARDIR@/run/maxscale
|
||||
chmod 0755 @MAXSCALE_VARDIR@/log/maxscale
|
||||
chmod 0755 @MAXSCALE_VARDIR@/lib/maxscale
|
||||
chmod 0755 @MAXSCALE_VARDIR@/cache/maxscale
|
||||
chmod 0755 @MAXSCALE_VARDIR@/run/maxscale
|
||||
|
||||
log_daemon_msg "Starting MaxScale"
|
||||
start_daemon -p "$MAXSCALE_PIDFILE" "$DAEMON" "$DAEMON_OPTS" 2> /dev/null > /dev/null
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -18,6 +18,13 @@
|
||||
#if !defined(LOG_MANAGER_H)
|
||||
# define LOG_MANAGER_H
|
||||
|
||||
/*
|
||||
* We need a common.h file that is included by every component.
|
||||
*/
|
||||
#if !defined(STRERROR_BUFLEN)
|
||||
#define STRERROR_BUFLEN 512
|
||||
#endif
|
||||
|
||||
typedef struct filewriter_st filewriter_t;
|
||||
typedef struct logfile_st logfile_t;
|
||||
typedef struct fnames_conf_st fnames_conf_t;
|
||||
@ -50,13 +57,13 @@ typedef struct log_info_st
|
||||
size_t li_sesid;
|
||||
int li_enabled_logs;
|
||||
} log_info_t;
|
||||
|
||||
|
||||
#define LE LOGFILE_ERROR
|
||||
#define LM LOGFILE_MESSAGE
|
||||
#define LT LOGFILE_TRACE
|
||||
#define LD LOGFILE_DEBUG
|
||||
|
||||
/**
|
||||
/**
|
||||
* Check if specified log type is enabled in general or if it is enabled
|
||||
* for the current session.
|
||||
*/
|
||||
@ -75,11 +82,11 @@ typedef struct log_info_st
|
||||
{ \
|
||||
cmd; \
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute the given command if specified log is enabled in general or
|
||||
* if the log is enabled for the current session.
|
||||
*/
|
||||
*/
|
||||
#define LOGIF(id,cmd) if (LOG_IS_ENABLED(id)) \
|
||||
{ \
|
||||
cmd; \
|
||||
@ -99,7 +106,16 @@ typedef struct log_info_st
|
||||
* RUN Struct is valid for run-time checking.
|
||||
* DONE means that possible memory allocations have been released.
|
||||
*/
|
||||
typedef enum { UNINIT = 0, INIT, RUN, DONE } flat_obj_state_t;
|
||||
typedef enum { UNINIT = 0, INIT, RUN, DONE } flat_obj_state_t;
|
||||
|
||||
/**
|
||||
* LOG_AUGMENT_WITH_FUNCTION Each logged line is suffixed with [function-name].
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
LOG_AUGMENT_WITH_FUNCTION = 1,
|
||||
LOG_AUGMENTATION_MASK = (LOG_AUGMENT_WITH_FUNCTION)
|
||||
} log_augmentation_t;
|
||||
|
||||
EXTERN_C_BLOCK_BEGIN
|
||||
|
||||
@ -111,11 +127,15 @@ void skygw_logmanager_exit(void);
|
||||
* free private write buffer list
|
||||
*/
|
||||
void skygw_log_done(void);
|
||||
int skygw_log_write(logfile_id_t id, const char* format, ...);
|
||||
int skygw_log_write_context(logfile_id_t id,
|
||||
const char* file, int line, const char* function,
|
||||
const char* format, ...);
|
||||
int skygw_log_flush(logfile_id_t id);
|
||||
void skygw_log_sync_all(void);
|
||||
int skygw_log_rotate(logfile_id_t id);
|
||||
int skygw_log_write_flush(logfile_id_t id, const char* format, ...);
|
||||
int skygw_log_write_context_flush(logfile_id_t id,
|
||||
const char* file, int line, const char* function,
|
||||
const char* format, ...);
|
||||
int skygw_log_enable(logfile_id_t id);
|
||||
int skygw_log_disable(logfile_id_t id);
|
||||
void skygw_log_sync_all(void);
|
||||
@ -123,6 +143,20 @@ void skygw_set_highp(int);
|
||||
void logmanager_enable_syslog(int);
|
||||
void logmanager_enable_maxscalelog(int);
|
||||
|
||||
#define skygw_log_write(id, format, ...)\
|
||||
skygw_log_write_context(id, __FILE__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__)
|
||||
|
||||
#define skygw_log_write_flush(id, format, ...)\
|
||||
skygw_log_write_context_flush(id, __FILE__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* What augmentation if any should a logged message be augmented with.
|
||||
*
|
||||
* Currently this is a global setting and affects all loggers.
|
||||
*/
|
||||
void skygw_log_set_augmentation(int bits);
|
||||
int skygw_log_get_augmentation();
|
||||
|
||||
EXTERN_C_BLOCK_END
|
||||
|
||||
const char* get_trace_prefix_default(void);
|
||||
|
@ -358,10 +358,11 @@ int main(int argc, char** argv)
|
||||
"set.\n");
|
||||
ss_dassert(workingdir != NULL);
|
||||
} else if (access(workingdir, R_OK) != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"Failed to access the working directory due %d, %s\n",
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
ss_dassert(false);
|
||||
} else {
|
||||
char** so = server_options;
|
||||
|
87
script/stacktrace
Executable file
87
script/stacktrace
Executable file
@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
|
||||
# How we recognize whether a line in the file is from the stack-trace.
|
||||
STACK_LINE=".*\(.*\) \[.*\]"
|
||||
# How we match the date + time part of a line.
|
||||
DATE_TIME="[0-9]\+-[0-9]\+-[0-9]\+ [0-9]\+:[0-9]\+:[0-9]\+"
|
||||
|
||||
function print_usage {
|
||||
echo "usage: stacktrace [-p prefix] [stacktrace.txt]"
|
||||
echo
|
||||
echo "-p frefix: The path prefix (e.g. /usr/local/mariadb-maxscale/) "
|
||||
echo " to remove when searching for files."
|
||||
echo
|
||||
echo "stacktrace.txt: A file containing a stack-trace."
|
||||
exit 1
|
||||
}
|
||||
|
||||
function print_usage_and_exit {
|
||||
print_usage
|
||||
exit 1
|
||||
}
|
||||
|
||||
function parse_stack_trace {
|
||||
local prefix=$1
|
||||
local file=$2
|
||||
|
||||
cat $file | egrep "$STACK_LINE" | sed "s/$DATE_TIME//" | \
|
||||
while read line
|
||||
do
|
||||
local path=${line%%(*}
|
||||
local entry="("${line##*(}
|
||||
|
||||
path=${path#$prefix}
|
||||
|
||||
if [ -e "${path}" ]
|
||||
then
|
||||
file ${path} | fgrep -q executable
|
||||
let rc=$?
|
||||
local address;
|
||||
|
||||
if [ $rc -eq 0 ]
|
||||
then
|
||||
address=${entry#*\[}
|
||||
address=${address%\]*}
|
||||
else
|
||||
address=${entry#*\+}
|
||||
address=${address%\)*}
|
||||
fi
|
||||
|
||||
addr2line -e ${path} ${address}
|
||||
else
|
||||
echo ${line}
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function main {
|
||||
local prefix
|
||||
local key
|
||||
|
||||
while [[ $# > 1 ]]
|
||||
do
|
||||
key="$1"
|
||||
|
||||
case $key in
|
||||
-h)
|
||||
print_usage
|
||||
exit
|
||||
;;
|
||||
-p|--prefix)
|
||||
prefix="$2";
|
||||
shift
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "error: Unknown parameter $key"
|
||||
print_usage_and_exit
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
local file=$1
|
||||
|
||||
parse_stack_trace "$prefix" "$file"
|
||||
}
|
||||
|
||||
main $*
|
@ -113,10 +113,11 @@ SHARED_BUF *sbuf;
|
||||
retblock:
|
||||
if (rval == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation failed due to %s.",
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
@ -182,10 +183,11 @@ GWBUF *rval;
|
||||
if ((rval = (GWBUF *)calloc(1,sizeof(GWBUF))) == NULL)
|
||||
{
|
||||
ss_dassert(rval != NULL);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation failed due to %s.",
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -246,10 +248,11 @@ GWBUF *gwbuf_clone_portion(
|
||||
if ((clonebuf = (GWBUF *)malloc(sizeof(GWBUF))) == NULL)
|
||||
{
|
||||
ss_dassert(clonebuf != NULL);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation failed due to %s.",
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
return NULL;
|
||||
}
|
||||
atomic_add(&buf->sbuf->refcount, 1);
|
||||
@ -500,10 +503,11 @@ void gwbuf_add_buffer_object(
|
||||
|
||||
if (newb == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation failed due to %s.",
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
return;
|
||||
}
|
||||
newb->bo_id = id;
|
||||
@ -590,11 +594,11 @@ BUF_PROPERTY *prop;
|
||||
if ((prop = malloc(sizeof(BUF_PROPERTY))) == NULL)
|
||||
{
|
||||
ss_dassert(prop != NULL);
|
||||
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation failed due to %s.",
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
return 0;
|
||||
}
|
||||
prop->name = strdup(name);
|
||||
|
@ -73,7 +73,11 @@
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <pcre.h>
|
||||
#include <dbusers.h>
|
||||
|
||||
/** According to the PCRE manual, this should be a multiple of 3 */
|
||||
#define MAXSCALE_PCRE_BUFSZ 24
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
@ -92,7 +96,7 @@ static void global_defaults();
|
||||
static void feedback_defaults();
|
||||
static void check_config_objects(CONFIG_CONTEXT *context);
|
||||
int config_truth_value(char *str);
|
||||
static int internalService(char *router);
|
||||
bool isInternalService(char *router);
|
||||
int config_get_ifaddr(unsigned char *output);
|
||||
int config_get_release_string(char* release);
|
||||
FEEDBACK_CONF * config_get_feedback_data();
|
||||
@ -125,6 +129,57 @@ char *ptr;
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove extra commas and whitespace from a string. This string is interpreted
|
||||
* as a list of string values separated by commas.
|
||||
* @param strptr String to clean
|
||||
* @return pointer to a new string or NULL if an error occurred
|
||||
*/
|
||||
char* config_clean_string_list(char* str)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
if((tmp = malloc(sizeof(char)*(strlen(str) + 1))) != NULL)
|
||||
{
|
||||
char *ptr;
|
||||
int match[MAXSCALE_PCRE_BUFSZ];
|
||||
pcre* re;
|
||||
const char *re_err;
|
||||
int err_offset,rval;
|
||||
|
||||
|
||||
tmp[0] = '\0';
|
||||
|
||||
if((re = pcre_compile("\\s*+([^,]*[^,\\s])",0,&re_err,&err_offset,NULL)) == NULL)
|
||||
{
|
||||
skygw_log_write(LE,"[%s] Error: Regular expression compilation failed at %d: %s",
|
||||
__FUNCTION__,err_offset,re_err);
|
||||
free(tmp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ptr = str;
|
||||
|
||||
while((rval = pcre_exec(re,NULL,ptr,strlen(ptr),0,0,(int*)&match,MAXSCALE_PCRE_BUFSZ)) > 1)
|
||||
{
|
||||
const char* substr;
|
||||
|
||||
pcre_get_substring(ptr,(int*)&match,rval,1,&substr);
|
||||
if(strlen(tmp) > 0)
|
||||
strcat(tmp,",");
|
||||
strcat(tmp,substr);
|
||||
pcre_free_substring(substr);
|
||||
ptr = &ptr[match[1]];
|
||||
}
|
||||
pcre_free(re);
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LE,"[%s] Error: Memory allocation failed.",__FUNCTION__);
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
/**
|
||||
* Config item handler for the ini file reader
|
||||
*
|
||||
@ -174,12 +229,24 @@ CONFIG_PARAMETER *param, *p1;
|
||||
{
|
||||
if (!strcmp(p1->name, name))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Configuration object '%s' has multiple "
|
||||
"parameters names '%s'.",
|
||||
ptr->object, name)));
|
||||
return 0;
|
||||
char *tmp;
|
||||
int paramlen = strlen(p1->value) + strlen(value) + 2;
|
||||
|
||||
if((tmp = realloc(p1->value,sizeof(char) * (paramlen))) == NULL)
|
||||
{
|
||||
skygw_log_write(LE,"[%s] Error: Memory allocation failed.",__FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
strcat(tmp,",");
|
||||
strcat(tmp,value);
|
||||
if((p1->value = config_clean_string_list(tmp)) == NULL)
|
||||
{
|
||||
p1->value = tmp;
|
||||
skygw_log_write(LE,"[%s] Error: Cleaning configuration parameter failed.",__FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
free(tmp);
|
||||
return 1;
|
||||
}
|
||||
p1 = p1->next;
|
||||
}
|
||||
@ -205,7 +272,7 @@ int
|
||||
config_load(char *file)
|
||||
{
|
||||
CONFIG_CONTEXT config;
|
||||
int rval;
|
||||
int rval, ini_rval;
|
||||
|
||||
MYSQL *conn;
|
||||
conn = mysql_init(NULL);
|
||||
@ -248,8 +315,23 @@ int rval;
|
||||
config.object = "";
|
||||
config.next = NULL;
|
||||
|
||||
if (ini_parse(file, handler, &config) < 0)
|
||||
if (( ini_rval = ini_parse(file, handler, &config)) != 0)
|
||||
{
|
||||
char errorbuffer[1024 + 1];
|
||||
|
||||
if (ini_rval > 0)
|
||||
snprintf(errorbuffer, sizeof(errorbuffer),
|
||||
"Error: Failed to parse configuration file. Error on line %d.", ini_rval);
|
||||
else if(ini_rval == -1)
|
||||
snprintf(errorbuffer, sizeof(errorbuffer),
|
||||
"Error: Failed to parse configuration file. Failed to open file.");
|
||||
else
|
||||
snprintf(errorbuffer, sizeof(errorbuffer),
|
||||
"Error: Failed to parse configuration file. Memory allocation failed.");
|
||||
|
||||
skygw_log_write(LE, errorbuffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
config_file = file;
|
||||
|
||||
@ -898,7 +980,7 @@ process_config_context(CONFIG_CONTEXT *context)
|
||||
s = strtok_r(NULL, ",", &lasts);
|
||||
}
|
||||
}
|
||||
else if (servers == NULL && internalService(router) == 0)
|
||||
else if (servers == NULL && !isInternalService(router))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -1107,6 +1189,7 @@ process_config_context(CONFIG_CONTEXT *context)
|
||||
monitorAddUser(obj->element,
|
||||
user,
|
||||
passwd);
|
||||
check_monitor_permissions(obj->element);
|
||||
}
|
||||
else if (obj->element && user)
|
||||
{
|
||||
@ -1460,6 +1543,33 @@ int i;
|
||||
{
|
||||
skygw_set_highp(config_truth_value((char*)value));
|
||||
}
|
||||
else if (strcmp(name, "auth_connect_timeout") == 0)
|
||||
{
|
||||
char* endptr;
|
||||
int intval = strtol(value, &endptr, 0);
|
||||
if(*endptr == '\0' && intval > 0)
|
||||
gateway.auth_conn_timeout = intval;
|
||||
else
|
||||
skygw_log_write(LE, "Invalid timeout value for 'auth_connect_timeout': %s", value);
|
||||
}
|
||||
else if (strcmp(name, "auth_read_timeout") == 0)
|
||||
{
|
||||
char* endptr;
|
||||
int intval = strtol(value, &endptr, 0);
|
||||
if(*endptr == '\0' && intval > 0)
|
||||
gateway.auth_read_timeout = intval;
|
||||
else
|
||||
skygw_log_write(LE, "Invalid timeout value for 'auth_read_timeout': %s", value);
|
||||
}
|
||||
else if (strcmp(name, "auth_write_timeout") == 0)
|
||||
{
|
||||
char* endptr;
|
||||
int intval = strtol(value, &endptr, 0);
|
||||
if(*endptr == '\0' && intval > 0)
|
||||
gateway.auth_write_timeout = intval;
|
||||
else
|
||||
skygw_log_write(LE, "Invalid timeout value for 'auth_write_timeout': %s", value);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; lognames[i].logname; i++)
|
||||
@ -1525,6 +1635,9 @@ global_defaults()
|
||||
gateway.n_threads = 1;
|
||||
gateway.n_nbpoll = DEFAULT_NBPOLLS;
|
||||
gateway.pollsleep = DEFAULT_POLLSLEEP;
|
||||
gateway.auth_conn_timeout = DEFAULT_AUTH_CONNECT_TIMEOUT;
|
||||
gateway.auth_read_timeout = DEFAULT_AUTH_READ_TIMEOUT;
|
||||
gateway.auth_write_timeout = DEFAULT_AUTH_WRITE_TIMEOUT;
|
||||
if (version_string != NULL)
|
||||
gateway.version_string = strdup(version_string);
|
||||
else
|
||||
@ -2217,9 +2330,11 @@ config_percentage_value(char *str)
|
||||
}
|
||||
|
||||
static char *InternalRouters[] = {
|
||||
"debugcli",
|
||||
"cli",
|
||||
NULL
|
||||
"debugcli",
|
||||
"cli",
|
||||
"maxinfo",
|
||||
"binlogrouter",
|
||||
NULL
|
||||
};
|
||||
|
||||
/**
|
||||
@ -2229,18 +2344,16 @@ static char *InternalRouters[] = {
|
||||
* @param router The router name
|
||||
* @return Non-zero if the router is in the InternalRouters table
|
||||
*/
|
||||
static int
|
||||
internalService(char *router)
|
||||
bool
|
||||
isInternalService(char *router)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (router)
|
||||
{
|
||||
for (i = 0; InternalRouters[i]; i++)
|
||||
for (int i = 0; InternalRouters[i]; i++)
|
||||
if (strcmp(router, InternalRouters[i]) == 0)
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Get the MAC address of first network interface
|
||||
|
@ -52,11 +52,6 @@
|
||||
#include <mysqld_error.h>
|
||||
#include <regex.h>
|
||||
|
||||
|
||||
#define DEFAULT_CONNECT_TIMEOUT 3
|
||||
#define DEFAULT_READ_TIMEOUT 1
|
||||
#define DEFAULT_WRITE_TIMEOUT 2
|
||||
|
||||
#define USERS_QUERY_NO_ROOT " AND user NOT IN ('root')"
|
||||
|
||||
#if 0
|
||||
@ -82,7 +77,7 @@
|
||||
#define MYSQL_USERS_COUNT "SELECT COUNT(1) AS nusers FROM mysql.user"
|
||||
|
||||
#define MYSQL_USERS_WITH_DB_ORDER " ORDER BY host DESC"
|
||||
#define LOAD_MYSQL_USERS_WITH_DB_QUERY "SELECT user.user AS user,user.host AS host,user.password AS password,concat(user.user,user.host,user.password,user.Select_priv,IFNULL(db,'')) AS userdata, user.Select_priv AS anydb,db.db AS db FROM mysql.user LEFT JOIN mysql.db ON user.user=db.user AND user.host=db.host WHERE user.user IS NOT NULL AND user.user <> ''" MYSQL_USERS_WITH_DB_ORDER
|
||||
#define LOAD_MYSQL_USERS_WITH_DB_QUERY "SELECT user.user AS user,user.host AS host,user.password AS password,concat(user.user,user.host,user.password,user.Select_priv,IFNULL(db,'')) AS userdata, user.Select_priv AS anydb,db.db AS db FROM mysql.user LEFT JOIN mysql.db ON user.user=db.user AND user.host=db.host WHERE user.user IS NOT NULL" MYSQL_USERS_WITH_DB_ORDER
|
||||
|
||||
#define MYSQL_USERS_WITH_DB_COUNT "SELECT COUNT(1) AS nusers_db FROM (" LOAD_MYSQL_USERS_WITH_DB_QUERY ") AS tbl_count"
|
||||
|
||||
@ -121,11 +116,7 @@ int add_wildcard_users(USERS *users,
|
||||
char* db,
|
||||
HASHTABLE* hash);
|
||||
|
||||
static int gw_mysql_set_timeouts(
|
||||
MYSQL* handle,
|
||||
int read_timeout,
|
||||
int write_timeout,
|
||||
int connect_timeout);
|
||||
static int gw_mysql_set_timeouts(MYSQL* handle);
|
||||
|
||||
/**
|
||||
* Load the user/passwd form mysql.user table into the service users' hashtable
|
||||
@ -584,7 +575,8 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
MYSQL_DATABASE_MAXLEN;
|
||||
int dbnames = 0;
|
||||
int db_grants = 0;
|
||||
|
||||
bool anon_user = false;
|
||||
|
||||
if (serviceGetUser(service, &service_user, &service_passwd) == 0)
|
||||
{
|
||||
ss_dassert(service_passwd == NULL || service_user == NULL);
|
||||
@ -629,10 +621,7 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
}
|
||||
|
||||
/** Set read, write and connect timeout values */
|
||||
if (gw_mysql_set_timeouts(con,
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
DEFAULT_WRITE_TIMEOUT,
|
||||
DEFAULT_CONNECT_TIMEOUT))
|
||||
if (gw_mysql_set_timeouts(con))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -701,10 +690,7 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
}
|
||||
|
||||
/** Set read, write and connect timeout values */
|
||||
if (gw_mysql_set_timeouts(con,
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
DEFAULT_WRITE_TIMEOUT,
|
||||
DEFAULT_CONNECT_TIMEOUT))
|
||||
if (gw_mysql_set_timeouts(con))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -906,12 +892,13 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
users_data = (char *)calloc(nusers, (users_data_row_len * sizeof(char)) + 1);
|
||||
|
||||
if (users_data == NULL) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation for user data failed due to "
|
||||
"Error : Memory allocation for user data failed due to "
|
||||
"%d, %s.",
|
||||
errno,
|
||||
strerror(errno))));
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
mysql_free_result(result);
|
||||
mysql_close(con);
|
||||
|
||||
@ -928,7 +915,16 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
|
||||
int rc = 0;
|
||||
char *password = NULL;
|
||||
|
||||
|
||||
/** If the username is empty, the backend server still has anonymous
|
||||
* user in it. This will mean that localhost addresses do not match
|
||||
* the wildcard host '%' */
|
||||
if(strlen(row[0]) == 0)
|
||||
{
|
||||
anon_user = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (row[2] != NULL) {
|
||||
/* detect mysql_old_password (pre 4.1 protocol) */
|
||||
if (strlen(row[2]) == 16) {
|
||||
@ -1077,7 +1073,10 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
SHA1((const unsigned char *) final_data, strlen(final_data), hash);
|
||||
|
||||
memcpy(users->cksum, hash, SHA_DIGEST_LENGTH);
|
||||
|
||||
|
||||
/** Set the parameter if it is not configured by the user */
|
||||
if(service->localhost_match_wildcard_host == SERVICE_PARAM_UNINIT)
|
||||
service->localhost_match_wildcard_host = anon_user ? 0 : 1;
|
||||
cleanup:
|
||||
|
||||
free(dpwd);
|
||||
@ -1119,6 +1118,7 @@ getUsers(SERVICE *service, USERS *users)
|
||||
int dbnames = 0;
|
||||
int db_grants = 0;
|
||||
char dbnm[MYSQL_DATABASE_MAXLEN+1];
|
||||
bool anon_user = false;
|
||||
|
||||
if (serviceGetUser(service, &service_user, &service_passwd) == 0)
|
||||
{
|
||||
@ -1141,10 +1141,7 @@ getUsers(SERVICE *service, USERS *users)
|
||||
return -1;
|
||||
}
|
||||
/** Set read, write and connect timeout values */
|
||||
if (gw_mysql_set_timeouts(con,
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
DEFAULT_WRITE_TIMEOUT,
|
||||
DEFAULT_CONNECT_TIMEOUT))
|
||||
if (gw_mysql_set_timeouts(con))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -1402,12 +1399,13 @@ getUsers(SERVICE *service, USERS *users)
|
||||
users_data = (char *)calloc(nusers, (users_data_row_len * sizeof(char)) + 1);
|
||||
|
||||
if (users_data == NULL) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation for user data failed due to "
|
||||
"%d, %s.",
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
mysql_free_result(result);
|
||||
mysql_close(con);
|
||||
|
||||
@ -1438,6 +1436,15 @@ getUsers(SERVICE *service, USERS *users)
|
||||
int rc = 0;
|
||||
char *password = NULL;
|
||||
|
||||
/** If the username is empty, the backend server still has anonymous
|
||||
* user in it. This will mean that localhost addresses do not match
|
||||
* the wildcard host '%' */
|
||||
if(strlen(row[0]) == 0)
|
||||
{
|
||||
anon_user = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (row[2] != NULL) {
|
||||
/* detect mysql_old_password (pre 4.1 protocol) */
|
||||
if (strlen(row[2]) == 16) {
|
||||
@ -1568,6 +1575,10 @@ getUsers(SERVICE *service, USERS *users)
|
||||
|
||||
memcpy(users->cksum, hash, SHA_DIGEST_LENGTH);
|
||||
|
||||
/** Set the parameter if it is not configured by the user */
|
||||
if(service->localhost_match_wildcard_host == SERVICE_PARAM_UNINIT)
|
||||
service->localhost_match_wildcard_host = anon_user ? 0 : 1;
|
||||
|
||||
free(users_data);
|
||||
mysql_free_result(result);
|
||||
mysql_close(con);
|
||||
@ -1997,17 +2008,15 @@ int useorig = 0;
|
||||
*
|
||||
* @return 0 if succeed, 1 if failed
|
||||
*/
|
||||
static int gw_mysql_set_timeouts(
|
||||
MYSQL* handle,
|
||||
int read_timeout,
|
||||
int write_timeout,
|
||||
int connect_timeout)
|
||||
static int gw_mysql_set_timeouts(MYSQL* handle)
|
||||
{
|
||||
int rc;
|
||||
|
||||
GATEWAY_CONF* cnf = config_get_global_options();
|
||||
|
||||
if ((rc = mysql_options(handle,
|
||||
MYSQL_OPT_READ_TIMEOUT,
|
||||
(void *)&read_timeout)))
|
||||
(void *)&cnf->auth_read_timeout)))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -2018,7 +2027,7 @@ static int gw_mysql_set_timeouts(
|
||||
|
||||
if ((rc = mysql_options(handle,
|
||||
MYSQL_OPT_CONNECT_TIMEOUT,
|
||||
(void *)&connect_timeout)))
|
||||
(void *)&cnf->auth_conn_timeout)))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -2029,7 +2038,7 @@ static int gw_mysql_set_timeouts(
|
||||
|
||||
if ((rc = mysql_options(handle,
|
||||
MYSQL_OPT_WRITE_TIMEOUT,
|
||||
(void *)&write_timeout)))
|
||||
(void *)&cnf->auth_write_timeout)))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -2315,3 +2324,133 @@ int add_wildcard_users(USERS *users, char* name, char* host, char* password, cha
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the service user has all required permissions to operate properly.
|
||||
* this checks for SELECT permissions on mysql.user and mysql.db tables and for
|
||||
* SHOW DATABASES permissions. If permissions are not adequate, an error message
|
||||
* is logged.
|
||||
* @param service Service to inspect
|
||||
* @return True if service permissions are correct. False if one or more permissions
|
||||
* are missing or if an error occurred.
|
||||
*/
|
||||
bool check_service_permissions(SERVICE* service)
|
||||
{
|
||||
MYSQL* mysql;
|
||||
MYSQL_RES* res;
|
||||
char *user,*password,*dpasswd;
|
||||
SERVER_REF* server;
|
||||
int conn_timeout = 1;
|
||||
bool rval = true;
|
||||
|
||||
if(isInternalService(service->routerModule))
|
||||
return true;
|
||||
|
||||
if(service->dbref == NULL)
|
||||
{
|
||||
skygw_log_write(LE,"%s: Error: Service is missing the servers parameter.",service->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
server = service->dbref;
|
||||
|
||||
if (serviceGetUser(service, &user, &password) == 0)
|
||||
{
|
||||
skygw_log_write(LE,
|
||||
"%s: Error: Service is missing the user credentials for authentication.",
|
||||
service->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
dpasswd = decryptPassword(password);
|
||||
|
||||
if((mysql = mysql_init(NULL)) == NULL)
|
||||
{
|
||||
skygw_log_write(LE,"[%s] Error: MySQL connection initialization failed.",__FUNCTION__);
|
||||
free(dpasswd);
|
||||
return false;
|
||||
}
|
||||
|
||||
mysql_options(mysql,MYSQL_OPT_USE_REMOTE_CONNECTION,NULL);
|
||||
mysql_options(mysql,MYSQL_OPT_CONNECT_TIMEOUT,&conn_timeout);
|
||||
/** Connect to the first server. This assumes all servers have identical
|
||||
* user permissions. */
|
||||
|
||||
if(mysql_real_connect(mysql,server->server->name,user,dpasswd,NULL,server->server->port,NULL,0) == NULL)
|
||||
{
|
||||
int my_errno = mysql_errno(mysql);
|
||||
|
||||
skygw_log_write(LE,"%s: Error: Failed to connect to server %s(%s:%d) when"
|
||||
" checking authentication user credentials and permissions: %d %s",
|
||||
service->name,
|
||||
server->server->unique_name,
|
||||
server->server->name,
|
||||
server->server->port,
|
||||
my_errno,
|
||||
mysql_error(mysql));
|
||||
mysql_close(mysql);
|
||||
free(dpasswd);
|
||||
|
||||
/** We don't know enough about user permissions */
|
||||
return my_errno != ER_ACCESS_DENIED_ERROR;
|
||||
}
|
||||
|
||||
if(mysql_query(mysql,"SELECT user, host, password,Select_priv FROM mysql.user limit 1") != 0)
|
||||
{
|
||||
if(mysql_errno(mysql) == ER_TABLEACCESS_DENIED_ERROR)
|
||||
{
|
||||
skygw_log_write(LE,"%s: Error: User '%s' is missing SELECT privileges"
|
||||
" on mysql.user table. MySQL error message: %s",
|
||||
service->name,user,mysql_error(mysql));
|
||||
rval = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LE,"%s: Error: Failed to query from mysql.user table."
|
||||
" MySQL error message: %s",
|
||||
service->name,mysql_error(mysql));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if((res = mysql_use_result(mysql)) == NULL)
|
||||
{
|
||||
skygw_log_write(LE,"%s: Error: Result retrieval failed when checking for"
|
||||
" permissions to the mysql.user table: %s",
|
||||
service->name,mysql_error(mysql));
|
||||
mysql_close(mysql);
|
||||
free(dpasswd);
|
||||
return true;
|
||||
}
|
||||
mysql_free_result(res);
|
||||
}
|
||||
if(mysql_query(mysql,"SELECT user, host, db FROM mysql.db limit 1") != 0)
|
||||
{
|
||||
if(mysql_errno(mysql) == ER_TABLEACCESS_DENIED_ERROR)
|
||||
{
|
||||
skygw_log_write(LE,"%s: Error: User '%s' is missing SELECT privileges on mysql.db table. MySQL error message: %s",
|
||||
service->name,user,mysql_error(mysql));
|
||||
rval = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LE,"%s: Error: Failed to query from mysql.db table. MySQL error message: %s",
|
||||
service->name,mysql_error(mysql));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if((res = mysql_use_result(mysql)) == NULL)
|
||||
{
|
||||
skygw_log_write(LE,"%s: Error: Result retrieval failed when checking for permissions to the mysql.db table: %s",
|
||||
service->name,mysql_error(mysql));
|
||||
}
|
||||
else
|
||||
{
|
||||
mysql_free_result(res);
|
||||
}
|
||||
}
|
||||
mysql_close(mysql);
|
||||
free(dpasswd);
|
||||
return rval;
|
||||
}
|
||||
|
@ -562,6 +562,7 @@ dcb_process_victim_queue(DCB *listofdcb)
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"%lu [dcb_process_victim_queue] Error : Failed to close "
|
||||
@ -570,7 +571,7 @@ dcb_process_victim_queue(DCB *listofdcb)
|
||||
dcb->fd,
|
||||
dcb,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -805,6 +806,7 @@ int dcb_read(
|
||||
|
||||
if (-1 == ioctl(dcb->fd, FIONREAD, &bytesavailable))
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
/* <editor-fold defaultstate="collapsed" desc=" Error Logging "> */
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -815,7 +817,7 @@ int dcb_read(
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
/* </editor-fold> */
|
||||
return -1;
|
||||
}
|
||||
@ -855,6 +857,7 @@ int dcb_read(
|
||||
* This is a fatal error which should cause shutdown.
|
||||
* Todo shutdown if memory allocation fails.
|
||||
*/
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
/* <editor-fold defaultstate="collapsed" desc=" Error Logging "> */
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -864,7 +867,7 @@ int dcb_read(
|
||||
dcb,
|
||||
dcb->fd,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
/* </editor-fold> */
|
||||
return -1;
|
||||
}
|
||||
@ -875,6 +878,7 @@ int dcb_read(
|
||||
{
|
||||
if (errno != 0 && errno != EAGAIN && errno != EWOULDBLOCK)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
/* <editor-fold defaultstate="collapsed" desc=" Error Logging "> */
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -885,7 +889,7 @@ int dcb_read(
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
/* </editor-fold> */
|
||||
}
|
||||
gwbuf_free(buffer);
|
||||
@ -951,6 +955,7 @@ int dcb_read_SSL(
|
||||
pending = SSL_pending(dcb->ssl);
|
||||
if (rc == -1)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : ioctl FIONREAD for dcb %p in "
|
||||
@ -959,7 +964,7 @@ int dcb_read_SSL(
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
n = -1;
|
||||
goto return_n;
|
||||
}
|
||||
@ -1012,6 +1017,7 @@ int dcb_read_SSL(
|
||||
* This is a fatal error which should cause shutdown.
|
||||
* Todo shutdown if memory allocation fails.
|
||||
*/
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed to allocate read buffer "
|
||||
@ -1019,7 +1025,7 @@ int dcb_read_SSL(
|
||||
dcb,
|
||||
dcb->fd,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
|
||||
n = -1;
|
||||
goto return_n;
|
||||
@ -1054,6 +1060,7 @@ int dcb_read_SSL(
|
||||
}
|
||||
else
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Read failed, dcb %p in state "
|
||||
@ -1062,7 +1069,7 @@ int dcb_read_SSL(
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
ssl_errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
|
||||
if(ssl_errno == SSL_ERROR_SSL ||
|
||||
ssl_errno == SSL_ERROR_SYSCALL)
|
||||
@ -1337,6 +1344,7 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
|
||||
{
|
||||
if (eno == EPIPE)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_write] Write to dcb "
|
||||
@ -1347,7 +1355,7 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1357,6 +1365,7 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
|
||||
eno != EAGAIN &&
|
||||
eno != EWOULDBLOCK)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Write to dcb %p in "
|
||||
@ -1366,7 +1375,7 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
|
||||
}
|
||||
|
||||
@ -1392,13 +1401,14 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
|
||||
}
|
||||
if (dolog)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_write] Writing to %s socket failed due %d, %s.",
|
||||
pthread_self(),
|
||||
dcb_isclient(dcb) ? "client" : "backend server",
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1513,7 +1523,7 @@ static int
|
||||
dcb_write_SSL_error_report (DCB *dcb, int ret)
|
||||
{
|
||||
int ssl_errno;
|
||||
char errbuf[256];
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
ssl_errno = SSL_get_error(dcb->ssl,ret);
|
||||
|
||||
if (LOG_IS_ENABLED(LOGFILE_DEBUG))
|
||||
@ -1573,9 +1583,7 @@ dcb_write_SSL_error_report (DCB *dcb, int ret)
|
||||
{
|
||||
if(ssl_errno == SSL_ERROR_SYSCALL)
|
||||
{
|
||||
strerror_r(errno,errbuf,255);
|
||||
errbuf[255] = '\0';
|
||||
skygw_log_write(LE,"%d:%s",errno,errbuf);
|
||||
skygw_log_write(LE,"%d:%s", errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
do
|
||||
{
|
||||
@ -1646,6 +1654,7 @@ int above_water;
|
||||
{
|
||||
break;
|
||||
}
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Write to dcb %p "
|
||||
@ -1654,7 +1663,7 @@ int above_water;
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
saved_errno,
|
||||
strerror(saved_errno))));
|
||||
strerror_r(saved_errno, errbuf, sizeof(errbuf)))));
|
||||
break;
|
||||
}
|
||||
/*
|
||||
@ -1750,7 +1759,10 @@ dcb_drain_writeq_SSL(DCB *dcb)
|
||||
skygw_log_write(LE,"%s",errbuf);
|
||||
}
|
||||
if(errno != 0)
|
||||
skygw_log_write(LE,"%d:%s",errno,strerror(errno));
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write(LE,"%d:%s", errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
break;
|
||||
case SSL_ERROR_ZERO_RETURN:
|
||||
skygw_log_write(LE,"Socket is closed.");
|
||||
|
@ -109,7 +109,7 @@ EXTERNCMD* externcmd_allocate(char* argstr)
|
||||
if(access(cmd->parameters[0],X_OK) != 0)
|
||||
{
|
||||
skygw_log_write(LE,
|
||||
"Error: Cannot execute file: %s",
|
||||
"Error: Cannot execute file '%s'. Missing execution permissions.",
|
||||
cmd->parameters[0]);
|
||||
externcmd_free(cmd);
|
||||
return NULL;
|
||||
@ -147,8 +147,9 @@ int externcmd_execute(EXTERNCMD* cmd)
|
||||
|
||||
if(pid < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write(LOGFILE_ERROR,"Error: Failed to execute command '%s', fork failed: [%d] %s",
|
||||
cmd->parameters[0],errno,strerror(errno));
|
||||
cmd->parameters[0],errno,strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
rval = -1;
|
||||
}
|
||||
else if(pid == 0)
|
||||
|
@ -349,12 +349,13 @@ DOWNSTREAM *me;
|
||||
}
|
||||
if ((me = (DOWNSTREAM *)calloc(1, sizeof(DOWNSTREAM))) == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation for filter session failed "
|
||||
"due to %d,%s.",
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
* this program; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
* Copyright MariaDB Corporation Ab 2013-2015
|
||||
*
|
||||
*/
|
||||
|
||||
@ -86,6 +86,10 @@
|
||||
#include <ini.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/file.h>
|
||||
|
||||
#define STRING_BUFFER_SIZE 1024
|
||||
#define PIDFD_CLOSED -1
|
||||
|
||||
/** for procname */
|
||||
#if !defined(_GNU_SOURCE)
|
||||
@ -139,7 +143,7 @@ static char datadir[PATH_MAX+1] = "";
|
||||
static bool datadir_defined = false; /*< If the datadir was already set */
|
||||
/* The data directory we created for this gateway instance */
|
||||
static char pidfile[PATH_MAX+1] = "";
|
||||
|
||||
static int pidfd = PIDFD_CLOSED;
|
||||
|
||||
/**
|
||||
* exit flag for log flusher.
|
||||
@ -156,6 +160,8 @@ static bool libmysqld_started = FALSE;
|
||||
*/
|
||||
static bool daemon_mode = true;
|
||||
|
||||
static const char* maxscale_commit = MAXSCALE_COMMIT;
|
||||
|
||||
const char *progname = NULL;
|
||||
static struct option long_options[] = {
|
||||
{"homedir", required_argument, 0, 'c'},
|
||||
@ -174,6 +180,7 @@ static struct option long_options[] = {
|
||||
{"user",required_argument,0,'U'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{"help", no_argument, 0, '?'},
|
||||
{"version-full", no_argument, 0, 'V'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
static int cnf_preparser(void* data, const char* section, const char* name, const char* value);
|
||||
@ -181,6 +188,7 @@ static void log_flush_shutdown(void);
|
||||
static void log_flush_cb(void* arg);
|
||||
static int write_pid_file(); /* write MaxScale pidfile */
|
||||
static void unlink_pidfile(void); /* remove pidfile */
|
||||
static void unlock_pidfile();
|
||||
static void libmysqld_done(void);
|
||||
static bool file_write_header(FILE* outfile);
|
||||
static bool file_write_footer(FILE* outfile);
|
||||
@ -207,7 +215,7 @@ static bool resolve_maxscale_conf_fname(
|
||||
|
||||
static char* check_dir_access(char* dirname,bool,bool);
|
||||
static int set_user();
|
||||
|
||||
bool pid_file_exists();
|
||||
/** SSL multi-threading functions and structures */
|
||||
|
||||
static SPINLOCK* ssl_locks;
|
||||
@ -315,9 +323,9 @@ static void sigusr1_handler (int i)
|
||||
static void sigterm_handler (int i) {
|
||||
extern void shutdown_server();
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"MaxScale received signal SIGTERM. Exiting.")));
|
||||
"MaxScale received signal SIGTERM. Exiting.");
|
||||
skygw_log_sync_all();
|
||||
shutdown_server();
|
||||
}
|
||||
@ -327,9 +335,9 @@ sigint_handler (int i)
|
||||
{
|
||||
extern void shutdown_server();
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"MaxScale received signal SIGINT. Shutting down.")));
|
||||
"MaxScale received signal SIGINT. Shutting down.");
|
||||
skygw_log_sync_all();
|
||||
shutdown_server();
|
||||
fprintf(stderr, "\n\nShutting down MaxScale\n\n");
|
||||
@ -343,10 +351,9 @@ sigchld_handler (int i)
|
||||
|
||||
if((child = wait(&exit_status)) == -1)
|
||||
{
|
||||
char errbuf[512];
|
||||
strerror_r(errno,errbuf,511);
|
||||
errbuf[511] = '\0';
|
||||
skygw_log_write_flush(LE,"Error: failed to wait child process: %d %s",errno,errbuf);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write_flush(LE,"Error: failed to wait child process: %d %s",
|
||||
errno,strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -383,12 +390,16 @@ sigfatal_handler (int i)
|
||||
_exit(1);
|
||||
}
|
||||
fatal_handling = 1;
|
||||
GATEWAY_CONF* cnf = config_get_global_options();
|
||||
fprintf(stderr, "\n\nMaxScale "MAXSCALE_VERSION" received fatal signal %d\n", i);
|
||||
|
||||
fprintf(stderr, "\n\nMaxScale received fatal signal %d\n", i);
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Fatal: MaxScale received fatal signal %d. Attempting backtrace.", i)));
|
||||
"Fatal: MaxScale "MAXSCALE_VERSION" received fatal signal %d. Attempting backtrace.", i);
|
||||
|
||||
skygw_log_write_flush(LE,"Commit ID: %s System name: %s "
|
||||
"Release string: %s Embedded library version: %s",
|
||||
maxscale_commit, cnf->sysname, cnf->release_string, cnf->version_string);
|
||||
|
||||
{
|
||||
void *addrs[128];
|
||||
@ -397,9 +408,9 @@ sigfatal_handler (int i)
|
||||
|
||||
if (symbols) {
|
||||
for( n = 0; n < count; n++ ) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
" %s\n", symbols[n])));
|
||||
" %s\n", symbols[n]);
|
||||
}
|
||||
free(symbols);
|
||||
} else {
|
||||
@ -444,12 +455,13 @@ static int signal_set (int sig, void (*handler)(int)) {
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed call sigaction() in %s due to %d, %s.",
|
||||
program_invocation_short_name,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
rc = 1;
|
||||
}
|
||||
return rc;
|
||||
@ -472,14 +484,14 @@ int ntfw_cb(
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed to remove the data directory %s of "
|
||||
"MaxScale due to %d, %s.",
|
||||
datadir,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@ -773,21 +785,23 @@ static void print_log_n_stderr(
|
||||
char* fpr_end = "\n*\n";
|
||||
|
||||
if (do_log) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"%s %s %s %s",
|
||||
log_err,
|
||||
logstr,
|
||||
eno == 0 ? " " : "Error :",
|
||||
eno == 0 ? " " : strerror(eno))));
|
||||
eno == 0 ? " " : strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
if (do_stderr) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"%s %s %s %s %s",
|
||||
fpr_err,
|
||||
fprstr,
|
||||
eno == 0 ? " " : "Error :",
|
||||
eno == 0 ? " " : strerror(eno),
|
||||
eno == 0 ? " " : strerror_r(eno, errbuf, sizeof(errbuf)),
|
||||
fpr_end);
|
||||
}
|
||||
}
|
||||
@ -801,6 +815,7 @@ static bool file_is_readable(
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
|
||||
if (!daemon_mode)
|
||||
{
|
||||
@ -808,16 +823,16 @@ static bool file_is_readable(
|
||||
"*\n* Warning : Failed to read the configuration "
|
||||
"file %s. %s.\n*\n",
|
||||
absolute_pathname,
|
||||
strerror(eno));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Warning : Failed to read the configuration file %s due "
|
||||
"to %d, %s.",
|
||||
absolute_pathname,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
LOGIF(LE,(skygw_log_sync_all()));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
skygw_log_sync_all();
|
||||
succp = false;
|
||||
}
|
||||
return succp;
|
||||
@ -832,6 +847,7 @@ static bool file_is_writable(
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
|
||||
if (!daemon_mode)
|
||||
{
|
||||
@ -840,15 +856,15 @@ static bool file_is_writable(
|
||||
"due %d, %s.\n*\n",
|
||||
absolute_pathname,
|
||||
eno,
|
||||
strerror(eno));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : unable to open file %s for write due "
|
||||
"to %d, %s.",
|
||||
absolute_pathname,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
succp = false;
|
||||
}
|
||||
return succp;
|
||||
@ -895,21 +911,22 @@ static char* get_expanded_pathname(
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
|
||||
fprintf(stderr,
|
||||
"*\n* Warning : Failed to read the "
|
||||
"directory %s. %s.\n*\n",
|
||||
relative_path,
|
||||
strerror(eno));
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Warning : Failed to read the "
|
||||
"directory %s, due "
|
||||
"to %d, %s.",
|
||||
relative_path,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
free(expanded_path);
|
||||
*output_path = NULL;
|
||||
goto return_cnf_file_buf;
|
||||
@ -930,11 +947,12 @@ static char* get_expanded_pathname(
|
||||
if (cnf_file_buf == NULL)
|
||||
{
|
||||
ss_dassert(cnf_file_buf != NULL);
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation failed due to %s.",
|
||||
strerror(errno))));
|
||||
"Error : Memory allocation failed due to %s.",
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
|
||||
free(expanded_path);
|
||||
expanded_path = NULL;
|
||||
@ -1006,6 +1024,7 @@ static void usage(void)
|
||||
" -s, --syslog=[yes|no] log messages to syslog (default:yes)\n"
|
||||
" -S, --maxscalelog=[yes|no] log messages to MaxScale log (default: yes)\n"
|
||||
" -v, --version print version info and exit\n"
|
||||
" -V, --version-full print full version info and exit\n"
|
||||
" -?, --help show this help\n"
|
||||
, progname);
|
||||
}
|
||||
@ -1046,6 +1065,7 @@ int main(int argc, char **argv)
|
||||
int l;
|
||||
int i;
|
||||
int n;
|
||||
int ini_rval;
|
||||
intptr_t thread_id;
|
||||
int n_threads; /*< number of epoll listener threads */
|
||||
int n_services;
|
||||
@ -1108,7 +1128,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "dc:f:l:vs:S:?L:D:C:B:U:A:P:",
|
||||
while ((opt = getopt_long(argc, argv, "dc:f:l:vVs:S:?L:D:C:B:U:A:P:",
|
||||
long_options, &option_index)) != -1)
|
||||
{
|
||||
bool succp = true;
|
||||
@ -1143,8 +1163,13 @@ int main(int argc, char **argv)
|
||||
|
||||
case 'v':
|
||||
rc = EXIT_SUCCESS;
|
||||
printf("%s\n",MAXSCALE_VERSION);
|
||||
goto return_main;
|
||||
printf("MaxScale %s\n", MAXSCALE_VERSION);
|
||||
goto return_main;
|
||||
|
||||
case 'V':
|
||||
rc = EXIT_SUCCESS;
|
||||
printf("MaxScale %s - %s\n", MAXSCALE_VERSION, maxscale_commit);
|
||||
goto return_main;
|
||||
|
||||
case 'l':
|
||||
if (strncasecmp(optarg, "file", PATH_MAX) == 0)
|
||||
@ -1582,8 +1607,27 @@ int main(int argc, char **argv)
|
||||
goto return_main;
|
||||
}
|
||||
|
||||
if(ini_parse(cnf_file_path,cnf_preparser,NULL) != 0)
|
||||
if((ini_rval = ini_parse(cnf_file_path, cnf_preparser,NULL)) != 0)
|
||||
{
|
||||
char errorbuffer[STRING_BUFFER_SIZE];
|
||||
|
||||
if(ini_rval > 0)
|
||||
snprintf(errorbuffer, sizeof(errorbuffer),
|
||||
"Error: Failed to pre-parse configuration file. Error on line %d.", ini_rval);
|
||||
else if(ini_rval == -1)
|
||||
snprintf(errorbuffer, sizeof(errorbuffer),
|
||||
"Error: Failed to pre-parse configuration file. Failed to open file.");
|
||||
else
|
||||
snprintf(errorbuffer, sizeof(errorbuffer),
|
||||
"Error: Failed to pre-parse configuration file. Memory allocation failed.");
|
||||
|
||||
skygw_log_write(LE, errorbuffer);
|
||||
if(!daemon_mode)
|
||||
{
|
||||
strncat(errorbuffer, "\n", STRING_BUFFER_SIZE);
|
||||
fprintf(stderr, errorbuffer);
|
||||
}
|
||||
|
||||
rc = MAXSCALE_BADCONFIG;
|
||||
goto return_main;
|
||||
}
|
||||
@ -1664,24 +1708,28 @@ int main(int argc, char **argv)
|
||||
* machine.
|
||||
*/
|
||||
|
||||
snprintf(datadir,PATH_MAX,"%s/data",get_datadir());
|
||||
snprintf(datadir,PATH_MAX, "%s", get_datadir());
|
||||
datadir[PATH_MAX] = '\0';
|
||||
if(mkdir(datadir, 0777) != 0){
|
||||
|
||||
if(errno != EEXIST){
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"Error: Cannot create data directory '%s': %d %s\n",datadir,errno,strerror(errno));
|
||||
"Error: Cannot create data directory '%s': %d %s\n",
|
||||
datadir, errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
goto return_main;
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(datadir,PATH_MAX, "%s/data/data%d", get_datadir(), getpid());
|
||||
snprintf(datadir,PATH_MAX, "%s/data%d", get_datadir(), getpid());
|
||||
|
||||
if(mkdir(datadir, 0777) != 0){
|
||||
|
||||
if(errno != EEXIST){
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"Error: Cannot create data directory '%s': %d %s\n",datadir,errno,strerror(errno));
|
||||
"Error: Cannot create data directory '%s': %d %s\n",
|
||||
datadir, errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
goto return_main;
|
||||
}
|
||||
}
|
||||
@ -1780,7 +1828,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
}
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : mysql_library_init failed. It is a "
|
||||
"mandatory component, required by router services and "
|
||||
@ -1788,7 +1836,7 @@ int main(int argc, char **argv)
|
||||
mysql_errno(NULL),
|
||||
mysql_error(NULL),
|
||||
__FILE__,
|
||||
__LINE__)));
|
||||
__LINE__);
|
||||
rc = MAXSCALE_NOLIBRARY;
|
||||
goto return_main;
|
||||
}
|
||||
@ -1799,11 +1847,11 @@ int main(int argc, char **argv)
|
||||
char* fprerr = "Failed to load MaxScale configuration "
|
||||
"file. Exiting. See the error log for details.";
|
||||
print_log_n_stderr(false, !daemon_mode, fprerr, fprerr, 0);
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed to load MaxScale configuration file %s. "
|
||||
"Exiting.",
|
||||
cnf_file_path)));
|
||||
cnf_file_path);
|
||||
rc = MAXSCALE_BADCONFIG;
|
||||
goto return_main;
|
||||
}
|
||||
@ -1816,8 +1864,22 @@ int main(int argc, char **argv)
|
||||
"MaxScale is running in process %i",
|
||||
getpid())));
|
||||
|
||||
/** Check if a MaxScale process is already running */
|
||||
if(pid_file_exists())
|
||||
{
|
||||
/** There is a process with the PID of the maxscale.pid file running.
|
||||
* Assuming that this is an already running MaxScale process, we
|
||||
* should exit with an error code. */
|
||||
rc = MAXSCALE_ALREADYRUNNING;
|
||||
goto return_main;
|
||||
}
|
||||
|
||||
/* Write process pid into MaxScale pidfile */
|
||||
write_pid_file();
|
||||
if(write_pid_file() != 0)
|
||||
{
|
||||
rc = MAXSCALE_ALREADYRUNNING;
|
||||
goto return_main;
|
||||
}
|
||||
|
||||
/* Init MaxScale poll system */
|
||||
poll_init();
|
||||
@ -1922,6 +1984,7 @@ int main(int argc, char **argv)
|
||||
|
||||
unload_all_modules();
|
||||
/* Remove Pidfile */
|
||||
unlock_pidfile();
|
||||
unlink_pidfile();
|
||||
|
||||
return_main:
|
||||
@ -1983,6 +2046,21 @@ static void log_flush_cb(
|
||||
"Finished MaxScale log flusher.")));
|
||||
}
|
||||
|
||||
static void unlock_pidfile()
|
||||
{
|
||||
if(pidfd != PIDFD_CLOSED)
|
||||
{
|
||||
if(flock(pidfd,LOCK_UN|LOCK_NB) != 0)
|
||||
{
|
||||
char logbuf[STRING_BUFFER_SIZE + PATH_MAX];
|
||||
char* logerr = "Failed to unlock PID file '%s'.";
|
||||
snprintf(logbuf,sizeof(logbuf),logerr,pidfile);
|
||||
print_log_n_stderr(true, true, logbuf, logbuf, errno);
|
||||
}
|
||||
close(pidfd);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlink pid file, called at program exit
|
||||
*/
|
||||
@ -1991,15 +2069,141 @@ static void unlink_pidfile(void)
|
||||
if (strlen(pidfile)) {
|
||||
if (unlink(pidfile))
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"MaxScale failed to remove pidfile %s: error %d, %s\n",
|
||||
pidfile,
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the maxscale.pid file exists and has a valid PID in it. If one has already been
|
||||
* written and a MaxScale process is running, this instance of MaxScale should shut down.
|
||||
* @return True if the conditions for starting MaxScale are not met and false if
|
||||
* no PID file was found or there is no process running with the PID of the maxscale.pid
|
||||
* file. If false is returned, this process should continue normally.
|
||||
*/
|
||||
bool pid_file_exists()
|
||||
{
|
||||
char pathbuf[PATH_MAX+1];
|
||||
char logbuf[STRING_BUFFER_SIZE + PATH_MAX];
|
||||
char pidbuf[STRING_BUFFER_SIZE];
|
||||
pid_t pid;
|
||||
bool lock_failed = false;
|
||||
|
||||
snprintf(pathbuf, PATH_MAX, "%s/maxscale.pid",get_piddir());
|
||||
pathbuf[PATH_MAX] = '\0';
|
||||
|
||||
if(access(pathbuf,F_OK) != 0)
|
||||
return false;
|
||||
|
||||
if(access(pathbuf,R_OK) == 0)
|
||||
{
|
||||
int fd, b;
|
||||
|
||||
if((fd = open(pathbuf, O_RDWR)) == -1)
|
||||
{
|
||||
char* logerr = "Failed to open PID file '%s'.";
|
||||
snprintf(logbuf,sizeof(logbuf),logerr,pathbuf);
|
||||
print_log_n_stderr(true, true, logbuf, logbuf, errno);
|
||||
return true;
|
||||
}
|
||||
if(flock(fd,LOCK_EX|LOCK_NB))
|
||||
{
|
||||
if(errno != EWOULDBLOCK)
|
||||
{
|
||||
char* logerr = "Failed to lock PID file '%s'.";
|
||||
snprintf(logbuf,sizeof(logbuf),logerr,pathbuf);
|
||||
print_log_n_stderr(true, true, logbuf, logbuf, errno);
|
||||
close(fd);
|
||||
return true;
|
||||
}
|
||||
lock_failed = true;
|
||||
}
|
||||
|
||||
pidfd = fd;
|
||||
b = read(fd,pidbuf,sizeof(pidbuf));
|
||||
|
||||
if(b == -1)
|
||||
{
|
||||
char* logerr = "Failed to read from PID file '%s'.";
|
||||
snprintf(logbuf,sizeof(logbuf),logerr,pathbuf);
|
||||
print_log_n_stderr(true, true, logbuf, logbuf, errno);
|
||||
unlock_pidfile();
|
||||
return true;
|
||||
}
|
||||
else if(b == 0)
|
||||
{
|
||||
/** Empty file */
|
||||
char* logerr = "PID file read from '%s'. File was empty.\n"
|
||||
"If the file is the correct PID file and no other MaxScale processes "
|
||||
"are running, please remove it manually and start MaxScale again.";
|
||||
snprintf(logbuf,sizeof(logbuf),logerr,pathbuf);
|
||||
print_log_n_stderr(true, true, logbuf, logbuf, errno);
|
||||
unlock_pidfile();
|
||||
return true;
|
||||
}
|
||||
|
||||
pidbuf[b < sizeof(pidbuf) ? b : sizeof(pidbuf) - 1] = '\0';
|
||||
pid = strtol(pidbuf,NULL,0);
|
||||
|
||||
if(pid < 1)
|
||||
{
|
||||
/** Bad PID */
|
||||
char* logerr = "PID file read from '%s'. File contents not valid.\n"
|
||||
"If the file is the correct PID file and no other MaxScale processes "
|
||||
"are running, please remove it manually and start MaxScale again.";
|
||||
snprintf(logbuf,sizeof(logbuf),logerr,pathbuf);
|
||||
print_log_n_stderr(true, true, logbuf, logbuf, errno);
|
||||
unlock_pidfile();
|
||||
return true;
|
||||
}
|
||||
|
||||
if(kill(pid,0) == -1)
|
||||
{
|
||||
if(errno == ESRCH)
|
||||
{
|
||||
/** no such process, old PID file */
|
||||
if(lock_failed)
|
||||
{
|
||||
char* logerr = "Locking the PID file '%s' failed. Read PID from file and no process found with PID %d. "
|
||||
"Confirm that no other process holds the lock on the PID file.";
|
||||
snprintf(logbuf,sizeof(logbuf),logerr,pathbuf,pid);
|
||||
print_log_n_stderr(true, true, logbuf, logbuf, 0);
|
||||
close(fd);
|
||||
}
|
||||
return lock_failed;
|
||||
}
|
||||
else
|
||||
{
|
||||
char* logerr = "Failed to check the existence of process %d read from file '%s'";
|
||||
snprintf(logbuf,sizeof(logbuf),logerr,pid,pathbuf);
|
||||
print_log_n_stderr(true, true, logbuf, logbuf, errno);
|
||||
unlock_pidfile();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char* logerr = "MaxScale is already running. Process id: %d. "
|
||||
"Use another location for the PID file to run multiple instances of MaxScale on the same machine.";
|
||||
snprintf(logbuf,sizeof(logbuf),logerr,pid);
|
||||
print_log_n_stderr(true, true, logbuf, logbuf, 0);
|
||||
unlock_pidfile();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char* logerr = "Cannot open PID file '%s', no read permissions. "
|
||||
"Please confirm that the user running MaxScale has read permissions on the file.";
|
||||
snprintf(logbuf,sizeof(logbuf),logerr,pathbuf);
|
||||
print_log_n_stderr(true, true, logbuf, logbuf, errno);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write process pid into pidfile anc close it
|
||||
* Parameters:
|
||||
@ -2009,33 +2213,58 @@ static void unlink_pidfile(void)
|
||||
*/
|
||||
|
||||
static int write_pid_file() {
|
||||
|
||||
int fd = -1;
|
||||
char logbuf[STRING_BUFFER_SIZE + PATH_MAX];
|
||||
char pidstr[STRING_BUFFER_SIZE];
|
||||
|
||||
snprintf(pidfile, PATH_MAX, "%s/maxscale.pid",get_piddir());
|
||||
|
||||
fd = open(pidfile, O_WRONLY | O_CREAT | O_TRUNC, 0777);
|
||||
if (fd == -1) {
|
||||
fprintf(stderr, "MaxScale failed to open pidFile %s: error %d, %s\n", pidfile, errno, strerror(errno));
|
||||
return 1;
|
||||
} else {
|
||||
char pidstr[50]="";
|
||||
/* truncate pidfile content */
|
||||
if (ftruncate(fd, 0) == -1) {
|
||||
fprintf(stderr, "MaxScale failed to truncate pidfile %s: error %d, %s\n", pidfile, errno, strerror(errno));
|
||||
if(pidfd == PIDFD_CLOSED)
|
||||
{
|
||||
int fd = -1;
|
||||
|
||||
fd = open(pidfile, O_WRONLY | O_CREAT, 0777);
|
||||
if (fd == -1) {
|
||||
char* logerr = "Failed to open PID file '%s'.";
|
||||
snprintf(logbuf,sizeof(logbuf),logerr,pidfile);
|
||||
print_log_n_stderr(true, true, logbuf, logbuf, errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(flock(fd,LOCK_EX|LOCK_NB))
|
||||
{
|
||||
if(errno == EWOULDBLOCK)
|
||||
{
|
||||
snprintf(logbuf,sizeof(logbuf),"Failed to lock PID file '%s', another process is holding a lock on it. "
|
||||
"Please confirm that no other MaxScale process is using the same PID file location.",pidfile);
|
||||
}
|
||||
|
||||
snprintf(pidstr, sizeof(pidstr)-1, "%d", getpid());
|
||||
|
||||
if (pwrite(fd, pidstr, strlen(pidstr), 0) != (ssize_t)strlen(pidstr)) {
|
||||
fprintf(stderr, "MaxScale failed to write into pidfile %s: error %d, %s\n", pidfile, errno, strerror(errno));
|
||||
/* close file and return */
|
||||
close(fd);
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
snprintf(logbuf,sizeof(logbuf),"Failed to lock PID file '%s'.",pidfile);
|
||||
}
|
||||
|
||||
/* close file */
|
||||
print_log_n_stderr(true, true, logbuf, logbuf, errno);
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
pidfd = fd;
|
||||
}
|
||||
|
||||
/* truncate pidfile content */
|
||||
if (ftruncate(pidfd, 0)) {
|
||||
char* logerr = "MaxScale failed to truncate PID file '%s'.";
|
||||
snprintf(logbuf,sizeof(logbuf),logerr,pidfile);
|
||||
print_log_n_stderr(true, true, logbuf, logbuf, errno);
|
||||
unlock_pidfile();
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(pidstr, sizeof(pidstr)-1, "%d", getpid());
|
||||
|
||||
if (pwrite(pidfd, pidstr, strlen(pidstr), 0) != (ssize_t)strlen(pidstr)) {
|
||||
char* logerr = "MaxScale failed to write into PID file '%s'.";
|
||||
snprintf(logbuf,sizeof(logbuf),logerr,pidfile);
|
||||
print_log_n_stderr(true, true, logbuf, logbuf, errno);
|
||||
unlock_pidfile();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* success */
|
||||
@ -2208,32 +2437,36 @@ static int set_user(char* user)
|
||||
pwname = getpwnam(user);
|
||||
if(pwname == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
printf("Error: Failed to retrieve user information for '%s': %d %s\n",
|
||||
user,errno,errno == 0 ? "User not found" : strerror(errno));
|
||||
user,errno,errno == 0 ? "User not found" : strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
return -1;
|
||||
}
|
||||
|
||||
rval = setgid(pwname->pw_gid);
|
||||
if(rval != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
printf("Error: Failed to change group to '%d': %d %s\n",
|
||||
pwname->pw_gid,errno,strerror(errno));
|
||||
pwname->pw_gid, errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
return rval;
|
||||
}
|
||||
|
||||
rval = setuid(pwname->pw_uid);
|
||||
if(rval != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
printf("Error: Failed to change user to '%s': %d %s\n",
|
||||
pwname->pw_name,errno,strerror(errno));
|
||||
pwname->pw_name, errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
return rval;
|
||||
}
|
||||
if(prctl(PR_GET_DUMPABLE) == 0)
|
||||
{
|
||||
if(prctl(PR_SET_DUMPABLE ,1) == -1)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
printf("Error: Failed to set dumpable flag on for the process '%s': %d %s\n",
|
||||
pwname->pw_name,errno,strerror(errno));
|
||||
pwname->pw_name, errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,8 @@ void gw_daemonize(void) {
|
||||
pid = fork();
|
||||
|
||||
if (pid < 0) {
|
||||
fprintf(stderr, "fork() error %s\n", strerror(errno));
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr, "fork() error %s\n", strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -157,7 +158,8 @@ void gw_daemonize(void) {
|
||||
}
|
||||
|
||||
if (setsid() < 0) {
|
||||
fprintf(stderr, "setsid() error %s\n", strerror(errno));
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr, "setsid() error %s\n", strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,8 @@
|
||||
#include <modules.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
#include <secrets.h>
|
||||
#include <mysql/mysqld_error.h>
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
@ -448,3 +450,80 @@ int *data;
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the monitor user has all required permissions to operate properly.
|
||||
* this checks for REPLICATION CLIENT permissions
|
||||
* @param service Monitor to inspect
|
||||
* @return False if an error with monitor permissions was detected or if an
|
||||
* error occurred. True if permissions are correct.
|
||||
*/
|
||||
bool check_monitor_permissions(MONITOR* monitor)
|
||||
{
|
||||
MYSQL* mysql;
|
||||
MYSQL_RES* res;
|
||||
char *user,*dpasswd;
|
||||
SERVER* server;
|
||||
int conn_timeout = 1;
|
||||
bool rval = true;
|
||||
|
||||
user = monitor->user;
|
||||
dpasswd = decryptPassword(monitor->password);
|
||||
|
||||
if((mysql = mysql_init(NULL)) == NULL)
|
||||
{
|
||||
skygw_log_write(LE,"[%s] Error: MySQL connection initialization failed.",__FUNCTION__);
|
||||
free(dpasswd);
|
||||
return false;
|
||||
}
|
||||
|
||||
server = monitor->databases->server;
|
||||
mysql_options(mysql,MYSQL_OPT_USE_REMOTE_CONNECTION,NULL);
|
||||
mysql_options(mysql,MYSQL_OPT_CONNECT_TIMEOUT,&conn_timeout);
|
||||
|
||||
/** Connect to the first server. This assumes all servers have identical
|
||||
* user permissions. */
|
||||
if(mysql_real_connect(mysql,server->name,user,dpasswd,NULL,server->port,NULL,0) == NULL)
|
||||
{
|
||||
skygw_log_write(LE,"%s: Error: Failed to connect to server %s(%s:%d) when"
|
||||
" checking monitor user credentials and permissions.",
|
||||
monitor->name,
|
||||
server->unique_name,
|
||||
server->name,
|
||||
server->port);
|
||||
mysql_close(mysql);
|
||||
free(dpasswd);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(mysql_query(mysql,"show slave status") != 0)
|
||||
{
|
||||
if(mysql_errno(mysql) == ER_SPECIFIC_ACCESS_DENIED_ERROR)
|
||||
{
|
||||
skygw_log_write(LE,"%s: Error: User '%s' is missing REPLICATION CLIENT privileges. MySQL error message: %s",
|
||||
monitor->name,user,mysql_error(mysql));
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LE,"%s: Error: Monitor failed to query for slave status. MySQL error message: %s",
|
||||
monitor->name,mysql_error(mysql));
|
||||
}
|
||||
rval = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((res = mysql_use_result(mysql)) == NULL)
|
||||
{
|
||||
skygw_log_write(LE,"%s: Error: Result retrieval failed when checking for REPLICATION CLIENT permissions: %s",
|
||||
monitor->name,mysql_error(mysql));
|
||||
rval = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mysql_free_result(res);
|
||||
}
|
||||
}
|
||||
mysql_close(mysql);
|
||||
free(dpasswd);
|
||||
return rval;
|
||||
}
|
@ -889,6 +889,7 @@ unsigned long qtime;
|
||||
dcb->func.write_ready(dcb);
|
||||
}
|
||||
} else {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
@ -896,7 +897,7 @@ unsigned long qtime;
|
||||
"dcb %p, fd %i",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno),
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)),
|
||||
dcb,
|
||||
dcb->fd)));
|
||||
}
|
||||
@ -949,6 +950,7 @@ unsigned long qtime;
|
||||
#if defined(FAKE_CODE)
|
||||
if (eno == 0) {
|
||||
eno = dcb_fake_write_errno[dcb->fd];
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
@ -956,18 +958,19 @@ unsigned long qtime;
|
||||
"%s",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
dcb_fake_write_errno[dcb->fd] = 0;
|
||||
#endif /* FAKE_CODE */
|
||||
if (eno != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"EPOLLERR due %d, %s.",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
atomic_add(&pollStats.n_error, 1);
|
||||
/** Read session id to thread's local storage */
|
||||
@ -985,7 +988,7 @@ unsigned long qtime;
|
||||
{
|
||||
int eno = 0;
|
||||
eno = gw_getsockerrno(dcb->fd);
|
||||
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
@ -995,7 +998,7 @@ unsigned long qtime;
|
||||
dcb,
|
||||
dcb->fd,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
atomic_add(&pollStats.n_hup, 1);
|
||||
spinlock_acquire(&dcb->dcb_initlock);
|
||||
if ((dcb->flags & DCBF_HUNG) == 0)
|
||||
@ -1021,7 +1024,7 @@ unsigned long qtime;
|
||||
{
|
||||
int eno = 0;
|
||||
eno = gw_getsockerrno(dcb->fd);
|
||||
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
@ -1031,7 +1034,7 @@ unsigned long qtime;
|
||||
dcb,
|
||||
dcb->fd,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
atomic_add(&pollStats.n_hup, 1);
|
||||
spinlock_acquire(&dcb->dcb_initlock);
|
||||
if ((dcb->flags & DCBF_HUNG) == 0)
|
||||
|
@ -81,24 +81,26 @@ static int reported = 0;
|
||||
{
|
||||
if (!reported)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LM, (skygw_log_write(
|
||||
LOGFILE_MESSAGE,
|
||||
"Encrypted password file %s can't be accessed "
|
||||
"(%s). Password encryption is not used.",
|
||||
secret_file,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
reported = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : access for secrets file "
|
||||
"[%s] failed. Error %d, %s.",
|
||||
secret_file,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -108,13 +110,14 @@ static int reported = 0;
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed opening secret "
|
||||
"file [%s]. Error %d, %s.",
|
||||
secret_file,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
return NULL;
|
||||
|
||||
}
|
||||
@ -124,13 +127,14 @@ static int reported = 0;
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
close(fd);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : fstat for secret file %s "
|
||||
"failed. Error %d, %s.",
|
||||
secret_file,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -139,13 +143,14 @@ static int reported = 0;
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
close(fd);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Secrets file %s has "
|
||||
"incorrect size. Error %d, %s.",
|
||||
secret_file,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
return NULL;
|
||||
}
|
||||
if (secret_stats.st_mode != (S_IRUSR|S_IFREG))
|
||||
@ -181,6 +186,7 @@ static int reported = 0;
|
||||
errno = 0;
|
||||
close(fd);
|
||||
free(keys);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Read from secrets file "
|
||||
@ -189,7 +195,7 @@ static int reported = 0;
|
||||
len,
|
||||
sizeof(MAXKEYS),
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -198,13 +204,14 @@ static int reported = 0;
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
free(keys);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed closing the "
|
||||
"secrets file %s. Error %d, %s.",
|
||||
secret_file,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
return NULL;
|
||||
}
|
||||
ss_dassert(keys != NULL);
|
||||
@ -239,24 +246,26 @@ if(strlen(path) > PATH_MAX)
|
||||
/* Open for writing | Create | Truncate the file for writing */
|
||||
if ((fd = open(secret_file, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR)) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed opening secret "
|
||||
"file [%s]. Error %d, %s.",
|
||||
secret_file,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Open for writing | Create | Truncate the file for writing */
|
||||
if ((randfd = open("/dev/random", O_RDONLY)) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed opening /dev/random. Error %d, %s.",
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
@ -278,13 +287,14 @@ if(strlen(path) > PATH_MAX)
|
||||
/* Write data */
|
||||
if (write(fd, &key, sizeof(key)) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed writing into "
|
||||
"secret file [%s]. Error %d, %s.",
|
||||
secret_file,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
@ -292,24 +302,26 @@ if(strlen(path) > PATH_MAX)
|
||||
/* close file */
|
||||
if (close(fd) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed closing the "
|
||||
"secret file [%s]. Error %d, %s.",
|
||||
secret_file,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
|
||||
if( chmod(secret_file, S_IRUSR) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed to change the permissions of the"
|
||||
"secret file [%s]. Error %d, %s.",
|
||||
secret_file,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -140,6 +140,7 @@ SERVICE *service;
|
||||
service->routerModule = strdup(router);
|
||||
service->users_from_all = false;
|
||||
service->resources = NULL;
|
||||
service->localhost_match_wildcard_host = SERVICE_PARAM_UNINIT;
|
||||
service->ssl_mode = SSL_DISABLED;
|
||||
service->ssl_init_done = false;
|
||||
service->ssl_ca_cert = NULL;
|
||||
@ -234,19 +235,19 @@ GWPROTOCOL *funcs;
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Unable to load users from %s:%d for "
|
||||
"service %s.",
|
||||
"Error : Unable to load users for "
|
||||
"service %s listening at %s:%d.",
|
||||
service->name,
|
||||
(port->address == NULL ? "0.0.0.0" : port->address),
|
||||
port->port,
|
||||
service->name)));
|
||||
port->port)));
|
||||
|
||||
{
|
||||
/* Try loading authentication data from file cache */
|
||||
char *ptr, path[4097];
|
||||
strcpy(path, get_cachedir());
|
||||
strncat(path, "/", 4096);
|
||||
strncat(path, service->name, 4096);
|
||||
strncat(path, "/.cache/dbusers", 4096);
|
||||
char *ptr, path[PATH_MAX+1];
|
||||
strncpy(path, get_cachedir(),sizeof(path)-1);
|
||||
strncat(path, "/", sizeof(path)-1);
|
||||
strncat(path, service->name, sizeof(path)-1);
|
||||
strncat(path, "/.cache/dbusers", sizeof(path)-1);
|
||||
loaded = dbusers_load(service->users, path);
|
||||
if (loaded != -1)
|
||||
{
|
||||
@ -281,10 +282,11 @@ GWPROTOCOL *funcs;
|
||||
{
|
||||
if(errno != EEXIST)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write(LOGFILE_ERROR,"Error : Failed to create directory '%s': [%d] %s",
|
||||
path,
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
mkdir_rval = 0;
|
||||
}
|
||||
@ -299,10 +301,11 @@ GWPROTOCOL *funcs;
|
||||
{
|
||||
if(errno != EEXIST)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write(LOGFILE_ERROR,"Error : Failed to create directory '%s': [%d] %s",
|
||||
path,
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
mkdir_rval = 0;
|
||||
}
|
||||
@ -416,6 +419,16 @@ serviceStart(SERVICE *service)
|
||||
SERV_PROTOCOL *port;
|
||||
int listeners = 0;
|
||||
|
||||
|
||||
if(!check_service_permissions(service))
|
||||
{
|
||||
skygw_log_write_flush(LE,
|
||||
"%s: Error: Inadequate user permissions for service. Service not started.",
|
||||
service->name);
|
||||
service->state = SERVICE_STATE_FAILED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(service->ssl_mode != SSL_DISABLED)
|
||||
{
|
||||
if(serviceInitSSL(service) != 0)
|
||||
|
@ -82,12 +82,13 @@ session_alloc(SERVICE *service, DCB *client_dcb)
|
||||
|
||||
if (session == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed to allocate memory for "
|
||||
"session object due error %d, %s.",
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
session_simple_free(session, client_dcb);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ int set_and_get_single_mysql_users_ipv4(char *username, unsigned long ipv4, char
|
||||
}
|
||||
if ((service = (SERVICE *)calloc(1, sizeof(SERVICE))) == NULL) {
|
||||
fprintf(stderr, "service_alloc() failed\n");
|
||||
dcb_free(dcb);
|
||||
dcb_close(dcb);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ int set_and_get_single_mysql_users_ipv4(char *username, unsigned long ipv4, char
|
||||
fprintf(stderr, "Failed adding %s@%s(%lu)\n", username, ret_ip, fix_ipv4);
|
||||
users_free(mysql_users);
|
||||
free(service);
|
||||
dcb_free(dcb);
|
||||
dcb_close(dcb);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ int set_and_get_single_mysql_users_ipv4(char *username, unsigned long ipv4, char
|
||||
|
||||
users_free(mysql_users);
|
||||
free(service);
|
||||
dcb_free(dcb);
|
||||
dcb_close(dcb);
|
||||
|
||||
if (!fetch_data)
|
||||
return 1;
|
||||
@ -198,7 +198,7 @@ int set_and_get_mysql_users_wildcards(char *username, char *hostname, char *pass
|
||||
}
|
||||
if ((service = (SERVICE *)calloc(1, sizeof(SERVICE))) == NULL) {
|
||||
fprintf(stderr, "service_alloc() failed\n");
|
||||
dcb_free(dcb);
|
||||
dcb_close(dcb);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -208,7 +208,7 @@ int set_and_get_mysql_users_wildcards(char *username, char *hostname, char *pass
|
||||
if(!setipaddress(&client_addr.sin_addr, from)) {
|
||||
fprintf(stderr, "setipaddress failed for host [%s]\n", from);
|
||||
free(service);
|
||||
dcb_free(dcb);
|
||||
dcb_close(dcb);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -216,7 +216,7 @@ int set_and_get_mysql_users_wildcards(char *username, char *hostname, char *pass
|
||||
if ((data = (MYSQL_session *) calloc(1, sizeof(MYSQL_session))) == NULL) {
|
||||
fprintf(stderr, "MYSQL_session alloc failed\n");
|
||||
free(service);
|
||||
dcb_free(dcb);
|
||||
dcb_close(dcb);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -235,7 +235,7 @@ int set_and_get_mysql_users_wildcards(char *username, char *hostname, char *pass
|
||||
else
|
||||
strncpy(data->db, "",MYSQL_DATABASE_MAXLEN);
|
||||
|
||||
/* freed by dcb_free(dcb) */
|
||||
/* freed by dcb_close(dcb) */
|
||||
dcb->data = data;
|
||||
|
||||
// the routine returns 1 on success
|
||||
@ -264,7 +264,7 @@ int set_and_get_mysql_users_wildcards(char *username, char *hostname, char *pass
|
||||
|
||||
users_free(mysql_users);
|
||||
free(service);
|
||||
dcb_free(dcb);
|
||||
dcb_close(dcb);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <housekeeper.h>
|
||||
#include <buffer.h>
|
||||
#include <regex.h>
|
||||
#include <modules.h>
|
||||
|
||||
static char* server_options[] = {
|
||||
"MariaDB Corporation MaxScale",
|
||||
@ -63,6 +64,9 @@ static char* server_groups[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
int config_load(char *);
|
||||
int module_create_feedback_report(GWBUF **buffer, MODULES *modules, FEEDBACK_CONF *cfg);
|
||||
int do_http_post(GWBUF *buffer, void *cfg);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
@ -61,7 +61,8 @@ int result;
|
||||
dcb->fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
|
||||
if(dcb->fd < 0){
|
||||
ss_dfprintf(stderr, "\nError on function call: socket() returned %d: %s\n",errno,strerror(errno));
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
ss_dfprintf(stderr, "\nError on function call: socket() returned %d: %s\n",errno,strerror_r(errno,errbuf,sizeof(errbuf)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -69,22 +69,24 @@ int setnonblocking(int fd) {
|
||||
int fl;
|
||||
|
||||
if ((fl = fcntl(fd, F_GETFL, 0)) == -1) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Can't GET fcntl for %i, errno = %d, %s.",
|
||||
fd,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fcntl(fd, F_SETFL, fl | O_NONBLOCK) == -1) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Can't SET fcntl for %i, errno = %d, %s",
|
||||
fd,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -42,6 +42,11 @@
|
||||
#define USERS_REFRESH_TIME 30 /* Allowed time interval (in seconds) after last update*/
|
||||
#define USERS_REFRESH_MAX_PER_TIME 4 /* Max number of load calls within the time interval */
|
||||
|
||||
/** Default timeout values used by the connections which fetch user authentication data */
|
||||
#define DEFAULT_AUTH_CONNECT_TIMEOUT 3
|
||||
#define DEFAULT_AUTH_READ_TIMEOUT 1
|
||||
#define DEFAULT_AUTH_WRITE_TIMEOUT 2
|
||||
|
||||
/* Max length of fields in the mysql.user table */
|
||||
#define MYSQL_USER_MAXLEN 128
|
||||
#define MYSQL_PASSWORD_LEN 41
|
||||
@ -68,4 +73,5 @@ extern char *mysql_users_fetch(USERS *users, MYSQL_USER_HOST *key);
|
||||
extern int replace_mysql_users(SERVICE *service);
|
||||
extern int dbusers_save(USERS *, char *);
|
||||
extern int dbusers_load(USERS *, char *);
|
||||
bool check_service_permissions(SERVICE* service);
|
||||
#endif
|
||||
|
@ -30,7 +30,7 @@ static const char* default_piddir = "@MAXSCALE_VARDIR@/run/maxscale"; /*< This s
|
||||
* the /var/run folder is an old standard and the newer FSH 3.0
|
||||
* uses /run for PID files.*/
|
||||
static const char* default_logdir = "@MAXSCALE_VARDIR@/log/maxscale";
|
||||
static const char* default_datadir = "@MAXSCALE_VARDIR@/lib/maxscale";
|
||||
static const char* default_datadir = "@MAXSCALE_VARDIR@/lib/maxscale/data";
|
||||
static const char* default_libdir = "@CMAKE_INSTALL_PREFIX@/@MAXSCALE_LIBDIR@";
|
||||
static const char* default_cachedir = "@MAXSCALE_VARDIR@/cache/maxscale";
|
||||
static const char* default_langdir = "@MAXSCALE_VARDIR@/lib/maxscale";
|
||||
|
@ -106,6 +106,9 @@ typedef struct {
|
||||
unsigned int pollsleep; /**< Wait time in blocking polls */
|
||||
int syslog; /*< Log to syslog */
|
||||
int maxlog; /*< Log to MaxScale's own logs */
|
||||
unsigned int auth_conn_timeout; /*< Connection timeout for the user authentication */
|
||||
unsigned int auth_read_timeout; /*< Read timeout for the user authentication */
|
||||
unsigned int auth_write_timeout; /*< Write timeout for the user authentication */
|
||||
} GATEWAY_CONF;
|
||||
|
||||
extern int config_load(char *);
|
||||
@ -146,4 +149,5 @@ void config_enable_feedback_task(void);
|
||||
void config_disable_feedback_task(void);
|
||||
unsigned long config_get_gateway_id(void);
|
||||
GATEWAY_CONF* config_get_global_options();
|
||||
bool isInternalService(char *router);
|
||||
#endif
|
||||
|
@ -37,7 +37,7 @@
|
||||
#define MAXSCALE_BADCONFIG 1 /* Configuration fiel error */
|
||||
#define MAXSCALE_NOLIBRARY 2 /* No embedded library found */
|
||||
#define MAXSCALE_NOSERVICES 3 /* No servics are running */
|
||||
#define MAXSCALE_HOMELESS 4 /* No MaxScale Home */
|
||||
#define MAXSCALE_ALREADYRUNNING 4 /* MaxScale is already runing */
|
||||
#define MAXSCALE_BADARG 5 /* Bad command line argument */
|
||||
#define MAXSCALE_INTERNALERROR 6 /* Internal error, see error log */
|
||||
#endif
|
||||
|
@ -169,4 +169,5 @@ extern void monitorList(DCB *);
|
||||
extern void monitorSetInterval (MONITOR *, unsigned long);
|
||||
extern void monitorSetNetworkTimeout(MONITOR *, int, int);
|
||||
extern RESULTSET *monitorGetList();
|
||||
bool check_monitor_permissions(MONITOR* monitor);
|
||||
#endif
|
||||
|
@ -128,6 +128,12 @@ enum{
|
||||
|
||||
#define DEFAULT_SSL_CERT_VERIFY_DEPTH 100 /*< The default certificate verification depth */
|
||||
|
||||
/**
|
||||
* Parameters that are automatically detected but can also be configured by the
|
||||
* user are initially set to this value.
|
||||
*/
|
||||
#define SERVICE_PARAM_UNINIT -1
|
||||
|
||||
/**
|
||||
* Defines a service within the gateway.
|
||||
*
|
||||
|
@ -1 +1,2 @@
|
||||
#define MAXSCALE_VERSION "@MAXSCALE_VERSION@"
|
||||
#define MAXSCALE_COMMIT "@MAXSCALE_COMMIT@"
|
||||
|
@ -1,2 +1,2 @@
|
||||
add_definitions(-DINI_MAX_LINE=1024)
|
||||
add_definitions(-DINI_MAX_LINE=1024 -DINI_ALLOW_MULTILINE)
|
||||
add_library(inih ini.c)
|
||||
|
@ -277,12 +277,13 @@ char *remote, *userName;
|
||||
(char *)malloc(strlen(my_instance->filebase) + 20))
|
||||
== NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation for qla filter "
|
||||
"file name failed due to %d, %s.",
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
free(my_session);
|
||||
return NULL;
|
||||
}
|
||||
@ -315,12 +316,13 @@ char *remote, *userName;
|
||||
|
||||
if (my_session->fp == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Opening output file for qla "
|
||||
"fileter failed due to %d, %s",
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
free(my_session->filename);
|
||||
free(my_session);
|
||||
my_session = NULL;
|
||||
@ -329,12 +331,13 @@ char *remote, *userName;
|
||||
}
|
||||
else
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation for qla filter failed due to "
|
||||
"%d, %s.",
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
return my_session;
|
||||
}
|
||||
|
@ -131,7 +131,8 @@ int open_file(char* str, unsigned int write)
|
||||
mode = O_RDONLY;
|
||||
}
|
||||
if((fd = open(str,mode,S_IRWXU|S_IRGRP|S_IXGRP|S_IXOTH)) < 0){
|
||||
printf("Error %d: %s\n",errno,strerror(errno));
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
printf("Error %d: %s\n", errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef _SHARDING_COMMON_HG
|
||||
#define _SHARDING_COMMON_HG
|
||||
|
||||
#include <my_config.h>
|
||||
#include <poll.h>
|
||||
#include <buffer.h>
|
||||
#include <modutil.h>
|
||||
|
@ -239,7 +239,7 @@ void mon_append_node_names(MONITOR_SERVERS* start,char* str, int len)
|
||||
}
|
||||
first = false;
|
||||
sprintf(arr,"%s:%d",ptr->server->name,ptr->server->port);
|
||||
strcat(str,arr);
|
||||
strncat(str,arr,len);
|
||||
ptr = ptr->next;
|
||||
slen = strlen(str);
|
||||
}
|
||||
@ -306,10 +306,10 @@ void monitor_launch_script(MONITOR* mon,MONITOR_SERVERS* ptr, char* script)
|
||||
ptr->server->name,
|
||||
ptr->server->port);
|
||||
|
||||
mon_append_node_names(mon->databases,argstr,PATH_MAX + MON_ARG_MAX + 1);
|
||||
mon_append_node_names(mon->databases,argstr,PATH_MAX + MON_ARG_MAX);
|
||||
if((cmd = externcmd_allocate(argstr)) == NULL)
|
||||
{
|
||||
skygw_log_write(LE,"Failed to execute script: %s",script);
|
||||
skygw_log_write(LE,"Failed to initialize script: %s",script);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -429,7 +429,10 @@ int syseno = 0;
|
||||
sizeof(one));
|
||||
|
||||
if(syseno != 0){
|
||||
skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s",errno,strerror(errno));
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write_flush(LOGFILE_ERROR,
|
||||
"Error: Failed to set socket options. Error %d: %s",
|
||||
errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
return 0;
|
||||
}
|
||||
/* set NONBLOCKING mode */
|
||||
@ -448,10 +451,11 @@ int syseno = 0;
|
||||
} else {
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\n* Failed to start listening http due error %d, %s\n\n",
|
||||
eno,
|
||||
strerror(eno));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -380,12 +380,13 @@ int rc;
|
||||
} else {
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"Failed to start listening for maxscale admin connections "
|
||||
"due error %d, %s\n\n",
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
* 17/06/2013 Massimiliano Pinto Added MaxScale To Backends routines
|
||||
* 01/07/2013 Massimiliano Pinto Put Log Manager example code behind SS_DEBUG macros.
|
||||
* 03/07/2013 Massimiliano Pinto Added delayq for incoming data before mysql connection
|
||||
* 04/07/2013 Massimiliano Pinto Added asyncrhronous MySQL protocol connection to backend
|
||||
* 04/07/2013 Massimiliano Pinto Added asynchronous MySQL protocol connection to backend
|
||||
* 05/07/2013 Massimiliano Pinto Added closeSession if backend auth fails
|
||||
* 12/07/2013 Massimiliano Pinto Added Mysql Change User via dcb->func.auth()
|
||||
* 15/07/2013 Massimiliano Pinto Added Mysql session change via dcb->func.session()
|
||||
@ -548,6 +548,18 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
rc = 0;
|
||||
goto return_rc;
|
||||
}
|
||||
|
||||
if (!read_buffer) {
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"%lu [gw_read_backend_event] "
|
||||
"Read buffer unexpectedly null, even though response "
|
||||
"not marked as complete. User: %s",
|
||||
pthread_self(),
|
||||
current_session->user)));
|
||||
rc = 0;
|
||||
goto return_rc;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check that session is operable, and that client DCB is
|
||||
@ -825,7 +837,6 @@ static int gw_error_backend_event(DCB *dcb)
|
||||
if (dcb->state != DCB_STATE_POLLING)
|
||||
{
|
||||
int error, len;
|
||||
char buf[100];
|
||||
|
||||
len = sizeof(error);
|
||||
|
||||
@ -833,12 +844,12 @@ static int gw_error_backend_event(DCB *dcb)
|
||||
{
|
||||
if (error != 0)
|
||||
{
|
||||
strerror_r(error, buf, 100);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"DCB in state %s got error '%s'.",
|
||||
STRDCBSTATE(dcb->state),
|
||||
buf)));
|
||||
strerror_r(error, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@ -868,18 +879,17 @@ static int gw_error_backend_event(DCB *dcb)
|
||||
if (ses_state != SESSION_STATE_ROUTER_READY)
|
||||
{
|
||||
int error, len;
|
||||
char buf[100];
|
||||
|
||||
len = sizeof(error);
|
||||
if (getsockopt(dcb->fd, SOL_SOCKET, SO_ERROR, &error, (socklen_t *)&len) == 0)
|
||||
{
|
||||
if (error != 0)
|
||||
{
|
||||
strerror_r(error, buf, 100);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error '%s' in session that is not ready for routing.",
|
||||
buf)));
|
||||
strerror_r(error, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
}
|
||||
gwbuf_free(errbuf);
|
||||
@ -1092,19 +1102,18 @@ gw_backend_hangup(DCB *dcb)
|
||||
if (ses_state != SESSION_STATE_ROUTER_READY)
|
||||
{
|
||||
int error, len;
|
||||
char buf[100];
|
||||
|
||||
len = sizeof(error);
|
||||
if (getsockopt(dcb->fd, SOL_SOCKET, SO_ERROR, &error, (socklen_t *)&len) == 0)
|
||||
{
|
||||
if (error != 0 && ses_state != SESSION_STATE_STOPPING)
|
||||
{
|
||||
strerror_r(error, buf, 100);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Hangup in session that is not ready for routing, "
|
||||
"Error reported is '%s'.",
|
||||
buf)));
|
||||
strerror_r(error, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
}
|
||||
gwbuf_free(errbuf);
|
||||
@ -1556,9 +1565,10 @@ static GWBUF* process_response_data (
|
||||
* enough data to read the packet length.
|
||||
*/
|
||||
init_response_status(readbuf, srvcmd, &npackets_left, &nbytes_left);
|
||||
initial_packets = npackets_left;
|
||||
initial_bytes = nbytes_left;
|
||||
}
|
||||
|
||||
initial_packets = npackets_left;
|
||||
initial_bytes = nbytes_left;
|
||||
}
|
||||
/** Only session commands with responses should be processed */
|
||||
ss_dassert(npackets_left > 0);
|
||||
|
@ -1355,11 +1355,12 @@ int gw_MySQLListener(
|
||||
|
||||
// UNIX socket create
|
||||
if ((l_so = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\n* Error: can't create UNIX socket due "
|
||||
"error %i, %s.\n\n\t",
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
return 0;
|
||||
}
|
||||
memset(&local_addr, 0, sizeof(local_addr));
|
||||
@ -1376,11 +1377,12 @@ int gw_MySQLListener(
|
||||
}
|
||||
// TCP socket create
|
||||
if ((l_so = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\n* Error: can't create socket due "
|
||||
"error %i, %s.\n\n\t",
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1392,13 +1394,15 @@ int gw_MySQLListener(
|
||||
|
||||
// socket options
|
||||
if((syseno = setsockopt(l_so, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one))) != 0){
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s",errno,strerror(errno))));
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s", errno, strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
|
||||
if(is_tcp)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
if((syseno = setsockopt(l_so, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one))) != 0){
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s",errno,strerror(errno))));
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s", errno, strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
}
|
||||
// set NONBLOCKING mode
|
||||
@ -1413,10 +1417,11 @@ int gw_MySQLListener(
|
||||
}
|
||||
|
||||
if (bind(l_so, (struct sockaddr *) &local_addr, sizeof(local_addr)) < 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\n* Bind failed due error %i, %s.\n",
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
fprintf(stderr, "* Can't bind to %s\n\n", config_bind);
|
||||
close(l_so);
|
||||
return 0;
|
||||
@ -1424,21 +1429,23 @@ int gw_MySQLListener(
|
||||
|
||||
/* set permission for all users */
|
||||
if (chmod(config_bind, 0777) < 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\n* chmod failed for %s due error %i, %s.\n\n",
|
||||
config_bind,
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case AF_INET:
|
||||
if (bind(l_so, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\n* Bind failed due error %i, %s.\n",
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
fprintf(stderr, "* Can't bind to %s\n\n", config_bind);
|
||||
close(l_so);
|
||||
return 0;
|
||||
@ -1458,10 +1465,11 @@ int gw_MySQLListener(
|
||||
} else {
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\n* Failed to start listening MySQL due error %d, %s\n\n",
|
||||
eno,
|
||||
strerror(eno));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
close(l_so);
|
||||
return 0;
|
||||
}
|
||||
@ -1554,22 +1562,24 @@ int gw_MySQLAccept(DCB *listener)
|
||||
* Exceeded system's (ENFILE) or processes
|
||||
* (EMFILE) max. number of files limit.
|
||||
*/
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_MySQLAccept] Error %d, %s. ",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error %d, %s. "
|
||||
"Failed to accept new client "
|
||||
"connection.",
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
i++;
|
||||
ts1.tv_nsec = 100*i*i*1000000;
|
||||
@ -1586,18 +1596,19 @@ int gw_MySQLAccept(DCB *listener)
|
||||
/**
|
||||
* Other error.
|
||||
*/
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_MySQLAccept] Error %d, %s.",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed to accept new client "
|
||||
"connection due to %d, %s.",
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
rc = 1;
|
||||
goto return_rc;
|
||||
} /* if (eno == ..) */
|
||||
@ -1618,15 +1629,16 @@ int gw_MySQLAccept(DCB *listener)
|
||||
#endif /* FAKE_CODE */
|
||||
/* set nonblocking */
|
||||
sendbuf = GW_CLIENT_SO_SNDBUF;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
|
||||
if((syseno = setsockopt(c_sock, SOL_SOCKET, SO_SNDBUF, &sendbuf, optlen)) != 0){
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s",errno,strerror(errno))));
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s", errno, strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
|
||||
sendbuf = GW_CLIENT_SO_RCVBUF;
|
||||
|
||||
if((syseno = setsockopt(c_sock, SOL_SOCKET, SO_RCVBUF, &sendbuf, optlen)) != 0){
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s",errno,strerror(errno))));
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s", errno, strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
setnonblocking(c_sock);
|
||||
|
||||
|
@ -90,13 +90,14 @@ MySQLProtocol* mysql_protocol_init(
|
||||
if (p == NULL) {
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"%lu [mysql_init_protocol] MySQL protocol init failed : "
|
||||
"memory allocation due error %d, %s.",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
goto return_p;
|
||||
}
|
||||
p->protocol_state = MYSQL_PROTOCOL_ALLOC;
|
||||
@ -731,8 +732,8 @@ int gw_send_authentication_to_backend(
|
||||
|
||||
rv = dcb_write(dcb, buffer);
|
||||
|
||||
if (rv < 0) {
|
||||
return rv;
|
||||
if (rv == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@ -767,6 +768,7 @@ int gw_do_connect_to_backend(
|
||||
so = socket(AF_INET,SOCK_STREAM,0);
|
||||
|
||||
if (so < 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error: Establishing connection to backend server "
|
||||
@ -775,7 +777,7 @@ int gw_do_connect_to_backend(
|
||||
host,
|
||||
port,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
rv = -1;
|
||||
goto return_rv;
|
||||
}
|
||||
@ -786,6 +788,7 @@ int gw_do_connect_to_backend(
|
||||
|
||||
if(setsockopt(so, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize)) != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error: Failed to set socket options "
|
||||
@ -794,7 +797,7 @@ int gw_do_connect_to_backend(
|
||||
host,
|
||||
port,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
rv = -1;
|
||||
/** Close socket */
|
||||
goto close_so;
|
||||
@ -803,6 +806,7 @@ int gw_do_connect_to_backend(
|
||||
|
||||
if(setsockopt(so, SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof(bufsize)) != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error: Failed to set socket options "
|
||||
@ -811,7 +815,7 @@ int gw_do_connect_to_backend(
|
||||
host,
|
||||
port,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
rv = -1;
|
||||
/** Close socket */
|
||||
goto close_so;
|
||||
@ -820,6 +824,7 @@ int gw_do_connect_to_backend(
|
||||
int one = 1;
|
||||
if(setsockopt(so, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)) != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error: Failed to set socket options "
|
||||
@ -828,7 +833,7 @@ int gw_do_connect_to_backend(
|
||||
host,
|
||||
port,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
rv = -1;
|
||||
/** Close socket */
|
||||
goto close_so;
|
||||
@ -846,6 +851,7 @@ int gw_do_connect_to_backend(
|
||||
}
|
||||
else
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error: Failed to connect backend server %s:%d, "
|
||||
@ -853,7 +859,7 @@ int gw_do_connect_to_backend(
|
||||
host,
|
||||
port,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
/** Close socket */
|
||||
goto close_so;
|
||||
}
|
||||
@ -878,13 +884,14 @@ close_so:
|
||||
/*< Close newly created socket. */
|
||||
if (close(so) != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error: Failed to "
|
||||
"close socket %d due %d, %s.",
|
||||
so,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
goto return_rv;
|
||||
}
|
||||
@ -2240,10 +2247,11 @@ char *create_auth_fail_str(
|
||||
|
||||
if (errstr == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation failed due to %s.",
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
|
@ -386,7 +386,8 @@ int syseno = 0;
|
||||
syseno = setsockopt(listener->fd, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one));
|
||||
|
||||
if(syseno != 0){
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s",errno,strerror(errno))));
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s", errno, strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
return 0;
|
||||
}
|
||||
// set NONBLOCKING mode
|
||||
@ -404,10 +405,11 @@ int syseno = 0;
|
||||
} else {
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\n* Failed to start listening telnet due error %d, %s\n\n",
|
||||
eno,
|
||||
strerror(eno));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -854,7 +854,8 @@ struct tm tm;
|
||||
|
||||
if (router_inst->lastEventTimestamp)
|
||||
{
|
||||
localtime_r((const time_t*)&router_inst->lastEventTimestamp, &tm);
|
||||
time_t last_event = (time_t)router_inst->lastEventTimestamp;
|
||||
localtime_r(&last_event, &tm);
|
||||
asctime_r(&tm, buf);
|
||||
dcb_printf(dcb, "\tLast binlog event timestamp: %ld (%s)\n",
|
||||
router_inst->lastEventTimestamp, buf);
|
||||
@ -982,7 +983,8 @@ struct tm tm;
|
||||
if (session->lastEventTimestamp
|
||||
&& router_inst->lastEventTimestamp)
|
||||
{
|
||||
localtime_r((const time_t*)&session->lastEventTimestamp, &tm);
|
||||
time_t session_last_event = (time_t)session->lastEventTimestamp;
|
||||
localtime_r(&session_last_event, &tm);
|
||||
asctime_r(&tm, buf);
|
||||
dcb_printf(dcb, "\t\tLast binlog event timestamp %u, %s", session->lastEventTimestamp, buf);
|
||||
dcb_printf(dcb, "\t\tSeconds behind master %u\n", router_inst->lastEventTimestamp - session->lastEventTimestamp);
|
||||
@ -1082,7 +1084,7 @@ errorReply(ROUTER *instance, void *router_session, GWBUF *message, DCB *backend_
|
||||
ROUTER_INSTANCE *router = (ROUTER_INSTANCE *)instance;
|
||||
int error;
|
||||
socklen_t len;
|
||||
char msg[85], *errmsg;
|
||||
char msg[STRERROR_BUFLEN + 1], *errmsg;
|
||||
|
||||
/** Don't handle same error twice on same DCB */
|
||||
if (backend_dcb->dcb_errhandle_called)
|
||||
@ -1099,8 +1101,8 @@ char msg[85], *errmsg;
|
||||
len = sizeof(error);
|
||||
if (router->master && getsockopt(router->master->fd, SOL_SOCKET, SO_ERROR, &error, &len) == 0 && error != 0)
|
||||
{
|
||||
strerror_r(error, msg, 80);
|
||||
strcat(msg, " ");
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
sprintf(msg, "%s ", strerror_r(error, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
else
|
||||
strcpy(msg, "");
|
||||
|
@ -950,7 +950,7 @@ int n_bufs = -1, pn_bufs = -1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
router->stats.n_binlogs++;
|
||||
|
||||
router->lastEventReceived = hdr.event_type;
|
||||
router->lastEventTimestamp = hdr.timestamp;
|
||||
|
||||
|
@ -1464,7 +1464,7 @@ static void fail_accept(
|
||||
{
|
||||
int failcount = MIN(atoi(arg2), 100);
|
||||
fail_accept_errno = atoi(arg1);
|
||||
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
|
||||
switch(fail_accept_errno) {
|
||||
case EAGAIN:
|
||||
@ -1486,7 +1486,7 @@ static void fail_accept(
|
||||
dcb_printf(dcb,
|
||||
"[%d, %s] is not valid errno for accept.\n",
|
||||
fail_accept_errno,
|
||||
strerror(fail_accept_errno));
|
||||
strerror_r(fail_accept_errno, errbuf, sizeof(errbuf)));
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
@ -1443,7 +1443,8 @@ static route_target_t get_route_target (
|
||||
{
|
||||
target = TARGET_SLAVE;
|
||||
}
|
||||
else if (QUERY_IS_TYPE(qtype, QUERY_TYPE_MASTER_READ) ||
|
||||
|
||||
if (QUERY_IS_TYPE(qtype, QUERY_TYPE_MASTER_READ) ||
|
||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_EXEC_STMT) ||
|
||||
/** Configured not to allow reading variables from slaves */
|
||||
(use_sql_variables_in == TYPE_MASTER &&
|
||||
@ -2587,8 +2588,8 @@ static bool route_single_stmt(
|
||||
rses_end_locked_router_action(rses);
|
||||
goto retblock;
|
||||
}
|
||||
GWBUF* wbuf = gwbuf_clone(querybuf);
|
||||
if ((ret = target_dcb->func.write(target_dcb, wbuf)) == 1)
|
||||
|
||||
if ((ret = target_dcb->func.write(target_dcb, gwbuf_clone(querybuf))) == 1)
|
||||
{
|
||||
backend_ref_t* bref;
|
||||
|
||||
@ -2602,7 +2603,6 @@ static bool route_single_stmt(
|
||||
}
|
||||
else
|
||||
{
|
||||
gwbuf_free(wbuf);
|
||||
LOGIF((LE|LT), (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Routing query failed.")));
|
||||
|
@ -610,9 +610,11 @@ char** tokenize_string(char* str)
|
||||
char** tmp = realloc(list,sizeof(char*)*(sz*2));
|
||||
if(tmp == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : realloc returned NULL: %s.",strerror(errno))));
|
||||
LOGFILE_ERROR,
|
||||
"Error : realloc returned NULL: %s.",
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
free(list);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -567,9 +567,11 @@ tokenize_string(char* str)
|
||||
char** tmp = realloc(list, sizeof(char*)*(sz * 2));
|
||||
if(tmp == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : realloc returned NULL: %s.", strerror(errno))));
|
||||
"Error : realloc returned NULL: %s.",
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
free(list);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
threads=4
|
||||
libdir=@CMAKE_INSTALL_PREFIX@/@MAXSCALE_LIBDIR@
|
||||
logdir=@CMAKE_INSTALL_PREFIX@/
|
||||
datadir=@CMAKE_INSTALL_PREFIX@/
|
||||
datadir=@CMAKE_INSTALL_PREFIX@/data/
|
||||
cachedir=@CMAKE_INSTALL_PREFIX@/
|
||||
language=@CMAKE_INSTALL_PREFIX@/lib/maxscale/
|
||||
piddir=@CMAKE_INSTALL_PREFIX@/
|
||||
|
@ -86,9 +86,10 @@ int skygw_rwlock_rdlock(
|
||||
rwlock->srw_rwlock_thr = pthread_self();
|
||||
} else {
|
||||
rwlock->srw_rwlock_thr = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
ss_dfprintf(stderr,
|
||||
"* pthread_rwlock_rdlock : %s\n",
|
||||
strerror(err));
|
||||
strerror_r(err, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@ -102,9 +103,10 @@ int skygw_rwlock_wrlock(
|
||||
rwlock->srw_rwlock_thr = pthread_self();
|
||||
} else {
|
||||
rwlock->srw_rwlock_thr = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
ss_dfprintf(stderr,
|
||||
"* pthread_rwlock_wrlock : %s\n",
|
||||
strerror(err));
|
||||
strerror_r(err, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@ -117,9 +119,10 @@ int skygw_rwlock_unlock(
|
||||
if (err == 0) {
|
||||
rwlock->srw_rwlock_thr = 0;
|
||||
} else {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
ss_dfprintf(stderr,
|
||||
"* pthread_rwlock_unlock : %s\n",
|
||||
strerror(err));
|
||||
strerror_r(err, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@ -133,10 +136,11 @@ int skygw_rwlock_destroy(
|
||||
/** Lock */
|
||||
if ((err = pthread_rwlock_wrlock(rwlock->srw_rwlock)) != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Error : pthread_rwlock_wrlock failed due to %d, %s.\n",
|
||||
err,
|
||||
strerror(err));
|
||||
strerror_r(err, errbuf, sizeof(errbuf)));
|
||||
goto retblock;
|
||||
}
|
||||
/** Clean the struct */
|
||||
@ -146,10 +150,11 @@ int skygw_rwlock_destroy(
|
||||
/** Destroy */
|
||||
if ((err = pthread_rwlock_destroy(rwlock->srw_rwlock)) != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Error : pthread_rwlock_destroy failed due to %d,%s\n",
|
||||
err,
|
||||
strerror(err));
|
||||
strerror_r(err, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -180,9 +185,10 @@ int skygw_rwlock_init(
|
||||
if (err != 0)
|
||||
{
|
||||
free(rwl);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
ss_dfprintf(stderr,
|
||||
"* Creating pthread_rwlock failed : %s\n",
|
||||
strerror(err));
|
||||
strerror_r(err, errbuf, sizeof(errbuf)));
|
||||
goto return_err;
|
||||
}
|
||||
*rwlock = rwl;
|
||||
@ -1143,11 +1149,12 @@ int skygw_thread_start(
|
||||
ss_dassert(err == 0);
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Starting file writer thread failed due error, "
|
||||
"%d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
goto return_err;
|
||||
}
|
||||
|
||||
@ -1323,12 +1330,13 @@ simple_mutex_t* simple_mutex_init(
|
||||
err = pthread_mutex_init(&sm->sm_mutex, NULL);
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Initializing simple mutex %s failed due error "
|
||||
"%d, %s\n",
|
||||
name,
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
perror("simple_mutex : ");
|
||||
|
||||
/** Write zeroes if flat, free otherwise. */
|
||||
@ -1362,12 +1370,13 @@ int simple_mutex_done(
|
||||
#if defined(NOT_USED)
|
||||
if (err != 0) {
|
||||
perror("simple_mutex : ");
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Destroying simple mutex %s failed due "
|
||||
"%d, %s\n",
|
||||
sm->sm_name,
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
goto return_err;
|
||||
}
|
||||
#endif
|
||||
@ -1409,12 +1418,13 @@ int simple_mutex_lock(
|
||||
}
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Locking simple mutex %s failed due error, "
|
||||
"%d, %s\n",
|
||||
sm->sm_name,
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
perror("simple_mutex : ");
|
||||
} else {
|
||||
/**
|
||||
@ -1439,12 +1449,13 @@ int simple_mutex_unlock(
|
||||
err = pthread_mutex_unlock(&sm->sm_mutex);
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Unlocking simple mutex %s failed due error "
|
||||
"%d, %s\n",
|
||||
sm->sm_name,
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
perror("simple_mutex : ");
|
||||
} else {
|
||||
/**
|
||||
@ -1473,11 +1484,12 @@ skygw_message_t* skygw_message_init(void)
|
||||
err = pthread_mutex_init(&(mes->mes_mutex), NULL);
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Initializing pthread mutex failed due error "
|
||||
"%d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
free(mes);
|
||||
mes = NULL;
|
||||
goto return_mes;
|
||||
@ -1485,11 +1497,12 @@ skygw_message_t* skygw_message_init(void)
|
||||
err = pthread_cond_init(&(mes->mes_cond), NULL);
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Initializing pthread cond var failed, "
|
||||
"due error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
pthread_mutex_destroy(&mes->mes_mutex);
|
||||
free(mes);
|
||||
mes = NULL;
|
||||
@ -1515,20 +1528,22 @@ void skygw_message_done(
|
||||
err = pthread_cond_destroy(&(mes->mes_cond));
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Destroying cond var failed due error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
err = pthread_mutex_destroy(&(mes->mes_mutex));
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Destroying pthread mutex failed, "
|
||||
"due error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
free(mes);
|
||||
@ -1544,11 +1559,12 @@ skygw_mes_rc_t skygw_message_send(
|
||||
err = pthread_mutex_lock(&(mes->mes_mutex));
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Locking pthread mutex failed, "
|
||||
"due to error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
goto return_mes_rc;
|
||||
}
|
||||
mes->mes_sent = true;
|
||||
@ -1560,21 +1576,23 @@ skygw_mes_rc_t skygw_message_send(
|
||||
}
|
||||
else
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Signaling pthread cond var failed, "
|
||||
"due to error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
err = pthread_mutex_unlock(&(mes->mes_mutex));
|
||||
|
||||
if (err != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Unlocking pthread mutex failed, "
|
||||
"due to error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
|
||||
return_mes_rc:
|
||||
@ -1590,11 +1608,12 @@ void skygw_message_wait(
|
||||
err = pthread_mutex_lock(&(mes->mes_mutex));
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Locking pthread mutex failed, "
|
||||
"due error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
|
||||
@ -1602,22 +1621,24 @@ void skygw_message_wait(
|
||||
err = pthread_cond_wait(&(mes->mes_cond), &(mes->mes_mutex));
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Locking pthread cond wait failed, "
|
||||
"due error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
}
|
||||
mes->mes_sent = false;
|
||||
err = pthread_mutex_unlock(&(mes->mes_mutex));
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Unlocking pthread mutex failed, "
|
||||
"due error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
}
|
||||
@ -1632,11 +1653,12 @@ void skygw_message_reset(
|
||||
err = pthread_mutex_lock(&(mes->mes_mutex));
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Locking pthread mutex failed, "
|
||||
"due error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
goto return_mes_rc;
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
@ -1644,11 +1666,12 @@ void skygw_message_reset(
|
||||
err = pthread_mutex_unlock(&(mes->mes_mutex));
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Unlocking pthread mutex failed, "
|
||||
"due error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
goto return_mes_rc;
|
||||
}
|
||||
return_mes_rc:
|
||||
@ -1896,11 +1919,12 @@ skygw_file_t* skygw_file_init(
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Opening file %s failed due %d, %s.\n",
|
||||
file->sf_fname,
|
||||
eno,
|
||||
strerror(eno));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
free(file);
|
||||
file = NULL;
|
||||
goto return_file;
|
||||
@ -1911,11 +1935,12 @@ skygw_file_t* skygw_file_init(
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\nError : Writing header of log file %s failed due %d, %s.\n",
|
||||
file->sf_fname,
|
||||
eno,
|
||||
strerror(eno));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
free(file);
|
||||
file = NULL;
|
||||
goto return_file;
|
||||
@ -1937,13 +1962,14 @@ skygw_file_t* skygw_file_init(
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"failed to create symlink %s -> "
|
||||
"%s due %d, %s. Exiting.",
|
||||
fname,
|
||||
symlinkname,
|
||||
eno,
|
||||
strerror(eno));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
free(file);
|
||||
file = NULL;
|
||||
goto return_file;
|
||||
@ -1986,11 +2012,12 @@ void skygw_file_close(
|
||||
|
||||
if ((err = fclose(file->sf_file)) != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Closing file %s failed due to %d, %s.\n",
|
||||
file->sf_fname,
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2031,8 +2058,9 @@ char* replace_literal(
|
||||
|
||||
if (search_re == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr, "Regex memory allocation failed : %s\n",
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
newstr = haystack;
|
||||
goto retblock;
|
||||
}
|
||||
@ -2043,8 +2071,9 @@ char* replace_literal(
|
||||
|
||||
if (newstr == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr, "Regex memory allocation failed : %s\n",
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
free(search_re);
|
||||
free(newstr);
|
||||
newstr = haystack;
|
||||
|
@ -1,6 +1,13 @@
|
||||
#if !defined(SKYGW_UTILS_H)
|
||||
#define SKYGW_UTILS_H
|
||||
|
||||
/*
|
||||
* We need a common.h file that is included by every component.
|
||||
*/
|
||||
#if !defined(STRERROR_BUFLEN)
|
||||
#define STRERROR_BUFLEN 512
|
||||
#endif
|
||||
|
||||
#define MLIST
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (a<b ? a : b)
|
||||
|
Loading…
x
Reference in New Issue
Block a user