MySql NDB cluster replication配置
文章目录
官方文档: https://dev.mysql.com/doc/refman/5.6/en/mysql-cluster.html
安装过程:略
单机部署:
1. 创建ndb_mgmd配置文件:
SC-1:/storage/ezohenz # cat m
[NDB_MGMD]
HostName=SC-1
[NDBD DEFAULT]
NoOfReplicas=2
[NDBD]
HostName=SC-1
Id=11
DataDir=/storage/ezohenz/data_ndbd1
[NDBD]
HostName=SC-1
Id=12
DataDir=/storage/ezohenz/data_ndbd2
[MYSQLD]
HostName=SC-1
Id=21
[MYSQLD]
HostName=SC-2
Id=22
2. 创建ndbd配置文件
SC-1:/storage/ezohenz # cat d
[MYSQLD]
ndbcluster
ndb-connectstring=SC-1:1186
[MYSQL_CLUSTER]
ndb-connectstring=SC-1:1186
3. 创建mysqld配置文件
SC-1:/storage/ezohenz # cat q
[MYSQLD]
ndbcluster
ndb-connectstring=SC-1:1186
default-storage-engine=ndbcluster
user=mysql
4. 安装初始数据库
mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=./data_mysqld
5. 按顺序启动ndb_mgmd, ndbd, mysqld
ndb_mgmd -f ./m --initial
ndbd --defaults-file=./d --initial
mysqld --defaults-file=./q --datadir=./data_mysqld &
6. 查看ndb cluster状态
ndb_mgm -e show
注意貌似需要确认配置文件m中的所有ndbd都启动并连接上mgmd,mysqld才能正常连接上mgmd并创建engine为ndb的数据表。
Geographic redundancy
以上为单机cluster,需要多个才有实际意义。而在不同地区的cluster之间,也可以进行数据的同步。
现在假设有另一套单机cluster,配置如上面的1-6步。假设两个cluster分别为A和B,则:
分别修改A和B的mysqld配置文件并重启mysqld:
SC-1:/storage/db_sc1 # cat q
[MYSQLD]
ndbcluster
ndb-connectstring=SC-1:1186
default-storage-engine=ndbcluster
user=mysql
server-id=1
replicate-do-db=test
replicate-do-table=test.ctest
slave-skip-errors=1062,1032,1590
log-slave-updates
log-bin=
sync_binlog=1
binlog_format=MIXED
expire_logs_days=3
binlog-do-db=test
slave-net-timeout=10
务必将A和B的server-id配置成不同的值。
重启后进入mysql客户端查看master状态
执行show master status;
mysql> show master status;
+-----------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-----------------+----------+--------------+------------------+-------------------+
| SC-1-bin.000001 | 120 | test | | |
+-----------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
分别记录A和B的File,在下面的命令中会用到。
分别重新配置A和B的slave
在A (sc-1)的mysql客户端输入以下命令
stop slave;
change master to master_host='sc-2', master_log_file='SC-2-bin.000001', master_user='mysql', master_password='', master_retry_count=86400, master_connect_retry=5;
start slave;
在B (sc-2)的mysql客户端输入以下命令
stop slave;
change master to master_host='sc-1', master_log_file='SC-1-bin.000001', master_user='mysql', master_password='', master_retry_count=86400, master_connect_retry=5;
start slave;
此时将会在两个site的客户端上分别看到连接成功的消息。
检查配置结果
在A和B上分别执行show slave status\G,应该看到Slave_IO_Running和Slave_SQL_Running状态都是Yes:
show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: sc-2
Master_User: mysql
Master_Port: 3306
Connect_Retry: 5
Master_Log_File: SC-2-bin.000001
Read_Master_Log_Pos: 120
Relay_Log_File: SC-1-relay-bin.000002
Relay_Log_Pos: 282
Relay_Master_Log_File: SC-2-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: test
Replicate_Ignore_DB:
Replicate_Do_Table: test.ctest
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 120
Relay_Log_Space: 454
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 2
Master_UUID: 5301a65f-34b9-11e8-a869-021020010200
Master_Info_File: /cluster/storage/db_sc1/data_mysqld/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec)
通过在数据库中修改数据来检查配置是否生效
在A的数据库test中建一个ctest表,并在其中插入一条记录,应该能在B上看到插入的结果。反之亦然。
mysql> USE test;
Database changed
mysql> CREATE TABLE ctest (i INT) ENGINE=NDBCLUSTER;
2018-03-31 16:49:10 619 [Note] NDB Binlog: CREATE TABLE Event: REPL$test/ctest
2018-03-31 16:49:10 619 [Note] NDB Binlog: logging ./test/ctest (UPDATED,USE_WRITE)
Query OK, 0 rows affected (0.48 sec)
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| ctest |
+----------------+
1 row in set (0.00 sec)
mysql> select * from ctest;
Empty set (0.00 sec)
mysql> insert into ctest values (111);
Query OK, 1 row affected (0.00 sec)
mysql> select * from ctest;
+------+
| i |
+------+
| 111 |
+------+
1 row in set (0.00 sec)
全文完。
MySql NDB cluster replication配置的更多相关文章
- Chapter 18 MySQL NDB Cluster 7.3 and NDB Cluster 7.4渣翻
Table of Contents 18.1 NDB Cluster Overview 18.2 NDB Cluster Installation 18.3 Configurati ...
- 安装mysql ndb cluster二进制版本在linux上
Installing an NDB Cluster Binary Release on Linux (官方安装手册)手册地址:https://dev.mysql.com/doc/refman/5.7/ ...
- MySQL InnoDB Cluster介绍
目录 一.MySQL InnoDB Cluster介绍 二.环境准备 三.将MGR节点加入MySQL Cluster 四.问题汇总 五.性能测试 六.个人总结 一.MySQL InnoDB Clust ...
- Mysql Innodb cluster集群搭建
之前搭建过一个Mysql Ndb cluster集群,但是mysql版本是5.7的,看到官网上mysql8的还是开发者版本,所以尝试搭建下mysql Innodb cluster集群. MySQL的高 ...
- MySQL NDB集群安装配置(mysql cluster 9.4.13 installation)
一.安装前规划 1.安装软件版本:mysql-cluster-gpl-7.4.13-linux-glibc2.5-x86_64.tar.gz 2.安装规划: 主机名 Ip地址 角色 db01 192. ...
- mysql cluster 安装配置方案
mysql cluster (mysql 集群)安装配置方案 一.准备 1.准备服务器 计划建立有5个节点的MySQL CLuster体系,需要用到5台服务器,但是我们做实验时没有这么多机器,可以 ...
- MySQL中双NDBD节点Cluster快速配置
是MySQL适合于分布式计算环境的高实用.高冗余版本.它采用了NDB Cluster 存储引擎,允许在1个 Cluster 中运行多个MySQL服务器.在MyQL 5.0及以上的二进制版本中.以及与最 ...
- MySql Replication配置
一.前言 Mysql Replication作为读写分离的廉价解决方案,支持一主多备的方式进行数据存储,采用二进制日志传送,目前存在着广泛应用,网上相关概念也比较多,不再重复介绍.引用一张官方提供的R ...
- Mysql 5.5 replication 多数据库主从备份Master-Slave配置总结
配置Mysql server 5.5 的双机备份,也就是master-slave模式.本例子还是一个多database复制的情况. 现在有两个database在同一台mysql server,也就是m ...
随机推荐
- flask不定参数的传递。多参数,多次传递
有的时候有一个分类查询,再来一个排序,这就有两个参数要传递多次. 还是不定长度,不定内容的传递. 这个是用request.args来实现: def home(): requests=request.a ...
- C++定义自己的异常
body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...
- 【转载】JVM系列一:JVM内存组成及分配
java内存组成介绍:堆(Heap)和非堆(Non-heap)内存 按照官方的说法:“Java 虚拟机具有一个堆,堆是运行时数据区域,所有类实例和数组的内存均从此处分配.堆是在 Java 虚拟机启动时 ...
- 侧滑返回导航栏以及TabBar隐藏和显示带来的坑
用系统的UINavigationBar时,返回手势重若碰到前一个页面有bar,后一个页面没bar,或者反过来时动画非常难看 如下图:因为首页隐藏了导航栏,在侧滑的时候导航栏竟然提前消失了,这是因为在侧 ...
- Cracking The Coding Interview5.2
//Given a (decimal - e.g. 3.72) number that is passed in as a string, print the binary representatio ...
- 2.6 C++通过引用来传递和返回类对象
参考:http://www.weixueyuan.net/view/6338.html 总结: C++语言中,由类声明的对象,和其它类型声明的变量一样,同样可以通过传值.引用和指针的方式作为函数的参数 ...
- Effective Java Methods Common to All Objects
Obey the general contract when overriding equals 先了解equals 和 == 的区别,如果不重写equals, equals比较的仅仅只是是否引用同一 ...
- java学习笔记6(面向对象1:概念,private)
1.思想: 面向过程的思想:遇到问题时想,我该如何做,然后分步骤实现: 面向对象的思想:遇到问题时想,我该派谁去做这件事,至于他怎么做,与我无关,我只要最后的结果. 实际举例:我们要组装一台电脑: 面 ...
- 临时调用call()与apply()方法
当在某个局域范围内要调用构造函数中或者其他局域范围内的方法 此时可以用到临时调用方法call与apply 虽然这两个方法都是起临时调用的功能,但是用法不一样 call(obj,val) obj:对象名 ...
- 【webdriver自动化】整理API框架(主要是关键字,具体例子在本地)
1. 获取网页源码 pageSource = self.driver.page_source print pageSource.encode("gbk","ignore& ...