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:
102
docker/README.md
102
docker/README.md
@ -4,10 +4,10 @@ This Docker image runs the latest GA version of MariaDB MaxScale.
|
|||||||
|
|
||||||
## Building
|
## 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
|
## Usage
|
||||||
@ -29,92 +29,30 @@ docker run --network host --rm -v /my_dir:/container_dir maxscale -f /path/to/ma
|
|||||||
|
|
||||||
## Default configuration
|
## Default configuration
|
||||||
|
|
||||||
```
|
The default configuration for the MaxScale docker image can be found in
|
||||||
# MaxScale documentation on GitHub:
|
[this configuration file](./maxscale.cnf).
|
||||||
# https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Documentation-Contents.md
|
|
||||||
|
|
||||||
# Complete list of configuration options:
|
## MaxScale docker-compose setup
|
||||||
# https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Getting-Started/Configuration-Guide.md
|
|
||||||
|
|
||||||
# Global parameters
|
[The MaxScale docker-compose setup](./docker-compose.yml) contains MaxScale
|
||||||
[maxscale]
|
configured with a three node master-slave cluster. To start it, run the
|
||||||
threads=auto
|
following commands in this directory.
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
```
|
```
|
||||||
# Global parameters
|
docker-compose build
|
||||||
[maxscale]
|
docker-compose up -d
|
||||||
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
|
|
||||||
```
|
```
|
||||||
|
|
||||||
For base configurations, servers are defined at runtime. Run the following
|
After MaxScale and the servers have started (takes a few minutes), you can find
|
||||||
command to create a server and link it into all services and monitors.
|
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
|
||||||
```
|
```
|
||||||
|
34
docker/docker-compose.yml
Normal file
34
docker/docker-compose.yml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
version: '2'
|
||||||
|
services:
|
||||||
|
master:
|
||||||
|
image: mariadb:10.2
|
||||||
|
environment:
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: Y
|
||||||
|
volumes:
|
||||||
|
- ./sql/master:/docker-entrypoint-initdb.d
|
||||||
|
command: mysqld --log-bin=mariadb-bin --binlog-format=ROW --server-id=3000
|
||||||
|
|
||||||
|
slave1:
|
||||||
|
image: mariadb:10.2
|
||||||
|
environment:
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: Y
|
||||||
|
volumes:
|
||||||
|
- ./sql/slave:/docker-entrypoint-initdb.d
|
||||||
|
command: mysqld --log-bin=mariadb-bin --binlog-format=ROW --server-id=3001
|
||||||
|
|
||||||
|
slave2:
|
||||||
|
image: mariadb:10.2
|
||||||
|
environment:
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: Y
|
||||||
|
volumes:
|
||||||
|
- ./sql/slave:/docker-entrypoint-initdb.d
|
||||||
|
command: mysqld --log-bin=mariadb-bin --binlog-format=ROW --server-id=3002
|
||||||
|
|
||||||
|
maxscale:
|
||||||
|
build: .
|
||||||
|
container_name: maxscale
|
||||||
|
volumes:
|
||||||
|
- ./maxscale.cnf.d:/etc/maxscale.cnf.d
|
||||||
|
ports:
|
||||||
|
- "4006:4006"
|
||||||
|
- "4008:4008"
|
@ -2,6 +2,24 @@
|
|||||||
[maxscale]
|
[maxscale]
|
||||||
threads=auto
|
threads=auto
|
||||||
|
|
||||||
|
[server1]
|
||||||
|
type=server
|
||||||
|
address=master
|
||||||
|
port=3306
|
||||||
|
protocol=MariaDBBackend
|
||||||
|
|
||||||
|
[server2]
|
||||||
|
type=server
|
||||||
|
address=slave1
|
||||||
|
port=3306
|
||||||
|
protocol=MariaDBBackend
|
||||||
|
|
||||||
|
[server3]
|
||||||
|
type=server
|
||||||
|
address=slave2
|
||||||
|
port=3306
|
||||||
|
protocol=MariaDBBackend
|
||||||
|
|
||||||
# Monitor for the servers
|
# Monitor for the servers
|
||||||
# This will keep MaxScale aware of the state of the servers.
|
# This will keep MaxScale aware of the state of the servers.
|
||||||
# MySQL Monitor documentation:
|
# MySQL Monitor documentation:
|
||||||
@ -10,9 +28,10 @@ threads=auto
|
|||||||
[MariaDB-Monitor]
|
[MariaDB-Monitor]
|
||||||
type=monitor
|
type=monitor
|
||||||
module=mariadbmon
|
module=mariadbmon
|
||||||
user=myuser
|
servers=server1,server2,server3
|
||||||
passwd=mypwd
|
user=maxuser
|
||||||
monitor_interval=1000
|
passwd=maxpwd
|
||||||
|
monitor_interval=2000
|
||||||
|
|
||||||
# Service definitions
|
# Service definitions
|
||||||
# Service Definition for a read-only service and a read/write splitting service.
|
# Service Definition for a read-only service and a read/write splitting service.
|
||||||
@ -23,8 +42,9 @@ monitor_interval=1000
|
|||||||
[Read-Only-Service]
|
[Read-Only-Service]
|
||||||
type=service
|
type=service
|
||||||
router=readconnroute
|
router=readconnroute
|
||||||
user=myuser
|
servers=server1,server2,server3
|
||||||
passwd=mypwd
|
user=maxuser
|
||||||
|
passwd=maxpwd
|
||||||
router_options=slave
|
router_options=slave
|
||||||
|
|
||||||
# ReadWriteSplit documentation:
|
# ReadWriteSplit documentation:
|
||||||
@ -33,9 +53,9 @@ router_options=slave
|
|||||||
[Read-Write-Service]
|
[Read-Write-Service]
|
||||||
type=service
|
type=service
|
||||||
router=readwritesplit
|
router=readwritesplit
|
||||||
user=myuser
|
servers=server1,server2,server3
|
||||||
passwd=mypwd
|
user=maxuser
|
||||||
max_slave_connections=100%
|
passwd=maxpwd
|
||||||
|
|
||||||
# Listener definitions for the services
|
# Listener definitions for the services
|
||||||
# Listeners represent the ports the services will listen on.
|
# Listeners represent the ports the services will listen on.
|
10
docker/sql/master/users.sql
Normal file
10
docker/sql/master/users.sql
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
RESET MASTER;
|
||||||
|
CREATE DATABASE test;
|
||||||
|
|
||||||
|
CREATE USER 'maxuser'@'127.0.0.1' IDENTIFIED BY 'maxpwd';
|
||||||
|
CREATE USER 'maxuser'@'%' IDENTIFIED BY 'maxpwd';
|
||||||
|
GRANT ALL ON *.* TO 'maxuser'@'127.0.0.1' WITH GRANT OPTION;
|
||||||
|
GRANT ALL ON *.* TO 'maxuser'@'%' WITH GRANT OPTION;
|
||||||
|
|
||||||
|
SET GLOBAL max_connections=10000;
|
||||||
|
SET GLOBAL gtid_strict_mode=ON;
|
4
docker/sql/slave/replication.sql
Normal file
4
docker/sql/slave/replication.sql
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
CHANGE MASTER TO MASTER_HOST='master', MASTER_PORT=3306, MASTER_USER='maxuser', MASTER_PASSWORD='maxpwd', MASTER_LOG_POS=4, MASTER_LOG_FILE='mariadb-bin.000001', MASTER_CONNECT_RETRY=1;
|
||||||
|
START SLAVE;
|
||||||
|
SET GLOBAL max_connections=10000;
|
||||||
|
SET GLOBAL gtid_strict_mode=ON;
|
7
docker/sql/users.sql
Normal file
7
docker/sql/users.sql
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
RESET MASTER;
|
||||||
|
|
||||||
|
CREATE USER 'maxuser'@'127.0.0.1' IDENTIFIED BY 'maxpwd';
|
||||||
|
GRANT ALL ON *.* TO 'maxuser'@'127.0.0.1' WITH GRANT OPTION;
|
||||||
|
|
||||||
|
CREATE USER 'maxuser'@'%' IDENTIFIED BY 'maxpwd';
|
||||||
|
GRANT ALL ON *.* TO 'maxuser'@'%' WITH GRANT OPTION;
|
Reference in New Issue
Block a user