GithubHelp home page GithubHelp logo

bendinrs / vagrant-mysql-master-slave-replication Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chrisleekr/vagrant-mysql-master-slave-replication

0.0 0.0 0.0 675 KB

Vagrantfile to spin up MySQL Master-Slave replication

Shell 100.00%

vagrant-mysql-master-slave-replication's Introduction

vagrant-mysql-master-slave-replication

Vagrantfile to spin up MySQL Master-Slave replication with persistent data storage

Note: This project is created for just practice. Not suitable for production use.

Prerequisites

Usage

    $ git clone https://github.com/chrisleekr/vagrant-mysql-master-slave-replication.git
    $ vagrant up

After vagrant machines are running, you can connect MySQL to:

  • Master machine: 192.168.100.11
  • Slave machine: 192.168.100.12

After vagrant halt/suspend, need to run provisioning scripts again to synchronize MySQL from master to slave machine

    $ vagrant halt
    $ vagrant up && vagrant provision

If having the error message 'The guest additions on this VM do not match the install version of VirtualBox!', then run following command before vagrant up

    $ vagrant plugin install vagrant-vbguest

Environments

  • VM Box: Ubuntu/prcise64
    • Master MySQL
    • Private IP: 192.168.100.11
    • Hostname: mysqlmaster
    • Database Name: sample
    • Database Username: root
    • Database Password: root
  • Slave MySQL
    • Private IP: 192.168.100.12
    • Hostname: mysqlslave
    • Database Name: sample
    • Database Username: root
    • Database Password: root

How it works

  1. MySQL slave machine will be launched first.
    • Vagrant provisioning script will update package list and upgrade system (Currently commented out. If need, uncomment it)
    • Set up timezone to Australia/Melbourne
    • Configure firewall to enable 22/3306 ports (may not need?)
    • Install MySQL server and client
    • Configure vagrant synced folder as persistent directory and move initial database file to persistent directory
    • Copy config/my-slave.cnf to /etc/mysql/conf.d/my_override.cnf, which will override default MySQL configurations
    • Create database and grant privileges to root user
    • Set up root user's host to be accessible from any remote
    • Restart MySQL service
  2. MySQL master machine will be launched following.
    • Vagrant provisioning script will update package list and upgrade system (Currently commented out. If need, uncomment it)
    • Set up timezone to Australia/Melbourne
    • Configure firewall to enable 22/3306 ports (may not need?)
    • Install MySQL server and client
    • Configure vagrant synced folder as persistent directory and move initial database file to persistent directory
    • Copy config/my-master.cnf to /etc/mysql/conf.d/my_override.cnf, which will override default MySQL configurations
    • Create database and grant privileges to root user
    • Set up root user's host to be accessible from any remote
    • Create replication user in MySQL master machine
    • Restart MySQL service
    • Install sshpass to access ssh to MySQL slave machine
    • Check slave machine is up and running and MySQL is configured by checking /var/log/setup_mysql
    • Dump database to SQL file from master machine
    • Get current log file and position from master machine
    • Log into MySQL slave machine and import dumped SQL file to sample database
    • Set slave machine to connect master machine for reading the master binary log
    • Create test transaction in master machine

Screenshots

Alt text Alt text Alt text

Todo

  • Vagrant MySQL Master-Master Replication

vagrant-mysql-master-slave-replication's People

Contributors

chrisleekr 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.