Skip to content

Docker cluster for testing with ProxySQL and MySQL (docker-compose)

License

Notifications You must be signed in to change notification settings

sysown/docker-mysql-proxysql

 
 

Repository files navigation

ProxySQL / Orchestrator / MySQL Docker Testing

This repository contains a docker-compose.yml used to launch a small cluster consisting of 3x MySQL 5.7 containers (1x Master and 2x Slaves), 3x Orchestrator nodes connected via RAFT and a ProxySQL 2.x container all connected via a frontend / backend network. ProxySQL is automatically configured with 2x hostgroups, a writer hostgroup used as the default hostgroup and a reader hostgroup for all SELECT statements.

Once the cluster is initialised, replication is started and a sysbench dataset is prepared. After that a short sysbench test is executed automatically. To launch a new cluster for the FIRST TIME please execute the following command:

# To start with benchmarks:
sudo ./docker-compose-init.bash

# To skip benchmarking:
sudo ./docker-compose-init.bash nobench

Thereafter you can just start and stop the cluster with regular docker-compose commands, for example:

sudo docker-compose stop
sudo docker-compose start

To stop the instances and destroy the containers execute:

sudo ./docker-compose-destroy.bash

The MySQL, Orchestrator and ProxySQL hosts have separate directories with their respective configuration in the conf directory. You can override any of the MySQL 5.7 variables by editing the my.cnf located in the respective subdirectory under conf for each container (i.e. conf/mysql/mysql1/my.cnf, conf/mysql/mysql2/my.cnf or conf/mysql/mysql3/my.cnf). Its also possible to edit the ProxySQL and Orchestrator config files as needed.

Note that you'll want the following pre-requisites installed on your host machine:

  • docker-ce / docker-ee (17.12+ required, see https://docs.docker.com/engine/install)
  • docker-compose (1.19+ required)
  • mysql-client (5.7+ required)
  • sysbench (1.0.12+ recommended if benchmarking)
  • orchestrator-client (3.0.8+ recommended if administering Orchestrator via CLI)
  • jq (required for Orchestrator)

Sample instructions for installing on Ubuntu 20.04:

# Install pre-requisites for Docker-CE & toolkit
sudo apt-get install apt-transport-https ca-certificates curl git gnupg jq lsb-release sysbench
git clone https://github.com/sysown/docker-mysql-proxysql.git

# Install Docker-CE keyring
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo   "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Install Docker-CE packages
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

# Install Orchestrator client package
wget https://github.com/openark/orchestrator/releases/download/v3.2.4/orchestrator-client_3.2.4_amd64.deb
sudo dpkg -i ./orchestrator-client_3.2.4_amd64.deb 

# Start containers
cd docker-mysql-proxysql/
./docker-compose-init.bash 

If you would like to run the benchmark just execute:

bin/docker-benchmark.bash

This script will drop / create the sysbench database, create a test dataset and run the benchmark. You can edit the file and tailor this behaviour as you would like. Please be aware that this is called during the provisioning stage so its best to make a copy of the file with your own benchmarks.

About

Docker cluster for testing with ProxySQL and MySQL (docker-compose)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 97.4%
  • Dockerfile 2.6%