User Tools

Site Tools


mysql_cluster_5_min

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

mysql_cluster_5_min [2009/04/25 03:00]
k2patel created
mysql_cluster_5_min [2009/04/25 03:07] (current)
k2patel
Line 5: Line 5:
 because „Cluster“ seems to be a magic and complicated topic? Then this article is for you.\\ because „Cluster“ seems to be a magic and complicated topic? Then this article is for you.\\
 In a couple of minutes, you can run your own Cluster. In a couple of minutes, you can run your own Cluster.
 +
    
 Sometimes, I need to demonstrate how MySQL cluster works.\\ Sometimes, I need to demonstrate how MySQL cluster works.\\
Line 10: Line 11:
 but for an introduction into MySQL cluster it‘s fine.\\ but for an introduction into MySQL cluster it‘s fine.\\
 And it‘s very easy to deploy the system on multiple machines later. And it‘s very easy to deploy the system on multiple machines later.
 +
    
 This article will show you how you can set up your own Cluster.\\ This article will show you how you can set up your own Cluster.\\
 All you need is a UNIX machine and the mysql-max package (version 4.1 or 5.0)\\ All you need is a UNIX machine and the mysql-max package (version 4.1 or 5.0)\\
 which is downloadable from the MySQL website. which is downloadable from the MySQL website.
 +
    
 Run „SHOW ENGINES“ to see that the cluster storage engine is included in your installation.\\ Run „SHOW ENGINES“ to see that the cluster storage engine is included in your installation.\\
Line 19: Line 22:
 Otherwise, get the mysql-max package. Again, it‘s only available on UNIX machines,\\ Otherwise, get the mysql-max package. Again, it‘s only available on UNIX machines,\\
 Windows is not supported for Cluster yet. Windows is not supported for Cluster yet.
 +
    
 Believe me, the most complicated part lies behind us already.\\ Believe me, the most complicated part lies behind us already.\\
 Next, we are going to create a configuration file for our little cluster.\\ Next, we are going to create a configuration file for our little cluster.\\
 It will consist of two data nodes, one management node and one mysqld node. It will consist of two data nodes, one management node and one mysqld node.
 +
    
 I created a directory /​usr/​local/​mysql/​cluster and put a cluster.cnf file in it. Here‘s the content. I created a directory /​usr/​local/​mysql/​cluster and put a cluster.cnf file in it. Here‘s the content.
Line 31: Line 36:
   - 1 MySQLd Node   - 1 MySQLd Node
    
-Management Node+<code text | Management Node>
 [ndb_mgmd] [ndb_mgmd]
 Id=1 Id=1
 Hostname=127.0.0.1 Hostname=127.0.0.1
 DataDir=/​usr/​local/​mysql/​cluster/​ DataDir=/​usr/​local/​mysql/​cluster/​
 +</​code>​
    
-Data Nodes, Defaults+<code text | Data Nodes, Defaults>
 [ndbd default] [ndbd default]
 NoOfReplicas=2 NoOfReplicas=2
Line 43: Line 49:
 IndexMemory=10M IndexMemory=10M
 DataDir=/​usr/​local/​mysql/​cluster/​ DataDir=/​usr/​local/​mysql/​cluster/​
 +</​code>​
    
-Data Node #1+<code text | Data Node #1>
 [ndbd] [ndbd]
 Id=2 Id=2
 Hostname=127.0.0.1 Hostname=127.0.0.1
 +</​code>​
    
-Data Node #2+<code text | Data Node #2>
 [ndbd] [ndbd]
 Id=3 Id=3
 Hostname=127.0.0.1 Hostname=127.0.0.1
-  +</​code>​ 
-MySQLd Node+ 
 +<code text | MySQLd Node>
 [mysqld] [mysqld]
 Id=4 Id=4
 Hostname=127.0.0.1 Hostname=127.0.0.1
 +</​code>​
    
-See, it‘s not complicated yet. All nodes reside on the local host and only a few parameters are set. Next, we also need to add some lines into the usual my.cnf file. +See, it‘s not complicated yet. All nodes reside on the local host and only a few parameters are set.\\ 
- +Next, we also need to add some lines into the usual my.cnf file. 
 + 
 +<code text> ​
 [mysql_cluster] [mysql_cluster]
 ndb_connectstring=127.0.0.1 ndb_connectstring=127.0.0.1
Line 69: Line 81:
 [ndb_mgmd] [ndb_mgmd]
 config-file=/​usr/​local/​mysql/​cluster/​cluster.cnf ​                                                                                   ​ config-file=/​usr/​local/​mysql/​cluster/​cluster.cnf ​                                                                                   ​
 +</​code>​
    
-Merge these lines into your existing my.cnf, they will make your mysqld enable the cluster storage engine, tell the management node where to find the configuration file and let all other nodes know where to find the management node.+Merge these lines into your existing my.cnf, they will make your mysqld enable the cluster storage engine,\\ 
 +tell the management node where to find the configuration file\\ 
 +and let all other nodes know where to find the management node.
    
 Now, we start the management server. Now, we start the management server.
    
 +<code bash>
 # ndb_mgmd # ndb_mgmd
 +</​code>​
    
 Easy, huh? The management server is now running and waits for other nodes to connect. Open a new terminal window and run the management client to see what‘s going on. Easy, huh? The management server is now running and waits for other nodes to connect. Open a new terminal window and run the management client to see what‘s going on.
- + 
 +<code bash>
 # ndb_mgm # ndb_mgm
- +</​code>​ 
 Run the SHOW command here now once in a while to get a status report. Run the SHOW command here now once in a while to get a status report.
 +
    
-Next, we go back to our original terminal window and start the data nodes. Since we set up the cluster the very first time, we must use the --initial option. If you later start a data node, you can omit this option. Keep in mind that we configured two data nodes, so we have to execute the ndbd program twice. +Next, we go back to our original terminal window and start the data nodes.\\ 
- +Since we set up the cluster the very first time, we must use the --initial option.\\ 
 +If you later start a data node, you can omit this option. Keep in mind that we configured two data nodes,\\ 
 +so we have to execute the ndbd program twice. 
 + 
 +<code bash>
 # ndbd --initial # ndbd --initial
 # ndbd --initial # ndbd --initial
- +</​code>​ 
 Check the SHOW output again and see how the data nodes connected. Check the SHOW output again and see how the data nodes connected.
    
 Now restart your mysqld server and check the SHOW output again. All nodes should be connected now and you can create your first cluster table. Now restart your mysqld server and check the SHOW output again. All nodes should be connected now and you can create your first cluster table.
- + 
 +<code mysql> ​
 mysql> CREATE TABLE myclustertable (a INT, b CHAR(10)) ENGINE=ndbcluster;​ mysql> CREATE TABLE myclustertable (a INT, b CHAR(10)) ENGINE=ndbcluster;​
-  +</​code>​ 
-Congratulations,​ you‘re done. Did it hurt? I think not. Now go and play with the cluster. Tear down one data node, restart it, grow the cluster with more nodes and machines, explore the other commands of the management clients and then read all the details in the online documentation.+ 
 +Congratulations,​ you‘re done. Did it hurt? I think not. Now go and play with the cluster.\\ 
 +Tear down one data node, restart it, grow the cluster with more nodes and machines,\\ 
 +explore the other commands of the management clients and then read all the details in the online documentation.
mysql_cluster_5_min.txt · Last modified: 2009/04/25 03:07 by k2patel