zoukankan      html  css  js  c++  java
  • 基于Docker的Mysql Cluster集群

    参考

    使用Docker创建Cluster步骤

    目标:一个管理节点,二个数据节点,二个mysqlserver节点

    1. Create a docker network
    docker network create cluster — subnet=192.168.0.0/16
    
    1. 修改管理节点的集群配置文件
      从https://github.com/mysql/mysql-docker/tree/mysql-cluster下载对应版本的mysql-cluster.cnf
      在结尾新增如下配置, 目的是增加一个mysql server节点
    [mysqld]
    NodeId=5
    hostname=192.168.0.11
    
    1. Create the manager node

    -v 参数自行调整

    docker run -d --net=cluster --name=management1 --ip=192.168.0.2 -v C:dockermysqlmysql-cluster.cnf:/etc/mysql-cluster.cnf mysql/mysql-cluster ndb_mgmd
    
    1. Create the data nodes

    集群配置文件中需要创建两个数据节点, 按指定的hostname参数自行调整--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. Create the Mysql nodes

    集群配置文件中需要创建两个mysql节点, 按指定的hostname参数自行调整--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
    
    
  • 相关阅读:
    thinkPHP入门之二
    thinkPHP入门
    斐波那契数列,冒泡排序,选择排序,数组去重
    jquery-懒加载插件
    本地存储之cookie
    javascript的快速排序法
    [luogu2165 AHOI2009] 飞行棋 (枚举)
    [luogu2576 SCOI2010] 幸运数字 (容斥原理)
    [luogu2587 ZJOI2008] 泡泡堂 (贪心)
    [luogu2602 ZJOI2010] 数字计数 (数位dp)
  • 原文地址:https://www.cnblogs.com/byxxw/p/11433571.html
Copyright © 2011-2022 走看看