Skip to content

Commit

Permalink
Merge pull request #15 from boomfish/feature/systemd
Browse files Browse the repository at this point in the history
Add files to run clustercheck under systemd
  • Loading branch information
olafz authored Jun 13, 2018
2 parents 14d829c + 4ab9275 commit d5da8be
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ Also, you should add the mysqlchk service to `/etc/services` before restarting x

Clustercheck will now listen on port 9200 after xinetd restart, and HAproxy is ready to check MySQL via HTTP poort 9200.

## Setup with systemd ##
This setup will register a socket on TCP port 9200 and an associated instantiated service with systemd. Connections to the socket will be forwarded to the clustercheck script from this repository to report the status of the node.

First, create a clustercheckuser that will be doing the checks.

mysql> GRANT PROCESS ON *.* TO 'clustercheckuser'@'localhost' IDENTIFIED BY 'clustercheckpassword!'

Copy the clustercheck from the repository to `/usr/bin` and make it executable. Then copy the `mysqlck.socket` and `mysqlchk@.service` files (under `systemd`) in the repository to `/usr/lib/systemd/system` and make them world-readable.

To activate the socket, run the following commands:

# systemctl enable mysqlchk.socket
# systemctl start mysqlchk.socket

Systemd will now service requests to port 9200 with the clustercheck script, and HAproxy is ready to check MySQL via HTTP port 9200.

## Setup with shell return values ##
If you do not want to use the setup with xinetd, you can also execute `clustercheck` on the commandline and check for the return value.

Expand Down
9 changes: 9 additions & 0 deletions systemd/mysqlchk.socket
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Percona XtraDB Cluster node check socket

[Socket]
ListenStream=9200
Accept=yes

[Install]
WantedBy=sockets.target
6 changes: 6 additions & 0 deletions systemd/mysqlchk@.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
Description=Percona XtraDB Cluster node check service

[Service]
ExecStart=-/usr/bin/clustercheck
StandardInput=socket

0 comments on commit d5da8be

Please sign in to comment.