centos5.5系统、32位cpu
5个安装软件包:
MySQL-Cluster-gpl-client-7.1.24-1.rhel5.i386.rpm
MySQL-Cluster-gpl-management-7.1.24-1.rhel5.i386.rpm
MySQL-Cluster-gpl-server-7.1.24-1.rhel5.i386.rpm
MySQL-Cluster-gpl-storage-7.1.24-1.rhel5.i386.rpm
MySQL-Cluster-gpl-tools-7.1.24-1.rhel5.i386.rpm
下载地址:
3台centos服务器:
SQL节点(mysqld): 10.10.21.16
数据节点(ndbd): 10.10.21.14
管理节点(ndb_mgmd): 10.10.21.13
最好按以下的安装顺序安装:首先是管理节点,然后是数据节点,最后是SQL节点。
一、管理节点安装:
[root@10-10-21-13 ~]# wget ... 24-1.rhel5.i386.rpm
[root@10-10-21-13 ~]# wget ... 24-1.rhel5.i386.rpm
[root@10-10-21-13 ~]# rpm -ivh MySQL-Cluster-gpl-management-7.1.24-1.rhel5.i386.rpm
[root@10-10-21-13 ~]# rpm -ivh MySQL-Cluster-gpl-tools-7.1.24-1.rhel5.i386.rpm
[root@10-10-21-13 ~]# mkdir /var/lib/mysql-cluster
[root@10-10-21-13~]# vim /var/lib/mysql-cluster/config.ini
[ndbd default]
NoOfReplicas=1
DataMemory=80M
IndexMemory=18M
[tcp default]
SendBufferMemory=2M
ReceiveBufferMemory=2M
[NDB_MGMD DEFAULT]
PortNumber=1186
Datadir=/var/lib/mysql-cluster
[ndb_mgmd]
NodeId=1
HostName=10.10.21.13
[ndbd]
NodeId=2
HostName=10.10.21.14
datadir=/var/lib/mysql-data
[mysqld]
NodeId=3
HostName=10.10.21.16
//启动管理节点
[root@10-10-21-13 ~]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini
MySQL Cluster Management Server mysql-5.1.63 ndb-7.1.24
这样管理节点就安装成功了!
注意:NoOfReplicas的数字要和数据节点的数量一样!
此外安装时如果碰到以下问题:
package MySQL-Cluster-gpl-management-7.1.24-1.rhel5.i386 is already installed
可以用下面办法解决:
[root@10-10-21-13 ~]# rpm -qa | grep -i '^mysql-'
MySQL-Cluster-gpl-management-7.1.24-1.rhel5
[root@10-10-21-13 ~]# rpm --nodeps -ev MySQL-Cluster-gpl-management-7.1.24-1.rhel5
二、数据节点安装:
[root@10-10-21-14 ~]# wget ... 24-1.rhel5.i386.rpm
[root@10-10-21-14 ~]# rpm -ivh MySQL-Cluster-gpl-storage-7.1.24-1.rhel5.i386.rpm
[root@10-10-21-14 ~]# mkdir /var/lib/mysql-data
[root@10-10-21-14~]# chmod 0777 /var/lib/mysql-data -R
[root@10-10-21-14 ~]# vim /etc/my.cnf
[mysqld]
max_connections = 100
slow_query_log = /var/lib/mysql-cluster/slow_query.log
long_query_time = 1
datadir = /var/lib/mysql-cluster
ndbcluster
ndb-connectstring = 10-10-21-13:1186
[mysql_cluster]
ndb-connectstring = 10-10-21-13:1186
//启动数据节点
[root@station1 ~]# ndbd --initial
2013-10-24 21:04:58 [ndbd] INFO -- Angel connected to '10.10.21.13:1186'
2013-10-24 21:04:58 [ndbd] INFO -- Angel allocated nodeid: 2
这样存储节点就安装成功了!
注意:(网上这么说未验证)ndbd --initial 不能同时在所有数据节点机器上执行,否者会删除所有数据.即该命令只能在其中一台数据节点中执行!
安装后第一次启动数据节点时要加上--initial参数,其它时候不要加,除非是在备份、恢复或配置变化后重启时!
三、SQL节点的安装:
[root@10-10-21-16 ~]# wget ... 24-1.rhel5.i386.rpm
[root@10-10-21-16 ~]# wget ... 24-1.rhel5.i386.rpm
[root@10-10-21-16 ~]# rpm -ivh MySQL-Cluster-gpl-server-7.1.24-1.rhel5.i386.rpm
[root@10-10-21-16 ~]# rpm -ivh MySQL-Cluster-gpl-client-7.1.24-1.rhel5.i386.rpm --nodeps --force
[root@10-10-21-16 ~]# vim /etc/my.cnf
[mysqld]
ndbcluster
ndb-connectstring=10-10-21-13:1186
[mysql_cluster]
ndb-connectstring=10-10-21-13:1186
//启动SQL节点
[root@localhost ~]# mysqld_safe
130923 11:19:41 mysqld_safe Logging to '/var/log/mysqld.log'.
130923 11:19:41 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
130923 11:20:13 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
这样SQL节点就安装成功了!
这个节点需要关闭1186和3306端口的防火墙(网上这么说但我未处理也能启动成功)!
四、验证各节点:
在管理节点的机子下(10-10-21-13)
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 1 node(s)
id=2 @10.10.21.14 (mysql-5.1.63 ndb-7.1.24, Nodegroup: 0, Master)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @10.10.21.13 (mysql-5.1.63 ndb-7.1.24)
[mysqld(API)] 1 node(s)
id=3 (not connected, accepting connect from 10.10.21.16)
出现not connected, accepting connect from any host是该节点没有启动或未配置正确。
[root@10-10-21-13~]# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 1 node(s)
id=2 @10.10.21.14 (mysql-5.1.63 ndb-7.1.24, Nodegroup: 0, Master)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @10.10.21.13 (mysql-5.1.63 ndb-7.1.24)
[mysqld(API)] 1 node(s)
id=3 @10.10.21.16 (mysql-5.1.63 ndb-7.1.24)
如果出现上面的信息说明全部安装成功了!
如果出现mysql-5.1.63 ndb-7.1.24, starting, Nodegroup: 0是数据节点已启动但sql节点未启动。
如何你的配置都没有错的话,那可能和你的防火墙设置有关!
五、动态更新节点
1、首先关闭全部ndb和sql节点:
注意关闭顺序:首先是SQL节点,然后是数据节点,最后是管理节点。
sql节点在sql节点上执行:
[root@10-10-21-16 ~]# service mysql stop
Shutting down MySQL.... [确定]
停止sql节点有点慢,不要用/etc/init.d/mysql restart。
ndb节点在管理节点上执行:
[root@10-10-21-13 ~]# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> all stop
Executing STOP on all nodes.
Node 2: Cluster shutdown initiated
Node 2: Node shutdown completed.
NDB Cluster has shutdown.
注意不能停止单个(网上说可以但本人尝试失败),否则会报如下错误:
Node 2: Node shutdown aborted
Shutdown failed.
* 2002: Stop failed
* Node shutdown would cause system crash: Permanent error: Application error
最后关闭管理节点!下面1 stop表示关闭管理节点,因为管理节点NodeId是1。
[root@10-10-21-13 ~]# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> 1 stop
Node 1 has shutdown.
Disconnecting to allow Management Server to shutdown
ndb_mgm> exit;
2、紧接着安装新的SQL节点和数据节点!
在10-10-21-14上同样执行上面“二、SQL节点的安装”的命令!
在10-10-21-16 上同样执行上面“三、数据节点安装”的命令!
3、接下来就是重启各节点:
注意启动顺序:首先是管理节点,然后是数据节点,最后是SQL节点。
[root@10-10-21-13 ~]# vim /var/lib/mysql-cluster/config.ini
[ndbd]
NodeId=4
HostName=10-10-21-16
datadir=/var/lib/mysql-data
[mysqld]
NodeId=5
HostName=10-10-21-14
[root@10-10-21-13 ~]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini --reload
MySQL Cluster Management Server mysql-5.1.63 ndb-7.1.24
//启动数据节点
[root@10-10-21-14 ~]# ndbd --initial
2012-11-13 00:45:47 [ndbd] INFO -- Angel connected to '10-10-21-13:1186'
2012-11-13 00:45:47 [ndbd] INFO -- Angel allocated nodeid: 2
//启动SQL节点
[root@10-10-21-16 ~]# mysqld_safe
121112 23:47:25 mysqld_safe Logging to '/var/lib/mysql/10-10-21-16.lightspeed.hstntx.sbcglobal.net.err'.
121112 23:47:26 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
121112 23:48:01 mysqld_safe mysqld from pid file /var/lib/mysql/10-10-21-13.lightspeed.hstntx.sbcglobal.net.pid ended
这样就动态更新节点成功了!
注意:修改NoOfReplicas的数字以保持和数据节点的数量一致!
都做完了在管理节点上show一下看看结果!如果不生效的话可能要考虑重启服务器!
[root@10-10-21-13 ~]# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @10-10-21-14 (mysql-5.1.63 ndb-7.1.24, Nodegroup: 0, Master)
id=4 @10-10-21-16 (mysql-5.1.63 ndb-7.1.24, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @10-10-21-13 (mysql-5.1.63 ndb-7.1.24)
[mysqld(API)] 2 node(s)
id=3 @10-10-21-16 (mysql-5.1.63 ndb-7.1.24)
id=5 @10-10-21-14 (mysql-5.1.63 ndb-7.1.24)
六、同步测试
从SQL节点10-10-21-16 登录,创建数据库和表,进行简单测试。
mysql> create database wangtest;
mysql> use wangtest;
Database changed
mysql> create table wang(id int,name varchar(10)) engine=ndb;
mysql> insert into wang values(1,'rschome.com');
mysql> select * from wang;
+------+------------+
| id | name |
+------+------------+
| 1 | rschome.com |
+------+------------+
1 row in set (0.01 sec)
登陆SQL节点10-10-21-13,查看效果,库,表和数据已经同步。
从B节点插入一条数据,同样登陆A,也能看到数据已经同步。
阅读(2604) | 评论(0) | 转发(1) |