├── README.md ├── conf.ori ├── my.cnf └── mysql-cluster.cnf ├── docker-compose.yml └── mysql.conf ├── my.cnf └── mysql-cluster.cnf /README.md: -------------------------------------------------------------------------------- 1 | # cluster-mysql 2 | -------------------------------------------------------------------------------- /conf.ori/my.cnf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | [mysqld] 17 | ndbcluster 18 | ndb-connectstring=192.168.0.2 19 | user=mysql 20 | 21 | [mysql_cluster] 22 | ndb-connectstring=192.168.0.2 23 | 24 | -------------------------------------------------------------------------------- /conf.ori/mysql-cluster.cnf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | [ndbd default] 17 | NoOfReplicas=2 18 | DataMemory=80M 19 | IndexMemory=18M 20 | 21 | 22 | [ndb_mgmd] 23 | NodeId=1 24 | hostname=192.168.0.2 25 | datadir=/var/lib/mysql 26 | 27 | [ndbd] 28 | NodeId=2 29 | hostname=192.168.0.3 30 | datadir=/var/lib/mysql 31 | 32 | [ndbd] 33 | NodeId=3 34 | hostname=192.168.0.4 35 | datadir=/var/lib/mysql 36 | 37 | [mysqld] 38 | NodeId=4 39 | hostname=192.168.0.10 40 | 41 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | #version: '3.1' 3 | services: 4 | management1: 5 | image: mysql/mysql-cluster 6 | volumes: 7 | - ./mysql.conf/my.cnf:/etc/my.cnf 8 | - ./mysql.conf/mysql-cluster.cnf:/etc/mysql-cluster.cnf 9 | #command: "ndb_mgmd --ndb-nodeid=1" 10 | command: ndb_mgmd 11 | networks: 12 | mysqlcluster: 13 | # ipv4_address: 192.168.0.2 14 | ipv4_address: 172.28.0.2 15 | ndb1: 16 | image: mysql/mysql-cluster 17 | volumes: 18 | - ./mysql.conf/my.cnf:/etc/my.cnf 19 | - ./mysql.conf/mysql-cluster.cnf:/etc/mysql-cluster.cnf 20 | #command: bash -c 'sleep 40; exec ndbd' 21 | command: ndbd 22 | depends_on: 23 | - "management1" 24 | networks: 25 | mysqlcluster: 26 | # ipv4_address: 192.168.0.3 27 | ipv4_address: 172.28.0.3 28 | ndb2: 29 | image: mysql/mysql-cluster 30 | volumes: 31 | - ./mysql.conf/my.cnf:/etc/my.cnf 32 | - ./mysql.conf/mysql-cluster.cnf:/etc/mysql-cluster.cnf 33 | #command: bash -c 'sleep 40; exec ndbd' 34 | command: ndbd 35 | depends_on: 36 | - "management1" 37 | networks: 38 | mysqlcluster: 39 | # ipv4_address: 192.168.0.4 40 | ipv4_address: 172.28.0.4 41 | mysql1: 42 | image: mysql/mysql-cluster 43 | ports: 44 | - "3306:3306" 45 | volumes: 46 | - ./mysql.conf/my.cnf:/etc/my.cnf 47 | - ./mysql.conf/mysql-cluster.cnf:/etc/mysql-cluster.cnf 48 | # restart: always 49 | environment: 50 | MYSQL_ROOT_PASSWORD: example 51 | MYSQL_DATABASE: bdteste 52 | MYSQL_USER: teste 53 | MYSQL_PASSWORD: teste 54 | MYSQL_ROOT_HOST: '%' 55 | #command: bash -c 'sleep 60; exec mysqld' 56 | command: mysqld 57 | depends_on: 58 | - "management1" 59 | - "ndb1" 60 | - "ndb2" 61 | networks: 62 | mysqlcluster: 63 | # ipv4_address: 192.168.0.10 64 | ipv4_address: 172.28.0.10 65 | adminer: 66 | image: adminer 67 | restart: always 68 | ports: 69 | - 8081:8080 70 | links: 71 | - mysql1:db 72 | networks: 73 | mysqlcluster: 74 | 75 | networks: 76 | mysqlcluster: 77 | # driver: overlay 78 | driver: bridge 79 | ipam: 80 | config: 81 | # - subnet: 192.168.0.0/16 82 | - subnet: 172.28.0.0/16 83 | gateway: 172.28.5.254 84 | ## - ip-range: 172.28.5.0/24 85 | 86 | # docker run -it -v "$PWD/mysql.conf/my.cnf:/etc/my.cnf" -v "$PWD/mysql.conf/mysql-cluster.cnf:/etc/mysql-cluster.cnf" --net=mysqlcluster_mysqlcluster mysql/mysql-cluster ndb_mgm 87 | -------------------------------------------------------------------------------- /mysql.conf/my.cnf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | [mysqld] 17 | ndbcluster 18 | ndb-connectstring=172.28.0.2 19 | user=mysql 20 | skip_name_resolve 21 | 22 | [mysql_cluster] 23 | ndb-connectstring=172.28.0.2 24 | 25 | -------------------------------------------------------------------------------- /mysql.conf/mysql-cluster.cnf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | [ndbd default] 17 | NoOfReplicas=2 18 | DataMemory=80M 19 | IndexMemory=18M 20 | 21 | 22 | [ndb_mgmd] 23 | NodeId=1 24 | hostname=172.28.0.2 25 | datadir=/var/lib/mysql 26 | 27 | [ndbd] 28 | NodeId=2 29 | hostname=172.28.0.3 30 | datadir=/var/lib/mysql 31 | 32 | [ndbd] 33 | NodeId=3 34 | hostname=172.28.0.4 35 | datadir=/var/lib/mysql 36 | 37 | [mysqld] 38 | NodeId=4 39 | hostname=172.28.0.10 40 | 41 | --------------------------------------------------------------------------------