Chinaunix首页 | 论坛 | 博客
  • 博客访问: 746749
  • 博文数量: 95
  • 博客积分: 1754
  • 博客等级: 上尉
  • 技术积分: 1607
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-12 10:06
文章分类

全部博文(95)

文章存档

2015年(3)

2013年(15)

2012年(77)

分类: Mysql/postgreSQL

2012-03-18 22:15:05

配置NDB集群

//安装文件

Management节点:192.168.70.161

SQL节点:192.168.70.160

NDB-A节点:192.168.70.150

NDB-B节点:192.168.70.151

(1),server

 [root@appdb /]#groupadd mysql

 [root@appdb /]#useradd -g mysql mysql

 [root@appdb /]#rpm ivh MySQL-Cluster-gpl-server-7.0.28-1.rhel5.i386.rpm

 [root@appdb /]#rpm ivh MySQL-Cluster-gpl-client-7.0.28-1.rhel5.i386.rpm  

(2),storage

 [root@appdb /]#groupadd mysql

 [root@appdb /]#useradd -g mysql mysql

 [root@appdb /]#rpm ivh MySQL-Cluster-gpl-storage-7.0.28-1.rhel5.i386.rpm

 [root@appdb /]#rpm ivh MySQL-Cluster-gpl-client-7.0.28-1.rhel5.i386.rpm

 [root@appdb /]#rpm ivh MySQL-Cluster-gpl-tools-7.0.28-1.rhel5.i386.rpm

 

(3),management

 [root@appdb /]#groupadd mysql

 [root@appdb /]#useradd -g mysql mysql

  [root@appdb /]#rpm ivh MySQL-Cluster-gpl-management-7.0.28-1.rhel5.i386.rpm

 [root@appdb /]#rpm ivh MySQL-Cluster-gpl-client-7.0.28-1.rhel5.i386.rpm
 [root@appdb /]#rpm ivh MySQL-Cluster-gpl-extra-7.0.28-1.rhel5.i386.rpm  

 [root@appdb /]#rpm ivh MySQL-Cluster-gpl-tools-7.0.28-1.rhel5.i386.rpm

//配置文件

(1)在data节点和storage节点,都需要my.cnf配置文件。ndb-connectstring告诉节点可以找到management(管理节点),ndbcluster 告诉节点使用ndbcluster存储引擎。
(2)在management节点需要config.ini配置文件,在数据节点有多少复制维护,分配多少内存给数据和索引。怎么找到数据节点,怎么保存数据到硬盘在每个数据节点上,怎么找到数据节点。

(3)[root@appdb /]#vim /etc/my.cnf

[mysqld]
#run NDB  storage engine
ndbcluster
#location of management server
ndb-connectstring = 192.168.70.161
#options for ndbd process:
[ndb_cluster]
#location of management server
ndb-connectstring = 192.168.70.161

 
配置management节点,首先创建一个目录(/var/lib/mysql-cluster),然后在改目录下创建config.ini
[root@appdb /]#mkdir -pv /var/lib/mysql-cluster

[root@appdb /]#cd /var/lib/mysql-cluster/

[root@appdb /]#vim config.ini

[ndbd default]
NoOfReplicas=2
DataMemory=80M
IndexMemory=18M
[tcp default]
# TCP/IP options:
portnumber=2202
[ndb_mgmd]
# Management process options:

# Hostname or IP address of MGM node
hostname=192.168.70.161

# Directory for MGM node log files
datadir=/var/lib/mysql-cluster 
[ndbd]
# Options for data node "A":
# Hostname or IP address
hostname=192.168.70.150

# Directory for this data node's data files
datadir=/usr/local/mysql/data
[ndbd]
# Options for data node "B":

# Hostname or IP address
hostname=192.168.70.151

# Directory for this data node's data files
datadir=/usr/local/mysql/data  
[mysqld]
# SQL node options:
hostname=192.168.70.160

----------

 

//启动顺序

Management node节点--->NDB node节点--->SQL node节点

启动Management节点(192.168.70.161)

[root@appdb share]# ndb_mgmd /var/lib/mysql-cluster/config.ini

[root@localhost mysql-cluster]# netstat -ntlp|grep ndb_mgmd
tcp        0      0 0.0.0.0:1186                0.0.0.0:*                   LISTEN      7238/ndb_mgmd 
[root@localhost mysql-cluster]# ps -ef|grep ndb|grep -v grep
root      7238     1  0 Nov30 ?        00:00:22 ndb_mgmd /var/lib/mysql-cluster/config.ini

NDB-A节点:(192.168.70.150)

[root@appdb share]# ndbd --initial --ndb-connectstring=192.168.70.161:1186

[root@appdb share]# netstat -ntlp|grep ndbd
tcp        0      0 192.168.70.150:2202         0.0.0.0:*                   LISTEN      2837/ndbd    

NDB-B节点:(192.168.70.151)

[root@appdb share]# ndbd --initial --ndb-connectstring=192.168.70.161:1186

[root@appdb share]# netstat -ntlp|grep ndbd
tcp        0      0 192.168.70.150:2202         0.0.0.0:*                   LISTEN      2837/ndbd    

启动SQL节点(192.168.70.160)

[root@localhost share]# /etc/init.d/mysql start

[root@localhost share]# netstat -ntlp|grep 3306
tcp        0      0 :::3306                     :::*                        LISTEN      7004/mysqld     

[root@localhost share]# ps -ef|grep mysql|grep -v grep
root      6943     1  0 Nov30 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid
mysql     7004  6943  0 Nov30 ?        00:00:22 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --log-error=/var/lib/mysql/localhost.localdomain.err --pid-file=/var/lib/mysql/localhost.localdomain.pid

 //查看management节点查看

 [root@localhost mysql-cluster]# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)]     2 node(s)
id=2    @192.168.70.150  (mysql-5.1.56 ndb-7.0.28, Nodegroup: 0)
id=3    @192.168.70.151  (mysql-5.1.56 ndb-7.0.28, Nodegroup: 0, Master)

[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.70.161  (mysql-5.1.56 ndb-7.0.28)

[mysqld(API)]   1 node(s)
id=4    @192.168.70.160  (mysql-5.1.56 ndb-7.0.28

//编译配置实例

 ./configure --prefix=/usr/local/MySQL --without-debug --without-bench --enable-thread-safe-client --enable-assembler --with-charset=utf8 --with-extra-charsets=complex --with-client-ldflags=-all-static --with-MySQLd-ldflags=-all-static --with-ndbcluster --with-server-suffix=-max --datadir=/usr/local/mysql/data --with-unix-socket-path=/usr/local/mysql/sock/mysql.sock

 

阅读(1741) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~