我的MySQL-Cluster集群结构是1台服务器单独作为管理节点,两台服务器作为数据节点和mysql节点
配置文件如下:
管理节点配置文件config.ini
[ndbd default]
NoOfReplicas= 2
MaxNoOfConcurrentOperations= 500000
MaxNoOfLocalOperations=500000
MaxNoOfConcurrentTransactions=500000
MaxNoOfConcurrentIndexOperations=50000
# Amount of memory required=(SizeofDatabase * NumberOfReplicas * 1.1 ) / NumberOfDataNodes
DataMemory= 49152M
IndexMemory= 6144M
TimeBetweenWatchDogCheck= 30000
DataDir=/var/lib/mysql/data
MaxNoOfAttributes=500000
MaxNoOfTables=1000
MaxNoOfOrderedIndexes= 512
#StartPartialTimeout=100
#StartPartitionedTimeout=100
#ArbitrationTimeout=5000
#MaxNoOfFiredTriggers=8000
#TransactionBufferMemory=5M
TransactionDeadlockDetectionTimeout=90000
HeartbeatIntervalDbDb=5000
#StopOnError=1
[ndb_mgmd default]
DataDir=/var/lib/mysql/data
[ndb_mgmd]
NodeId=1
HostName= 172.16.1.78
[ndbd]
NodeId= 2
HostName= 172.16.1.74
[ndbd]
NodeId= 3
HostName= 172.16.1.75
[mysqld]
ArbitrationRank=2
[mysqld]
ArbitrationRank=2
[mysqld]
[mysqld]
[mysqld]
[mysqld]
[tcp default]
portnumber=2279
ndb节点和mysql节点的配置文件my.cnf
[mysqld]
datadir=/var/lib/mysql/data/
socket=/var/lib/mysql/mysql.sock
lower_case_table_names=1
ndb_cluster_connection_pool=2
tmp_table_size=512M
max_heap_table_size=512M
max_connections =400
thread_stack=1M
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
default-storage-engine=ndbcluster
ndbcluster
ndb-connectstring=172.16.1.78
[ndbd]
connect-string=172.16.1.78
[ndb_mgm]
connect-string=172.16.1.78
[ndb_mgmd]
config-file=/var/lib/mysql-cluster/config.ini
[mysql_cluster]
ndb-connectstring=172.16.1.78
[mysql.server]
user=mysql
basedir=/usr
[mysqld_safe]
log-error=/var/log/mysqld.log
#pid-file=/var/run/mysqld/mysqld.pid
[mysql]
#socket=/usr/local/var/mysql.sock
[mysqladmin]
#socket=/usr/local/var/mysql.sock
[ndb_restore default]
第一步:确保数据节点和mysql节点运行正常,在管理节点服务器上杀掉管理节点的进程(此时只杀掉管理节点进程,不会对NDB节点和mysql节点产生影响,数据库功能一样可以进行运行)。
第二步:如果只是调整当前数据库的配置参数,可以直接修改/var/lib/mysql-cluster/config.ini,修改完成之后保存,同时将/usr/mysql-cluster/目录下的config.ini.bin.1文件删除掉,然后执行管理节点启动命令ndb_mgmd -f /var/lib/mysql-cluster/config.ini启动管理节点即可,已经修改的内容即可生效。
如果是需要添加数据节点或者mysql节点的话。同样需要先停掉管理节点的管理进程,原有的数据节点和mysql节无需进行任何操作。直接在管理服务器上修改/var/lib/mysql-cluster/config.ini文件。比如需要新增两台服务器172.16.1.76、172.16.1.77来做数据节点,先在两台服务器上安装MySQL-Cluster-server-gpl-7.2.13-1.rhel5.i386.rpm,然后修改管理节点上的config.ini文件为如下:
[ndbd default]
NoOfReplicas= 2
MaxNoOfConcurrentOperations= 500000
MaxNoOfLocalOperations=500000
MaxNoOfConcurrentTransactions=500000
MaxNoOfConcurrentIndexOperations=50000
# Amount of memory required=(SizeofDatabase * NumberOfReplicas * 1.1 ) / NumberOfDataNodes
DataMemory= 49152M
IndexMemory= 6144M
TimeBetweenWatchDogCheck= 30000
DataDir=/var/lib/mysql/data
MaxNoOfAttributes=500000
MaxNoOfTables=1000
MaxNoOfOrderedIndexes= 512
#StartPartialTimeout=100
#StartPartitionedTimeout=100
#ArbitrationTimeout=5000
#MaxNoOfFiredTriggers=8000
#TransactionBufferMemory=5M
TransactionDeadlockDetectionTimeout=90000
HeartbeatIntervalDbDb=5000
#StopOnError=1
[ndb_mgmd default]
DataDir=/var/lib/mysql/data
[ndb_mgmd]
NodeId=1
HostName= 172.16.1.78
[ndbd]
NodeId= 2
HostName= 172.16.1.74
[ndbd]
NodeId= 3
HostName= 172.16.1.75
[ndbd]
NodeId= 4
HostName= 172.16.1.76
[ndbd]
NodeId= 5
HostName= 172.16.1.77
[mysqld]
ArbitrationRank=2
[mysqld]
ArbitrationRank=2
[mysqld]
[mysqld]
[mysqld]
[mysqld]
[tcp default]
portnumber=2279
在172.16.1.76和172.16.1.77服务器上在/etc/目录下,添加my.cnf配置文件,配置文件内容如下:
default-storage-engine=ndbcluster
ndbcluster
ndb-connectstring=172.16.1.78
[ndbd]
connect-string=172.16.1.78
[ndb_mgm]
connect-string=172.16.1.78
[ndb_mgmd]
config-file=/var/lib/mysql-cluster/config.ini
[mysql_cluster]
ndb-connectstring=172.16.1.78
[ndb_restore default]