Git Product home page Git Product logo

mysql-cluster's Introduction

#Introduction

This Docker container provides a MySQL Cluster installation.

The project sources can be found on GitHub. The Docker image build is hosted at Docker Hub.

#Build

git clone https://github.com/g17/MySQL-Cluster.git
cd MySQL-Cluster
docker build -t h3nrik/mysql-cluster .

#Prerequisites

In order to set up the MySQL Cluster you should have prepared a proper network setup similar to the following. It includes one management node, two data nodes and two SQL nodes.

  • Management Node: host name mgm01 (192.168.0.1).
  • SQL Nodes: host name mysqld01 (192.168.0.100) and mysqld02 (192.168.0.101).
  • Data Nodes: host name ndbd01 (192.168.0.10) and ndbd02 (192.168.0.11).

#Installation

Prepare a configuration file for the management node similar to the following one (but do not change the datadir definitions!):

[NDBD DEFAULT]
NoOfReplicas=2
DataMemory=80M
IndexMemory=18M
datadir=/usr/local/mysql/data

[NDB_MGMD DEFAULT]
datadir=/var/lib/mysql-cluster

[NDB_MGMD]
NodeId=1
hostname=192.168.0.1

[NDBD]
NodeId=10
hostname=192.168.0.10

[NDBD]
NodeId=11
hostname=192.168.0.11

[MYSQLD]
NodeId=100
hostname=192.168.0.100

[MYSQLD]
NodeId=101
hostname=192.168.0.101

#Usage

  1. Start the management node on host 192.168.0.1:

     docker run -d --name ndb_mgmd01 --net=host -p 192.168.0.1:1186:1186 -v /path/to/your/config.ini:/etc/mysql-cluster.ini:ro h3nrik/mysql-cluster ndb_mgmd
    
  2. Connect with the management console to the management node to issue the SHOW command that displays your cluster configuration and state:

     docker run -it --rm --name ndb_mgm h3nrik/mysql-cluster ndb_mgm 192.168.0.1
    
  3. Run the data nodes on host 192.168.0.10 and 192.168.0.11:

     docker run -d --name ndbd01 --net=host h3nrik/mysql-cluster ndbd 192.168.0.1
     docker run -d --name ndbd02 --net=host h3nrik/mysql-cluster ndbd 192.168.0.1
    
  4. Run the SQL nodes on host 192.168.0.100 and 192.168.0.101:

     docker run -d --name mysqld01 --net=host -p 192.168.0.100:3306:3306 h3nrik/mysql-cluster mysqld 192.168.0.1
     docker run -d --name mysqld02 --net=host -p 192.168.0.101:3306:3306 h3nrik/mysql-cluster mysqld 192.168.0.1
    
  5. Now you can connect to any of the SQL nodes with your client.

#Update Nodes

You can easily update the data/SQL nodes e.g. for up-scaling the cluster:

  1. Modify the config.ini file mounted into the management node.
  2. Stop the management node.
  3. Start it again. It will do a reload of that configuration file automatically.
  4. Start the new SQL/data nodes on the hosts configured in the config.ini file.

#Further Ideas

In addition to this setup a MySQL proxy could be used to access the SQL nodes.

mysql-cluster's People

Contributors

alirajabi avatar

Watchers

James Cloos avatar minamoto 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.