9.5. Process Management in MySQL ClusterUnderstanding how to manage MySQL Cluster requires a knowledge of four essential processes. In the next few sections of this chapter, we cover the roles played by these processes in a cluster, how to use them, and what startup options are available for each of them:
9.5.1. MySQL Server Process Usage for MySQL Clustermysqld is the traditional MySQL server process. To be used with MySQL Cluster, mysqld needs to be built with support for the NDB Cluster storage engine, as it is in the precompiled -max binaries available from http://dev.mysql.com/downloads/. If you build MySQL from source, you must invoke configure with the --with-ndbcluster option to enable NDB Cluster storage engine support. If the mysqld binary has been built with Cluster support, the NDB Cluster storage engine is still disabled by default. You can use either of two possible options to enable this engine:
An easy way to verify that your server is running with the NDB Cluster storage engine enabled is to issue the SHOW ENGINES statement in the MySQL Monitor (mysql). You should see the value YES as the Support value in the row for NDBCLUSTER. If you see NO in this row or if there is no such row displayed in the output, you are not running an NDB-enabled version of MySQL. If you see DISABLED in this row, you need to enable it in either one of the two ways just described. To read cluster configuration data, the MySQL server requires at a minimum three pieces of information:
Node IDs can be allocated dynamically, so it is not strictly necessary to specify them explicitly. The mysqld parameter ndb-connectstring is used to specify the connectstring either on the command line when starting mysqld or in my.cnf. The connectstring contains the hostname or IP address where the management server can be found, as well as the TCP/IP port it uses. In the following example, ndb_mgmd.mysql.com is the host where the management server resides, and the management server listens for cluster messages on port 1186: shell> mysqld --ndb-connectstring=ndb_mgmd.mysql.com:1186
See Section 9.4.4.2, "The MySQL Cluster connectstring," for more information on connectstrings. Given this information, the MySQL server will be a full participant in the cluster. (We sometimes refer to a mysqld process running in this manner as an "SQL node.") It will be fully aware of all cluster data nodes as well as their status, and will establish connections to all data nodes. In this case, it is able to use any data node as a transaction coordinator and to read and update node data. 9.5.2. ndbd, the Storage Engine Node Processndbd is the process that is used to handle all the data in tables using the NDB Cluster storage engine. This is the process that empowers a storage node to accomplish distributed transaction handling, node recovery, checkpointing to disk, online backup, and related tasks. In a MySQL Cluster, a set of ndbd processes cooperate in handling data. These processes can execute on the same computer (host) or on different computers. The correspondences between data nodes and Cluster hosts is completely configurable. ndbd generates a set of log files that are placed in the directory specified by DataDir in the config.ini configuration file. These log files are listed below. Note that node_id represents the node's unique identifier. For example, ndb_2_error.log is the error log generated by the storage node whose node ID is 2.
It is recommended not to use a directory mounted through NFS because in some environments this can cause problems in which the lock on the .pid file remains in effect even after the process has terminated. To start ndbd, it may also be necessary to specify the hostname of the management server and the port on which it is listening. Optionally, you may also specify the node ID that the process is to use. shell> ndbd --connect-string="nodeid=2;host=ndb_mgmd.mysql.com:1186"
See Section 9.4.4.2, "The MySQL Cluster connectstring," for additional information about this issue. Section 9.5.5, "Command Options for MySQL Cluster Processes," describes other options for ndbd. When ndbd starts, it actually initiates two processes. The first of these is called the "angel process"; its only job is to discover when the execution process has been completed, and then to restart the ndbd process if it is configured to do so. Thus, if you attempt to kill ndbd via the Unix kill command, it is necessary to kill both processes, beginning with the angel process. The preferred method of terminating an ndbd process is to use the management client and stop the process from there. The execution process uses one thread for reading, writing, and scanning data, as well as all other activities. This thread is implemented asynchronously so that it can easily handle thousands of concurrent activities. In addition, a watch-dog thread supervises the execution thread to make sure that it does not hang in an endless loop. A pool of threads handles file I/O, with each thread able to handle one open file. Threads can also be used for transporter connections by the transporters in the ndbd process. In a system performing a large number of operations, including updates, the ndbd process can consume up to 2 CPUs if permitted to do so. For a machine with many CPUs it is recommended to use several ndbd processes that belong to different node groups. 9.5.3. ndb_mgmd, the Management Server ProcessThe management server is the process that reads the cluster configuration file and distributes this information to all nodes in the cluster that request it. It also maintains a log of cluster activities. Management clients can connect to the management server and check the cluster's status. It is not strictly necessary to specify a connectstring when starting the management server. However, if you are using more than one management server, a connectstring should be provided and each node in the cluster should specify its node ID explicitly. See Section 9.4.4.2, "The MySQL Cluster connectstring," for information about using connectstrings. Section 9.5.5, "Command Options for MySQL Cluster Processes," describes other options for ndb_mgmd. The following files are created or used by ndb_mgmd in its starting directory, and are placed in the DataDir as specified in the config.ini configuration file. In the list that follows, node_id is the unique node identifier.
9.5.4. ndb_mgm, the Management Client ProcessThe management client process is actually not needed to run the cluster. Its value lies in providing a set of commands for checking the cluster's status, starting backups, and performing other administrative functions. The management client accesses the management server using a C API. Advanced users can also employ this API for programming dedicated management processes to perform tasks similar to those performed by ndb_mgm. To start the management client, it is necessary to supply the hostname and port number of the management server: shell> ndb_mgm [host_name[port_num]] shell> ndb_mgm ndb_mgmd.mysql.com 1186
The default hostname and port number are localhost and 1186, respectively. Additional information about using ndb_mgm can be found in Section 9.5.5.4, "Command Options for ndb_mgm," and Section 9.6.2, "Commands in the Management Client." 9.5.5. Command Options for MySQL Cluster ProcessesAll MySQL Cluster executables (except for mysqld) take the options described in this section. Users of earlier MySQL Cluster versions should note that some of these options have been changed from those in MySQL 4.1 Cluster to make them consistent with one another as well as with mysqld. You can use the --help option to view a list of supported options. The following sections describe options specific to individual NDB programs:
9.5.5.1. MySQL Cluster-Related Command Options for mysqld
9.5.5.2. Command Options for ndbdFor options common to NDB programs, see Section 9.5.5, "Command Options for MySQL Cluster Processes."
9.5.5.3. Command Options for ndb_mgmdFor options common to NDB programs, see Section 9.5.5, "Command Options for MySQL Cluster Processes."
9.5.5.4. Command Options for ndb_mgmFor options common to NDB programs, see Section 9.5.5, "Command Options for MySQL Cluster Processes."
|