MySQL NDB 6.3.20集群安装
时间:2010-07-17 来源:ygl23
引言:
本文会先对MySQL集群稍作一点介绍,然后会提供一个安装过程。
介绍:
MySQL集群是一种在无共享架构系统里应用内存数据库集群的技术。这种无共享的架构可以使得系统使用非常便宜的并且是最小配置的硬件。
MySQL集群是一种分布式设计,目标是要达到没有任何单点故障点。因此,任何组成部分都应该拥有自己的内存和磁盘。任何共享存储方案如网络共享,网络文件系统和SAN设备是不推荐或不支持的。通过这种冗余设计,MySQL声称数据的可用度可以达到99。999%。
实际上,MySQL集群是把一个叫做NDB的内存集群存储引擎集成与标准的MySQL服务器集成。它包含一组计算机,每个都跑一个或者多个进程,这可能包括一个MySQL服务器,一个数据节点,一个管理服务器和一个专有的一个数据访问程序。它们之间的关系如下图所示:
安装
准备:
机器: 全部安装Red Hat Linux AS 5且关闭防火墙
软件: mysql-cluster-gpl-6.3.20-linux-i686-glibc23.tar.gz
四台机器分别分配如下IP及用途:
IP |
Description |
192.168.99.80 |
Management Node |
192.168.99.88 |
SQL Node |
192.168.99.89 |
Data Node |
192.168.99.90 |
Data Node |
安装节点,四台机器,需要重复四次:
[root@candyshop ~]#groupadd mysql [root@candyshop ~]#useradd –g mysql mysql [root@candyshop ~]#tar zxvf mysql-cluster-gpl-6.3.20-linux-i686-glibc23.tar.gz [root@candyshop ~]#chown mysql:mysql mysql-cluster-gpl-6.3.20-linux-i686-glibc23 [root@candyshop ~]#mv mysql-cluster-gpl-6.3.20-linux-i686-glibc23 /usr/local/mysql |
上述命令先创建mysql组和mysql用户,并且把mysql分配到mysql组,然后将安装文件解压,把它放置到/usr/local/mysql目录。
配置
配置管理节点[192.168.99.80]:
创建以下文件/usr/local/mysql/cluster-conf/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.
# Management process options: [ndb_mgmd] Id=1 Hostname=192.168.99.80 # Hostname or IP address of management node Datadir=/usr/local/mysql/logs # Directory for management node log files
# Options for data node "A": [ndbd] Id=2 Hostname=192.168.99.89 # Hostname or IP address Datadir=/usr/local/mysql/ndbdata # Directory for this data node's data files
# Options for data node "B": [ndbd] Id=3 Hostname=192.168.99.90 # Hostname or IP address Datadir=/usr/local/mysql/ndbdata # Directory for this data node's data files
# SQL node options: [mysqld] Id=4 Hostname=192.168.99.88 # Hostname or IP address # (additional mysqld connections can be # specified for this node for various # purposes such as running ndb_restore)
|
在这个文件里,我们分别给四个节点分配了ID,这有利于更好的管理和区分各个节点。当然,要是不指定,MySQL也会动态分配一个。上述几个Datadir如果还不存在的需要手动创建。用mkdir –p命令即可。
配置数据节点[192.168.99.89, 192.168.99.90]:
创建/etc/my.cnf文件,内容如下
# Options for mysqld process: [mysqld] Datadir=/usr/local/mysql/ndbdata ndbcluster # run NDB storage engine ndb-connectstring=192.168.99.80 # location of management server
# Options for ndbd process: [mysql_cluster] ndb-connectstring=192.168.99.80 # location of management server |
配置SQL节点[192.168.99.88]
创建/etc/my.cnf文件,内容如下
# Options for mysqld process: [mysqld] ndbcluster # run NDB storage engine ndb-connectstring=192.168.99.80 # location of management server
# Options for ndbd process: [mysql_cluster] ndb-connectstring=192.168.99.80 # location of management server |
[root@server88 mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --ldata=/usr/local/mysql/data/ Installing MySQL system tables... OK Filling help tables... OK |
到这里,所有配置已经完成了。
启动
启动管节点[192.168.99.80]:
[root@candyshop mysql]# ./bin/ndb_mgmd -f cluster-conf/config.ini [root@candyshop mysql]# ./bin/ndb_mgm -- NDB Cluster -- Management Client -- ndb_mgm> show Connected to Management Server at: 192.168.99.80:1186 Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=2 (not connected, accepting connect from 192.168.99.89) id=3 (not connected, accepting connect from 192.168.99.90)
[ndb_mgmd(MGM)] 1 node(s) id=1 @192.168.99.80 (mysql-5.1.30 ndb-6.3.20)
[mysqld(API)] 1 node(s) id=4 (not connected, accepting connect from 192.168.99.88) |
我们可以看到集群的状态都还没有启动,都是not connected状态。
[root@candyshop mysql]# ./bin/ndb_mgmd -f cluster-conf/config.ini [root@candyshop mysql]# ./bin/ndb_mgm -- NDB Cluster -- Management Client -- ndb_mgm> show Connected to Management Server at: 192.168.99.80:1186 Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=2 (not connected, accepting connect from 192.168.99.89) id=3 (not connected, accepting connect from 192.168.99.90)
[ndb_mgmd(MGM)] 1 node(s) id=1 @192.168.99.80 (mysql-5.1.30 ndb-6.3.20)
[mysqld(API)] 1 node(s) id=4 (not connected, accepting connect from 192.168.99.88) |
启动数据节点[192.168.99.89, 192.168.99.90]:
[root@server89 ~]#cd /usr/local/mysql [root@server89 mysql]#./bin/ndbd |
启动SQL节点[192.168.99.88]:
[root@server88 mysql]# ./bin/mysqld_safe & |
至此,所有节点已经启动完成,让我们来查看系统状态:
ndb_mgm> show Connected to Management Server at: localhost:1186 Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=2 @192.168.99.89 (mysql-5.1.30 ndb-6.3.20, Nodegroup: 0, Master) id=3 @192.168.99.90 (mysql-5.1.30 ndb-6.3.20, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s) id=1 @192.168.99.80 (mysql-5.1.30 ndb-6.3.20)
[mysqld(API)] 1 node(s) id=4 @192.168.99.88 (mysql-5.1.30 ndb-6.3.20) |
至此,安装已经结束.
原文: http://ginge.javaeye.com/blog/320205 其它: http://www.oschina.net/bbs/thread/414