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. 关于SpringMVC中找不到<mvc:resources/>标签的解决办法

    在springMVC中我们经常会用到<mvc:resources/>标签,但是有些编辑器中的schema过于陈旧.导致找不到<mvc:resources/>标签. 经过试验,有 ...

  2. BZOJ3231(矩阵连乘,稍有点复杂)

    题目:3231: [Sdoi2008]递归数列 题意: 一个由自然数组成的数列按下式定义:   对于i <= k:ai = bi 对于i > k: ai = c1ai-1 + c2ai-2 ...

  3. HDU4099(斐波那契数列与字典树)

    题目:Revenge of Fibonacci 题意:给出斐波那契数列的前k位,k不超过40,找出最小的正整数n,满足F(n)的前k位与给定数的前k位相同,斐波那契数列的项数不超过100000. 解析 ...

  4. config -导航

    在config进行中配置 1在config中添加SITmap  <siteMap enabled="true" defaultProvider="UserSiteM ...

  5. 比较和排序 IComparable And IComparer

    1.List<Student>默认排序 为类创建默认排序实现IComparable,此代码的实现为年龄升序 using System; using System.Collections.G ...

  6. Compare the value of entity field.

    public class Program { static void Main(string[] args) { Program p = new Program(); p.Test(); Consol ...

  7. When to use HTML Helper?

    HTML Helper Single or closely related HTML elements(template) Simpler,low level logic for displaying ...

  8. if和switch的区别,循环的for 和while的区别, 字符串常用的7种方法

    相同点: 都是用于多重选择 不同点: 多重IF没有switch选择结构的限制,特别适合变量处于某个连续区间的情况 switch只能处理等值条件判断的情况,而且条件必须是整型变量或者字符串变量 字符串的 ...

  9. 「Foundation」集合

    一.NSArray和NSMutableArray (一)NSArray不可变数组 (1)NSArray的基本介绍 NSArray是OC中使用的数组,是面向对象的,以面向对象的形式操纵对象,是不可变数组 ...

  10. 在VS2010上使用C#调用非托管C++生成的DLL文件

    背景 在项目过程中,有时候你需要调用非C#编写的DLL文件,尤其在使用一些第三方通讯组件的时候,通过C#来开发应用软件时,就需要利用DllImport特性进行方法调用.本篇文章将引导你快速理解这个调用 ...