Code Monkey home page Code Monkey logo

docker-percona's Introduction

Percona MySQL server with Percona Tools, Replication Support & Shared Volume Initialization

This Dockerfile has full test coverage. You can run the specs through bin/spec. A caveat is that some of these specs rely on boot2docker. This is due to this container being developed on OS X. Before running the spec do bundle install and docker pull klevo/test_mysql_master.

To run a container with a mysql data dir mounted for persistence:

docker run -d --name percona \
  -v /home/docker/percona-data:/var/lib/mysql \
  -e MYSQL_ROOT_PASSWORD=mypass \
  -p 3308:3306 \
  klevo/percona

Hot Backups

Percona XtraBackup included. To do a hot backup on a running container:

docker exec -i -t percona innobackupex /backups
docker exec -i -t percona innobackupex --apply-log /backups/2014-12-16_14-44-35

Replication Over SSH Tunnel

This container includes autossh which creates a tunnel to the master server if the below env variables are specified. The master must have a tunnels user account available which is reacheable through ssh with the slave's private key, which is mounted in the example below. Run a container with replication enabled like this:

docker run -d --name db1_slave \
  -v /home/docker/percona-data:/var/lib/mysql \
  -v /tunnels_id_rsa:/tunnels_id_rsa \
  -e MYSQL_ROOT_PASSWORD=mypass \
  -e REPLICATION_SLAVE_MASTER_HOST=someip \
  -e REPLICATION_SLAVE_REMOTE_PORT=3306 \
  -e REPLICATION_SLAVE_USER=slave_db1 \
  -e REPLICATION_SLAVE_PASSWORD=slaveuserpass \
  -p 3308:3306 \
  klevo/percona

Then get the SQL for master to set up the replication:

docker exec -i -t db1_slave replication_master_sql

outputs something like:

GRANT REPLICATION SLAVE ON *.* TO 'slave_db1'@'localhost' IDENTIFIED BY 'slaveuserpass';

Finally start replication on the slave (execute this once master was configured with the above sql):

docker exec -i -t db1_slave start_replication mysql-bin.000001 107

Runs something like this in the background on the slave container:

STOP SLAVE;
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='slave_db1', MASTER_PASSWORD='slaveuserpass', MASTER_PORT=3307, MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=107;
START SLAVE;

This was fun to write a spec for :)

Create a master db container for testing

If you want to test the replication over the ssh tunnel with two docker containers, use my testing image: klevo/test_mysql_master and check the README.

docker-percona's People

Contributors

klevo avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.