Public Repository

Last pushed: 2 years ago
Short Description
MySQL-Cluster GPL in Centos 7
Full Description

centos7 + MySQL-Cluster-gpl-7.4.5-1.el7.x86_64 , with sshd service

Tag init , this is an initial version , without any config files in this images.

Docker Pull Command
Owner
rayeds2007

Comments (3)
rayeds2007
2 years ago

#Dockerfile of tag init

 FROM centos:7

#MAINTAINER Raymond Yang "13916311823@163.com"  

RUN yum install -y openssh-clients  net-tools openssh-server perl rsync libaio unzip \
                bind-utils bind-libs wget  NetworkManager  perl-Module-Install && \
        wget -c --no-check-certificate http://cdn.mysql.com/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-client-gpl-7.4.5-1.el7.x86_64.rpm \
                http://cdn.mysql.com/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-server-gpl-7.4.5-1.el7.x86_64.rpm \
                http://cdn.mysql.com/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-shared-gpl-7.4.5-1.el7.x86_64.rpm \
                http://cdn.mysql.com/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-shared-compat-gpl-7.4.5-1.el7.x86_64.rpm && \
        yum localinstall -y MySQL-Cluster-client-gpl-7.4.5-1.el7.x86_64.rpm \
                            MySQL-Cluster-server-gpl-7.4.5-1.el7.x86_64.rpm \
                            MySQL-Cluster-shared-gpl-7.4.5-1.el7.x86_64.rpm \
                            MySQL-Cluster-shared-compat-gpl-7.4.5-1.el7.x86_64.rpm  
RUN mkdir -p /var/run/sshd /mysql/mgmd  /mysql/data /mysql/data/backup /mysql/mysqld_data /root/.ssh && \
        sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd && \
        ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N '' && \
        ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N '' && \
        ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' && \
        ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' && \
        echo "export VISIBLE=now" >> /etc/profile && echo "vm.swappiness=1" >> /etc/sysctl.conf && \
        mv /var/lib/mysql/* /mysql/mysqld_data/  && \
        rm -f MySQL-Cluster*  

VOLUME /mysql
EXPOSE 3306 1186 22 2200
CMD ["/usr/sbin/sshd", "-D"]
rayeds2007
2 years ago

if you seprate the 4 nodes into diff hosts, you may need add some route rule to help the access by the container.

for example ,

MGM and SQLD running on host1 (10.116.15.240)
Data Node1 running on host2 (10.116.15.239)
Data Node2 running on host3 (10.116.15.238)

then need below command for add route :

in host1 :

ip route show | column -t

ip route add 172.17.42.71/16 via 10.116.15.239 dev ens192

ip route add 172.17.42.72/16 via 10.116.15.238 dev ens192

ip route show | column -t

in host2 :

ip route show | column -t

ip route add 172.17.42.72/16 via 10.116.15.238 dev ens192

ip route add 172.17.42.81/16 via 10.116.15.240 dev ens192

ip route add 172.17.42.91/16 via 10.116.15.240 dev ens192

ip route show | column -t

in host3 :

ip route show | column -t

ip route add 172.17.42.71/16 via 10.116.15.239 dev ens192

ip route add 172.17.42.81/16 via 10.116.15.240 dev ens192

ip route add 172.17.42.91/16 via 10.116.15.240 dev ens192

ip route show | column -t

rayeds2007
2 years ago

#About this image#

This is the image of Mysql Cluster 7.4.5 for Centos7.

##If you want to try##

  • 4 docker containers needed at least , 1 MGM , 2 data Nodes , 1 MYSQLD
  • The config.ini and my.cnf file saved on /etc folder.
  • using pipiwork to bind the ip address for each docker container.

In the config.ini and my.cnf , the 4 nodes defined and the ip address list below

172.17.42.91 MysqlMGM

172.17.42.71 DATANODE1

172.17.42.72 DATANODE2

172.17.42.81 MysqlSQLD

if you want using others ip address , please modify the config.ini and my.cnf by yourself , and please change the command below of docker run

#How to start cluster via this image#

##First time to startup cluster (--initial) ##

  • start MGM node, command list below , using pipework to bind the ip address for this container

docker run -d -h MysqlMGM --add-host=MysqlMGM:172.17.42.91 --expose 1186 --expose 22 --net=none --name MysqlMGM centos7_mysqlcluster:MGM;

pipework docker0 MysqlMGM 172.17.42.91/16@172.17.42.1

  • Start 2 DATA NODEs

docker run -d -h MysqlD1 --add-host=MysqlD1:172.17.42.71 --expose 2200 --expose 22 --net=none --name MysqlD1 centos7_mysqlcluster

pipework docker0 MysqlD1 172.17.42.71/16@172.17.42.1

docker run -d -h MysqlD2 --add-host=MysqlD2:172.17.42.72 --expose 2200 --expose 22 --net=none --name MysqlD2 centos7_mysqlcluster

pipework docker0 MysqlD2 172.17.42.72/16@172.17.42.1

  • Start MYSQLD NODE

docker run -d -h MysqlSQLD --add-host=MysqlSQLD:172.17.42.81 --expose 3306 --expose 22 --net=none --name MysqlSQLD centos7_mysqlcluster

pipework docker0 MysqlSQLD 172.17.42.81/16@172.17.42.1

now you can using docker-enter script sign into those containers to startup cluster with initial parameter, an example list below

  • in MGM

docker-enter MysqlMGM

ndb_mgmd --ndb-nodeid=1 --ndb-connectstring=172.17.42.91:1186 --config-dir=/etc --config-file=/etc/config.ini --initial

  • in DATA NODEs

docker-enter MysqlD1

ndbd --ndb-nodeid=2 --ndb-connectstring=172.17.42.91:1186 --nostart --initial

docker-enter MysqlD2

ndbd --ndb-nodeid=3 --ndb-connectstring=172.17.42.91:1186 --nostart --initial

  • Now you can start data nodes in ndb_mgm

    docker-enter MysqlMGM

ndb_mgm

show

2 start

3 start

wait a moment , then

show

all report memory

Now you can see the status and memory report of cluster

  • in SQLD NODE

docker-enter MysqlSQLD

mysqld -uroot --explicit_defaults_for_timestamp &

mysql -uroot -p123

show databases;

the root's password of mysql is 123

##Next time to startup cluster (without --initial) ##
almost the same as above , but DO NOT using --initial parameter in the command.

enjoy!