MXS-1803: Simplify docker image

The docker image now simply installs the latest MaxScale version instead
of building it. This significantly reduces the amount of maintenance that
the image requires.

Updated the configurations to allow runtime definition of servers and
updated README.md to reflect the changes in the files. Pointed links to
2.2 instead of develop. Removed text from the readme that was not strictly
related to running the MaxScale image.
This commit is contained in:
Markus Mäkelä
2018-04-16 08:45:14 +03:00
parent 890902e338
commit 41626202ed
4 changed files with 51 additions and 124 deletions

View File

@ -1,53 +1,7 @@
# This Dockerfile builds an image for MariaDB MaxScale: # Dockerfile for the 2.2 GA version of MariaDB MaxScale
# https://mariadb.com/products/technology/maxscale FROM centos:7
# The example configuration file maxscale.cnf should be in the build directory
# when building the image.
FROM alpine:latest
# Packages required for building MaxScale and Avro-C
ARG DEPENDENCIES_PKGS="bash bison cmake curl flex gcc git gnutls gnutls-dev g++ \
jansson jansson-dev libedit libedit-dev libgcrypt libgcrypt-dev libstdc++ lua \
lua-dev make ncurses ncurses-dev openssl openssl-dev perl sqlite sqlite-dev \
sqlite-libs tcl-dev util-linux-dev xz xz-dev"
# Packages that can be removed after build
ARG REM_PKGS="bison bash cmake flex gcc git gnutls-dev g++ jansson-dev \
libedit-dev libgcrypt-dev lua-dev make ncurses-dev openssl-dev perl sqlite-dev \
tcl-dev xz-dev"
# MaxScale-specific parameters
ARG MS_DIR=/MaxScale_workdir
ARG MS_CMAKE_PARS="-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DWITH_SCRIPTS=N -DTARGET_COMPONENT=all"
ARG MS_BRANCH=develop
ARG MS_REPO=https://github.com/mariadb-corporation/MaxScale.git
# Avro-specific parameters
ARG AV_DIR=/Avro_workdir
ARG AV_PREF=avro-c-1.8.2
ARG AV_ARCH=$AV_PREF.tar.gz
ARG AV_URL=ftp://ftp.funet.fi/pub/mirrors/apache.org/avro/avro-1.8.2/c/$AV_ARCH
ARG AV_CMAKE_PARS="-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_C_FLAGS=-fPIC -DCMAKE_CXX_FLAGS=-fPIC"
RUN apk -U add $DEPENDENCIES_PKGS && \
mkdir $MS_DIR && mkdir $AV_DIR && mkdir $MS_DIR/Build && mkdir $AV_DIR/Build && \
cd $AV_DIR && \
# Download Avro-C, build and install
curl --output $AV_ARCH $AV_URL && \
tar -zxvf $AV_ARCH && cd Build && \
cmake $AV_CMAKE_PARS ../$AV_PREF && \
make install && \
cd $MS_DIR && \
# Download MaxScale, build and install
git clone --depth 1 --branch $MS_BRANCH $MS_REPO && cd Build && \
cmake $MS_CMAKE_PARS ../MaxScale && \
make install && (./postinst || true) && \
# Remove unneeded packages and work directories
apk del $REM_PKGS && \
cd / && rm -rf $MS_DIR $AV_DIR
RUN curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash && yum -y install maxscale
COPY ./maxscale.cnf /etc/ COPY ./maxscale.cnf /etc/
ENTRYPOINT ["maxscale", "-d"] ENTRYPOINT ["maxscale", "-d", "-U", "maxscale"]
CMD ["-lstdout"] CMD ["-lstdout"]

View File

