参考

使用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:\docker\mysql\mysql-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

基于Docker的Mysql Cluster集群的更多相关文章

  1. MySQL Cluster 集群

    本文转载 http://www.cnblogs.com/gomysql/p/3664783.html MySQL Cluster是一个基于NDB Cluster存储引擎的完整的分布式数据库系统.不仅仅 ...

  2. MySQL Cluster 集群部署

    前言 此篇博客用以介绍 MySQL Cluster 集群部署方法 一.节点规划 序号 IP地址 节点名称 1 172.16.1.201 mysql-manage 2 172.16.1.202 mysq ...

  3. 庐山真面目之十微服务架构 Net Core 基于 Docker 容器部署 Nginx 集群

    庐山真面目之十微服务架构 Net Core 基于 Docker 容器部署 Nginx 集群 一.简介      前面的两篇文章,我们已经介绍了Net Core项目基于Docker容器部署在Linux服 ...

  4. centos7 mysql cluster集群搭建基于docker

    1.准备 mn:集群管理服务器用于管理集群的其他节点.我们可以从管理节点创建和配置集群上的新节点.重新启动.删除或备份节点. db2/db3:这是节点间同步和数据复制的过程发生的层. db4/db5: ...

  5. Docker 搭建 Redis Cluster 集群环境

    使用 Docker 搭建 Redis Cluster,最重要的环节就是容器通信的问题,这一块我们在之前的文章中已经给大家解决了<Docker 网络模式详解及容器间网络通信>,本篇文章主要练 ...

  6. 基于keepalived搭建MySQL热机集群

    背景 MySQL的高可用方案一般有如下几种: keepalived+双主,MHA,MMM,Heartbeat+DRBD,PXC,Galera Cluster 比较常用的是keepalived+双主,M ...

  7. 【原创】强撸基于 .NET 的 Redis Cluster 集群访问组件

    Hello 大家好,我是TANZAME,我们又见面了.今天我们来聊聊怎么手撸一个 Redis Cluster 集群客户端,纯手工有干货,您细品. 随着业务增长,线上环境的QPS暴增,自然而然将当前的单 ...

  8. Docker搭建MySQL主从集群,基于GTID

    写在前边 搭建MySQL读写分离主从集群,这里未使用binlog方式,使用的是GTID方式 源码见我的Github https://github.com/hellxz/mysql-cluster-do ...

  9. MySQL Cluster 集群简介

    简介 MySQL集群是一种在无共享架构(SNA,Share Nothing Architecture)系统里应用内存数据库集群的技术.这种无共享的架构可以使得系统使用低廉的硬件获取高的可扩展性. My ...

随机推荐

  1. linux服务基础之nginx配置详解

    nginx简单介绍:https://www.cnblogs.com/ckh2014/p/10848670.html nginx编译安装:https://www.cnblogs.com/ckh2014/ ...

  2. 阿里支付:User Notice: invalid [default store dir]: /tmp/

    主要是因为windows和linux文件系统不一致才导致此错误的.在linux系统上阿里提供的SDK没问题,但在windows上我们做测试或者开发的时候就会遇到这样的错误. 解决方法就是在alipay ...

  3. 给静态网站的链接添加nofollow属性

    给网站的链接添加nofollow属性对SEO非常有效,如果是动态网站,实现的方法比较多,但是对于静态网站来说只能借助CSS或者JS来实现,单纯的CSS实现需要覆盖所有的链接出现位置:JS与CSS结合则 ...

  4. spark之RDD练习

    目录 一.基础练习 练习一:翻倍列表中的数值并排序列表,并选出其中大于等于10的元素. 练习二:将字符数组里面的每一个元素先切分在压平. 练习三:求两个列表中的交集.并集.及去重后的结果 练习四:对L ...

  5. nginx技术

    Nginx 处理高并发,单台服务器存在服务瓶颈 Nginx属于nio ,noblocking Io非阻塞式的 Apache属于Bio,Blocking IO 阻塞式的 安装部分 依赖安装:yum -y ...

  6. cURL error 60: SSL certificate problem: unable to get local issuer certificate 解决方法

    微信开发的时,请求接口报错如下: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see ...

  7. 遇到的基础php函数、方法

    0x01 PHP file() 函数 file() 函数把整个文件读入一个数组中. 数组中的每个元素都是文件中相应的一行,包括换行符在内. 实例: <?php print_r(file(&quo ...

  8. Python 序列化与反序列化

    序列化是为了将内存中的字典.列表.集合以及各种对象,保存到一个文件中(字节流).而反序列化是将字节流转化回原始的对象的一个过程. json库 序列化:json.dumps() 反序列化:json.lo ...

  9. navicat连接mysql查询结果中文都是?号(C#)

    记录解决方法,方便以后查看.  有几个地方需要注意: 1.连接mysql数据库的字符串最后加上Charset=utf8; 2.mysql中character_set_XX设置都为utf8,使用show ...

  10. 浅谈C#委托的用法-delegate

    2018年11月7日     小雨 一.委托的概念 委托和类一样是一种用户自定义类型,它存储的就是一系列具有相同签名和返回类型的方法的地址,调用委托的时候,它所包含的所有方法都会被执行. 借用百度上的 ...