Configure the storage/SQL servers and start MySQL- On each of the two storage/SQL servers (192.168.0.1 and 192.168.0.2) enter the following (changing the bits as appropriate):
vi /etc/my.cnf
- Enter i to go to insert mode again and insert this on both servers (changing the IP address to the IP of the managment server that you set up in stage 2):
[mysqld]
ndbcluster
# the IP of the MANAGMENT (THIRD) SERVER
ndb-connectstring=192.168.0.3
[mysql_cluster]
# the IP of the MANAGMENT (THIRD) SERVER
ndb-connectstring=192.168.0.3
- Be aware that anything in the [mysql_cluster] section will override the defaults in [mysql], so if you introduce a nodeid and then try to run multiple daemons on the same machines you should be aware of this!
- Now, we make the data directory and start the storage engine:
mkdir /var/lib/mysql-cluster
cd /var/lib/mysql-cluster
/usr/local/mysql/bin/ndbd --initial
/etc/rc.d/init.d/mysql.server start
If you have done one server now go back to the start of stage 3 and repeat exactly the same procedure on the second server.
NOTE that you should ONLY use --initial if you are either starting from scratch or have changed the config.ini file on the managment.
Check if its working
You can now return to the managment server (Server 3) and enter the managment console:
/usr/local/mysql/bin/ndb_mgm
Enter the command SHOW to see what is going on. A sample output looks like this:
[root@mysql3 mysql-cluster]# /usr/local/mysql/bin/ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @192.168.0.1 (Version: 5.0.15, Nodegroup: 0, Master)
id=3 @192.168.0.2 (Version: 5.0.15, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.0.3 (Version: 5.0.15)
[mysqld(API)] 2 node(s)
id=4 (Version: 5.0.15)
id=5 (Version: 5.0.15)
ndb_mgm>
If you see not connected, accepting connect from 192.168.0.[1/2/3]
In the first or last two lines they you have a problem.
If you are OK to here it is time to test mysql. On either server Server 1 or Server 2 enter the following commands: Note that we have no root password yet.
mysql
use test;
CREATE TABLE ctest (i INT) ENGINE=NDBCLUSTER;
INSERT INTO ctest () VALUES (1);
SELECT * FROM ctest;
You should see 1 row returned (with the value 1).
If this works, now go to the other server and run the same SELECT and see what you get. Insert from that host and go back to host 1 and see if it works. If it works then congratulations.
The final test is to kill one server to see what happens. If you have physical access to the machine simply unplug its network cable and see if the other server keeps on going fine (try the SELECT query). If you dont have physical access do the following:
ps aux | grep ndbdYou get an output like this:
root 5578 0.0 0.3 6220 1964 ? S 03:14 0:00 ndbd
root 5579 0.0 20.4 492072 102828 ? R 03:14 0:04 ndbd
root 23532 0.0 0.1 3680 684 pts/1 S 07:59 0:00 grep ndbd
In this case ignore the command "grep ndbd" (the last line) but kill the first two processes by issuing the command kill -9 pid pid:
kill -9 5578 5579
Then try the select on the other server. While you are at it run a SHOW command on the managment node to see that the server has died. To restart it, just issue
ndbd
NOTE no --inital! Putting initial will clear the database
IssuesIf a node goes down. Restart that node from the server the node resides in. Steps given below. (
http://bugs.mysql.com/bug.php?id=23121)
- ps aux | grep ndb
- If /usr/local/mysql/bin/ndbd shows up then kill them.
- Next type /usr/local/mysql/bin/ndbd and hit enter.
- The process will start.
- Go back to the management server.
- Two possibilities here are
- The node is already started.
- The node is trying to start.
- If the node is trying to start and eventually fails. Then retry this entire process. Sometimes the node starts other times it does not. This could be because of packets getting lost.
If any issues arise try killing all the processes used for clustering. That is ndbd, ndb_mgmd, ndb_mdm and mysql.server. Bring the processes of Server 1, Server 2 and Server 3 down. Then start them back up.
To locate processes use
ps aux | grep ndbProcesses
ndbd is for the storage node
mysql.server is for the mysql server
ndb_mgmd is for the management node
Sourceshttp://www.davz.net/static/howto/mysqlcluster