@ -1,60 +1,48 @@
# MariaDB MaxScale Docker image # MariaDB MaxScale Docker image
This Docker image runs MariaDB MaxScale. The MaxScale version used to build the This Docker image runs the latest GA version of MariaDB MaxScale.
image is an unreleased development build so this should not be used for a
production system. ## Building
Run the following command to build the image.
```
sudo docker build -t maxscale .
```
## Usage ## Usage
MaxScale is a proxy so its configuration is dependent on the use case and there You must mount your configuration file into `/etc/maxscale.cnf.d/`. To do
is no generally valid default. The configuration file inside the image (shown in this, pass it as an argument to the `-v` option:
[Default configuration](#default-configuration)) includes only the bare minimum
to start MaxScale and has no useful services. The simplest way to add more to
the configuration is to place another file (*my_config.cnf*) in a directory
(*/my_dir/*) and then mount the directory to */etc/maxscale.cnf.d/* inside the
container when starting it. MaxScale will add any files inside
*/etc/maxscale.cnf.d/* to its configuration.
``` ```
docker run --network host --rm -v /my_dir:/etc/maxscale.cnf.d/ maxscale docker run -v $PWD/my-maxscale.cnf:/etc/maxscale.cnf.d/my-maxscale.cnf maxscale:latest
``` ```
In the examples, the Docker network mode is set to *host* so that the container By default, MaxScale runs with the `-l stdout` arguments. To explicitly
has full network access (`--network host`). define a configuration file, use the `-f /path/to/maxscale.cnf` argument
and add `-l stdout` after it.
To replace the configuration file completely, start MaxScale with `-f <path_to_config>`.
Adding custom options removes all default options defined in the image. When
adding new flags to MaxScale, one should add back `-l stdout` to print log to
stdout.
``` ```
docker run --network host --rm -v /my_dir:/container_dir maxscale -l stdout -f /container_dir/my_config.cnf docker run --network host --rm -v /my_dir:/container_dir maxscale -f /path/to/maxscale.cnf -l stdout
```
To save logs to */my_dir*, remove the `-l stdout` and set */container_dir* as
log directory with the option `-L /container_dir`.
```
docker run --network host --rm -v /my_dir:/container_dir maxscale -L /container_dir -f /container_dir/my_config.cnf
``` ```
## Default configuration ## Default configuration
``` ```
# MaxScale documentation on GitHub: # MaxScale documentation on GitHub:
# https://github.com/mariadb-corporation/MaxScale/blob/develop/Documentation/Documentation-Contents.md # https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Documentation-Contents.md
# Complete list of configuration options: # Complete list of configuration options:
# https://github.com/mariadb-corporation/MaxScale/blob/develop/Documentation/Getting-Started/Configuration-Guide.md # https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Getting-Started/Configuration-Guide.md
# Global parameters # Global parameters
[maxscale] [maxscale]
threads=2 threads=auto
# This service enables the use of the MaxAdmin interface # This service enables the use of the MaxAdmin interface
# MaxScale administration guide: # MaxScale administration guide:
# https://github.com/mariadb-corporation/MaxScale/blob/develop/Documentation/Reference/MaxAdmin.md # https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Reference/MaxAdmin.md
[MaxAdmin-Service] [MaxAdmin-Service]
type=service type=service
router=cli router=cli
@ -66,27 +54,21 @@ protocol=maxscaled
socket=default socket=default
``` ```
## Example configuration extension ## Example base configuration
``` ```
# Server definitions # Global parameters
# Set the address of the server to the network address of a MySQL server. [maxscale]
threads=auto
[server1]
type=server
address=127.0.0.1
port=3306
protocol=MySQLBackend
# 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:
# https://github.com/mariadb-corporation/MaxScale/blob/develop/Documentation/Monitors/MySQL-Monitor.md # https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Monitors/MariaDB-Monitor.md
[MySQL-Monitor] [MariaDB-Monitor]
type=monitor type=monitor
module=mysqlmon module=mariadbmon
servers=server1
user=myuser user=myuser
passwd=mypwd passwd=mypwd
monitor_interval=1000 monitor_interval=1000
@ -95,23 +77,21 @@ monitor_interval=1000
# 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.
# ReadConnRoute documentation: # ReadConnRoute documentation:
# https://github.com/mariadb-corporation/MaxScale/blob/develop/Documentation/Routers/ReadConnRoute.md # https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Routers/ReadConnRoute.md
[Read-Only-Service] [Read-Only-Service]
type=service type=service
router=readconnroute router=readconnroute
servers=server1
user=myuser user=myuser
passwd=mypwd passwd=mypwd
router_options=slave router_options=slave
# ReadWriteSplit documentation: # ReadWriteSplit documentation:
# https://github.com/mariadb-corporation/MaxScale/blob/develop/Documentation/Routers/ReadWriteSplit.md # https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Routers/ReadWriteSplit.md
[Read-Write-Service] [Read-Write-Service]
type=service type=service
router=readwritesplit router=readwritesplit
servers=server1
user=myuser user=myuser
passwd=mypwd passwd=mypwd
max_slave_connections=100% max_slave_connections=100%
@ -131,3 +111,10 @@ service=Read-Write-Service
protocol=MySQLClient protocol=MySQLClient
port=4006 port=4006
``` ```
For base configurations, servers are defined at runtime. Run the following
command to create a server and link it into all services and monitors.
```
maxctrl create server <name> <host> <port> --monitors MariaDB-Monitor --services Read-Only-Service Read-Write-Service
```

View File

@ -1,21 +1,15 @@
# Server definitions # Global parameters
# Set the address of the server to the network address of a MySQL server. [maxscale]
threads=auto
[server1]
type=server
address=127.0.0.1
port=3306
protocol=MySQLBackend
# 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:
# https://github.com/mariadb-corporation/MaxScale/blob/develop/Documentation/Monitors/MySQL-Monitor.md # https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Monitors/MariaDB-Monitor.md
[MySQL-Monitor] [MariaDB-Monitor]
type=monitor type=monitor
module=mysqlmon module=mariadbmon
servers=server1
user=myuser user=myuser
passwd=mypwd passwd=mypwd
monitor_interval=1000 monitor_interval=1000
@ -24,23 +18,21 @@ monitor_interval=1000
# 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.
# ReadConnRoute documentation: # ReadConnRoute documentation:
# https://github.com/mariadb-corporation/MaxScale/blob/develop/Documentation/Routers/ReadConnRoute.md # https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Routers/ReadConnRoute.md
[Read-Only-Service] [Read-Only-Service]
type=service type=service
router=readconnroute router=readconnroute
servers=server1
user=myuser user=myuser
passwd=mypwd passwd=mypwd
router_options=slave router_options=slave
# ReadWriteSplit documentation: # ReadWriteSplit documentation:
# https://github.com/mariadb-corporation/MaxScale/blob/develop/Documentation/Routers/ReadWriteSplit.md # https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Routers/ReadWriteSplit.md
[Read-Write-Service] [Read-Write-Service]
type=service type=service
router=readwritesplit router=readwritesplit
servers=server1
user=myuser user=myuser
passwd=mypwd passwd=mypwd
max_slave_connections=100% max_slave_connections=100%

View File

@ -1,18 +1,12 @@
# MaxScale documentation on GitHub: # MaxScale documentation on GitHub:
# https://github.com/mariadb-corporation/MaxScale/blob/develop/Documentation/Documentation-Contents.md # https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Documentation-Contents.md
# Complete list of configuration options: # Complete list of configuration options:
# https://github.com/mariadb-corporation/MaxScale/blob/develop/Documentation/Getting-Started/Configuration-Guide.md # https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Getting-Started/Configuration-Guide.md
# Global parameters
[maxscale]
threads=2
# This service enables the use of the MaxAdmin interface # This service enables the use of the MaxAdmin interface
# MaxScale administration guide: # MaxScale administration guide:
# https://github.com/mariadb-corporation/MaxScale/blob/develop/Documentation/Reference/MaxAdmin.md # https://github.com/mariadb-corporation/MaxScale/blob/2.2/Documentation/Reference/MaxAdmin.md
[MaxAdmin-Service] [MaxAdmin-Service]
type=service type=service
router=cli router=cli