基于Docker的Mysql Cluster集群
参考
使用Docker创建Cluster步骤
目标:一个管理节点,二个数据节点,二个mysqlserver节点
- Create a docker network
docker network create cluster — subnet=192.168.0.0/16
- 修改管理节点的集群配置文件
从https://github.com/mysql/mysql-docker/tree/mysql-cluster下载对应版本的mysql-cluster.cnf
在结尾新增如下配置, 目的是增加一个mysql server节点
[mysqld]
NodeId=5
hostname=192.168.0.11
- 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
- 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
- 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
- 在管理节点查看集群状态
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集群的更多相关文章
- MySQL Cluster 集群
本文转载 http://www.cnblogs.com/gomysql/p/3664783.html MySQL Cluster是一个基于NDB Cluster存储引擎的完整的分布式数据库系统.不仅仅 ...
- MySQL Cluster 集群部署
前言 此篇博客用以介绍 MySQL Cluster 集群部署方法 一.节点规划 序号 IP地址 节点名称 1 172.16.1.201 mysql-manage 2 172.16.1.202 mysq ...
- 庐山真面目之十微服务架构 Net Core 基于 Docker 容器部署 Nginx 集群
庐山真面目之十微服务架构 Net Core 基于 Docker 容器部署 Nginx 集群 一.简介 前面的两篇文章,我们已经介绍了Net Core项目基于Docker容器部署在Linux服 ...
- centos7 mysql cluster集群搭建基于docker
1.准备 mn:集群管理服务器用于管理集群的其他节点.我们可以从管理节点创建和配置集群上的新节点.重新启动.删除或备份节点. db2/db3:这是节点间同步和数据复制的过程发生的层. db4/db5: ...
- Docker 搭建 Redis Cluster 集群环境
使用 Docker 搭建 Redis Cluster,最重要的环节就是容器通信的问题,这一块我们在之前的文章中已经给大家解决了<Docker 网络模式详解及容器间网络通信>,本篇文章主要练 ...
- 基于keepalived搭建MySQL热机集群
背景 MySQL的高可用方案一般有如下几种: keepalived+双主,MHA,MMM,Heartbeat+DRBD,PXC,Galera Cluster 比较常用的是keepalived+双主,M ...
- 【原创】强撸基于 .NET 的 Redis Cluster 集群访问组件
Hello 大家好,我是TANZAME,我们又见面了.今天我们来聊聊怎么手撸一个 Redis Cluster 集群客户端,纯手工有干货,您细品. 随着业务增长,线上环境的QPS暴增,自然而然将当前的单 ...
- Docker搭建MySQL主从集群,基于GTID
写在前边 搭建MySQL读写分离主从集群,这里未使用binlog方式,使用的是GTID方式 源码见我的Github https://github.com/hellxz/mysql-cluster-do ...
- MySQL Cluster 集群简介
简介 MySQL集群是一种在无共享架构(SNA,Share Nothing Architecture)系统里应用内存数据库集群的技术.这种无共享的架构可以使得系统使用低廉的硬件获取高的可扩展性. My ...
随机推荐
- tensorflow张量限幅
本篇内容有clip_by_value.clip_by_norm.gradient clipping 1.tf.clip_by_value a = tf.range(10) print(a) # if ...
- react 项目 测试
Enzyme 来自 airbnb 公司,是一个用于 React 的 JavaScript 测试工具,方便你判断.操纵和历遍 React Components 输出.Enzyme 的 API 通过模仿 ...
- Linux下快速删除大量小文件引起的磁盘inode(目录索引)过满
1)首先建立一个空白文件夹. mkdir /tmp/empty 然后安装下rsync yum install -y rsync 2)之后使用以下语句即可快速的删除文件. rsync --delete- ...
- Docker常用命令和功能介绍
可以搜索 dockerfile 定制创建一个redis镜像image 表示镜像docker search 搜索镜像的名称和标签docker 所在目录/var/lib/dockerdocker的镜像文件 ...
- Centos7 同时运行PHP5.2和PHP7.1配置
工作环境一直都是lnmp,其中PHP已经升级到7.1版本了.突然有份代码需要运行在PHP5.2上.但是之前的环境还是需要的,所以需要在centos中再安装PHP5.2. 0.之前的php7安装在/us ...
- 最新NetSarang Xmanager安装激活-XShell、XFtp
NetSarang Xmanager Enterprise 是一个简单易用的高性能的运行在 Windows 平台上的 X Server 软件.它能把远端 Unix/Linux 的桌面无缝地带到你的Wi ...
- Java锁机制深入理解
Java锁机制 背景知识 指令流水线 CPU的基本工作是执行存储的指令序列,即程序.程序的执行过程实际上是不断地取出指令.分析指令.执行指令的过程. 几乎所有的冯•诺伊曼型计算机的CPU,其工 ...
- thinkphp3.2短信群发项目实例
项目功能是企业给客户群发短信,我就写这么多,也不知道你能不能运行成功,如果有问题可以在QQ上问我:605114821 项目文件SMS_V2.zip下载地址,百度云:http://yun.baidu.c ...
- Java连载76-基础数据类型包装类型及其方法简介
一.java中八种基本数据类型对应的包装类型 基本数据类型 包装类型 byte java.lang.Byte short ...
- Typecho的卡哇伊小猫咪小插件(Live2D猫咪插件)
之前看到一个博客,被它博客上的动态小猫咪给吸引了,这个纯粹就是一个在线撸猫的神器啊.但是在网上寻找一番,并没有找到合适的插件,或者说没有找到合适的模型,因此无奈之后,只能向该博主请教,在它写的博客上, ...