MySQL Cluster Tutorial
The MySQL database allows you to combine more than one computer into a cluster which acts as a single MySQL database. There are minimal specific hardware or software requirements other than a large amount of RAM and MySQL 5.0 or higher. Of course, multiple and faster CPUs will enhance the performance, if they are available. The live data for the cluster will be stored completely within memory in a shared-nothing architecture. The MySQL cluster should be run on its own subnet because communication between nodes is not encrypted, and so the cluster can have exclusive use of the bandwidth.
-
The Basics
-
The MySQL cluster is configured independently of the MySQL server and is designed with no single point of failure. Each component must have its own memory and disk space and shared storage is neither recommended or supported. Each computer in the cluster will have one or more processes running on it. These processes (called nodes) include a MySQL server, a data node, a management server and specialized data access programs. Configuration involves configuring each individual node and setting up individual communication links. All the data for the cluster as a whole is located in one configuration file managed by the management node.
Each computer running an SQL node must have a MySQL binary installed on it. Management and data nodes do not require a MySQL binary, but do require the management server daemon (ndb_mgmd) for management node or the data node daemon (ndbd) for the data nodes. It is recommended to install the management client (ndb_mgm) on the management server host.
The Cluster uses the NDBCLUSTER storage engine. NDBCLUSTER is an in-memory, high-availability, data-persistent storage engine that can be configured with a range of failover and load-balancing options. When data is stored in the NDBCLUSTER storage engine, the tables are stored in the data nodes. The tables are then accessible from all other MySQL servers in the cluster. The data stored this way can be mirrored and the cluster can handle failures of individual nodes with only a small number of transactions impacted due to the loss of the transaction state.
Creating a Cluster
-
Download the binaries for the MySQL server, the NDB Cluster -- Storage engine, NDB Cluster -- Storage Engine management, NDB Cluster -- Storage engine basic tools, NDB Cluster -- Storage engine extra tools. All the Cluster software must have the same version number.
Each data node or SQL node needs a "my.cnf" file that provides a "connectstring" that tells the server where to find the management node, and a line telling the MySQL server to enable the NDBCLUSTER storage engine. The management node needs a "config.ini" file telling it how many replicas to maintain, how much memory to allocate for data and indexes on each data node, where to find the data nodes, where to save the data on the disks on each data node and where to find the SQL nodes.
Each cluster node process must be started separately on the host where it resides. The management node must be started first, then data nodes are started, the final step is to start the SQL nodes.
To start the management node type the command:
ndb_mgmd -f /var/lib/mysql-cluster/config.ini
Start the data nodes with the "ndbd" command and use the start up script supplied with MySQL binaries to start the SQL nodes.
Test the configuration by typing the command "ndb_mgm." Once all the nodes are started, you can work with the databases and objects in the MySQL cluster.
-