免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 8617 | 回复: 10
打印 上一主题 下一主题

MYSQL集群中NDB如何同步数据? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-09-19 20:40 |只看该作者 |倒序浏览
在某运营商的HLR设备上,是有MYSQL集群来做的,总共6块板卡,每个上相当于一个小电脑,

A,B两个做MGMD管理节点,也做SQLD节点

其余C,D,E,F四块板卡做NDB节点

请问下这四个NDB节点如何进行数据的同步呢?

我在网上搜索MYSQL集群,没看到关于NDB之间的同步的说明啊,

请问谁呢说明下呢?

SQLD过来数据,NDB不是如何向四个节点发数据呢?他们如何进行数据的同步呢?
如果一次数据在节点C上,一次在节点D上,那数据不就是不一样了吗?

谢谢,请帮忙看看。

另外,四块NDB节点之间怎么做均衡呢?他们是平均的吗?

如果想改一下呢?比如C,D做一组,C主D备,然后E,F一组,E主F备,一次数据过来,随即发送到C,E上吗?然后再同步?

谢谢了啊。

我不是做集群的,我就是好奇而已,对LINUX下的服务好奇,谢谢了啊。

论坛徽章:
0
2 [报告]
发表于 2009-09-20 13:25 |只看该作者
咋没有人帮帮忙呢?

哪位帅哥靓妹高手们指点指点啊?

论坛徽章:
0
3 [报告]
发表于 2009-09-20 13:32 |只看该作者
这是config.ini文件

# file "config.ini" - showing minimal setup with 1 DB node
# This file is placed in the start directory of ndb_mgmd,
# the management server.

[TCP DEFAULT]
SendBufferMemory=2M
PortNumber = 28020

[API DEFAULT]

[NDB_MGMD DEFAULT]
PortNumber = 1186
DataDir=/var/local/nectar/log

# ndb_mgmd is the cluster manager
# it can run on pilot stations
[NDB_MGMD]
id=1
hostname=STATION_A
ArbitrationRank: 1
LogDestination=FILE:filename=ndb_1_cluster.log,maxsize=10000000,maxfiles=5

[NDB_MGMD]
id=2
hostname=STATION_B
ArbitrationRank: 1
LogDestination=FILE:filename=ndb_2_cluster.log,maxsize=10000000,maxfiles=5


[NDBD DEFAULT]
DataDir=/user/database/log
#DataDir=/var/local/nectar/log/
NoOfReplicas: 2
DataMemory = 1900M
IndexMemory: 250M
#MaxNoOfSavedMessages: 5
LockPagesInMainMemory: 2
#StartPartialTimeout: 10000
StartPartitionedTimeout: 60000
StartFailureTimeout: 0
HeartbeatIntervalDbDb:  600
#HeartbeatIntervalDbApi: 3000
MaxNoOfOrderedIndexes: 200
MaxNoOfTables: 250
MaxNoOfUniqueHashIndexes: 200
MaxNoOfAttributes:  5000
MaxNoOfOpenFiles: 107
InitialNoOfOpenFiles: 106
TimebetweenLocalCheckpoints: 20
TimebetweenGlobalCheckpoints: 1000
#TransactionDeadlockDetectionTimeout: 1000000000
#TransactionDeadlockDetectionTimeout: 50
TransactionDeadlockDetectionTimeout: 1000
TransactionInactiveTimeout: 300000
TimeBetweenInactiveTransactionAbortCheck: 1000
NoOfFragmentLogFiles: 128
MaxNoOfConcurrentTransactions: 7000
RedoBuffer: 48M
LogLevelStartup: 15
LogLevelShutdown: 15
LogLevelConnection: 15
LogLevelInfo: 15
LogLevelError: 15
LogLevelNodeRestart: 15
LogLevelCheckpoint: 1
StopOnError: Y

# There are 4 data nodes
DataMemory2 = 300M
[NDBD]
id=3
hostname=STATION_C
FileSystemPath: /user/database/ndbd

[NDBD]
id=4
hostname=STATION_D
FileSystemPath: /user/database/ndbd

[NDBD]
id=5
hostname=STATION_E
FileSystemPath: /user/database/ndbd

[NDBD]
id=6
hostname=STATION_F
FileSystemPath: /user/database/ndbd

# mysqld is the mysql server daemon, it can run on both pilot stations
[MYSQLD]
id=7
hostname=STATION_A

[MYSQLD]
id=8
hostname=STATION_B

论坛徽章:
0
4 [报告]
发表于 2009-09-21 00:17 |只看该作者
首先,4个ndb节点的数据是有冗余的
你的配置文件里NoOfReplicas=2,所以每一行记录会在ndb节点上存2份
ndb有nodegroup的概念,在你的配置情况下,4个ndb节点会分为2个nodegroup,每个nodegrup中的每个节点的数据都是一样的,所以只要不是整个nodegroup中的所有节点都挂掉,就不会出现数据丢失。
NoOfNodes = NoOfNodegroups * NoOfReplicas
在你的配置中,ndb节点的id分别为3、4、5、6,一般情况下,ndb会自动将3、4作为一个nodegroup,5、6作为另一个nodegroup
至于ndb节点内部的数据是如何同步的,都是MySQL Cluster内部的事情,手工没法干预的

