mysql cluter启动顺序:
management node ---> data node ---> sql node ############源代码安装mysql-cluster-gpl-7.2.15[root@Cent67 local]# mv mysql/* ndbbin/1.下载最新版本cmakeyum remove cmakewget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gztar xvf cmake-2.8.12.2.tar.gz cd cmake-2.8.12.2编译:./configure make && make install2.安装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 install3.创建MYSQL用户有:[root@tech2 mysql-5.1.70]# cat /etc/passwd|grep mysqlmysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash没有时:[root mysql-5.5.30]# groupadd mysql[root mysql-5.5.30]# useradd -g mysql mysql4.复制mysql配置文件my.cnf cp /soft/mysql-cluster-gpl-7.2.15/support-files/my-large.cnf /etc/my.cnf5.复制启动脚本 cp /soft/mysql-cluster-gpl-7.2.15/support-files/mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqld6.配置管理节点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=2DataMemory=200MIndexMemory=20M[NDB_MGMD]nodeid=1hostname=10.10.54.64datadir=/data/ndb#数据节点配置[NDBD]nodeid=2hostname=10.10.54.67datadir=/data/ndbBackupDataDir=/data/backup[NDBD]nodeid=3hostname=10.10.54.63datadir=/data/ndbBackupDataDir=/data/backup[NDBD]nodeid=4hostname=10.10.54.57datadir=/data/ndbBackupDataDir=/data/backup[NDBD]nodeid=5hostname=10.10.54.115datadir=/data/ndbBackupDataDir=/data/backup#sql节点配置[MYSQLD]nodeid=10hostname=10.10.54.67[MYSQLD]nodeid=11hostname=10.10.54.63[MYSQLD]nodeid=12hostname=10.10.54.57[MYSQLD]nodeid=13hostname=10.10.54.115[MYSQLD][MYSQLD][MYSQLD]################7.创建目录10.10.54.64/67/63/57/115//级联创建数据目录mkdir -p /data/ndbdatachown -R mysql.mysql /data/ndbdata //创建安装目录mkdir -p /usr/local/mysqlchown -R mysql.mysql /usr/local/mysql //创建备份节点目录[root@Cent64 data]# mkdir -p /data/backup8.修该管理节点配置文件10.10.54.64[root@Cent64 data]# vim /etc/my.cnf datadir = /data/ndb9.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/ndbdatandbclusterndb-connectstring=10.10.54.6410.//初始化数据库10.10.54.64/67/63/57/115初始化[root@CentOS63 mysql]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysqlInstalling 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 --initialMySQL Cluster Management Server mysql-5.5.35 ndb-7.2.1512.启动data节点10.10.54.67/63/57/115[root@CentOS63 mysql]# ndbd --initial --ndb-connectstring=10.10.54.642014-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: 313.启动sql节点/etc/init.d/mysqld start[root@Cent67 mysql]# ps -ef |grep mysql[root@Cent67 mysql]# kill -9 2205 259514.察看连接状态[root@Cent64 ndb]# ndb_mgm-- NDB Cluster -- Management Client --ndb_mgm> showConnected to Management Server at: localhost:1186Cluster 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 19:28>create table aa(a int)engine=ndbcluster;root 19:33>show tables;+----------------+| Tables_in_test |+----------------+| aa |+----------------+在10.10.54.63自动有root 19:34>show tables;+----------------+| Tables_in_test |+----------------+| aa |+----------------+