启动管理(MGM)节点:
这类节点的作用是管理MySQL簇内的其他节点,
如提供配置数据、启动并停止节点、运行备份等。由于这类节点
负责管理其他节点的配置,应在启动其他节点之前首先启动这类
节点。
[root@yan mysql-cluster]# ndb_mgmd --ndb_nodeid=1
Warning line 35: Cluster configuration warning:
arbitrator with id 1 and db node with id 3 on same host 192.168.10.100
arbitrator with id 2 and db node with id 4 on same host 192.168.10.200
arbitrator with id 5 has no hostname specified
arbitrator with id 6 has no hostname specified
Running arbitrator on the same host as a database node may
cause complete cluster shutdown in case of host failure.
[root@hui mysql-cluster]# ndb_mgmd --ndb_nodeid=2
启动数据节点(ndbd):
这类节点用于保存簇的数据。数据节点的数目与副本的数目相关,
是片段的倍数。例如,对于两个副本,每个副本有两个片段,那么
就有4个数据节点。
[root@yan mysql-cluster]# ndbd --connect-string="nodeid=3;host=192.168.10.100:1186"
[root@hui mysql-cluster]# ndbd --connect-string="nodeid=4;host=192.168.10.200:1186"
启动SQL节点(mysqld):
这是用来访问簇数据的节点。对于MySQL簇,客户端节点是使用NDB
簇存储引擎的传统MySQL服务器。典型情况下,SQL节点是使用命令
mysqld –ndbcluster启动的,或将ndbcluster添加到my.cnf后使用
mysqld启动。
[root@yan mysql-cluster]# mysqld_safe --ndb_nodeid=5 --user=mysql &
[root@hui mysql-cluster]# mysqld_safe --ndb_nodeid=6 --user=mysql &
在一个节点上建立数据库
[root@yan ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.30-ndb-6.3.20-cluster-gpl MySQL Cluster Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database yan;
Query OK, 1 row affected (0.23 sec)
mysql> use yan;
Database changed
mysql> create table hui(id int,name varchar(20));
Query OK, 0 rows affected (1.11 sec)
mysql>
在另一个节点上查看
[root@hui ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.30-ndb-6.3.20-cluster-gpl MySQL Cluster Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use yan;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select *from hui;
Empty set (0.01 sec)
mysql>
出现以上结果证明成功了
集群的停止
[root@yan mysql-cluster]# ndb_mgm -e shutdown
※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※