另,很想知道您这个MySQL Cluster是做什么类型的应用

评分

参与人数 1可用积分 +5 收起 理由
枫影谁用了 + 5 精品文章

查看全部评分

论坛徽章:
0
5 [报告]
发表于 2009-09-21 11:00 |只看该作者
可以参考一下mysql cluster的官文,上面说的很清楚。

论坛徽章:
1
白银圣斗士
日期:2015-11-23 08:33:04
6 [报告]
发表于 2009-09-21 17:54 |只看该作者
原帖由 shujun579 于 2009-9-21 00:17 发表
首先,4个ndb节点的数据是有冗余的
你的配置文件里NoOfReplicas=2,所以每一行记录会在ndb节点上存2份
ndb有nodegroup的概念,在你的配置情况下,4个ndb节点会分为2个nodegroup,每个nodegrup中的每个节点的数 ...

恩,很不错

论坛徽章:
0
7 [报告]
发表于 2009-09-21 22:05 |只看该作者
这个是某厂家的通信行业里的HLR产品,现在正在用的

就是这个东西,而且是新产品哦,是在线用的产品哦

论坛徽章:
0
8 [报告]
发表于 2009-09-21 22:12 |只看该作者
NoOfReplicas=2,所以每一行记录会在ndb节点上存2份

是啥意思?是每个NDB上一个记录存两份?

NoOfNodes = NoOfNodegroups * NoOfReplicas

如果NoOfReplicas是每个节点存两份,那这个公式怎么解释呢?谢谢


我已经理解了,NODE之间备份是在一个组里的,因此肯定是NOD NUMBER/NoOfReplicas=node group的

因此在俩NODE的话,比如NoOfReplicas=1的话,那就是俩组,一个NODE一般数据,所以挂了任何一个都不行。而NoOfReplicas=2的话,因为要有备份,占用俩NODE,因此只能有一个组了。而一个每一个NODE里有完整的数据,因此挂了任何一个都不会坏。

在四个NODE的话,NoOfReplicas=2,因此每个组占俩NODE,那可以分成两个组,每个组里有一半的数据,因此不能整个组坏掉。
在四个NODE的话,NoOfReplicas=4的话,因此每个组就占用4个NODE,因此只能有一个组,每个NODE有四份数据,因此坏了任何一个NODE都不能坏。

[ 本帖最后由 wuhen33400 于 2009-9-21 23:46 编辑 ]

论坛徽章:
0
9 [报告]
发表于 2009-09-21 22:24 |只看该作者
The following diagram illustrates a MySQL Cluster with four data nodes, arranged in two node groups of two nodes each; nodes 1 and 2 belong to node group 0, and nodes 3 and 4 belong to node group 1. Note that only data (ndbd) nodes are shown here; although a working cluster requires an ndb_mgm process for cluster management and at least one SQL node to access the data stored by the cluster, these have been omitted in the figure for clarity.


The data stored by the cluster is divided into four partitions, numbered 0, 1, 2, and 3. Each partition is stored — in multiple copies — on the same node group. Partitions are stored on alternate node groups:
•        Partition 0 is stored on node group 0; a primary replica (primary copy) is stored on node 1, and a backup replica (backup copy of the partition) is stored on node 2.
•        Partition 1 is stored on the other node group (node group 1); this partition's primary replica is on node 3, and its backup replica is on node 4.
•        Partition 2 is stored on node group 0. However, the placing of its two replicas is reversed from that of Partition 0; for Partition 2, the primary replica is stored on node 2, and the backup on node 1.
•        Partition 3 is stored on node group 1, and the placement of its two replicas are reversed from those of partition 1. That is, its primary replica is located on node 4, with the backup on node 3.

[ 本帖最后由 wuhen33400 于 2009-9-21 23:25 编辑 ]

replicas-groups-1-1.png (12.02 KB, 下载次数: 39)

replicas-groups-1-1.png

论坛徽章:
0
10 [报告]
发表于 2009-09-21 23:34 |只看该作者
原帖由 shujun579 于 2009-9-21 00:17 发表
首先,4个ndb节点的数据是有冗余的
你的配置文件里NoOfReplicas=2,所以每一行记录会在ndb节点上存2份
ndb有nodegroup的概念,在你的配置情况下,4个ndb节点会分为2个nodegroup,每个nodegrup中的每个节点的数 ...


在这个里面比如CD一组,EF一组,那只要CD或者EF不同时坏就没有问题,

那么其实在簇里,其实整个簇里的数据是被分成了NOD NUMER份的对吧?

在这个例子里就是分成了4份对吧?

CD是一样的,EF是一样的,但是CD,EF不能同时坏,可以坏CE、CF、DE、DF,但是不能CD同时坏,和EF坏对吧?

继续请教,谢谢。

看上面文章是那样写的。

就是不知道MYSQLD在查数据的时候怎么知道数据到底在哪个组里了,是在CD组还是在EF组里?

还是多多指教。

[ 本帖最后由 wuhen33400 于 2009-9-21 23:36 编辑 ]
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP