MySQL集群实践详解系列之三:如何配置Data node&SQL node&Management Node

笔者(mqboss)近期在做MySQL集群的技术调研,会陆续把自己的心得体会写出来和大家分享,请大家继续关注。

在安装完成后,接下来就要进行配置了。

每个data node和SQL node都需要一个my.cnf文件来配置两条信息:

a.connectstring 用于找到management node;

b.一行信息(ndbcluster)用来告诉MySQL server使用NDBCLUSTER存储引擎;

具体配置如下:(注意:如果/etc/目录下没有my.cnf文件,需要自己创建一个)

shell> vi /etc/my.cnf my.cnf的内容为:

# Options for mysqld process:

[mysqld]

ndbcluster # run NDB storage engine

ndb-connectstring=192.168.0.10

# location of management server

# Options for ndbd process:

[mysql_cluster]

ndb-connectstring=192.168.0.10# location of management server

management node需要一个config.ini文件,完成以下功能:

a.维护的replicas的数量;

b.为每个data node的data和indexe分配的内存的数量;

c.data node的主机名或IP;

d.data node中data在磁盘上的路径;

e.SQL node的主机名或IP;

首先需要创建存放配置文件的文件夹及配置文件本身
shell> mkdir /var/lib/mysql-cluster
shell> cd /var/lib/mysql-cluster
shell> vi config.ini

文件的内容示例如下:
# Options affecting ndbd processes on all data nodes:
[ndbd default]
NoOfReplicas=2 # Number of replicas
DataMemory=80M # How much memory to allocate for data storage
IndexMemory=18M # How much memory to allocate for index storage
# For DataMemory and IndexMemory, we have used the
# default values. Since the "world" database takes up
# only about 500KB, this should be more than enough for
# this example Cluster setup.
# TCP/IP options:
[tcp default]
portnumber=2202 # This the default; however, you can use any port that is free
# for all the hosts in the cluster
# Note: It is recommended that you do not specify the port
# number at all and allow the default value to be used instead
# Management process options:
[ndb_mgmd]
hostname=192.168.0.10 # Hostname or IP address of management node
datadir=/var/lib/mysql-cluster # Directory for management node log files
# Options for data node "A":
[ndbd]
# (one [ndbd] section per data node)
hostname=192.168.0.30 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
# Options for data node "B":
[ndbd]
hostname=192.168.0.40 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
# SQL node options:
[mysqld]
hostname=192.168.0.20 # Hostname or IP address
# (additional mysqld connections can be
# specified for this node for various
# purposes such as running ndb_restore)

作者简介: mqboss 是作者笔名,曾就职于普天和中兴,现在一外企工作,一直从事通信软件的测试、开发与设计工作,专注于JAVA, J2EE, WEB, DB等领域的理论研究、测试、开发与设计

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值