db2:192.168.1.171
db1,db2上分别执行一下命令:
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
rpm -Uvh MySQL-Cluster-gpl-server-6.3.20-0.rhel5.i386.rpm
rpm -Uvh MySQL-Cluster-gpl-client-6.3.20-0.rhel5.i386.rpm
rpm -Uvh MySQL-Cluster-gpl-storage-6.3.20-0.rhel5.i386.rpm
rpm -Uvh MySQL-Cluster-gpl-management-6.3.20-0.rhel5.i386.rpm
rpm -Uvh MySQL-Cluster-gpl-tools-6.3.20-0.rhel5.i386.rpm
rpm -Uvh MySQL-Cluster-gpl-extra-6.3.20-0.rhel5.i386.rpm
(db1,db2上分别执行)
1.config.ini文件配置
cd /var/lib/mysql-cluster
vi config.ini
在config.ini中添加如下内容:
[ndbd default]
NoOfReplicas= 2
MaxNoOfConcurrentOperations= 10000
DataMemory= 80M
IndexMemory= 24M
TimeBetweenWatchDogCheck= 30000
DataDir= /var/lib/mysql-cluster
MaxNoOfOrderedIndexes= 512
StartPartialTimeout=100
StartPartitionedTimeout=100
ArbitrationTimeout=5000
TransactionDeadlockDetectionTimeout=5000
HeartbeatIntervalDbDb=5000
StopOnError=0
DataDir= /var/lib/mysql-cluster
[ndb_mgmd]
Id=1
HostName= 192.168.1.188
[ndb_mgmd]
Id=2
HostName= 192.168.1.171
[ndbd]
Id= 3
HostName= 192.168.1.188
[ndbd]
Id= 4
HostName= 192.168.1.171
[mysqld]
ArbitrationRank=2
[mysqld]
ArbitrationRank=2
[tcp default]
PortNumber= 63132
vi /etc/my.cnf
在my.cnf中添加如下内容:
[mysqld]
default-storage-engine=ndbcluster
ndbcluster
ndb-connectstring=192.168.1.188,192.168.1.171
[ndbd]
connect-string=192.168.1.188,192.168.1.171
[ndb_mgm]
connect-string=192.168.1.188,192.168.1.171
[ndb_mgmd]
config-file=/var/lib/mysql-cluster/config.ini
[mysql_cluster]
ndb-connectstring= 192.168.1.188,192.168.1.171
三、启动管理节点
Server1为:
# ndb_mgmd --ndb_nodeid=1
Server2为:
# ndb_mgmd --ndb_nodeid=2
# ndb_mgmd -f /var/lib/mysql-cluster/config.ini
Server2为:
# ndb_mgmd -f /var/lib/mysql-cluster/config.ini
在启动时有一个警告提示
Cluster configuration warning:
arbitrator with id 1 and db node with id 3 on same host 192.168.1.188
arbitrator with id 2 and db node with id 4 on same host 192.168.1.171
Running arbitrator on the same host as a database node may
cause complete cluster shutdown in case of host failure.
说节点1和3,2和4的arbitrator一样,可能引起整个集群失败。(可以不用放在心上)
方法一:初始化集群,--initial参数只有在第一次启动是使用.
在Server1中
# ndbd --nodeid=3 --initial
在Server2中
# ndbd --nodeid=4 --iniitial
Server1为:
# ndbd --connect-string="nodeid=3;host=192.168.1.188:1186"
Server2为:
# ndbd --connect-string="nodeid=4;host=192.168.1.111:1186"
# mysqld_safe --ndb_nodeid=5 --user=mysql &
在Server2中
# mysqld_safe --ndb_nodeid=6 --user=mysql &
在任意一台机子上启动管理终端:
# ndb_mgm
键入show命令查看当前工作状态:
---------------------
[ndbd(NDB)] 2 node(s)
id=3 @192.168.1.188 (Version: 6.0.0, Nodegroup: 0, Master)
id=4 @192.168.1.171 (Version: 6.0.0, Nodegroup: 0)
id=1 @192.168.1.188 (Version: 6.0.0)
id=2 @192.168.1.171 (Version: 6.0.0)
id=5 (not connected, accepting connect from any host)
id=6 (not connected, accepting connect from any host)
六、检查数据是否同步
七、破坏性测试
八、集群的关闭
#ndb_mgm -e shutdown
 
 
                     
            
        













 
                    

 
                 
                    