Architecture

Manager Node
mysql-mag1   192.168.1.31
mysql-mag2   192.168.1.32

SQL Node
mysql-sql1   192.168.1.33
mysql-sql2   192.168.1.34

NDB Node
mysql-ndb1   192.168.1.35
mysql-ndb2   192.168.1.36

[root@mysql-mag1 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6 #manager node
192.168.1.31 mysql-mag1
192.168.1.32 mysql-mag2 #sql node
192.168.1.33 mysql-sql1
192.168.1.34 mysql-sql2 #ndb node
192.168.1.35 mysql-ndb1
192.168.1.36 mysql-ndb2

MySQL Cluster7.2 JAVA must be installed configuration environment

[root@mysql-mag1 ~]# chmod u+x jdk-6u13-linux-x64.bin
[root@mysql-mag1 ~]# ./jdk-6u13-linux-x64.bin
[root@mysql-mag1 ~]# mv jdk1.6.0_13 /usr/local/
[root@mysql-mag1 ~]# echo "export JAVA_HOME=/usr/local/jdk1.6.0_13" >> /etc/profile
[root@mysql-mag1 ~]# echo "export CLASSPATH=.:$JAVA_HOME/lib/tools.jar" >> /etc/profile
[root@mysql-mag1 ~]# echo "export PATH=$JAVA_HOME/bin:$PATH" >> /etc/profile
[root@mysql-mag1 ~]# source /etc/profile
[root@mysql-mag1 ~]# java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02, mixed mode)
[root@mysql-mag1 ~]#
[root@mysql-mag1 ~]# javac -version
javac 1.6.0_13

Installation Manager Node1

[root@mysql-mag1 ~]# tar -zxvf mysql-cluster-gpl-7.2.10.tar.gz
[root@mysql-mag1 ~]# cd mysql-cluster-gpl-7.2.10
[root@mysql-mag1 mysql-cluster-gpl-7.2.10]#
[root@mysql-mag1 mysql-cluster-gpl-7.2.10]# cmake . -DCMAKE_INSTALL_PREFIX=/service/mysql -DSYSCONFDIR=/etc/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DCOMPILATION_COMMENT=Mysql-Cluster -DCMAKE_BUILD_TYPE=Release -DMYSQL_USER=mysql -DWITH_MYSQLMANAGER=ON -DWITH_EMBEDDED_SERVER=ON -DWITH_NDB_TEST=ON -DWITH_DEBUG=ON -DWITH_NDB_DEBUG=ON
[root@mysql-mag1 mysql-cluster-gpl-7.2.10]# make && make install
[root@mysql-mag1 mysql-cluster-gpl-7.2.10]# du -sh /service/mysql/
1017M /service/mysql/
[root@mysql-mag1 mysql-cluster-gpl-7.2.10]# cd /service/mysql/
[root@mysql-mag1 mysql]# mkdir mysql-cluster
[root@mysql-mag1 mysql]# chown -R mysql.mysql /service/mysql
[root@mysql-mag1 mysql]# mkdir -p /etc/mysql
[root@mysql-mag1 mysql]# cp /root/mysql-cluster-gpl-7.2.10/support-files/config.huge.ini /etc/mysql/config.ini
[root@mysql-mag1 mysql]# cat config.ini
[NDBD DEFAULT]
NoOfReplicas: 2
DataDir: /service/mysql/mysql-cluster
FileSystemPath: /service/mysql/data LockPagesInMainMemory: 1 DataMemory: 128M
IndexMemory: 64M [MGM DEFAULT]
PortNumber: 1186
DataDir: /service/mysql/mysql-cluster [TCP DEFAULT]
SendBufferMemory: 2M
ReceiveBufferMemory: 2M [NDB_MGMD]
NodeId: 1
HostName: 192.168.1.31
ArbitrationRank: 1 [NDB_MGMD]
NodeId: 2
HostName: 192.168.1.32
ArbitrationRank: 1 [NDBD]
NodeId: 3
HostName: 192.168.1.35 [NDBD]
NodeId: 4
HostName: 192.168.1.36 [API]
NodeId: 5
HostName: 192.168.1.33 [API]
NodeId: 6
HostName: 192.168.1.34

Installation Manager Node2

From manager node1 copy "config.ini,MYSQL_HOME/bin/*" to manager node2 and give permission.

[root@mysql-mag1 mysql]# scp /etc/mysql/config.ini mysql-mag2:/etc/mysql/
[root@mysql-mag1 mysql]# scp -rp /service/mysql/* mysql-mag2:/service/mysql/

On manager node2  give permission.

[root@mysql-mag2 mysql]# chown -R mysql.mysql /etc/mysql /service/mysql

Start Manager Node

The first time on the manager node to start the manager serverThe first time on the manager node to start the manager server.
On manager node1

[root@mysql-mag1 ~]# /service/mysql/bin/ndb_mgmd -f /etc/mysql/config.ini --config-dir=/service/mysql/mysql-cluster/ --initial
MySQL Cluster Management Server mysql-5.5.29 ndb-7.2.10

On manager node2

[root@mysql-mag2 mysql]# /service/mysql/bin/ndb_mgmd -f /etc/mysql/config.ini --config-dir=/service/mysql/mysql-cluster/ --initial
MySQL Cluster Management Server mysql-5.5.29 ndb-7.2.10

Start using reload parameters again

/service/mysql/bin/ndb_mgmd -f /etc/mysql/config.ini --config-dir=/service/mysql/mysql-cluster/ --reload

[root@mysql-mag1 ~]# /service/mysql/bin/ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=3 (not connected, accepting connect from 192.168.1.35)
id=4 (not connected, accepting connect from 192.168.1.36) [ndb_mgmd(MGM)] 2 node(s)
id=1 @192.168.1.31 (mysql-5.5.29 ndb-7.2.10)
id=2 @192.168.1.32 (mysql-5.5.29 ndb-7.2.10) [mysqld(API)] 2 node(s)
id=5 (not connected, accepting connect from 192.168.1.33)
id=6 (not connected, accepting connect from 192.168.1.34)

Installation NDB Node1 


Create my.cnf

[root@mysql-ndb1 ~]# cat /etc/mysql/my.cnf
[mysqld]
datadir=/service/mysql/data
basedir=/service/mysql
socket=/service/mysql/mysql.sock
default_storage_engine=NDBCLUSTER
ndbcluster
ndb-connectstring=mysql-mag1,mysql-mag2 [mysql_cluster]
ndb-connectstring=mysql-mag1,mysql-mag2

From manager node1 copy "MYSQL_HOME/bin/*" to ndb node1 and give permission.

[root@mysql-mag1 ~]# scp -rp /service/mysql/* mysql-ndb1:/service/mysql

On NDB node1 
give permission.

[root@mysql-ndb1 mysql]# chown -R mysql.mysql /etc/mysql /service/mysql

Installation NDB Node2

From ndb node1 copy "my.cnf,MYSQL_HOME/bin/*" to ndb node2 and give permission.

[root@mysql-ndb1 mysql]# scp -rp /etc/mysql/my.cnf mysql-ndb2:/etc/mysql/
[root@mysql-ndb1 mysql]# scp -rp /service/mysql/* mysql-ndb2:/service/mysql/

On NDB node2 
give permission.

[root@mysql-ndb2 mysql]# chown -R mysql.mysql /etc/mysql /service/mysql

Start NDB Node

[root@mysql-ndb1 ~]# /service/mysql/bin/ndbd --initial
2013-11-19 22:50:40 [ndbd] INFO -- Angel connected to 'mysql-mag1:1186'
2013-11-19 22:50:40 [ndbd] INFO -- Angel allocated nodeid: 3
[root@mysql-ndb2 ~]# /service/mysql/bin/ndbd --initial
2013-11-19 23:02:26 [ndbd] INFO -- Angel connected to 'mysql-mag1:1186'
2013-11-19 23:02:26 [ndbd] INFO -- Angel allocated nodeid: 4

NDB nodes "ndbd --initial" starting up only when the first time you start or need to recover from a backup database needs, other times as long as the executive  "ndbd -d"

View Manager Node

ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=3 @192.168.1.35 (mysql-5.5.29 ndb-7.2.10, Nodegroup: 0, Master)
id=4 @192.168.1.36 (mysql-5.5.29 ndb-7.2.10, Nodegroup: 0) [ndb_mgmd(MGM)] 2 node(s)
id=1 @192.168.1.31 (mysql-5.5.29 ndb-7.2.10)
id=2 @192.168.1.32 (mysql-5.5.29 ndb-7.2.10) [mysqld(API)] 5 node(s)
id=5 (not connected, accepting connect from 192.168.1.33)
id=6 (not connected, accepting connect from 192.168.1.34)
id=7 (not connected, accepting connect from any host)
id=8 (not connected, accepting connect from any host)
id=9 (not connected, accepting connect from any host)

Installation SQL Node1

[root@mysql-sql1 mysql-cluster-gpl-7.2.10]# cmake . -DCMAKE_INSTALL_PREFIX=/service/mysql -DMEMCACHED_HOME=/service/mysql/memcached -DSYSCONFDIR=/etc/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DCOMPILATION_COMMENT=Mysql-Cluster -DCMAKE_BUILD_TYPE=Release -DMYSQL_USER=mysql -DWITH_MYSQLMANAGER=ON -DBACKUP_TEST=OFF -DWITH_DEBUG=ON -DWITH_NDB_DEBUG=ON
[root@mysql-sql1 mysql-cluster-gpl-7.2.10]# make && make install
[root@mysql-sql1 mysql-cluster-gpl-7.2.10]# cp support-files/my-huge.cnf /etc/mysql/my.cnf
[root@mysql-sql1 mysql-cluster-gpl-7.2.10]# cat /etc/mysql/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock [mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 128M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
thread_concurrency = 8 ndbcluster
ndb-connectstring=mysql-mag1,mysql-mag2
user=mysql log-bin=mysql-bin
log-error [mysql_cluster]
ndb-connectstring=mysql-mag1,mysql-mag2 [mysqldump]
quick
max_allowed_packet = 16M [mysql]
no-auto-rehash [myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M [mysqlhotcopy]
interactive-timeout [root@mysql-sql1 mysql-cluster-gpl-7.2.10]# chown -R mysql.mysql /etc/mysql /service/mysql
[root@mysql-sql1 mysql-cluster-gpl-7.2.10]# cp support-files/mysql.server /etc/init.d/mysql
[root@mysql-sql1 mysql-cluster-gpl-7.2.10]# /service/mysql/scripts/mysql_install_db --user=mysql --basedir=/service/mysql
Installing MySQL system tables...
OK
Filling help tables...
OK To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands: /service/mysql/bin/mysqladmin -u root password 'new-password'
/service/mysql/bin/mysqladmin -u root -h mysql-sql1 password 'new-password' Alternatively you can run:
/service/mysql/bin/mysql_secure_installation which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with:
cd /service/mysql ; /service/mysql/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl
cd /service/mysql/mysql-test ; perl mysql-test-run.pl Please report any problems with the /service/mysql/scripts/mysqlbug script! [root@mysql-sql1 mysql-cluster-gpl-7.2.10]#

Installation SQL Node2

Installation is the same as the SQL Node1

Start SQL Node

On SQL Node1

[root@mysql-sql1 mysql-cluster-gpl-7.2.10]# /etc/init.d/mysql start
Starting MySQL....[ OK ]

On SQL Node2

[root@mysql-sql2 mysql]# /etc/init.d/mysql start
Starting MySQL.....[ OK ]

View Manager Node

ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=3 @192.168.1.35 (mysql-5.5.29 ndb-7.2.10, Nodegroup: 0, Master)
id=4 @192.168.1.36 (mysql-5.5.29 ndb-7.2.10, Nodegroup: 0) [ndb_mgmd(MGM)] 2 node(s)
id=1 @192.168.1.31 (mysql-5.5.29 ndb-7.2.10)
id=2 @192.168.1.32 (mysql-5.5.29 ndb-7.2.10) [mysqld(API)] 5 node(s)
id=5 @192.168.1.33 (mysql-5.5.29 ndb-7.2.10)
id=6 @192.168.1.34 (mysql-5.5.29 ndb-7.2.10)
id=7 (not connected, accepting connect from any host)
id=8 (not connected, accepting connect from any host)
id=9 (not connected, accepting connect from any host)

Test MySQL Cluster

[root@mysql-sql2 mysql]# /service/mysql/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.29-ndb-7.2.10-debug-log Mysql-Cluster Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| ndbcluster | YES | Clustered, fault-tolerant tables | YES | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| ndbinfo | YES | MySQL Cluster system information storage engine | NO | NO | NO |
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
11 rows in set (0.01 sec) mysql> select @@version;
+-----------------------------+
| @@version |
+-----------------------------+
| 5.5.29-ndb-7.2.10-debug-log |
+-----------------------------+
1 row in set (0.00 sec) mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| ndbinfo |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec) mysql> use test
Database changed
mysql> show tables;
Empty set (0.06 sec) mysql> create table t_test(
-> id int(5) primary key,
-> name varchar(20)
-> )engine=ndb comment='ndb test';
Query OK, 0 rows affected (0.24 sec) mysql> show create table t_test\G
*************************** 1. row ***************************
Table: t_test
Create Table: CREATE TABLE `t_test` (
`id` int(5) NOT NULL,
`name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=ndbcluster DEFAULT CHARSET=utf8 COMMENT='ndb test'
1 row in set (0.00 sec) mysql> insert into t_test values(1,'zwc');
Query OK, 1 row affected (0.00 sec)

Installation and Configuration MySQL Cluster 7.2 on CentOS 5 (include MySQL 5.5)的更多相关文章

  1. Scalable MySQL Cluster with Master-Slave Replication, ProxySQL Load Balancing and Orchestrator

    MySQL is one of the most popular open-source relational databases, used by lots of projects around t ...

  2. MySQL Cluster搭建与测试

    MySQL Cluster是一个基于NDB Cluster存储引擎的完整的分布式数据库系统.不仅仅具有高可用性,而且可以自动切分数据,冗余数据等高级功能.和Oracle Real Cluster Ap ...

  3. MySQL Cluster 集群

    本文转载 http://www.cnblogs.com/gomysql/p/3664783.html MySQL Cluster是一个基于NDB Cluster存储引擎的完整的分布式数据库系统.不仅仅 ...

  4. mysql cluster 名词概念解读

    Node Group [number_of_node_groups] = number_of_data_nodes / NoOfReplicas Partition When using ndbd, ...

  5. Mysql Cluster 集群 windows版本

    VM1:192.168.220.102 管理节点(MGM) VM2:192.168.220.103 数据节点(NDBD1),SQL节点(SQL1) VM3:192.168.220.104 数据节点(N ...

  6. 第 16 章 MySQL Cluster

    前言: MySQL Cluster 是一个基于 NDB Cluster 存储引擎的完整的分布式数据库系统.不仅仅具有高可用性,而且可以自动切分数据,冗余数据等高级功能.和 Oracle Real Cl ...

  7. MySql(十六):MySql架构设计——MySQL Cluster

    前言: MySQL Cluster 是一个基于 NDB Cluster 存储引擎的完整的分布式数据库系统.不仅仅具有高可用性,而且可以自动切分数据,冗余数据等高级功能.和 Oracle Real Cl ...

  8. MySQL性能调优与架构设计——第 16 章 MySQL Cluster

    第 16 章 MySQL Cluster 前言: MySQL Cluster 是一个基于 NDB Cluster 存储引擎的完整的分布式数据库系统.不仅仅具有高可用性,而且可以自动切分数据,冗余数据等 ...

  9. MySQL Cluster 配置文件(config.ini)详解

    MySQL Cluster 配置文件(config.ini)详解 ################################################################### ...

随机推荐

  1. Threads and Anonymous Classes in JAVA

    As we all know,a thread is a separate process on your computer.you can run multiple threads all at t ...

  2. Extjs 3.0 htmleditor实现插入图片功能

    首先感谢前辈们的无私奉献.贴出参考地址 http://zhidao.baidu.com/link?url=Q0ZM405OFNy_xAHSut9TepRJxgXCxFayQttrQz1N82dlA1_ ...

  3. dict和set的使用

    使用dict和set dict Python内置了字典:dict的支持,dict全称dictionary,在其他语言中也称为map,使用键-值(key-value)存储,具有极快的查找速度. 举个例子 ...

  4. BZOJ 1261: [SCOI2006]zh_tree( 区间dp )

    dp(l, r)表示[l, r]这段作为一棵树的最小访问代价. 对于dp(l, r), 我们枚举它的根x, 则dp(l, r) = min(dp(l, x-1)+dp(x+1, r)+C*fx) + ...

  5. 【转】从底层了解ASP.NET体系结构

    从底层了解ASP.NET体系结构 原文:http://blog.csdn.net/zhoufoxcn/article/details/1890158 Java体系架构的书多如牛毛,比如SSH架构什么的 ...

  6. 让innerHTML方法添加到元素里的js可以被解析执行

    <!DOCTYPE html> <html> <head> </head> <body> <div id="test&quo ...

  7. MyEclipse2014不支持jre1.8吗

    myeclipse 2015才支持了java 8 也可以用Eclipse Kepler加插件的形式来支持java 8

  8. IF的使用

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  9. java实现随机验证码的图片

    链接地址:http://blog.sina.com.cn/s/blog_407a68fc010006qo.html 1.一共需要2个常用java文件(RandomCode.java和RandomCod ...

  10. input file 在开发中遇到的问题 类似ajax form表单提交 input file中的文件

    最近在做项目的过程中遇到个问题,在这里做个记录防止日后忘记 现今的主流浏览器由于ajax提交form表单无法把文件类型数据提交到后台,供后台处理,可是开发中由于某些原因又不得不用ajax提交文件, 为 ...