具體安裝與配置:1)準備工作:6臺機器,IP地址分別為192.168.0.(231-236)MGM節點:192.168.0.231(232)SQL 節點:192.168.0.233-234NDBD 節點:192.168.0.235-236系統都是REDHAT AS 5.0裝了基本的部件,具有聯網功能,而且關閉了防火墻。軟件,版本是: mysql-5.1.21-beta-linux-i686-glibc23.tar.gz
2)管理節點的安裝:(232和231的機器)??? shell> cd /var/tmp
??? shell> tar -zxvf?? mysql-5.1.21-beta-linux-i686-glibc23.tar.gz
??? shell> cd /var/tmp/mysql-5.1.21-beta-linux-i686-glibc23
??? shell> mkdir /usr/local/mysql
??? shell> cp bin/ndb_mgm* /usr/local/mysql
??? shell> cd /usr/local/mysql
??? shell> chmod a+x ndb_mgm*
??? shell> mkdir data(
用來存放管理節點的數據)
3)SQL節點和NDBD 節點的安裝:(233-236 四臺機器)
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /var/tmp
shell> tar -C /usr/local -xzvf mysql-5.1.21-beta-linux-i686-glibc23.tar.gz
shell> mv /usr/local/mysql-5.1.21-beta-linux-i686-glibc23 /usr/local/mysql
shell> cd mysql
shell> scripts/mysql_install_db --user=mysql
shell> chown -R mysql:mysql /usr/local/mysql
SQL節點還要增加下面的步驟才可以:
shell> cp support-files/mysql.server /etc/rc.d/init.d/mysqld
shell> chmod a+x /etc/rc.d/init.d/mysqld
shell> chkconfig --add mysqld
shell> chkconfig mysqld on (注冊MYSQL為系統的服務)
4)配置NDBD節點:[root@localhost mysql]# cat /etc/my.cnf
[mysqld]
ndbcluster
#ndb-connectstring=192.168.0.231#ndb-connectstring=192.168.0.232這樣寫是可以連接成功。不過我今天來的時候發現全部DOWN掉了。
ndb-connectstring=192.168.0.231,192.168.0.232[mysql_cluster]
#ndb-connectstring=192.168.0.231#ndb-connectstring=192.168.0.232ndb-connectstring=192.168.0.231,192.168.0.232[root@localhost mysql]#
5)配置SQL 節點:[root@localhost mysql]# cat /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/
port=3306
user=nobody
socket=/tmp/mysql.sock
ndbcluster
#ndb-connectstring=192.168.0.231#ndb-connectstring=192.168.0.232ndb-connectstring=192.168.0.231,192.168.0.232[ndbd]
connect-string=192.168.0.235
[ndbd]
connect-string=192.168.0.236
[ndbd_mgm]
connect-string=192.168.0.231
[ndbd_mgm]
connect-string=192.168.0.232
[ndbd_mgmd]
config-file=/etc/config.ini
[mysql_cluster]
#ndb-connectstring=192.168.0.231#ndb-connectstring=192.168.0.232ndb-connectstring=192.168.0.231,192.168.0.232[root@localhost mysql]#
6) 配置管理節點:??
[root@localhost ~]# cat /etc/config.ini
[NDBD DEFAULT]
NoOfReplicas=2
DataMemory=600M
IndexMemory=100M
# TCP/IP options:
[TCP DEFAULT]
portnumber=2202
# Management process options:
[NDB_MGMD]
id=1
hostname=192.168.0.231
datadir=/usr/local/mysql/data
[NDB_MGMD]
id=2
hostname=192.168.0.232
datadir=/usr/local/mysql/data
# Options for data node A
[NDBD]
id=5
hostname=192.168.0.235
datadir=/usr/local/mysql/data
# Options for data node B
[NDBD]
id=6
hostname=192.168.0.236
datadir=/usr/local/mysql/data
# SQL node options:
[MYSQLD]
id=3
hostname=192.168.0.233
[MYSQLD]
id=4
hostname=192.168.0.234
[MYSQLD]
[MYSQLD]
[root@localhost ~]#
7)啟動管理節點:[root@localhost mysql]# /usr/local/mysql/ndb_mgmd -f /etc/config.ini
[root@localhost mysql]# ps aux | grep ndb | grep -v grep
root????? 6230? 0.0? 0.1? 17428? 1780 ???????? Ssl? 22:16?? 0:00 /usr/local/mysql/ndb_mgmd -f /etc/config.ini
啟動成功了。
默認MGMD是后臺啟動的。
8)啟動NDBD節點
[root@localhost mysql]# /usr/local/mysql/bin/ndbd --initial
(只是第一次啟動還有添加節點而且恢復的時候要加)
[root@localhost mysql]# ps aux | grep ndb | grep -v grep
root????? 3191? 0.0? 0.2? 17516? 1992 ???????? Ss?? 22:24?? 0:00 /usr/local/mysql/bin/ndbd --initial
root????? 3192? 4.2 15.3 911740 149120 ??????? Sl?? 22:24?? 0:00 /usr/local/mysql/bin/ndbd --initial
[root@localhost mysql]#
9)啟動SQL 節點:
[root@localhost mysql]# service mysqld start
Starting MySQL. SUCCESS!
10)查看是否連接成功
[root@localhost ~]# /usr/local/mysql/ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=5 @192.168.0.235 (Version: 5.1.21, Nodegroup: 0, Master)
id=6 @192.168.0.236 (Version: 5.1.21, Nodegroup: 0)
[ndb_mgmd(MGM)] 2 node(s)
id=1 @192.168.0.231 (Version: 5.1.21)
id=2 @192.168.0.232 (Version: 5.1.21)
[mysqld(API)] 3 node(s)
id=3 @192.168.0.233 (Version: 5.1.21)
id=4 @192.168.0.234 (Version: 5.1.21)
id=7 (not connected, accepting connect from any host)
id=8 (not connected, accepting connect from any host)
ndb_mgm>
我這個是配置兩臺管理節點和兩臺SQL節點以及兩臺NDBD節點的。以此類推。
以下是我在使用中遇到的錯誤信息:
?
1、
[mysqld(API)]? ?2 node(s)
id=4 (not connected, accepting connect from any host)
id=5 (not connected, accepting connect from any host)
2、[root@localhost ~]# /usr/local/mysql/bin/mysql -uroot -pEnter password:
Welcome to the MySQL monitor.??Commands end with ; or /g.
Your MySQL connection id is 1 to server version: 5.0.24-max
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
m
ysql> use testDatabase changed
mysql> show tables;
Empty set, 1 warning (0.00 sec)
mysql> create table t11 (id int) engine=ndb;ERROR 1050 (42S01): Table 't11' already exists
解決辦法:
運行setup或者ntsysv命令進入系統啟動設置。
去掉iptables.
關掉防火墻。不過保持sellinux是打開的。
早上還碰到一個錯誤:
[root@localhost data]# vi ndb_pid6423_error.log
Current byte-offset of file-pointer is: 568
Time: Friday 30 November 2007 - 23:15:28
Status: Permanent error, external action neededMessage: Invalid configuration received from Management Server (Configuration error)Error: 2350Error data: Could not connect to ndb_mgmdError object:Program: /usr/local/mysql/bin/ndbdPid: 6423
Trace: <no tracefile>
Version: Version 5.1.21 (beta)
***EOM***
~由于我沒有把ndb-connectstring=db1,db2,..dbn這樣的規律寫導致,已經解決。
PS:集群的數據節點是非常重要的,如果不能保證一個數據節點正常運行的話,集群也就失去了意義。管理節點在啟動了集群后也就沒有了意義。所以我在想多個管理節點是否有必要。