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. UC/0S2之中断

    中断是计算机系统处理异步事件的重要机制.当异步事件发生时,事件通常是通过硬件向cpu发出中断请求的.在一般情况下,cpu响应这个请求后会立即运行中断服务程序来处理该事件: 为了处理任务延时.任务调度等 ...

  2. 基于表单的身份验证(FBA)

    https://technet.microsoft.com/zh-cn/library/ee806890(office.15).aspx http://www.tuicool.com/articles ...

  3. 面向对象之静态方法(static)和实例化方法的区别

    这是一个经常被时时提出来的问题,很多时候我们以为理解了.懂了,但深究一下,我们却发现并不懂. 方法是我们每天都在写得,很多程序员大多都使用实例化方法,而很少使用静态方法,问原因也说不出来所以然,或者简 ...

  4. Hive环境搭建心得(Ubuntu)

    Hive是什么? 基于Hadoop的数据查询工具,可以使用类SQL进行数据查询. Hadoop安装 参考了Hadoop安装 注意到etc/hadoop/hadoop-env.sh里设置JAVA_HOM ...

  5. easyui-datagrid通过action从数据库获取数据的关键代码

    实际上是结合struts2来从数据获取json格式的数据.   关键代码: GetUserAction.java代码   package com.log.control; import java.io ...

  6. android设置按钮按下的不同效果图

    <!-- 按钮设置按下去的不同效果的方式,设置android:background属性, 下面的 button_select实际上是button_select.xml --> <Bu ...

  7. Single Number i and ii

    Single Number Given an array of integers, every element appears twice except for one. Find that sing ...

  8. UIWebvView 解决onClick 延迟相应问题

    在使用 UIWebView 的过程中, 发现 onClick 触发需要等待300-500ms, Google了一下, 发现是因为ScrollView 在等待doubleTap, 所以有延迟 使用如下代 ...

  9. 挺有意思的HBase日志+Splunk

    如题,转载自: http://hi.baidu.com/harry_lime/item/10cf2c174853c7ea39cb3042 如何模拟拔盘操作 Linux has a nifty way ...

  10. 用Response对象的write方法和<%%>及<%=%>输出同样效果的乘法表格

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Response1.aspx ...