Giter Club home page Giter Club logo

mysql-master-slave's Introduction

MySQL master/slave example + using ProxySQL service as MySQL Balancer

Build status:

Build Status


Requirements

  1. docker-engine
  2. docker-compose (that supports docker-compose.yml file of version 3)

Usage

$ docker-compose build
$ docker-compose up -d
$ docker-compose ps
            Name                          Command               State            Ports          
-----------------------------------------------------------------------------------------------
mysqlhighload_configurator_1   docker-entrypoint.sh /conf ...   Exit 0                          
mysqlhighload_master_1         docker-entrypoint.sh --cha ...   Up       3306/tcp               
mysqlhighload_phpmyadmin_1     /run.sh phpmyadmin               Up       0.0.0.0:8080->80/tcp   
mysqlhighload_proxysql_1       /entrypoint.sh proxysql -c ...   Up       0.0.0.0:3306->6033/tcp
mysqlhighload_slave_1          docker-entrypoint.sh --cha ...   Up       3306/tcp         

After successfully deployment, user can open phpmyadmin to check connectivity with master and slave MySQL servers.

phpmyadmin is accessible by url: http://localhost:8080/


Project scheme

scheme.png


Running tests

Tests items:

  • Creating test table on master servers
  • Instert new record in previously created table
  • Testing SQL queries through the ProxySQL service (INSERT and SELECT)
  • Drop test table on master server

All these actions sequentally will be checked on slave server in 1 second after execution query on master.

To launch unit tests for testing MySQL master/slave configuration, please execute:

$ docker-compose run --rm miscellaneous /tests/run.sh

...
Waiting for MySQL on slave will be ready. Ready for testing.
Checking all requirements for running tests against this project.

Running tests in tests.sh
Checking environment. Done.
Running test_00_check_slave_status... SUCCESS
Running test_01_replication_create_table... SUCCESS
Running test_02_replication_compare_tables_names... SUCCESS
Running test_03_replication_insert... SUCCESS
Running test_04_proxysql_check_insert... SUCCESS
Running test_05_proxysql_check_select_balancing... Was matched 7/10 times. SUCCESS
Running test_06_replication_drop_table... SUCCESS

Custom configuration

It is possible to enable custom mysql configuration for each type of nodes. Locate custom configuration files in special folder:

  1. ./conf.d/master - for master nodes
  2. ./conf.d/slave - for slave nodes

Also if it is require to create custom DB schemes, it is possible to locate them by path: ./scripts/docker-entrypoint-initdb.d/master/custom.sql. It can be any file, with SQL code inside but it has to have .sql extension.

mysql-master-slave's People

Contributors

mdihtyar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mysql-master-slave's Issues

Changing variable PROXYSQL_DB_PORT does not take any effect to service.

Expected behaviour

ProxySQL has to listen specific port as MySQL access point

Actual behaviour

Service is still working on 6033 port

How can be reproduced the issue on clean environment?

Changing PROXYSQL_DB_PORT variable only changes ProxySQL external bind port, but internal service keep working on standard port 6033

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.