Mysql-cluster Cluster
Conf File Reference:
Vim/etc/mysql-cluster.ini
[NDBD Default]
noofreplicas=2
datamemory=80m
indexmemory=16m
[NDB_MGMD]
Nodeid=32
hostname=192.168.10.132
Datadir=/usr/local/cluster/ndbdata
[Mysqld]
Nodeid=28
hostname=192.168.10.128
[Mysqld]
nodeid=29
hostname=192.168.10.129
[NDBD]
Nodeid=30
hostname=192.168.10.130
Datadir=/usr/local/cluster/ndbdata
[NDBD]
Nodeid=31
hostname=192.168.10.131
Datadir=/usr/local/cluster/ndbdata
-----------------------------------------------------------
------------------------------------my.cnf configuration file
Ms
Cat >/etc/my.cnf<< EOF
[Mysqld]
#datadir =/var/lib/mysql
Datadir=/data/mysql/data
#socket =/var/lib/mysql/mysql.sock
Socket=/tmp/mysql.sock
User=mysql
# Disabling Symbolic-links is recommended to prevent assorted security risks
Symbolic-links=0
[Mysqld_safe]
Log-error=/data/mysql/log/mysqld.log
Pid-file=/usr/local/mysql/mysqld.pid
Eof
Vi/var/lib/mysql-cluster/config.ini---------------------Management Node configuration file
Cat >/var/lib/mysql-cluster/config.ini<< EOF
[NDBD Default]
noofreplicas=2
datamemory=80m
indexmemory=18m
[NDB_MGMD]
Nodeid=1
hostname=192.168.1.210 #//Management IP
Datadir=/usr/local/mysql
[NDBD]
nodeid=2
hostname=192.168.1.209 #//Data Node 1
#datadir =/usr/local/mysql/data/#//Data File location
datadir=/data/mysql/data/#//Data File location
[NDBD]
Nodeid=3
hostname=192.168.1.208//Data Node 2
#datadir =/usr/local/mysql/data///Data File location
datadir=/data/mysql/data///Data File location
[MYSQLD]
Nodeid=4
hostname=192.168.1.207
[MYSQLD]
Nodeid=5
hostname=192.168.1.206
Eof
-------------------------------------
Md
Cat >/etc/my.cnf<< EOF
[Mysqld]
Basedir=/usr/local/mysql
Datadir=/data/mysql/data
Socket=/tmp/mysql.sock
User=mysql
# Disabling Symbolic-links is recommended to prevent assorted security risks
Symbolic-links=0
[Mysqld_safe]
Log-error=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid
[Mysql_cluster]
ndb-connectstring=192.168.1.210
Eof
--------------------------------------
Ms
Cat >/etc/my.cnf<< EOF
[Client]
Socket=/tmp/mysql.sock
[Mysqld]
Ndbcluster
Basedir=/usr/local/mysql
Datadir=/data/mysql/data
Socket=/tmp/mysql.sock
ndb-connectstring=192.168.1.210
[Mysqld_safe]
Log-error=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid
[Mysql_cluster]
ndb-connectstring=192.168.1.210
Eof
-------------------------------------------------Start Configuration
Mkdir-p/var/lib/mysql-cluster
Mkdir-p/data/mysql
Useradd MySQL
Tar zxvf mysql-cluster-gpl-7.4.6-linux-glibc2.5-x86_64.tar.gz
MV Mysql-cluster-gpl-7.4.6-linux-glibc2.5-x86_64.tar.gz/usr/local/mysql
cd/usr/local/
Chown Mysql.mysql-r mysql/
CD mysql/
scripts/mysql_install_db--user=mysql (Initialize)
#scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir=/data/mysql/data
(Note: MySQL adds environment variables)
Cp.. /support-files/mysql.server/etc/init.d/mysqld
#cp Support-files/mysql.server/etc/rc.d/init.d/mysqld
chmod +x/etc/rc.d/init.d/mysqld
Chkconfig--add mysqld
#启动管理节点服务
/usr/local/mysql/bin/ndb_mgmd-f/var/lib/mysql-cluster/config.ini--initial
Ndb_mgmd-f/var/lib/mysql-cluster/config.ini--initial
Netstat-lntpu
#看到1186开放说明启动正常
#★ must be aware that the –initial parameter is only added when the NDBD is restarted on the first boot or after a backup/restore or configuration change!
#备注: When you start here, you need to turn on the 1186,3306 port for the firewall, and the data node on port 2202.
#在两台机器上启动服务, perform the same operation
#★ must be aware that the –initial parameter is only added when the NDBD is restarted on the first boot or after a backup/restore or configuration change!
#数据库节点运行
/USR/LOCAL/MYSQL/BIN/NDBD--initial
#查询结果
#[ndbd] INFO--Angel connected to ' 192.168.1.210:1186 '
#[ndbd] INFO--Angel allocated Nodeid:3
-------------------------------------------------------------------
1. Start the Management node
Run the following command in the shell:
Ndb_mgmd-f/var/lib/mysql-cluster/config.ini
You can also use NDB_MGM to listen to clients, as follows:
Ndb_mgm
2. Start the Data node
The first time you start, you need to add the--initial parameter for the initialization of the NDB node. You cannot add this parameter during a later boot process, otherwise the NDBD program clears all data files and log files that were previously established for recovery.
/USR/LOCAL/MYSQL/BIN/NDBD--initial
If it is not the first time, execute the following command.
/usr/local/mysql/bin/ndbd
3. Start the SQL node
If the MySQL service is not running, run the following command in the shell:
/usr/local/mysql/bin/mysqld_safe--user=mysql &
--------------------------------------------------------------------
This article from "SQL" blog, declined reprint!
Mysql-cluster Cluster