http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-overview.html
mysql cluster是一个基于NDB cluster存储引擎的完整的分布式数据库系统,不仅具有高可用性,而且自动切分数据,冗余数据等高级功能。
主要组成部分:
1.sql层的sql服务器节点,主要做数据访问,通常称作mysql server
2.storage层的NDB数据节点,主要功能是保存cluster数据,即NDBcluster
3.manage节点主机,主要管理整个集群中各个节点的管理工作,包括集群配置,关闭启动,常规维护,数据备份恢复等
实验环境:
操作系统:rhel
所需软件包:mysql-cluster-gpl-7.1.4b-linux-x86_64-glibc23.tar.gz
manage节点:192.168.1.20 NDB.lu.com
sql1节点:192.168.1.21 sql1.lu.com
sql2节点:192.168.1.22 sql2.lu.com
ndb1节点: 192.168.1.23 DB1.lu.com
ndb2节点: 192.168.1.24 DB2.lu.com
预期效果,对sql1进行写动作,在sql2中查询,得到更新的数据。
结果:
[root@sql1 ~]# /usr/local/mysql/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.44-ndb-7.1.4b-cluster-gpl-log MySQL Cluster Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use test;
Database changed
mysql> create table user(id int,name varchar(30));
Query OK, 0 rows affected (0.58 sec)
mysql> insert into user values(1,'lu');
Query OK, 1 row affected (0.03 sec)
[root@sql2 ~]# /usr/local/mysql/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.44-ndb-7.1.4b-cluster-gpl-log MySQL Cluster Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| ndbinfo |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> use test;
Database changed
mysql> select * from user;
Empty set (0.06 sec)
mysql> select * from user;
+------+------+
| id | name |
+------+------+
| 1 | lu |
+------+------+
1 row in set (0.00 sec)
[root@NDB ~]# /usr/local/mysql/bin/ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @192.168.1.23 (mysql-5.1.44 ndb-7.1.4, Nodegroup: 0, Master)
id=3 @192.168.1.24 (mysql-5.1.44 ndb-7.1.4, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.1.20 (mysql-5.1.44 ndb-7.1.4)
[mysqld(API)] 4 node(s)
id=4 @192.168.1.21 (mysql-5.1.44 ndb-7.1.4)
id=5 @192.168.1.22 (mysql-5.1.44 ndb-7.1.4)