ドッカーのMySQLクラスタのクラスタに基づいて、

参照

ドッカーは、クラスタの手順を使用して作成しました

目標の例:管理ノードは、2つのデータ・ノード、2つのmysqlserverノード

  1. ドッキングウィンドウのネットワークを作成します。
docker network create cluster — subnet=192.168.0.0/16
  1. クラスタ構成ファイルの管理ノードを変更して
    、私の-cluster.cnfの対応バージョンをダウンロードしhttps://github.com/mysql/mysql-docker/tree/mysql-clusterから
    最後に次の設定を追加し、目的は、ノードmysqlserverを追加することです
[mysqld]
NodeId=5
hostname=192.168.0.11
  1. マネージャー・ノードを作成します。

    -vパラメータ自動調整

docker run -d --net=cluster --name=management1 --ip=192.168.0.2 -v C:\docker\mysql\mysql-cluster.cnf:/etc/mysql-cluster.cnf mysql/mysql-cluster ndb_mgmd
  1. データノードを作成します。

    クラスタ構成ファイル、あなた自身をパラメータ--ip指定したホスト名のパラメータ調整によると、二つのデータノードを作成する必要があります

docker run -d --net=cluster --name=ndb1 --ip=192.168.0.3 mysql/mysql-cluster ndbd
docker run -d --net=cluster --name=ndb2 --ip=192.168.0.4 mysql/mysql-cluster ndbd
  1. MySQLのノードを作成します。

    クラスタ構成ファイル、MySQLは自分をパラメータ--ip指定したホスト名パラメータの調整で二つのノードを作成する必要があります

docker run -d --net=cluster --name=mysql1 --ip=192.168.0.10 -e MYSQL_ROOT_PASSWORD=123 mysql/mysql-cluster mysqld
docker run -d --net=cluster --name=mysql2 --ip=192.168.0.11 -e MYSQL_ROOT_PASSWORD=123 mysql/mysql-cluster mysqld
  1. 管理ノードでのビュークラスタのステータス
docker run -it --net=cluster mysql/mysql-cluster ndb_mgm

showコマンドを実行して、クラスタの状態を印刷

ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)]     2 node(s)
id=2    @192.168.0.3  (mysql-5.7.27 ndb-7.6.11, Nodegroup: 0, *)
id=3    @192.168.0.4  (mysql-5.7.27 ndb-7.6.11, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.0.2  (mysql-5.7.27 ndb-7.6.11)

[mysqld(API)]   2 node(s)
id=4    @192.168.0.10  (mysql-5.7.27 ndb-7.6.11)
id=5    @192.168.0.11  (mysql-5.7.27 ndb-7.6.11)

my.cnfの

# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

[mysqld]
ndbcluster
ndb-connectstring=192.168.0.2
user=mysql

[mysql_cluster]
ndb-connectstring=192.168.0.2

MySQLの-cluster.cnf

# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

[ndbd default]
NoOfReplicas=2
DataMemory=80M
IndexMemory=18M


[ndb_mgmd]
NodeId=1
hostname=192.168.0.2
datadir=/var/lib/mysql

[ndbd]
NodeId=2
hostname=192.168.0.3
datadir=/var/lib/mysql

[ndbd]
NodeId=3
hostname=192.168.0.4
datadir=/var/lib/mysql

[mysqld]
NodeId=4
hostname=192.168.0.10

[mysqld]
NodeId=5
hostname=192.168.0.11

おすすめ

転載: www.cnblogs.com/byxxw/p/11433571.html