Add basic docker-compose setup

The setup contains a three node master-slave cluster with both
readwritesplit and readconnroute.

Removed the duplication of the configuration files in the README and
provided links instead.
This commit is contained in:
Markus Mäkelä
2018-04-16 14:58:22 +03:00
parent ff7f06cd66
commit 0adb4b6ffa
6 changed files with 103 additions and 90 deletions

View File

@ -4,10 +4,10 @@ This Docker image runs the latest GA version of MariaDB MaxScale.
## Building
Run the following command to build the image.
Run the following command in this directory to build the image.
```
sudo docker build -t maxscale .
docker build -t maxscale .
```
## Usage
@ -29,92 +29,30 @@ docker run --network host --rm -v /my_dir:/container_dir maxscale -f /path/to/ma
## Default configuration
```
# MaxScale documentation on GitHub:
# https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Documentation-Contents.md
The default configuration for the MaxScale docker image can be found in
[this configuration file](./maxscale.cnf).
# Complete list of configuration options:
# https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Getting-Started/Configuration-Guide.md
## MaxScale docker-compose setup
# Global parameters
[maxscale]
threads=auto
# This service enables the use of the MaxAdmin interface
# MaxScale administration guide:
# https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Reference/MaxAdmin.md
[MaxAdmin-Service]
type=service
router=cli
[MaxAdmin-Listener]
type=listener
service=MaxAdmin-Service
protocol=maxscaled
socket=default
```
## Example base configuration
[The MaxScale docker-compose setup](./docker-compose.yml) contains MaxScale
configured with a three node master-slave cluster. To start it, run the
following commands in this directory.
```
# Global parameters
[maxscale]
threads=auto
# Monitor for the servers
# This will keep MaxScale aware of the state of the servers.
# MySQL Monitor documentation:
# https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Monitors/MariaDB-Monitor.md
[MariaDB-Monitor]
type=monitor
module=mariadbmon
user=myuser
passwd=mypwd
monitor_interval=1000
# Service definitions
# Service Definition for a read-only service and a read/write splitting service.
# ReadConnRoute documentation:
# https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Routers/ReadConnRoute.md
[Read-Only-Service]
type=service
router=readconnroute
user=myuser
passwd=mypwd
router_options=slave
# ReadWriteSplit documentation:
# https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Routers/ReadWriteSplit.md
[Read-Write-Service]
type=service
router=readwritesplit
user=myuser
passwd=mypwd
max_slave_connections=100%
# Listener definitions for the services
# Listeners represent the ports the services will listen on.
[Read-Only-Listener]
type=listener
service=Read-Only-Service
protocol=MySQLClient
port=4008
[Read-Write-Listener]
type=listener
service=Read-Write-Service
protocol=MySQLClient
port=4006
docker-compose build
docker-compose up -d
```
For base configurations, servers are defined at runtime. Run the following
command to create a server and link it into all services and monitors.
After MaxScale and the servers have started (takes a few minutes), you can find
the readwritesplit router on port 4006 and the readconnroute on port 4008. The
user `maxuser` with the password `maxpwd` can be used to test the cluster.
You can edit the [`maxscale.cnf.d/example.cnf`](./maxscale.cnf.d/example.cnf)
file and recreate the MaxScale container to change the configuration.
To stop the containers, execute the following command. Optionally, use the -v
flag to also remove the volumes.
```
maxctrl create server <name> <host> <port> --monitors MariaDB-Monitor --services Read-Only-Service Read-Write-Service
docker-compose down
```