源码安装mysql-cluster-gpl-7.2.15.tar.gz 及 ndb集群设置


搭建sql节点(4个),data节点(4个),manage节点(1个)---源代码版本

mysql cluter启动顺序:
management node ---> data node ---> sql node


############
源代码安装mysql-cluster-gpl-7.2.15
[root@Cent67 local]# mv mysql/* ndbbin/
1.下载最新版本cmake
yum remove cmake
wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz
tar xvf cmake-2.8.12.2.tar.gz
cd cmake-2.8.12.2
编译:./configure
      make && make install

2.安装mysql-cluster-gpl-7.2.15.tar.gz
##解压缩文件
[root@Cent67 soft]# tar xvf mysql-cluster-gpl-7.2.15.tar.gz
##切换目录
cd mysql-cluster-gpl-7.2.15
##编译

cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_UNIX_ADDR=/tmp/mysql-cluster.sock
-DMYSQL_DATADIR=/data/ndbdata
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DEXTRA_CHARSETS=all
 -DWITH_EMBEDDED_SERVER=0
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
 -DWITH_MEMORY_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_FEDERATED_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DWITH_NDBCLUSTER_STORAGE_ENGINE=1
-DMYSQL_TCP_PORT=3306
-DENABLED_LOCAL_INFILE=1
-DMYSQL_USER=mysql
-DWITH_DEBUG=0
-DWITH_SSL=yes
-DWITH_NDB_JAVA=OFF


编译错误后:
清除缓存:rm CMakeCache.txt
重新编译

安装 make && make install

3.创建MYSQL用户
有:
[root@tech2 mysql-5.1.70]# cat /etc/passwd|grep mysql
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
没有时:
[root@gyf  mysql-5.5.30]# groupadd mysql
[root@gyf  mysql-5.5.30]# useradd -g mysql mysql

4.复制mysql配置文件my.cnf

 cp /soft/mysql-cluster-gpl-7.2.15/support-files/my-large.cnf /etc/my.cnf

5.复制启动脚本
 cp /soft/mysql-cluster-gpl-7.2.15/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld

6.配置管理节点
10.10.54.64
//把命令复制到/usr/local/bin/ 的path下
[root@Cent64 mysql]# cd mysql-cluster-gpl-7.2.15-linux2.6-x86_64/bin/
[root@Cent64 bin]# cp ndb_mgm* /usr/local/bin/
//管理节点配置
10.10.54.64
[root@tech03 ndb]# vim /etc/ndb/config.ini
#####################
[NDBD DEFAULT]
NoOfReplicas=2
DataMemory=200M
IndexMemory=20M

[NDB_MGMD]
nodeid=1
hostname=10.10.54.64
datadir=/data/ndb
#数据节点配置
[NDBD]
nodeid=2
hostname=10.10.54.67
datadir=/data/ndb
BackupDataDir=/data/backup
[NDBD]
nodeid=3
hostname=10.10.54.63
datadir=/data/ndb
BackupDataDir=/data/backup
[NDBD]
nodeid=4
hostname=10.10.54.57
datadir=/data/ndb
BackupDataDir=/data/backup

[NDBD]
nodeid=5
hostname=10.10.54.115
datadir=/data/ndb
BackupDataDir=/data/backup
#sql节点配置
[MYSQLD]
nodeid=10
hostname=10.10.54.67

[MYSQLD]
nodeid=11
hostname=10.10.54.63

[MYSQLD]
nodeid=12
hostname=10.10.54.57
[MYSQLD]
nodeid=13
hostname=10.10.54.115
[MYSQLD]
[MYSQLD]
[MYSQLD]

################
7.创建目录
10.10.54.64/67/63/57/115
//级联创建数据目录
mkdir -p /data/ndbdata
chown -R mysql.mysql /data/ndbdata
//创建安装目录
mkdir -p /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql
//创建备份节点目录
[root@Cent64 data]# mkdir -p /data/backup
8.修该管理节点配置文件
10.10.54.64
[root@Cent64 data]# vim /etc/my.cnf
datadir         = /data/ndb


9.SQL节点配置
10.10.54.67/63/57/115    

vim /etc/my.cnf添加:
#在[client]与[mysqld]

[mysql_cluster]
ndb-connectstring=10.10.54.64

[mysqld]
datadir         = /data/ndbdata
ndbcluster
ndb-connectstring=10.10.54.64

10.//初始化数据库
10.10.54.64/67/63/57/115

初始化
[root@CentOS63 mysql]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql
Installing MySQL system tables...
/usr/local/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

[root@CentOS63 mysql]# yum install libaio.x86_64  



11.启动管理节点10.10.54.64
[root@Cent64 ndb]# ndb_mgmd -f /etc/ndb/config.ini  --initial
MySQL Cluster Management Server mysql-5.5.35 ndb-7.2.15

12.启动data节点
10.10.54.67/63/57/115
[root@CentOS63 mysql]# ndbd --initial --ndb-connectstring=10.10.54.64
2014-02-26 11:37:45 [ndbd] INFO     -- Angel connected to '10.10.54.64:1186'
2014-02-26 11:37:45 [ndbd] INFO     -- Angel allocated nodeid: 3

13.启动sql节点
/etc/init.d/mysqld start
[root@Cent67 mysql]# ps -ef |grep mysql
[root@Cent67 mysql]# kill -9 2205 2595
14.察看连接状态
[root@Cent64 ndb]# 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    @10.10.54.67  (mysql-5.5.35 ndb-7.2.15, Nodegroup: 0, *)
id=3    @10.10.54.63  (mysql-5.5.35 ndb-7.2.15, Nodegroup: 0)

[ndb_mgmd(MGM)]    1 node(s)
id=1    @10.10.54.64  (mysql-5.5.35 ndb-7.2.15)

[mysqld(API)]    6 node(s)
id=10    @10.10.54.67  (mysql-5.5.35 ndb-7.2.15)
id=11    @10.10.54.63  (mysql-5.5.35 ndb-7.2.15)

//修改密码
[root@Cent64 ndb]# /usr/local/mysql/bin/mysqladmin  -u root password 'aaa12345'

#####验证NDB集群
在10.10.54.67上
root@test  19:28>create table aa(a int)engine=ndbcluster;

root@test  19:33>show  tables;
+----------------+
| Tables_in_test |
+----------------+
| aa             |
+----------------+
在10.10.54.63自动有

root@test  19:34>show tables;
+----------------+
| Tables_in_test |
+----------------+
| aa             |
+----------------+

你可能感兴趣的:(ndb集群)