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 07:07]
k2patel
mysql_cluster_5_min [2020/08/10 02:35]
Line 1: Line 1:
-====== MySQL cluster 5 Min. ====== 
-From : [[http://​forge.mysql.com/​tools/​tool.php?​id=16 | Kai Voigt]] 
  
-You have heard about MySQL Cluster, but you were always afraid to get into it\\ 
-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. 
- 
-  
-Sometimes, I need to demonstrate how MySQL cluster works.\\ 
-I usually set up a single machine cluster which of course won‘t make sense in production scenarios,​\\ 
-but for an introduction into MySQL cluster it‘s fine.\\ 
-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.\\ 
-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. 
- 
-  
-Run „SHOW ENGINES“ to see that the cluster storage engine is included in your installation.\\ 
-If it says „DISABLED“ or „YES“ in the row for „ndbcluster“,​ you‘re fine and you can continue.\\ 
-Otherwise, get the mysql-max package. Again, it‘s only available on UNIX machines,\\ 
-Windows is not supported for Cluster yet. 
- 
-  
-Believe me, the most complicated part lies behind us already.\\ 
-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. 
- 
-  
-I created a directory /​usr/​local/​mysql/​cluster and put a cluster.cnf file in it. Here‘s the content. 
-  
-  - Cluster Example Configuration 
-  - 2 Data Nodes 
-  - 1 Management Node 
-  - 1 MySQLd Node 
-  
-<code text | Management Node> 
-[ndb_mgmd] 
-Id=1 
-Hostname=127.0.0.1 
-DataDir=/​usr/​local/​mysql/​cluster/​ 
-</​code>​ 
-  
-<code text | Data Nodes, Defaults>​ 
-[ndbd default] 
-NoOfReplicas=2 
-DataMemory=30M 
-IndexMemory=10M 
-DataDir=/​usr/​local/​mysql/​cluster/​ 
-</​code>​ 
-  
-<code text | Data Node #1> 
-[ndbd] 
-Id=2 
-Hostname=127.0.0.1 
-</​code>​ 
-  
-<code text | Data Node #2> 
-[ndbd] 
-Id=3 
-Hostname=127.0.0.1 
-</​code>​ 
- 
-<code text | MySQLd Node> 
-[mysqld] 
-Id=4 
-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. 
- 
-<code text> ​ 
-[mysql_cluster] 
-ndb_connectstring=127.0.0.1 
-  
-[mysqld] 
-ndbcluster 
-  
-[ndb_mgmd] 
-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. 
-  
-Now, we start the management server. 
-  
-<code bash> 
-# 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. 
- 
-<code bash> 
-# ndb_mgm 
-</​code>​ 
- 
-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. 
- 
-<code bash> 
-# ndbd --initial 
-# ndbd --initial 
-</​code>​ 
- 
-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. 
- 
-<code mysql> ​ 
-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. 
mysql_cluster_5_min.txt · Last modified: 2020/08/10 02:35 (external edit)