Skip to content

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

License

Notifications You must be signed in to change notification settings

renecannao/ProxySQL-Tutorial-PLSC2018

 
 

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 1.4.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)
  • 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)

Step-by-step instructions to install dependencies.

On Ubuntu Xenial:

apt-get remove docker docker-engine docker.io
apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -

add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install docker-ce jq mysql-client-5.7 docker-compose sysbench git
wget https://github.com/github/orchestrator/releases/download/v3.0.10/orchestrator-client_3.0.10_amd64.deb
dpkg -i orchestrator-client_3.0.10_amd64.deb

git clone https://github.com/renecannao/ProxySQL-Tutorial-PLSC2018.git
cd ProxySQL-Tutorial-PLSC2018
./docker-compose-init.bash nobench

On CentOS 7:

yum remove docker docker-client docker-client-latest docker-common docker-latest \
   docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager --enable docker-ce-test

yum install epel-release
yum install -y python-pip
pip install --upgrade pip

yum install docker-ce mysql sysbench git jq
rpm -ihv https://github.com/github/orchestrator/releases/download/v3.0.10/orchestrator-client-3.0.10-1.x86_64.rpm
pip install docker-compose
service docker start


git clone https://github.com/renecannao/ProxySQL-Tutorial-PLSC2018.git
cd ProxySQL-Tutorial-PLSC2018
./docker-compose-init.bash nobench

In addition if you prefer not to use docker-compose you'll also find some scripts for launching the MySQL and ProxySQL instances without docker-compose in the legacy/ directory:

  • legacy/docker-mysql.bash
  • legacy/docker-proxysql.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 100.0%