网上所有讲述关于MySQL Cluster 的文章
要不就是跳过了某些步骤没说
要不就是搞得太复杂.把配置文件能写的都加上了
这对于按需自定义很不方便
甚至MySQL官网的HELP
对于某些内容的描述也是有些模糊和遗漏的
只能参考N多文档进行N多试验.
最后得出正确以及最简化的配置方法
然后大家可以按照最简化的配置.
自行加上所需的配置内容.
网络分布
MySQL Server1 : 192.168.210.131
MySQL Server2 : 192.168.210.132
NDB MGM : 192.168.210.133
NDB1 : 192.168.210.134
NDB2 : 192.168.210.135
NDB节点
先从MYSQL官网下载NDB Storage Engine
http://mirrors.24-7-solutions.net/pub/mysql/Downloads/MySQL-5.0/MySQL-ndb-storage-5.0.45-0.glibc23.i386.rpm
安装后配置my.cnf
NDB节点的配置文件只需要一句话用来指定MGM的地址即可
# vi /etc/my.cnf
[MYSQL_CLUSTER]
ndb-connectstring=192.168.210.133
初始化ndbd
# ndbd –initial
启动ndbd
# ndbd
MGM节点
安装PERL模块
# yum install perl
# wget http://dag.wieers.com/rpm/packages/perl-HTML-Template/perl-HTML-Template-2.9-1.el5.rf.noarch.rpm
# rpm -ivh perl-HTML-Template-2.9-1.el5.rf.noarch.rpm
下载MGM服务以及管理工具
http://mirrors.24-7-solutions.net/pub/mysql/Downloads/MySQL-5.0/MySQL-ndb-management-5.0.45-0.glibc23.i386.rpm
http://mirrors.24-7-solutions.net/pub/mysql/Downloads/MySQL-5.0/MySQL-ndb-tools-5.0.45-0.glibc23.i386.rpm
安装之后配置MGM配置文件
#vi /etc/ndb.ini
# Example Ndbcluster storage engine config file.
#
[ndbd default]
NoOfReplicas= 2
MaxNoOfConcurrentOperations= 10000
DataMemory= 80M
IndexMemory= 24M
TimeBetweenWatchDogCheck= 30000
DataDir= /var/lib/mysql-cluster
MaxNoOfOrderedIndexes= 512
[ndb_mgmd default]
DataDir= /var/lib/mysql-cluster
[ndb_mgmd]
Id=1
HostName=192.168.210.133
[ndbd]
Id= 2
HostName=192.168.210.134
[ndbd]
Id= 3
HostName=192.168.210.135
[mysqld]
Id= 4
hostname=192.168.210.131
[mysqld]
Id= 5
hostname=192.168.210.132
# choose an unused port number
# in this configuration 63132, 63133, and 63134
# will be used
[tcp default]
PortNumber= 63132
启动MGM
# ndb_mgmd -f /etc/ndb.ini
MySQL节点
安装MySQL服务端,Redhat自带的5.0.22版本似乎不支持mysql cluster
http://mirrors.24-7-solutions.net/pub/mysql/Downloads/MySQL-5.0/MySQL-devel-5.0.45-0.glibc23.i386.rpm
http://mirrors.24-7-solutions.net/pub/mysql/Downloads/MySQL-5.0/MySQL-server-5.0.45-0.glibc23.i386.rpm
安装MySQL客户端
http://mirrors.24-7-solutions.net/pub/mysql/Downloads/MySQL-5.0/MySQL-shared-5.0.45-0.glibc23.i386.rpm
http://mirrors.24-7-solutions.net/pub/mysql/Downloads/MySQL-5.0/MySQL-client-5.0.45-0.glibc23.i386.rpm
MySQL配置文件
# vi /etc/my.cnf
[MYSQLD]
ndbcluster
ndb-connectstring=192.168.210.133
#将默认存储方式改成NDB,对于生产环境下的MySQL Cluster会方便很多.
default-storage-engine=ndbcluster
启动MySQL
# /etc/rc.d/init.d/mysql restart
然后我们回到MGM节点服务器192.168.210.133
查看节点情况
# ndb_mgm
> show
ndb_mgm> show
Cluster Configuration
———————
[ndbd(NDB)] 2 node(s)
id=2 @192.168.210.134 (Version: 5.0.45, Nodegroup: 0)
id=3 @192.168.210.135 (Version: 5.0.45, Nodegroup: 0, Master)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.210.133 (Version: 5.0.45)
[mysqld(API)] 4 node(s)
id=4 @192.168.210.131 (Version: 5.0.45)
id=5 @192.168.210.132 (Version: 5.0.45)
所有节点都已正常启动
安装MySQL Cluster有几点要注意
1.不能使用RedHat或者CentOS自带的mysql服务.此服务甚至不支持NDB的参数
2.似乎NDB只有二进制代码下载.至今没有找到源代码包下载