Chapter 17. MySQL Cluster NDB 6.X/7.X
Table of Contents
- 17.1. MySQL Cluster Overview
- 17.2. MySQL Cluster Multi-Computer How-To
- 17.2.1. MySQL Cluster Hardware, Software, and Networking Requirements
- 17.2.2. MySQL Cluster Multi-Computer Installation
- 17.2.3. MySQL Cluster Multi-Computer Configuration
- 17.2.4. Initial Startup of MySQL Cluster
- 17.2.5. Loading Sample Data into MySQL Cluster and Performing Queries
- 17.2.6. Safe Shutdown and Restart of MySQL Cluster
- 17.3. MySQL Cluster Configuration
- 17.3.1. Building MySQL Cluster from Source Code
- 17.3.2. Installing MySQL Cluster Software
- 17.3.3. Quick Test Setup of MySQL Cluster
- 17.3.4. MySQL Cluster Configuration Files
- 17.3.5. Overview of MySQL Cluster Configuration Parameters
- 17.3.6. Configuring MySQL Cluster Parameters for Local Checkpoints
- 17.3.7. Configuring MySQL Cluster Send Buffer Parameters
- 17.4. MySQL Cluster Options and Variables
- 17.5. Upgrading and Downgrading MySQL Cluster
- 17.6. MySQL Cluster Programs
- 17.6.1. MySQL Server Usage for MySQL Cluster
- 17.6.2. ndbd — The MySQL Cluster Data Node Daemon
- 17.6.3. ndbmtd — The MySQL Cluster Data Node Daemon (Multi-Threaded)
- 17.6.4. ndb_mgmd — The MySQL Cluster Management Server Daemon
- 17.6.5. ndb_mgm — The MySQL Cluster Management Client
- 17.6.6. ndb_config — Extract MySQL Cluster Configuration Information
- 17.6.7. ndb_cpcd — Automate Testing for NDB Development
- 17.6.8. ndb_delete_all — Delete All Rows from an NDB Table
- 17.6.9. ndb_desc — Describe NDB Tables
- 17.6.10. ndb_drop_index — Drop Index from an NDB Table
- 17.6.11. ndb_drop_table — Drop an NDB Table
- 17.6.12. ndb_error_reporter — NDB Error-Reporting Utility
- 17.6.13. ndb_print_backup_file — Print NDB Backup File Contents
- 17.6.14. ndb_print_schema_file — Print NDB Schema File Contents
- 17.6.15. ndb_print_sys_file — Print NDB System File Contents
- 17.6.16. ndbd_redo_log_reader — Check and Print Content of Cluster Redo Log
- 17.6.17. ndb_restore — Restore a MySQL Cluster Backup
- 17.6.18. ndb_select_all — Print Rows from an NDB Table
- 17.6.19. ndb_select_count — Print Row Counts for NDB Tables
- 17.6.20. ndb_show_tables — Display List of NDB Tables
- 17.6.21. ndb_size.pl — NDBCLUSTER Size Requirement Estimator
- 17.6.22. ndb_waiter — Wait for MySQL Cluster to Reach a Given Status
- 17.6.23. Options Common to MySQL Cluster Programs
- 17.6.24. Summary Tables of NDB Program Options
- 17.7. Management of MySQL Cluster
- 17.7.1. Summary of MySQL Cluster Start Phases
- 17.7.2. Commands in the MySQL Cluster Management Client
- 17.7.3. Online Backup of MySQL Cluster
- 17.7.4. Event Reports Generated in MySQL Cluster
- 17.7.5. MySQL Cluster Log Messages
- 17.7.6. MySQL Cluster Single User Mode
- 17.7.7. Quick Reference: MySQL Cluster SQL Statements
- 17.7.8. Adding MySQL Cluster Data Nodes Online
- 17.8. MySQL Cluster Security Issues
- 17.9. MySQL Cluster Replication
- 17.9.1. MySQL Cluster Replication — Abbreviations and Symbols
- 17.9.2. MySQL Cluster Replication — Assumptions and General Requirements
- 17.9.3. Known Issues in MySQL Cluster Replication
- 17.9.4. MySQL Cluster Replication Schema and Tables
- 17.9.5. Preparing the MySQL Cluster for Replication
- 17.9.6. Starting MySQL Cluster Replication (Single Replication Channel)
- 17.9.7. Using Two Replication Channels for MySQL Cluster Replication
- 17.9.8. Implementing Failover with MySQL Cluster Replication
- 17.9.9. MySQL Cluster Backups With MySQL Cluster Replication
- 17.9.10. MySQL Cluster Replication — Multi-Master and Circular Replication
- 17.9.11. MySQL Cluster Replication Conflict Resolution
- 17.10. MySQL Cluster Disk Data Tables
- 17.11. Using High-Speed Interconnects with MySQL Cluster
- 17.12. Known Limitations of MySQL Cluster
- 17.12.1. Noncompliance with SQL Syntax in MySQL Cluster
- 17.12.2. Limits and Differences of MySQL Cluster from Standard MySQL Limits
- 17.12.3. Limits Relating to Transaction Handling in MySQL Cluster
- 17.12.4. MySQL Cluster Error Handling
- 17.12.5. Limits Associated with Database Objects in MySQL Cluster
- 17.12.6. Unsupported or Missing Features in MySQL Cluster
- 17.12.7. Limitations Relating to Performance in MySQL Cluster
- 17.12.8. Issues Exclusive to MySQL Cluster
- 17.12.9. Limitations Relating to MySQL Cluster Disk Data Storage
- 17.12.10. Limitations Relating to Multiple MySQL Cluster Nodes
- 17.12.11. Previous MySQL Cluster Issues Resolved in MySQL 5.1 and MySQL Cluster NDB 6.x
- 17.13. MySQL Cluster Development Roadmap
- 17.14. MySQL Cluster Glossary
- 17.15. Changes in MySQL Cluster NDB 6.X and 7.X
- 17.16. Unified Changelogs — MySQL Cluster NDB 6.X and 7.X
This chapter contains information about MySQL
Cluster, which is a high-availability, high-redundancy
version of MySQL adapted for the distributed computing environment.
Current releases of MySQL Cluster use versions 6 and 7 of the
NDBCLUSTER storage engine (also known
as NDB) to enable running several
computers with MySQL servers and other software in a cluster.
Beginning with MySQL 5.1.24, support for the
NDBCLUSTER storage engine was removed
from the standard MySQL server binaries built by MySQL. Instead,
users of MySQL Cluster binaries built by MySQL should upgrade to the
most recent binary release of MySQL Cluster NDB 6.2 or MySQL Cluster
6.3 for supported platforms — these include RPMs that should
work with most Linux distributions. MySQL Cluster users who build
from source should be aware that, also beginning with MySQL 5.1.24,
NDBCLUSTER sources in the standard
MySQL 5.1 tree are no longer maintained; these users should use the
sources provided for MySQL Cluster NDB 6.2 or later. (Locations
where the sources can be obtained are listed later in this section.)
Note
MySQL Cluster NDB 6.1, 6.2, and 6.3 were formerly known as “MySQL Cluster Carrier Grade Edition”. Beginning with MySQL Cluster NDB 6.2.15 and MySQL Cluster NDB 6.3.14, this term is no longer applied to the MySQL Cluster software — which is now known simply as “MySQL Cluster” — but rather to a commercial licensing and support package. You can learn more about available options for commercial licensing of MySQL Cluster from MySQL Cluster Features, on the MySQL web site.
This chapter contains information about MySQL Cluster in MySQL 5.1 mainline releases through MySQL 5.1.23, MySQL Cluster NDB 6.2 releases through 5.1.34-ndb-6.2.18, MySQL Cluster NDB 6.3 releases through 5.1.34-ndb-6.3.26, and MySQL Cluster NDB 7.0 releases through 5.1.34-ndb-7.0.7. Currently, the MySQL Cluster NDB 6.2, MySQL Cluster NDB 6.3, and MySQL Cluster NDB 7.0 (formerly known as “MySQL Cluster NDB 6.4”) release series are Generally Available (GA).
This chapter also contains historical information about MySQL Cluster NDB 6.1, although this release series is no longer in active development, and should not be used in new deployments. Users of MySQL Cluster NDB 6.1 should upgrade to a later MySQL Cluster NDB 6.x or 7.x release series as soon as possible.
Platforms supported. MySQL Cluster is currently available and supported on a number of platforms, including Linux, Solaris, Mac OS X, HP-UX, and other Unix-style operating systems on a variety of hardware. Beginning with MySQL Cluster NDB 7.0, MySQL Cluster is also available (on an experimental basis) on Microsoft Windows platforms. For exact levels of support available for on specific combinations of operating system versions, operating system distributions, and hardware platforms, please refer to the Cluster Supported Platforms list, maintained by the MySQL Support Team on the MySQL web site.
We are continuing to work to make MySQL Cluster available on all operating systems supported by MySQL and will update the information provided here as this work continues.
Availability. MySQL Cluster NDB 6.2, MySQL Cluster NDB 6.3, and MySQL Cluster NDB 7.0 binary and source packages are available for supported platforms from http://dev.mysql.com/downloads/cluster.
Note
Binary releases and RPMs were not available for MySQL Cluster NDB 6.2 prior to MySQL Cluster NDB 6.2.15.
MySQL Cluster release numbers.
Starting with MySQL Cluster NDB 6.1 and 6.2, MySQL Cluster follows
a somewhat different release pattern from the mainline MySQL 5.1
Cluster series of releases. In this Manual and other MySQL
documentation, we identify these and later MySQL Cluster releases
employing a version number that begins with “NDB”.
This version number is that of the
NDBCLUSTER storage engine used, and
not of the MySQL server version on which the MySQL Cluster release
is based.
Version strings used in MySQL Cluster NDB 6.x and 7.x software. The version string displayed by MySQL Cluster NDB 6.x and 7.x software uses this format:
mysql-mysql_server_version-ndb-ndbcluster_engine_version
mysql_server_version represents the
version of the MySQL Server on which the MySQL Cluster release is
based. For all MySQL Cluster NDB 6.x and 7.x releases, this is
“5.1”.
ndbcluster_engine_version is the
version of the NDBCLUSTER storage
engine used by this release of the MySQL Cluster software. You can
see this format used in the mysql client, as
shown here:
shell>mysqlWelcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.34-ndb-7.0.7 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>SELECT VERSION()\G*************************** 1. row *************************** VERSION(): 5.1.34-ndb-7.0.7 1 row in set (0.00 sec)
This version string is also displayed in the output of the
SHOW command in the ndb_mgm
client:
ndb_mgm> SHOW
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=1 @10.0.10.6 (5.1.34-ndb-7.0.7, Nodegroup: 0, Master)
id=2 @10.0.10.8 (5.1.34-ndb-7.0.7, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=3 @10.0.10.2 (5.1.34-ndb-7.0.7)
[mysqld(API)] 2 node(s)
id=4 @10.0.10.10 (5.1.34-ndb-7.0.7)
id=5 (not connected, accepting connect from any host)
The version string identifies the mainline MySQL version from
which the MySQL Cluster release was branched and the version of
the NDBCLUSTER storage engine used.
For example, the full version string for MySQL Cluster NDB 6.2.15
(the first MySQL Cluster NDB 6.2 binary release) was
mysql-5.1.24-ndb-6.2.15. From this we can
determine the following:
Since the portion of the version string preceding “
-ndb-” is the base MySQL Server version, this means that MySQL Cluster NDB 6.2.15 derives from the MySQL 5.1.24, and contains all feature enhancements and bugfixes from MySQL 5.1 up to and including MySQL 5.1.24.Since the portion of the version string following “
-ndb-” represents the version number of theNDB(orNDBCLUSTER) storage engine, MySQL Cluster NDB 6.2.15 uses version 6.2.15 of theNDBCLUSTERstorage engine.
MySQL Cluster development source trees. MySQL Cluster development trees can also be accessed via https://code.launchpad.net/~mysql/:
MySQL Cluster NDB 6.1(OBSOLETE — no longer maintained)MySQL Cluster NDB 6.2(CURRENT)MySQL Cluster NDB 6.3(CURRENT)MySQL Cluster NDB 7.0(CURRENT)
The MySQL Cluster development sources maintained at https://code.launchpad.net/~mysql/ are licensed under the GPL. For information about obtaining MySQL sources using Bazaar and building them yourself, see Section 2.10.3, “Installing from the Development Source Tree”.
Currently, MySQL Cluster NDB 6.2, MySQL Cluster NDB 6.3, and MySQL Cluster NDB 7.0 releases are all Generally Available (GA). MySQL Cluster NDB 6.1 is no longer in active development. For an overview of major features added in MySQL Cluster NDB 6.x and 7.x, see Section 17.13, “MySQL Cluster Development Roadmap”.
This chapter represents a work in progress, and its contents are subject to revision as MySQL Cluster continues to evolve. Additional information regarding MySQL Cluster can be found on the MySQL AB Web site at http://www.mysql.com/products/cluster/.
Additional resources. More information may be found in the following places:
Answers to some commonly asked questions about Cluster may be found in the Section A.10, “MySQL 5.1 FAQ — MySQL Cluster”.
The MySQL Cluster mailing list: http://lists.mysql.com/cluster.
The MySQL Cluster Forum: http://forums.mysql.com/list.php?25.
Many MySQL Cluster users and some of the MySQL Cluster developers blog about their experiences with Cluster, and make feeds of these available through PlanetMySQL.
If you are new to MySQL Cluster, you may find our Developer Zone article How to set up a MySQL Cluster for two servers to be helpful.
MySQL Cluster is a technology that enables clustering of in-memory databases in a shared-nothing system. The shared-nothing architecture allows the system to work with very inexpensive hardware, and with a minimum of specific requirements for hardware or software.
MySQL Cluster is designed not to have any single point of failure. For this reason, each component is expected to have its own memory and disk, and the use of shared storage mechanisms such as network shares, network file systems, and SANs is not recommended or supported.
MySQL Cluster integrates the standard MySQL server with an in-memory
clustered storage engine called NDB. In
our documentation, the term NDB refers
to the part of the setup that is specific to the storage engine,
whereas “MySQL Cluster” refers to the combination of
MySQL and the NDB storage engine.
A MySQL Cluster consists of a set of computers, each running one or more processes which may include a MySQL server, a data node, a management server, and (possibly) specialized data access programs. The relationship of these components in a cluster is shown here:

All these programs work together to form a MySQL Cluster. When data
is stored in the NDBCLUSTER storage
engine, the tables are stored in the data nodes. Such tables are
directly accessible from all other MySQL servers in the cluster.
Thus, in a payroll application storing data in a cluster, if one
application updates the salary of an employee, all other MySQL
servers that query this data can see this change immediately.
The data stored in the data nodes for MySQL Cluster can be mirrored; the cluster can handle failures of individual data nodes with no other impact than that a small number of transactions are aborted due to losing the transaction state. Because transactional applications are expected to handle transaction failure, this should not be a source of problems.
NDBCLUSTER
(also known as NDB) is an in-memory
storage engine offering high-availability and data-persistence
features.
The NDBCLUSTER storage engine can be
configured with a range of failover and load-balancing options,
but it is easiest to start with the storage engine at the cluster
level. MySQL Cluster's NDB storage
engine contains a complete set of data, dependent only on other
data within the cluster itself.
The “Cluster” portion of MySQL Cluster is configured independently of the MySQL servers. In a MySQL Cluster, each part of the cluster is considered to be a node.
Note
In many contexts, the term “node” is used to indicate a computer, but when discussing MySQL Cluster it means a process. It is possible to run multiple nodes on a single computer; for a computer on which one or more cluster nodes are being run we use the term cluster host.
There are three types of cluster nodes, and in a minimal MySQL Cluster configuration, there will be at least three nodes, one of each of these types:
Management node (MGM node): The role of this type of node is to manage the other nodes within the MySQL Cluster, performing such functions as providing configuration data, starting and stopping nodes, running backup, and so forth. Because this node type manages the configuration of the other nodes, a node of this type should be started first, before any other node. An MGM node is started with the command ndb_mgmd.
Data node: This type of node stores cluster data. There are as many data nodes as there are replicas, times the number of fragments. For example, with two replicas, each having two fragments, you need four data nodes. One replica is sufficient for data storage, but provides no redundancy; therefore, it is recommended to have 2 (or more) replicas to provide redundancy, and thus high availability. A data node is started with the command ndbd.
SQL node: This is a node that accesses the cluster data. In the case of MySQL Cluster, an SQL node is a traditional MySQL server that uses the
NDBCLUSTERstorage engine. An SQL node is a mysqld process started with the--ndbclusterand--ndb-connectstringoptions, which are explained elsewhere in this chapter, possibly with additional MySQL server options as well.An SQL node is actually just a specialized type of API node, which designates any application which accesses Cluster data. Another example of an API node is the ndb_restore utility that is used to restore a cluster backup. It is possible to write such applications using the NDB API. For basic information about the NDB API, see Getting Started with the NDB API.
Important
It is not realistic to expect to employ a three-node setup in a production environment. Such a configuration provides no redundancy; in order to benefit from MySQL Cluster's high-availability features, you must use multiple data and SQL nodes. The use of multiple management nodes is also highly recommended.
For a brief introduction to the relationships between nodes, node groups, replicas, and partitions in MySQL Cluster, see Section 17.1.2, “MySQL Cluster Nodes, Node Groups, Replicas, and Partitions”.
Configuration of a cluster involves configuring each individual node in the cluster and setting up individual communication links between nodes. MySQL Cluster is currently designed with the intention that data nodes are homogeneous in terms of processor power, memory space, and bandwidth. In addition, to provide a single point of configuration, all configuration data for the cluster as a whole is located in one configuration file.
The management server (MGM node) manages the cluster configuration file and the cluster log. Each node in the cluster retrieves the configuration data from the management server, and so requires a way to determine where the management server resides. When interesting events occur in the data nodes, the nodes transfer information about these events to the management server, which then writes the information to the cluster log.
In addition, there can be any number of cluster client processes or applications. These are of two types:
Standard MySQL clients. MySQL Cluster can be used with existing MySQL applications written in PHP, Perl, C, C++, Java, Python, Ruby, and so on. Such client applications send SQL statements to and receive responses from MySQL servers acting as MySQL Cluster SQL nodes in much the same way that they interact with standalone MySQL servers. However, MySQL clients using a MySQL Cluster as a data source can be modified to take advantage of the ability to connect with multiple MySQL servers to achieve load balancing and failover. For example, Java clients using Connector/J 5.0.6 and later can use
jdbc:mysql:loadbalance://URLs (improved in Connector/J 5.1.7) to achieve load balancing transparently .Management clients. These clients connect to the management server and provide commands for starting and stopping nodes gracefully, starting and stopping message tracing (debug versions only), showing node versions and status, starting and stopping backups, and so on. Such clients — such as the ndb_mgm management client supplied with MySQL Cluster — are written using the MGM API, a C-language API that communicates directly with one or more MySQL Cluster management servers. For more information, see The MGM API.
This section discusses the manner in which MySQL Cluster divides and duplicates data for storage.
Central to an understanding of this topic are the following concepts, listed here with brief definitions:
(Data) Node. An ndbd process, which stores a replica —that is, a copy of the partition (see below) assigned to the node group of which the node is a member.
Each data node should be located on a separate computer. While it is also possible to host multiple ndbd processes on a single computer, such a configuration is not supported.
It is common for the terms “node” and “data node” to be used interchangeably when referring to an ndbd process; where mentioned, management (MGM) nodes (ndb_mgmd processes) and SQL nodes (mysqld processes) are specified as such in this discussion.
Node Group. A node group consists of one or more nodes, and stores partitions, or sets of replicas (see next item).
The number of node groups in a MySQL Cluster is not directly configurable; it is function of the number of data nodes and of the number of replicas (
NumberOfReplicasconfiguration parameter), as shown here:[
number_of_node_groups] =number_of_data_nodes/NumberOfReplicasThus, a MySQL Cluster with 4 data nodes has 4 node groups if
NumberOfReplicasis set to 1 in theconfig.inifile, 2 node groups ifNumberOfReplicasis set to 2, and 1 node group ifNumberOfReplicasis set to 4. Replicas are discussed later in this section; for more information aboutNumberOfReplicas, see Section 17.3.4.6, “Defining MySQL Cluster Data Nodes”.Note
All node groups in a MySQL Cluster must have the same number of data nodes.
Prior to MySQL Cluster NDB 7.0, it was not possible to add new data nodes to a MySQL Cluster without shutting down the cluster completely and reloading all of its data. In MySQL Cluster NDB 7.0 (beginning with MySQL Cluster version NDB 6.4.0), you can add new node groups (and thus new data nodes) to a running MySQL Cluster — see Section 17.7.8, “Adding MySQL Cluster Data Nodes Online”, for information about how this can be done.
Partition. This is a portion of the data stored by the cluster. There are as many cluster partitions as nodes participating in the cluster. Each node is responsible for keeping at least one copy of any partitions assigned to it (that is, at least one replica) available to the cluster.
A replica belongs entirely to a single node; a node can (and usually does) store several replicas.
MySQL Cluster normally partitions
NDBCLUSTERtables automatically. However, in MySQL 5.1 and MySQL Cluster NDB 6.x, it is possible to employ user-defined partitioning withNDBCLUSTERtables. This is subject to the following limitations:Only
KEYandLINEAR KEYpartitioning schemes can be used withNDBCLUSTERtables.The maximum number of partitions that may be definied explicitly for any
NDBCLUSTERtable is 8 per node group. (The number of node groups in a MySQL Cluster is determined as discussed previously in this section.)
For more information relating to MySQL Cluster and user-defined partitioning, see Section 17.12, “Known Limitations of MySQL Cluster”, and Section 18.5.2, “Partitioning Limitations Relating to Storage Engines”.
Replica. This is a copy of a cluster partition. Each node in a node group stores a replica. Also sometimes known as a partition replica. The number of replicas is equal to the number of nodes per node group.
The following diagram illustrates a MySQL Cluster with four data nodes, arranged in two node groups of two nodes each; nodes 1 and 2 belong to node group 0, and nodes 3 and 4 belong to node group 1. Note that only data (ndbd) nodes are shown here; although a working cluster requires an ndb_mgm process for cluster management and at least one SQL node to access the data stored by the cluster, these have been omitted in the figure for clarity.

The data stored by the cluster is divided into four partitions, numbered 0, 1, 2, and 3. Each partition is stored — in multiple copies — on the same node group. Partitions are stored on alternate node groups:
Partition 0 is stored on node group 0; a primary replica (primary copy) is stored on node 1, and a backup replica (backup copy of the partition) is stored on node 2.
Partition 1 is stored on the other node group (node group 1); this partition's primary replica is on node 3, and its backup replica is on node 4.
Partition 2 is stored on node group 0. However, the placing of its two replicas is reversed from that of Partition 0; for Partition 2, the primary replica is stored on node 2, and the backup on node 1.
Partition 3 is stored on node group 1, and the placement of its two replicas are reversed from those of partition 1. That is, its primary replica is located on node 4, with the backup on node 3.
What this means regarding the continued operation of a MySQL Cluster is this: so long as each node group participating in the cluster has at least one node operating, the cluster has a complete copy of all data and remains viable. This is illustrated in the next diagram.

In this example, where the cluster consists of two node groups of two nodes each, any combination of at least one node in node group 0 and at least one node in node group 1 is sufficient to keep the cluster “alive” (indicated by arrows in the diagram). However, if both nodes from either node group fail, the remaining two nodes are not sufficient (shown by the arrows marked out with an X); in either case, the cluster has lost an entire partition and so can no longer provide access to a complete set of all cluster data.
- 17.2.1. MySQL Cluster Hardware, Software, and Networking Requirements
- 17.2.2. MySQL Cluster Multi-Computer Installation
- 17.2.3. MySQL Cluster Multi-Computer Configuration
- 17.2.4. Initial Startup of MySQL Cluster
- 17.2.5. Loading Sample Data into MySQL Cluster and Performing Queries
- 17.2.6. Safe Shutdown and Restart of MySQL Cluster
This section is a “How-To” that describes the basics for how to plan, install, configure, and run a MySQL Cluster. Whereas the examples in Section 17.3, “MySQL Cluster Configuration” provide more in-depth information on a variety of clustering options and configuration, the result of following the guidelines and procedures outlined here should be a usable MySQL Cluster which meets the minimum requirements for availability and safeguarding of data.
This section covers hardware and software requirements; networking issues; installation of MySQL Cluster; configuration issues; starting, stopping, and restarting the cluster; loading of a sample database; and performing queries.
Basic assumptions. This How-To makes the following assumptions:
The cluster is to be set up with four nodes, each on a separate host, and each with a fixed network address on a typical Ethernet network as shown here:
Node IP Address Management (MGMD) node 192.168.0.10 MySQL server (SQL) node 192.168.0.20 Data (NDBD) node "A" 192.168.0.30 Data (NDBD) node "B" 192.168.0.40 This may be made clearer in the following diagram:

In the interest of simplicity (and reliability), this How-To uses only numeric IP addresses. However, if DNS resolution is available on your network, it is possible to use host names in lieu of IP addresses in configuring Cluster. Alternatively, you can use the
/etc/hostsfile or your operating system's equivalent for providing a means to do host lookup if such is available.Note
A common problem when trying to use host names for Cluster nodes arises because of the way in which some operating systems (including some Linux distributions) set up the system's own host name in the
/etc/hostsduring installation. Consider two machines with the host namesndb1andndb2, both in theclusternetwork domain. Red Hat Linux (including some derivatives such as CentOS and Fedora) places the following entries in these machines'/etc/hostsfiles:# ndb1
/etc/hosts: 127.0.0.1 ndb1.cluster ndb1 localhost.localdomain localhost# ndb2
/etc/hosts: 127.0.0.1 ndb2.cluster ndb2 localhost.localdomain localhostSUSE Linux (including OpenSUSE) places these entries in the machines'
/etc/hostsfiles:# ndb1
/etc/hosts: 127.0.0.1 localhost 127.0.0.2 ndb1.cluster ndb1# ndb2
/etc/hosts: 127.0.0.1 localhost 127.0.0.2 ndb2.cluster ndb2In both instances,
ndb1routesndb1.clusterto a loopback IP address, but gets a public IP address from DNS forndb2.cluster, whilendb2routesndb2.clusterto a loopback address and obtains a public address forndb1.cluster. The result is that each data node connects to the management server, but cannot tell when any other data nodes have connected, and so the data nodes appear to hang while starting.You should also be aware that you cannot mix
localhostand other host names or IP addresses inconfig.ini. For these reasons, the solution in such cases (other than to use IP addresses for allconfig.iniHostNameentries) is to remove the fully qualified host names from/etc/hostsand use these inconfig.inifor all cluster hosts.Each host in our scenario is an Intel-based desktop PC running a common, generic Linux distribution installed to disk in a standard configuration, and running no unnecessary services. The core OS with standard TCP/IP networking capabilities should be sufficient. Also for the sake of simplicity, we also assume that the file systems on all hosts are set up identically. In the event that they are not, you will need to adapt these instructions accordingly.
Standard 100 Mbps or 1 gigabit Ethernet cards are installed on each machine, along with the proper drivers for the cards, and that all four hosts are connected via a standard-issue Ethernet networking appliance such as a switch. (All machines should use network cards with the same throughout. That is, all four machines in the cluster should have 100 Mbps cards or all four machines should have 1 Gbps cards.) MySQL Cluster will work in a 100 Mbps network; however, gigabit Ethernet will provide better performance.
Note that MySQL Cluster is not intended for use in a network for which throughput is less than 100 Mbps. For this reason (among others), attempting to run a MySQL Cluster over a public network such as the Internet is not likely to be successful, and is not recommended.
For our sample data, we will use the
worlddatabase which is available for download from the MySQL AB Web site. As this database takes up a relatively small amount of space, we assume that each machine has 256MB RAM, which should be sufficient for running the operating system, host NDB process, and (for the data nodes) for storing the database.
Although we refer to a Linux operating system in this How-To, the instructions and procedures that we provide here should be easily adaptable to other supported operating systems. We also assume that you already know how to perform a minimal installation and configuration of the operating system with networking capability, or that you are able to obtain assistance in this elsewhere if needed.
We discuss MySQL Cluster hardware, software, and networking requirements in somewhat greater detail in the next section. (See Section 17.2.1, “MySQL Cluster Hardware, Software, and Networking Requirements”.)
One of the strengths of MySQL Cluster is that it can be run on commodity hardware and has no unusual requirements in this regard, other than for large amounts of RAM, due to the fact that all live data storage is done in memory. (It is possible to reduce this requirement using Disk Data tables — see Section 17.10, “MySQL Cluster Disk Data Tables”, for more information about these.) Naturally, multiple and faster CPUs can enhance performance. Memory requirements for other Cluster processes are relatively small.
The software requirements for Cluster are also modest. Host operating systems do not require any unusual modules, services, applications, or configuration to support MySQL Cluster. For supported operating systems, a standard installation should be sufficient. The MySQL software requirements are simple: all that is needed is a production release of MySQL 5.1.34-ndb-6.2.18 or 5.1.34-ndb-6.3.26 to have Cluster support. It is not necessary to compile MySQL yourself merely to be able to use Cluster. In this How-To, we assume that you are using the server binary appropriate to your platform, available via the MySQL Cluster software downloads page at http://dev.mysql.com/downloads/cluster.
For communication between nodes, Cluster supports TCP/IP networking in any standard topology, and the minimum expected for each host is a standard 100 Mbps Ethernet card, plus a switch, hub, or router to provide network connectivity for the cluster as a whole. We strongly recommend that a MySQL Cluster be run on its own subnet which is not shared with non-Cluster machines for the following reasons:
Security. Communications between Cluster nodes are not encrypted or shielded in any way. The only means of protecting transmissions within a MySQL Cluster is to run your Cluster on a protected network. If you intend to use MySQL Cluster for Web applications, the cluster should definitely reside behind your firewall and not in your network's De-Militarized Zone (DMZ) or elsewhere.
See Section 17.8.1, “MySQL Cluster Security and Networking Issues”, for more information.
Efficiency. Setting up a MySQL Cluster on a private or protected network allows the cluster to make exclusive use of bandwidth between cluster hosts. Using a separate switch for your MySQL Cluster not only helps protect against unauthorized access to Cluster data, it also ensures that Cluster nodes are shielded from interference caused by transmissions between other computers on the network. For enhanced reliability, you can use dual switches and dual cards to remove the network as a single point of failure; many device drivers support failover for such communication links.
It is also possible to use the high-speed Scalable Coherent Interface (SCI) with MySQL Cluster, but this is not a requirement. See Section 17.11, “Using High-Speed Interconnects with MySQL Cluster”, for more about this protocol and its use with MySQL Cluster.
Each MySQL Cluster host computer running an SQL node must have installed on it a MySQL binary. For management nodes and data nodes, it is not necessary to install the MySQL server binary, but management nodes require the management server daemon (ndb_mgmd) and data nodes require the data node daemon (ndbd). It is also a good idea to install the management client (ndb_mgm) on the management server host. This section covers the steps necessary to install the correct binaries for each type of Cluster node.
MySQL AB provides precompiled binaries that support Cluster.
However, we also include information relating to installing a
MySQL Cluster after building MySQL from source. For setting up a
cluster using MySQL's binaries, the first step in the
installation process for each cluster host is to download the
latest MySQL Cluster NDB 6.2 or MySQL Cluster NDB 6.3 binary
archive
(mysql-cluster-gpl-6.2.18-linux-i686-glibc23.tar.gz
or
mysql-cluster-gpl-6.3.26-linux-i686-glibc23.tar.gz,
respectively) from the
MySQL Cluster downloads
area. We assume that you have placed this file in each
machine's /var/tmp directory. (If you do
require a custom binary, see
Section 2.10.3, “Installing from the Development Source Tree”.)
Note
When compiling MySQL Cluster NDB 7.0 from source, no special
options are required for building multi-threaded data node
binaries. On Unix platforms, configuring the build with any of
the options --plugins=max,
--plugins=max-no-innodb, or
--with-ndbcluster causes
ndbmtd to be built automatically;
make install places the
ndbmtd binary in the
libexec directory along with
mysqld, ndbd, and
ndb_mgm. Similarly, on Windows, using
WITH_NDBCLUSTER_STORAGE_ENGINE with
configure.js causes
ndbmtd.exe to be built automatically, and to
be found in the bin directory of the
archive created by make_win_bin_dist.
RPMs are also available for both 32-bit and 64-bit Linux platforms. For a MySQL Cluster, three RPMs are required:
The Server RPM (for example,
MySQL-Cluster-gpl-server-6.2.18-0.sles10.i586.rpmorMySQL-Cluster-gpl-server-6.3.26-0.sles10.i586.rpm), which supplies the core files needed to run a MySQL Server withNDBCLUSTERstorage engine support (that is, as a MySQL Cluster SQL node).If you do not have your own client application capable of administering a MySQL server, you should also obtain and install the Client RPM (for example,
MySQL-Cluster-gpl-client-6.2.18-0.sles10.i586.rpmorMySQL-Cluster-gpl-client-6.3.26-0.sles10.i586.rpm).The Cluster storage engine RPM (for example,
MySQL-Cluster-gpl-storage-6.2.18-0.sles10.i586.rpmorMySQL-Cluster-gpl-storage-6.3.26-0.sles10.i586.rpm), which supplies the MySQL Cluster data node binary (ndbd).The Cluster storage engine management RPM (for example,
MySQL-Cluster-gpl-management-6.2.18-0.sles10.i586.rpmorMySQL-Cluster-gpl-management-6.3.26-0.sles10.i586.rpm), which provides the MySQL Cluster management server binary (ndb_mgmd).
In addition, you should also obtain the NDB
Cluster - Storage engine basic tools RPM (for example,
MySQL-Cluster-gpl-tools-6.2.18-0.sles10.i586.rpm
or
MySQL-Cluster-gpl-tools-6.3.26-0.sles10.i586.rpm),
which supplies several useful applications for working with a
MySQL Cluster. The most important of these is the MySQL Cluster
management client (ndb_mgm). The
NDB Cluster - Storage engine extra
tools RPM (for example,
MySQL-Cluster-gpl-extra-6.2.18-0.sles10.i586.rpm
or
MySQL-Cluster-gpl-extra-6.3.26-0.sles10.i586.rpm)
contains some additional testing and monitoring programs, but is
not required to install a MySQL Cluster. (For more information
about these additional programs, see
Section 17.6, “MySQL Cluster Programs”.)
The MySQL Cluster version number in the RPM file names (shown here
as 6.2.18 or
6.3.26) can vary according to
the version which you are actually using. It is very
important that all of the Cluster RPMs to be installed have the
same version number. The glibc
version number (if present), and architecture designation (shown
here as i586) should be appropriate to the
machine on which the RPM is to be installed.
See Section 2.4, “Installing MySQL from RPM Packages on Linux”, for general information about installing MySQL using RPMs supplied by MySQL AB.
After installing from RPM, you still need to configure the cluster as discussed in Section 17.2.3, “MySQL Cluster Multi-Computer Configuration”.
Note
After completing the installation, do not yet start any of the binaries. We show you how to do so following the configuration of all nodes.
Data and SQL Node Installation — .tar.gz
Binary.
On each of the machines designated to host data or SQL nodes,
perform the following steps as the system
root user:
Check your
/etc/passwdand/etc/groupfiles (or use whatever tools are provided by your operating system for managing users and groups) to see whether there is already amysqlgroup andmysqluser on the system. Some OS distributions create these as part of the operating system installation process. If they are not already present, create a newmysqluser group, and then add amysqluser to this group:shell>
groupadd mysqlshell>useradd -g mysql mysqlThe syntax for useradd and groupadd may differ slightly on different versions of Unix, or they may have different names such as adduser and addgroup.
Change location to the directory containing the downloaded file, unpack the archive, and create a symlink to the
mysqldirectory namedmysql. Note that the actual file and directory names will vary according to the MySQL Cluster version number.shell>
cd /var/tmpshell>tar -C /usr/local -xzvf mysql-cluster-gpl-6.3.26-linux-i686-glibc23.tar.gzshell>ln -s /usr/local/mysql-cluster-gpl-6.3.26-linux-i686-glibc23.tar.gz /usr/local/mysqlChange location to the
mysqldirectory and run the supplied script for creating the system databases:shell>
cd mysqlshell>scripts/mysql_install_db --user=mysqlSet the necessary permissions for the MySQL server and data directories:
shell>
chown -R root .shell>chown -R mysql datashell>chgrp -R mysql .Note that the data directory on each machine hosting a data node is
/usr/local/mysql/data. This piece of information is essential when configuring the management node. (See Section 17.2.3, “MySQL Cluster Multi-Computer Configuration”.)Copy the MySQL startup script to the appropriate directory, make it executable, and set it to start when the operating system is booted up:
shell>
cp support-files/mysql.server /etc/rc.d/init.d/shell>chmod +x /etc/rc.d/init.d/mysql.servershell>chkconfig --add mysql.server(The startup scripts directory may vary depending on your operating system and version — for example, in some Linux distributions, it is
/etc/init.d.)Here we use Red Hat's chkconfig for creating links to the startup scripts; use whatever means is appropriate for this purpose on your operating system and distribution, such as update-rc.d on Debian.
Remember that the preceding steps must be repeated on each machine where an SQL node is to reside.
SQL node installation — RPM files. On each machine to be used for hosting a cluster SQL node, install the Server RPM by executing the following command as the system root user, replacing the name shown for the RPM as necessary to match the name of the RPM downloaded from the MySQL AB web site:
shell> rpm -Uhv MySQL-Cluster-gpl-server-6.3.26-0.sles10.i586.rpm
This installs the MySQL server binary
(mysqld) in the
/usr/sbin directory, as well as all needed
MySQL Server support files. It also installs the
mysql.server and
mysqld_safe startup scripts in
/usr/share/mysql and
/usr/bin, respectively. The RPM installer
should take care of general configuration issues (such as
creating the mysql user and group, if needed)
automatically.
Note
To administer the SQL node (MySQL server), you should also install the Client RPM, as shown here:
shell> rpm -Uhv MySQL-Cluster-gpl-client-6.3.26-0.sles10.i586.rpm
This installs the mysql client program.
SQL node installation — building from source.
If you compile MySQL with clustering support (for example, by
using the
BUILD/compile-platform_name-max
script appropriate to your platform), and perform the default
installation (using make install as the root
user), mysqld is placed in
/usr/local/mysql/bin. Follow the steps
given in Section 2.10, “MySQL Installation Using a Source Distribution” to make
mysqld ready for use. If you want to run
multiple SQL nodes, you can use a copy of the same
mysqld executable and its associated support
files on several machines. The easiest way to do this is to copy
the entire /usr/local/mysql directory and
all directories and files contained within it to the other SQL
node host or hosts, then repeat the steps from
Section 2.10, “MySQL Installation Using a Source Distribution” on each machine. If you
configure the build with a nondefault
--prefix, you need to adjust
the directory accordingly.
Data node installation — RPM Files. On a computer that is to host a cluster data node it is necessary to install only the NDB Cluster - Storage engine RPM. To do so, copy this RPM to the data node host, and run the following command as the system root user, replacing the name shown for the RPM as necessary to match that of the RPM downloaded from the MySQL AB web site:
shell> rpm -Uhv MySQL-Cluster-gpl-storage-6.2.18-0.sles10.i586.rpm
The previous command installs the MySQL Cluster data node binary
(ndbd) in the /usr/sbin
directory.
Data node installation — building from source.
The only executable required on a data node host is
ndbd (mysqld, for example,
does not have to be present on the host machine). By default
when doing a source build, this file is placed in the directory
/usr/local/mysql/libexec. For installing on
multiple data node hosts, only ndbd need be
copied to the other host machine or machines. (This assumes that
all data node hosts use the same architecture and operating
system; otherwise you may need to compile separately for each
different platform.) ndbd need not be in any
particular location on the host's file system, as long as the
location is known.
Management node installation — .tar.gz binary.
Installation of the management node does not require the
mysqld binary. Only the MySQL Cluster
management server (ndb_mgmd) is required; you
most likely want to install the management client
(ndb_mgm) as well. Both of these binaries
also be found in the .tar.gz archive.
Again, we assume that you have placed this archive in
/var/tmp.
As system root (that is, after using
sudo, su root, or your
system's equivalent for temporarily assuming the system
administrator account's privileges), perform the following steps
to install ndb_mgmd and
ndb_mgm on the Cluster management node host:
Change location to the
/var/tmpdirectory, and extract the ndb_mgm and ndb_mgmd from the archive into a suitable directory such as/usr/local/bin:shell>
cd /var/tmpshell>tar -zxvf mysql-5.1.34-ndb-6.3.26-linux-i686-glibc23.tar.gzshell>cd mysql-5.1.34-ndb-6.3.26-linux-i686-glibc23shell>cp bin/ndb_mgm* /usr/local/bin(You can safely delete the directory created by unpacking the downloaded archive, and the files it contains, from
/var/tmponce ndb_mgm and ndb_mgmd have been copied to the executables directory.)Change location to the directory into which you copied the files, and then make both of them executable:
shell>
cd /usr/local/binshell>chmod +x ndb_mgm*
Management node installation — RPM file. To install the MySQL Cluster management server, it is necessary only to use the NDB Cluster - Storage engine management RPM. Copy this RPM to the computer intended to host the management node, and then install it by running the following command as the system root user (replace the name shown for the RPM as necessary to match that of the Storage engine management RPM downloaded from the MySQL AB web site):
shell> rpm -Uhv MySQL-Cluster-gpl-management-6.3.26-0.sles10.i586.rpm
This installs the management server binary
(ndb_mgmd) to the
/usr/sbin directory.
You should also install the NDB
management client, which is supplied by the
Storage engine basic tools RPM.
Copy this RPM to the same computer as the management node, and
then install it by running the following command as the system
root user (again, replace the name shown for the RPM as necessary
to match that of the Storage engine basic
tools RPM downloaded from the MySQL AB web site):
shell> rpm -Uhv MySQL-Cluster-gpl-tools-6.3.26-0.sles10.i586.rpm
The Storage engine basic tools
RPM installs the MySQL Cluster management client
(ndb_mgm) to the /usr/bin
directory.
Note
You can also install the Cluster storage engine extra tools RPM, if you wish, as shown here:
shell> rpm -Uhv MySQL-Cluster-gpl-extra-6.3.26-0.sles10.i586.rpm
You may find the extra tools useful; however the Cluster storage engine extra tools RPM is not required to install a working MySQL Cluster.
Management node installation — building from source.
When building from source and running the default make
install, the management server binary
(ndb_mgmd) is placed in
/usr/local/mysql/libexec, while the
management client binary (ndb_mgm) can be
found in /usr/local/mysql/bin. Only
ndb_mgmd is required to be present on a
management node host; however, it is also a good idea to have
ndb_mgm present on the same host machine.
Neither of these executables requires a specific location on the
host machine's file system.
In Section 17.2.3, “MySQL Cluster Multi-Computer Configuration”, we create configuration files for all of the nodes in our example MySQL Cluster.
MySQL Cluster on Windows (alpha).
In MySQL Cluster NDB 7.0, experimental support is added for
Microsoft Windows platforms. To compile MySQL Cluster from
source on Windows, you must configure the build using the
WITH_NDBCLUSTER_STORAGE_ENGINE option before
creating the Visual Studio project files. After running
make_win_bin_dist, the MySQL Cluster binaries
can be found in the bin directory of the
resulting archive. For more information, see
Section 2.10.6, “Installing MySQL from Source on Windows”.
For our four-node, four-host MySQL Cluster, it is necessary to write four configuration files, one per node host.
Each data node or SQL node requires a
my.cnffile that provides two pieces of information: a connectstring that tells the node where to find the management node, and a line telling the MySQL server on this host (the machine hosting the data node) to enable theNDBCLUSTERstorage engine.For more information on connectstrings, see Section 17.3.4.3, “The MySQL Cluster Connectstring”.
The management node needs a
config.inifile 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 data to disk on each data node, and where to find any SQL nodes.
Configuring the Storage and SQL Nodes
The my.cnf file needed for the data nodes is
fairly simple. The configuration file should be located in the
/etc directory and can be edited using any
text editor. (Create the file if it does not exist.) For example:
shell> vi /etc/my.cnf
Note
We show vi being used here to create the file, but any text editor should work just as well.
For each data node and SQL node in our example setup,
my.cnf should look like this:
# Options for mysqld process: [mysqld] ndbcluster # run NDB storage engine ndb-connectstring=192.168.0.10 # location of management server # Options for ndbd process: [mysql_cluster] ndb-connectstring=192.168.0.10 # location of management server
After entering the preceding information, save this file and exit the text editor. Do this for the machines hosting data node “A”, data node “B”, and the SQL node.
Important
Once you have started a mysqld process with
the NDBCLUSTER and
ndb-connectstring parameters in the
[mysqld] in the my.cnf
file as shown previously, you cannot execute any
CREATE TABLE or
ALTER TABLE statements without
having actually started the cluster. Otherwise, these statements
will fail with an error. This is by design.
Configuring the management node.
The first step in configuring the management node is to create
the directory in which the configuration file can be found and
then to create the file itself. For example (running as
root):
shell>mkdir /var/lib/mysql-clustershell>cd /var/lib/mysql-clustershell>vi config.ini
For our representative setup, the config.ini
file should read as follows:
# Options affecting ndbd processes on all data nodes:
[ndbd default]
NoOfReplicas=2 # Number of replicas
DataMemory=80M # How much memory to allocate for data storage
IndexMemory=18M # How much memory to allocate for index storage
# For DataMemory and IndexMemory, we have used the
# default values. Since the "world" database takes up
# only about 500KB, this should be more than enough for
# this example Cluster setup.
# TCP/IP options:
[tcp default]
portnumber=2202 # This the default; however, you can use any port that is free
# for all the hosts in the cluster
# Note: It is recommended that you do not specify the port
# number at all and allow the default value to be used instead
# Management process options:
[ndb_mgmd]
hostname=192.168.0.10 # Hostname or IP address of management node
datadir=/var/lib/mysql-cluster # Directory for management node log files
# Options for data node "A":
[ndbd]
# (one [ndbd] section per data node)
hostname=192.168.0.30 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
# Options for data node "B":
[ndbd]
hostname=192.168.0.40 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
# SQL node options:
[mysqld]
hostname=192.168.0.20 # Hostname or IP address
# (additional mysqld connections can be
# specified for this node for various
# purposes such as running ndb_restore)
Note
The world database can be downloaded from
http://dev.mysql.com/doc/, where it can be found listed
under “Examples”.
After all the configuration files have been created and these minimal options have been specified, you are ready to proceed with starting the cluster and verifying that all processes are running. We discuss how this is done in Section 17.2.4, “Initial Startup of MySQL Cluster”.
For more detailed information about the available MySQL Cluster configuration parameters and their uses, see Section 17.3.4, “MySQL Cluster Configuration Files”, and Section 17.3, “MySQL Cluster Configuration”. For configuration of MySQL Cluster as relates to making backups, see Section 17.7.3.3, “Configuration for MySQL Cluster Backups”.
Note
The default port for Cluster management nodes is 1186; the default port for data nodes is 2202. However, the cluster can automatically allocate ports for data nodes from those that are already free.
Starting the cluster is not very difficult after it has been configured. Each cluster node process must be started separately, and on the host where it resides. The management node should be started first, followed by the data nodes, and then finally by any SQL nodes:
On the management host, issue the following command from the system shell to start the management node process:
shell>
ndb_mgmd -f /var/lib/mysql-cluster/config.iniNote
ndb_mgmd must be told where to find its configuration file, using the
-for--config-fileoption. (See Section 17.6.4, “ndb_mgmd — The MySQL Cluster Management Server Daemon”, for details.)For additional options which can be used with ndb_mgmd, see Section 17.6.23, “Options Common to MySQL Cluster Programs”.
On each of the data node hosts, run this command to start the ndbd process:
shell>
ndbdIf you used RPM files to install MySQL on the cluster host where the SQL node is to reside, you can (and should) use the supplied startup script to start the MySQL server process on the SQL node.
If all has gone well, and the cluster has been set up correctly, the cluster should now be operational. You can test this by invoking the ndb_mgm management node client. The output should look like that shown here, although you might see some slight differences in the output depending upon the exact version of MySQL that you are using:
shell>ndb_mgm-- NDB Cluster -- Management Client -- ndb_mgm>SHOWConnected to Management Server at: localhost:1186 Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=2 @192.168.0.30 (Version: 5.1.34-ndb-6.3.26, Nodegroup: 0, Master) id=3 @192.168.0.40 (Version: 5.1.34-ndb-6.3.26, Nodegroup: 0) [ndb_mgmd(MGM)] 1 node(s) id=1 @192.168.0.10 (Version: 5.1.34-ndb-6.3.26) [mysqld(API)] 1 node(s) id=4 @192.168.0.20 (Version: 5.1.34-ndb-6.3.26)
The SQL node is referenced here as
[mysqld(API)], which reflects the fact that the
mysqld process is acting as a MySQL Cluster API
node.
Note
The IP address shown for a given MySQL Cluster SQL or other API
node in the output of SHOW
is the address used by the SQL or API node to connect to the
cluster data nodes, and not to any management node.
You should now be ready to work with databases, tables, and data in MySQL Cluster. See Section 17.2.5, “Loading Sample Data into MySQL Cluster and Performing Queries”, for a brief discussion.
Working with data in MySQL Cluster is not much different from doing so in MySQL without Cluster. There are two points to keep in mind:
For a table to be replicated in the cluster, it must use the
NDBCLUSTERstorage engine. To specify this, use theENGINE=NDBCLUSTERorENGINE=NDBoption when creating the table:CREATE TABLE
tbl_name(col_namecolumn_definitions) ENGINE=NDBCLUSTER;Alternatively, for an existing table that uses a different storage engine, use
ALTER TABLEto change the table to useNDBCLUSTER:ALTER TABLE
tbl_nameENGINE=NDBCLUSTER;Each
NDBCLUSTERtable must have a primary key. If no primary key is defined by the user when a table is created, theNDBCLUSTERstorage engine automatically generates a hidden one.Note
This hidden key takes up space just as does any other table index. It is not uncommon to encounter problems due to insufficient memory for accommodating these automatically created indexes.)
If you are importing tables from an existing database using the
output of mysqldump, you can open the SQL
script in a text editor and add the ENGINE
option to any table creation statements, or replace any existing
ENGINE (or TYPE) options.
Suppose that you have the world sample database
on another MySQL server that does not support MySQL Cluster, and
you want to export the City table:
shell> mysqldump --add-drop-table world City > city_table.sql
The resulting city_table.sql file will
contain this table creation statement (and the
INSERT statements necessary to
import the table data):
DROP TABLE IF EXISTS `City`;
CREATE TABLE `City` (
`ID` int(11) NOT NULL auto_increment,
`Name` char(35) NOT NULL default '',
`CountryCode` char(3) NOT NULL default '',
`District` char(20) NOT NULL default '',
`Population` int(11) NOT NULL default '0',
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `City` VALUES (1,'Kabul','AFG','Kabol',1780000);
INSERT INTO `City` VALUES (2,'Qandahar','AFG','Qandahar',237500);
INSERT INTO `City` VALUES (3,'Herat','AFG','Herat',186800);
(remaining INSERT statements omitted)
You need to make sure that MySQL uses the
NDBCLUSTER storage engine for this
table. There are two ways that this can be accomplished. One of
these is to modify the table definition
before importing it into the Cluster
database. Using the City table as an example,
modify the ENGINE option of the definition as
follows:
DROP TABLE IF EXISTS `City`;
CREATE TABLE `City` (
`ID` int(11) NOT NULL auto_increment,
`Name` char(35) NOT NULL default '',
`CountryCode` char(3) NOT NULL default '',
`District` char(20) NOT NULL default '',
`Population` int(11) NOT NULL default '0',
PRIMARY KEY (`ID`)
) ENGINE=NDBCLUSTER DEFAULT CHARSET=latin1;
INSERT INTO `City` VALUES (1,'Kabul','AFG','Kabol',1780000);
INSERT INTO `City` VALUES (2,'Qandahar','AFG','Qandahar',237500);
INSERT INTO `City` VALUES (3,'Herat','AFG','Herat',186800);
(remaining INSERT statements omitted)
This must be done for the definition of each table that is to be
part of the clustered database. The easiest way to accomplish this
is to do a search-and-replace on the file that contains the
definitions and replace all instances of
TYPE= or
engine_nameENGINE=
with engine_nameENGINE=NDBCLUSTER. If you do not want to
modify the file, you can use the unmodified file to create the
tables, and then use ALTER TABLE to
change their storage engine. The particulars are given later in
this section.
Assuming that you have already created a database named
world on the SQL node of the cluster, you can
then use the mysql command-line client to read
city_table.sql, and create and populate the
corresponding table in the usual manner:
shell> mysql world < city_table.sql
It is very important to keep in mind that the preceding command
must be executed on the host where the SQL node is running (in
this case, on the machine with the IP address
192.168.0.20).
To create a copy of the entire world database
on the SQL node, use mysqldump on the
noncluster server to export the database to a file named
world.sql; for example, in the
/tmp directory. Then modify the table
definitions as just described and import the file into the SQL
node of the cluster like this:
shell> mysql world < /tmp/world.sql
If you save the file to a different location, adjust the preceding instructions accordingly.
Running SELECT queries on the SQL
node is no different from running them on any other instance of a
MySQL server. To run queries from the command line, you first need
to log in to the MySQL Monitor in the usual way (specify the
root password at the Enter
password: prompt):
shell> mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.1.34-ndb-6.2.18
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
We simply use the MySQL server's root
account and assume that you have followed the standard security
precautions for installing a MySQL server, including setting a
strong root password. For more information, see
Section 2.11.3, “Securing the Initial MySQL Accounts”.
It is worth taking into account that Cluster nodes do
not make use of the MySQL privilege system
when accessing one another. Setting or changing MySQL user
accounts (including the root account) effects
only applications that access the SQL node, not interaction
between nodes. See
Section 17.8.2, “MySQL Cluster and MySQL Privileges”, for
more information.
If you did not modify the ENGINE clauses in the
table definitions prior to importing the SQL script, you should
run the following statements at this point:
mysql>USE world;mysql>ALTER TABLE City ENGINE=NDBCLUSTER;mysql>ALTER TABLE Country ENGINE=NDBCLUSTER;mysql>ALTER TABLE CountryLanguage ENGINE=NDBCLUSTER;
Selecting a database and running a SELECT query against a table in that database is also accomplished in the usual manner, as is exiting the MySQL Monitor:
mysql>USE world;mysql>SELECT Name, Population FROM City ORDER BY Population DESC LIMIT 5;+-----------+------------+ | Name | Population | +-----------+------------+ | Bombay | 10500000 | | Seoul | 9981619 | | São Paulo | 9968485 | | Shanghai | 9696300 | | Jakarta | 9604900 | +-----------+------------+ 5 rows in set (0.34 sec) mysql>\qBye shell>
Applications that use MySQL can employ standard APIs to access
NDB tables. It is important to
remember that your application must access the SQL node, and not
the management or data nodes. This brief example shows how we
might execute the SELECT statement
just shown by using the PHP 5.X mysqli
extension running on a Web server elsewhere on the network:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<title>SIMPLE mysqli SELECT</title>
</head>
<body>
<?php
# connect to SQL node:
$link = new mysqli('192.168.0.20', 'root', 'root_password', 'world');
# parameters for mysqli constructor are:
# host, user, password, database
if( mysqli_connect_errno() )
die("Connect failed: " . mysqli_connect_error());
$query = "SELECT Name, Population
FROM City
ORDER BY Population DESC
LIMIT 5";
# if no errors...
if( $result = $link->query($query) )
{
?>
<table border="1" width="40%" cellpadding="4" cellspacing ="1">
<tbody>
<tr>
<th width="10%">City</th>
<th>Population</th>
</tr>
<?
# then display the results...
while($row = $result->fetch_object())
printf("<tr>\n <td align=\"center\">%s</td><td>%d</td>\n</tr>\n",
$row->Name, $row->Population);
?>
</tbody
</table>
<?
# ...and verify the number of rows that were retrieved
printf("<p>Affected rows: %d</p>\n", $link->affected_rows);
}
else
# otherwise, tell us what went wrong
echo mysqli_error();
# free the result set and the mysqli connection object
$result->close();
$link->close();
?>
</body>
</html>
We assume that the process running on the Web server can reach the IP address of the SQL node.
In a similar fashion, you can use the MySQL C API, Perl-DBI, Python-mysql, or MySQL AB's own Connectors to perform the tasks of data definition and manipulation just as you would normally with MySQL.
To shut down the cluster, enter the following command in a shell on the machine hosting the management node:
shell> ndb_mgm -e shutdown
The -e option here is used to pass a command to
the ndb_mgm client from the shell. (See
Section 17.6.23, “Options Common to MySQL Cluster Programs”, for more
information about this option.) The command causes the
ndb_mgm, ndb_mgmd, and any
ndbd processes to terminate gracefully. Any SQL
nodes can be terminated using mysqladmin
shutdown and other means.
To restart the cluster, run these commands:
On the management host (
192.168.0.10in our example setup):shell>
ndb_mgmd -f /var/lib/mysql-cluster/config.iniOn each of the data node hosts (
192.168.0.30and192.168.0.40):shell>
ndbdOn the SQL host (
192.168.0.20):shell>
mysqld_safe &
In a production setting, it is usually not desirable to shut down the cluster completely. In many cases, even when making configuration changes, or performing upgrades to the cluster hardware or software (or both), which require shutting down individual host machines, it is possible to do so without shutting down the cluster as a whole by performing a rolling restart of the cluster. For more information about doing this, see Section 17.5.1, “Performing a Rolling Restart of a MySQL Cluster”.
- 17.3.1. Building MySQL Cluster from Source Code
- 17.3.2. Installing MySQL Cluster Software
- 17.3.3. Quick Test Setup of MySQL Cluster
- 17.3.4. MySQL Cluster Configuration Files
- 17.3.5. Overview of MySQL Cluster Configuration Parameters
- 17.3.6. Configuring MySQL Cluster Parameters for Local Checkpoints
- 17.3.7. Configuring MySQL Cluster Send Buffer Parameters
A MySQL server that is part of a MySQL Cluster differs in one chief
respect from a normal (nonclustered) MySQL server, in that it
employs the NDBCLUSTER storage engine.
This engine is also referred to simply as
NDB, and the two forms of the name are
synonymous.
To avoid unnecessary allocation of resources, the server is
configured by default with the NDB
storage engine disabled. To enable NDB,
you must modify the server's my.cnf
configuration file, or start the server with the
--ndbcluster option.
For more information about
--ndbcluster and other MySQL server
options specific to MySQL Cluster, see
Section 17.4.2, “mysqld Command Options for MySQL Cluster”.
The MySQL server is a part of the cluster, so it also must know how
to access an MGM node to obtain the cluster configuration data. The
default behavior is to look for the MGM node on
localhost. However, should you need to specify
that its location is elsewhere, this can be done in
my.cnf or on the MySQL server command line.
Before the NDB storage engine can be
used, at least one MGM node must be operational, as well as any
desired data nodes.
NDBCLUSTER, the MySQL Cluster storage
engine, is available in binary distributions for Linux, Mac OS X,
and Solaris. We are working to make Cluster run on all operating
systems supported by MySQL, including Windows. Beginning with
MySQL Cluster NDB 6.4.0, there is experimental support for MySQL
Cluster on Windows.
If you choose to build from a source tarball or one of the MySQL
Cluster public development trees, be sure to use the
--with-ndbcluster option when running
configure (if building from source on Microsoft
Windows platforms, use the
WITH_NDBCLUSTER_STORAGE_ENGINE option with
configure.js). You can also use the
BUILD/compile-pentium-max build scripts
provided for most Unix platforms. Note that this script includes
OpenSSL, so you must either have or obtain OpenSSL to build
successfully, or else modify
compile-pentium-max to exclude this
requirement. Of course, you can also just follow the standard
instructions for compiling your own binaries, and then perform the
usual tests and installation procedure. See
Section 2.10.3, “Installing from the Development Source Tree”.
BUILD/compile-pentium-max also includes OpenSSL, so you must either have or obtain OpenSSL to build successfully, or else modify compile-pentium-max to exclude this requirement. Of course, you can also just follow the standard instructions for compiling your own binaries, and then perform the usual tests and installation procedure. See Section 2.10.3, “Installing from the Development Source Tree”.
You should also note that compile-pentium-max
installs MySQL to the directory
/usr/local/mysql, placing all MySQL Cluster
executables, scripts, databases, and support files in
subdirectories under this directory. If this is not what you
desire, be sure to modify the script accordingly.
In the next few sections, we assume that you are already familiar with installing MySQL, and here we cover only the differences between configuring MySQL Cluster and configuring MySQL without clustering. (See Chapter 2, Installing and Upgrading MySQL, if you require more information about the latter.)
You will find Cluster configuration easiest if you have already
have all management and data nodes running first; this is likely
to be the most time-consuming part of the configuration. Editing
the my.cnf file is fairly straightforward,
and this section will cover only any differences from configuring
MySQL without clustering.
To familiarize you with the basics, we will describe the simplest possible configuration for a functional MySQL Cluster. After this, you should be able to design your desired setup from the information provided in the other relevant sections of this chapter.
First, you need to create a configuration directory such as
/var/lib/mysql-cluster, by executing the
following command as the system root user:
shell> mkdir /var/lib/mysql-cluster
In this directory, create a file named
config.ini that contains the following
information. Substitute appropriate values for
HostName and DataDir as
necessary for your system.
# file "config.ini" - showing minimal setup consisting of 1 data node, # 1 management server, and 3 MySQL servers. # The empty default sections are not required, and are shown only for # the sake of completeness. # Data nodes must provide a hostname but MySQL Servers are not required # to do so. # If you don't know the hostname for your machine, use localhost. # The DataDir parameter also has a default value, but it is recommended to # set it explicitly. # Note: [db], [api], and [mgm] are aliases for [ndbd], [mysqld], and [ndb_mgmd], # respectively. [db] is deprecated and should not be used in new installations. [ndbd default] NoOfReplicas= 1 [mysqld default] [ndb_mgmd default] [tcp default] [ndb_mgmd] HostName= myhost.example.com [ndbd] HostName= myhost.example.com DataDir= /var/lib/mysql-cluster [mysqld] [mysqld] [mysqld]
You can now start the ndb_mgmd management
server. By default, it attempts to read the
config.ini file in its current working
directory, so change location into the directory where the file is
located and then invoke ndb_mgmd:
shell>cd /var/lib/mysql-clustershell>ndb_mgmd
Then start a single data node by running ndbd:
shell> ndbd
For command-line options which can be used when starting ndbd, see Section 17.6.23, “Options Common to MySQL Cluster Programs”.
By default, ndbd looks for the management
server at localhost on port 1186.
Note
If you have installed MySQL from a binary tarball, you will need
to specify the path of the ndb_mgmd and
ndbd servers explicitly. (Normally, these
will be found in /usr/local/mysql/bin.)
Finally, change location to the MySQL data directory (usually
/var/lib/mysql or
/usr/local/mysql/data), and make sure that
the my.cnf file contains the option necessary
to enable the NDB storage engine:
[mysqld] ndbcluster
You can now start the MySQL server as usual:
shell> mysqld_safe --user=mysql &
Wait a moment to make sure the MySQL server is running properly.
If you see the notice mysql ended, check the
server's .err file to find out what went
wrong.
If all has gone well so far, you now can start using the cluster.
Connect to the server and verify that the
NDBCLUSTER storage engine is enabled:
shell>mysqlWelcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 5.1.36 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>SHOW ENGINES\G... *************************** 12. row *************************** Engine: NDBCLUSTER Support: YES Comment: Clustered, fault-tolerant, memory-based tables *************************** 13. row *************************** Engine: NDB Support: YES Comment: Alias for NDBCLUSTER ...
The row numbers shown in the preceding example output may be different from those shown on your system, depending upon how your server is configured.
Try to create an NDBCLUSTER table:
shell>mysqlmysql>USE test;Database changed mysql>CREATE TABLE ctest (i INT) ENGINE=NDBCLUSTER;Query OK, 0 rows affected (0.09 sec) mysql>SHOW CREATE TABLE ctest \G*************************** 1. row *************************** Table: ctest Create Table: CREATE TABLE `ctest` ( `i` int(11) default NULL ) ENGINE=ndbcluster DEFAULT CHARSET=latin1 1 row in set (0.00 sec)
To check that your nodes were set up properly, start the management client:
shell> ndb_mgm
Use the SHOW command from within the management client to obtain a report on the cluster's status:
ndb_mgm> SHOW
Cluster Configuration
---------------------
[ndbd(NDB)] 1 node(s)
id=2 @127.0.0.1 (Version: 3.5.3, Nodegroup: 0, Master)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @127.0.0.1 (Version: 3.5.3)
[mysqld(API)] 3 node(s)
id=3 @127.0.0.1 (Version: 3.5.3)
id=4 (not connected, accepting connect from any host)
id=5 (not connected, accepting connect from any host)
At this point, you have successfully set up a working MySQL
Cluster. You can now store data in the cluster by using any table
created with ENGINE=NDBCLUSTER or its alias
ENGINE=NDB.
- 17.3.4.1. MySQL Cluster Configuration — Basic Example
- 17.3.4.2. Recommended Starting Configurations for MySQL Cluster NDB 6.2 and Later
- 17.3.4.3. The MySQL Cluster Connectstring
- 17.3.4.4. Defining Computers in a MySQL Cluster
- 17.3.4.5. Defining a MySQL Cluster Management Server
- 17.3.4.6. Defining MySQL Cluster Data Nodes
- 17.3.4.7. Defining SQL and Other API Nodes in a MySQL Cluster
- 17.3.4.8. MySQL Cluster TCP/IP Connections
- 17.3.4.9. MySQL Cluster TCP/IP Connections Using Direct Connections
- 17.3.4.10. MySQL Cluster Shared-Memory Connections
- 17.3.4.11. SCI Transport Connections in MySQL Cluster
Configuring MySQL Cluster requires working with two files:
my.cnf: Specifies options for all MySQL Cluster executables. This file, with which you should be familiar with from previous work with MySQL, must be accessible by each executable running in the cluster.config.ini: This file, sometimes known as the global configuration file, is read only by the MySQL Cluster management server, which then distributes the information contained therein to all processes participating in the cluster.config.inicontains a description of each node involved in the cluster. This includes configuration parameters for data nodes and configuration parameters for connections between all nodes in the cluster. For a quick reference to the sections that can appear in this file, and what sorts of configuration parameters may be placed in each section, see Sections of theconfig.iniFile.
Caching of configuration data. Beginning with MySQL Cluster NDB 6.4.0, MySQL Cluster uses stateful configuration. The global configuration file is no longer read every time the management server is restarted. Instead, the management server caches the configuration the first time it is started, and thereafter, the global confiuration file is read only when one of the following items is true:
The management server is started using
--initialoption. In this case, the global configuration file is re-read, any existing cache files are deleted, and the management server creates a new configuration cache.The management server is started using
--reloadoption. In this case, the management server compares its cache with the global configuration file. If they differ, the management server creates a new configuration cache; any existing configuration cache is preserved, but not used. If the management server's cache and the global configuration file contain the same configuration data, then the existing cache is used, and no new cache is created.No configuration cache is found. In this case, the management server reads the global configuration file and creates a cache containing the same configuration data as found in the file.
Configuration cache files.
Beginning with MySQL Cluster 6.4.0, the management server by
default creates configuration cache files in a directory named
mysql-cluster in the MySQL installation
directory. (If you build MySQL Cluster from source on a Unix
system, the default location is
/usr/local/mysql-cluster.) This can be
overridden at run time by starting the management server with
the --configdir option. Configuration cache
files are binary files named according to the pattern
ndb_,
where node_id_config.bin.seq_idnode_id is the management
server's node ID in the cluster, and
seq_id is a cache idenitifer. Cache
files are numbered sequentially using
seq_id, in the order in which they
are created. The management server uses the latest cache file as
determined by the seq_id.
Note
It is possible to roll back to a previous configuration by
deleting later configuration cache files, or by renaming an
earlier cache file so that it has a higher
seq_id. However, since configuration
cache files are written in a binary format, you should not
attempt to edit their contents by hand.
For more information about the --configdir,
--initial, and --reload options
for the MySQL Cluster management server, see
Section 17.6.24.3, “Program Options for ndb_mgmd”.
We are continuously making improvements in Cluster configuration and attempting to simplify this process. Although we strive to maintain backward compatibility, there may be times when introduce an incompatible change. In such cases we will try to let Cluster users know in advance if a change is not backward compatible. If you find such a change and we have not documented it, please report it in the MySQL bugs database using the instructions given in Section 1.6, “How to Report Bugs or Problems”.
To support MySQL Cluster, you will need to update
my.cnf as shown in the following example.
You may also specify these parameters on the command line when
invoking the executables.
Note
The options shown here should not be confused with those that
are used in config.ini global
configuration files. Global configuration options are
discussed later in this section.
# my.cnf # example additions to my.cnf for MySQL Cluster # (valid in MySQL 5.1) # enable ndbcluster storage engine, and provide connectstring for # management server host (default port is 1186) [mysqld] ndbcluster ndb-connectstring=ndb_mgmd.mysql.com # provide connectstring for management server host (default port: 1186) [ndbd] connect-string=ndb_mgmd.mysql.com # provide connectstring for management server host (default port: 1186) [ndb_mgm] connect-string=ndb_mgmd.mysql.com # provide location of cluster configuration file [ndb_mgmd] config-file=/etc/config.ini
(For more information on connectstrings, see Section 17.3.4.3, “The MySQL Cluster Connectstring”.)
# my.cnf # example additions to my.cnf for MySQL Cluster # (will work on all versions) # enable ndbcluster storage engine, and provide connectstring for management # server host to the default port 1186 [mysqld] ndbcluster ndb-connectstring=ndb_mgmd.mysql.com:1186
Important
Once you have started a mysqld process with
the NDBCLUSTER and
ndb-connectstring parameters in the
[mysqld] in the my.cnf
file as shown previously, you cannot execute any
CREATE TABLE or
ALTER TABLE statements without
having actually started the cluster. Otherwise, these
statements will fail with an error. This is by
design.
You may also use a separate [mysql_cluster]
section in the cluster my.cnf file for
settings to be read and used by all executables:
# cluster-specific settings [mysql_cluster] ndb-connectstring=ndb_mgmd.mysql.com:1186
For additional NDB variables that
can be set in the my.cnf file, see
Section 17.4.3, “MySQL Cluster System Variables”.
The MySQL Cluster global configuration file is named
config.ini by default. It is read by
ndb_mgmd at startup and can be placed
anywhere. Its location and name are specified by using
--config-file=
on the ndb_mgmd command line. If the
configuration file is not specified, ndb_mgmd
by default tries to read a file named
path_nameconfig.ini located in the current working
directory.
The global configuration file for MySQL Cluster uses INI format,
which consists of sections preceded by section headings
(surrounded by square brackets), followed by the appropriate
parameter names and values. One deviation from the standard INI
format is that the parameter name and value can be separated by
a colon (“:”) as well as the
equals sign (“=”); however, the
equals sign is preferred. Another deviation is that sections are
not uniquely identified by section name. Instead, unique
sections (such as two different nodes of the same type) are
identified by a unique ID specified as a parameter within the
section.
Default values are defined for most parameters, and can also be
specified in config.ini.
(Exception: The
NoOfReplicas configuration parameter has no
default value, and must always be specified explicitly in the
[ndbd default] section.) To create a default
value section, simply add the word default to
the section name. For example, an [ndbd]
section contains parameters that apply to a particular data
node, whereas an [ndbd default] section
contains parameters that apply to all data nodes. Suppose that
all data nodes should use the same data memory size. To
configure them all, create an [ndbd default]
section that contains a DataMemory line to
specify the data memory size.
The global configuration file must define the computers and nodes involved in the cluster and on which computers these nodes are located. An example of a simple configuration file for a cluster consisting of one management server, two data nodes and two MySQL servers is shown here:
# file "config.ini" - 2 data nodes and 2 SQL nodes # This file is placed in the startup directory of ndb_mgmd (the # management server) # The first MySQL Server can be started from any host. The second # can be started only on the host mysqld_5.mysql.com [ndbd default] NoOfReplicas= 2 DataDir= /var/lib/mysql-cluster [ndb_mgmd] Hostname= ndb_mgmd.mysql.com DataDir= /var/lib/mysql-cluster [ndbd] HostName= ndbd_2.mysql.com [ndbd] HostName= ndbd_3.mysql.com [mysqld] [mysqld] HostName= mysqld_5.mysql.com
Note
The preceding example is intended as a minimal starting configuration for purposes of familiarization with MySQL Cluster, and is almost certain not to be sufficient for production settings. See Section 17.3.4.2, “Recommended Starting Configurations for MySQL Cluster NDB 6.2 and Later”, which provides more complete example starting configurations for use with MySQL Cluster NDB 6.2 and newer versions of MySQL Cluster.
Each node has its own section in the
config.ini file. For example, this cluster
has two data nodes, so the preceding configuration file contains
two [ndbd] sections defining these nodes.
Note
Do not place comments on the same line as a section heading in
the config.ini file; this causes the
management server not to start because it cannot parse the
configuration file in such cases.
Sections of the
config.ini File
There are six different sections that you can use in the
config.ini configuration file, as described
in the following list:
[computer]: Defines cluster hosts. This is not required to configure a viable MySQL Cluster, but be may used as a convenience when setting up a large cluster. See Section 17.3.4.4, “Defining Computers in a MySQL Cluster”, for more information.[ndbd]: Defines a cluster data node (ndbd process). See Section 17.3.4.6, “Defining MySQL Cluster Data Nodes”, for details.[mysqld]: Defines the cluster's MySQL server nodes (also called SQL or API nodes). For a discussion of SQL node configuration, see Section 17.3.4.7, “Defining SQL and Other API Nodes in a MySQL Cluster”.[mgm]or[ndb_mgmd]: Defines a cluster management server (MGM) node. For information concerning the configuration of MGM nodes, see Section 17.3.4.5, “Defining a MySQL Cluster Management Server”.[tcp]: Defines a TCP/IP connection between cluster nodes, with TCP/IP being the default connection protocol. Normally,[tcp]or[tcp default]sections are not required to set up a MySQL Cluster, as the cluster handles this automatically; however, it may be necessary in some situations to override the defaults provided by the cluster. See Section 17.3.4.8, “MySQL Cluster TCP/IP Connections”, for information about available TCP/IP configuration parameters and how to use them. (You may also find Section 17.3.4.9, “MySQL Cluster TCP/IP Connections Using Direct Connections” to be of interest in some cases.)[shm]: Defines shared-memory connections between nodes. In MySQL 5.1, it is enabled by default, but should still be considered experimental. For a discussion of SHM interconnects, see Section 17.3.4.10, “MySQL Cluster Shared-Memory Connections”.[sci]:Defines Scalable Coherent Interface connections between cluster data nodes. Such connections require software which, while freely available, is not part of the MySQL Cluster distribution, as well as specialised hardware. See Section 17.3.4.11, “SCI Transport Connections in MySQL Cluster” for detailed information about SCI interconnects.
You can define default values for each
section. All Cluster parameter names are case-insensitive, which
differs from parameters specified in my.cnf
or my.ini files.
Achieving the best performance from a MySQL Cluster depends on a number of factors including the following:
MySQL Cluster software version
Numbers of data nodes and SQL nodes
Hardware
Operating system
Amount of data to be stored
Size and type of load under which the cluster is to operate
Therefore, obtaining an optimum configuration is likely to be an iterative process, the outcome of which can vary widely with the specifics of each MySQL Cluster deployment. Changes in configuration are also likely to be indicated when changes are made in the platform on which the cluster is run, or in applications that use the MySQL Cluster's data. For these reasons, it is not possible to offer a single configuration that is ideal for all usage scenarios. However, in this section, we provide recommended base configurations for MySQL Cluster NDB 6.2 and 6.3 that can serve as reasonable starting points.
Starting configuration for MySQL Cluster NDB 6.2. The following is a recommended starting point for configuring a cluster running MySQL Cluster NDB 6.2.
# TCP PARAMETERS [tcp default] SendBufferMemory=2M ReceiveBufferMemory=2M # Increasing the sizes of these 2 buffers beyond the default values # helps prevent bottlenecks due to slow disk I/O. # MANAGEMENT NODE PARAMETERS [ndb_mgmd default] DataDir=path/to/management/server/data/directory# It is possible to use a different data directory for each management # server, but for ease of administration it is preferable to be # consistent. [ndb_mgmd] HostName=management-server-1-hostname# Id=management-server-A-id[ndb_mgmd] HostName=management-server-2-hostname# Using 2 management servers helps guarantee that there is always an # arbitrator in the event of network partitioning, and so is # recommended for high availability. Each management server must be # identified by a HostName. You may for the sake of convenience specify # a node ID for any management server, although one will be allocated # for it automatically; if you do so, it must be in the range 1-255 # inclusive and must be unique among all IDs specified for cluster # nodes. # DATA NODE PARAMETERS [ndbd default] NoOfReplicas=2 # This parameter has no default value; it must always must be set # explicitly. Using 2 replicas is recommended to guarantee # availability of data; using only 1 replica does not provide any # redundancy, which means that the failure of a single data node causes # the entire cluster to shut down. We do not recommend using more than # 2 replicas, since 2 is sufficient to provide high availability, and # we do not currently test with greater values for this parameter. LockPagesInMainMemory=1 # On Linux and Solaris systems, setting this parameter locks data node # processes into memory. Doing so prevents them from swapping to disk, # which can severely degrade cluster performance. DataMemory=3072M IndexMemory=384M # The values provided for DataMemory and IndexMemory assume 4 GB RAM # per data node. However, for best results, you should first calculate # the memory that would be used based on the data you actually plan to # store (you may find the ndb_size.pl utility helpful in estimating # this), then allow an extra 20% over the calculated values. Naturally, # you should ensure that each data node host has at least as much # physical memory as the sum of these two values. # ODirect=1 # Enabling this parameter causes NDBCLUSTER to try using O_DIRECT # writes for local checkpoints and redo logs; this can reduce load on # CPUs. We recommend doing so when using MySQL Cluster NDB 6.2.3 or # newer on systems running Linux kernel 2.6 or later. NoOfFragmentLogFiles=300 DataDir=path/to/data/node/data/directoryMaxNoOfConcurrentOperations=100000 TimeBetweenGlobalCheckpoints=1000 TimeBetweenEpochs=200 DiskCheckpointSpeed=10M DiskCheckpointSpeedInRestart=100M RedoBuffer=32M # MaxNoOfLocalScans=64 MaxNoOfTables=1024 MaxNofOfOrderedIndexes=256 [ndbd] HostName=data-node-A-hostname# Id=data-node-A-id[ndbd] HostName=data-node-B-hostname# Id=data-node-B-id# You must have an [ndbd] section for every data node in the cluster; # each of these sections must include a HostName. Each section may # optionally include an Id for convenience, but in most cases, it is # sufficient to allow the cluster to allocate node IDs dynamically. If # you do specify the node ID for a data node, it must be in the range 1 # to 48 inclusive and must be unique among all IDs specified for # cluster nodes. # SQL NODE / API NODE PARAMETERS [mysqld] # HostName=SQL-node-1-hostname# Id=sql-node-A-id[mysqld] [mysqld] # Each API or SQL node that connects to the cluster requires a [mysqld] # or [api] section of its own. Each such section defines a connection # “slot”; you should have at least as many of these sections in the # config.ini file as the total number of API nodes and SQL nodes that # you wish to have connected to the cluster at any given time. There is # no performance or other penalty for having extra slots available in # case you find later that you want or need more API or SQL nodes to # connect to the cluster at the same time. # If no HostName is specified for a given [mysqld] or [api] section, # then any API or SQL node may use that slot to connect to the # cluster. You may wish to use an explicit HostName for one connection slot # to guarantee that an API or SQL node from that host can always # connect to the cluster. If you wish to prevent API or SQL nodes from # connecting from other than a desired host or hosts, then use a # HostName for every [mysqld] or [api] section in the config.ini file. # You can if you wish define a node ID (Id parameter) for any API or # SQL node, but this is not necessary; if you do so, it must be in the # range 1 to 255 inclusive and must be unique among all IDs specified # for cluster nodes.
Starting configuration for MySQL Cluster NDB 6.3.
The following is a recommended starting point for configuring
a cluster running MySQL Cluster NDB 6.3. It is similar to the
recommendation for MySQL Cluster NDB 6.2, with the addition of
parameters for better control of
NDBCLUSTER process threads.
# TCP PARAMETERS [tcp default] SendBufferMemory=2M ReceiveBufferMemory=2M # Increasing the sizes of these 2 buffers beyond the default values # helps prevent bottlenecks due to slow disk I/O. # MANAGEMENT NODE PARAMETERS [ndb_mgmd default] DataDir=path/to/management/server/data/directory# It is possible to use a different data directory for each management # server, but for ease of administration it is preferable to be # consistent. [ndb_mgmd] HostName=management-server-1-hostname# Id=management-server-A-id[ndb_mgmd] HostName=management-server-2-hostname# Using 2 management servers helps guarantee that there is always an # arbitrator in the event of network partitioning, and so is # recommended for high availability. Each management server must be # identified by a HostName. You may for the sake of convenience specify # a node ID for any management server, although one will be allocated # for it automatically; if you do so, it must be in the range 1-255 # inclusive and must be unique among all IDs specified for cluster # nodes. # DATA NODE PARAMETERS [ndbd default] NoOfReplicas=2 # This parameter has no default value; it must always must be set # explicitly. Using 2 replicas is recommended to guarantee # availability of data; using only 1 replica does not provide any # redundancy, which means that the failure of a single data node causes # the entire cluster to shut down. We do not recommend using more than # 2 replicas, since 2 is sufficient to provide high availability, and # we do not currently test with greater values for this parameter. LockPagesInMainMemory=1 # On Linux and Solaris systems, setting this parameter locks data node # processes into memory. Doing so prevents them from swapping to disk, # which can severely degrade cluster performance. DataMemory=3072M IndexMemory=384M # The values provided for DataMemory and IndexMemory assume 4 GB RAM # per data node. However, for best results, you should first calculate # the memory that would be used based on the data you actually plan to # store (you may find the ndb_size.pl utility helpful in estimating # this), then allow an extra 20% over the calculated values. Naturally, # you should ensure that each data node host has at least as much # physical memory as the sum of these two values. # ODirect=1 # Enabling this parameter causes NDBCLUSTER to try using O_DIRECT # writes for local checkpoints and redo logs; this can reduce load on # CPUs. We recommend doing so when using MySQL Cluster NDB 6.2.3 or # newer on systems running Linux kernel 2.6 or later. NoOfFragmentLogFiles=300 DataDir=path/to/data/node/data/directoryMaxNoOfConcurrentOperations=100000 SchedulerSpinTimer=400 SchedulerExecutionTimer=100 RealTimeScheduler=1 # Setting these parameters allows you to take advantage of real-time scheduling # of NDBCLUSTER threads (introduced in MySQL Cluster NDB 6.3.4) to get higher # throughput. TimeBetweenGlobalCheckpoints=1000 TimeBetweenEpochs=200 DiskCheckpointSpeed=10M DiskCheckpointSpeedInRestart=100M RedoBuffer=32M # CompressedLCP=1 # CompressedBackup=1 # Enabling CompressedLCP and CompressedBackup causes, respectively, local checkpoint files and backup files to be compressed, which can result in a space savings of up to 50% over noncompressed LCPs and backups. # MaxNoOfLocalScans=64 MaxNoOfTables=1024 MaxNofOfOrderedIndexes=256 [ndbd] HostName=data-node-A-hostname# Id=data-node-A-idLockExecuteThreadToCPU=1 LockMaintThreadsToCPU=0 # On systems with multiple CPUs, these parameters can be used to lock NDBCLUSTER # threads to specific CPUs [ndbd] HostName=data-node-B-hostname# Id=data-node-B-idLockExecuteThreadToCPU=1 LockMaintThreadsToCPU=0 # You must have an [ndbd] section for every data node in the cluster; # each of these sections must include a HostName. Each section may # optionally include an Id for convenience, but in most cases, it is # sufficient to allow the cluster to allocate node IDs dynamically. If # you do specify the node ID for a data node, it must be in the range 1 # to 48 inclusive and must be unique among all IDs specified for # cluster nodes. # SQL NODE / API NODE PARAMETERS [mysqld] # HostName=SQL-node-1-hostname# Id=sql-node-A-id[mysqld] [mysqld] # Each API or SQL node that connects to the cluster requires a [mysqld] # or [api] section of its own. Each such section defines a connection # “slot”; you should have at least as many of these sections in the # config.ini file as the total number of API nodes and SQL nodes that # you wish to have connected to the cluster at any given time. There is # no performance or other penalty for having extra slots available in # case you find later that you want or need more API or SQL nodes to # connect to the cluster at the same time. # If no HostName is specified for a given [mysqld] or [api] section, # then any API or SQL node may use that slot to connect to the # cluster. You may wish to use an explicit HostName for one connection slot # to guarantee that an API or SQL node from that host can always # connect to the cluster. If you wish to prevent API or SQL nodes from # connecting from other than a desired host or hosts, then use a # HostName for every [mysqld] or [api] section in the config.ini file. # You can if you wish define a node ID (Id parameter) for any API or # SQL node, but this is not necessary; if you do so, it must be in the # range 1 to 255 inclusive and must be unique among all IDs specified # for cluster nodes.
Recommended my.cnf options for SQL nodes.
MySQL Servers acting as MySQL Cluster SQL nodes must always be
started with the --ndbcluster
and --ndb-connectstring options, either on
the command line or in my.cnf. In
addition, set the following options for all
mysqld processes in the cluster, unless
your setup requires otherwise:
--ndb-use-exact-count=0--ndb-index-stat-enable=0--ndb-force-send=1--engine-condition-pushdown=1
With the exception of the MySQL Cluster management server (ndb_mgmd), each node that is part of a MySQL Cluster requires a connectstring that points to the management server's location. This connectstring is used in establishing a connection to the management server as well as in performing other tasks depending on the node's role in the cluster. The syntax for a connectstring is as follows:
[nodeid=node_id, ]host-definition[,host-definition[, ...]]host-definition:host_name[:port_number]
node_id is an integer larger than 1 which
identifies a node in config.ini.
host_name is a string representing a
valid Internet host name or IP address.
port_number is an integer referring
to a TCP/IP port number.
example 1 (long): "nodeid=2,myhost1:1100,myhost2:1100,192.168.0.3:1200" example 2 (short): "myhost1"
localhost:1186 is used as the default
connectstring value if none is provided. If
port_num is omitted from the
connectstring, the default port is 1186. This port should always
be available on the network because it has been assigned by IANA
for this purpose (see
http://www.iana.org/assignments/port-numbers for
details).
By listing multiple host definitions, it is possible to designate several redundant management servers. A MySQL Cluster data or API node attempts to contact successive management servers on each host in the order specified, until a successful connection has been established.
Beginning with MySQL Cluster NDB 6.3.19, it is also possible in a connectstring to specify one or more bind addresses to be used by nodes having multiple network interfaces for connecting to management servers. A bind address consists of a hostname or network address and an optional port number. This enhanced syntax for connectstrings is shown here:
[nodeid=node_id, ] [bind-address=host-definition, ]host-definition[; bind-address=host-definition]host-definition[; bind-address=host-definition] [, ...]]host-definition:host_name[:port_number]
If a single bind address is used in the connectstring
prior to specifying any management hosts,
then this address is used as the default for connecting to any
of them (unless overridden for a given management server; see
later in this section for an example). For example, the
following connectstring causes the node to use
192.168.178.242 regardless of the management
server to which it connects:
bind-address=192.168.178.242, poseidon:1186, perch:1186
If a bind address is specified following a management host definition, then it is used only for connecting to that management node. Consider the following connectstring:
poseidon:1186;bind-address=localhost, perch:1186;bind-address=192.168.178.242
In this case, the node uses localhost to
connect to the management server running on the host named
poseidon and
192.168.178.242 to connect to the management
server running on the host named perch.
You can specify a default bind address and then override this
default for one or more specific management hosts. In the
following example, localhost is used for
connecting to the management server running on host
poseidon; since
192.168.178.242 is specified first (before
any management server definitions), it is the default bind
address and so is used for connecting to the management servers
on hosts perch and orca:
bind-address=192.168.178.242,poseidon:1186;bind-address=localhost,perch:1186,orca:2200
There are a number of different ways to specify the connectstring:
Each executable has its own command-line option which enables specifying the management server at startup. (See the documentation for the respective executable.)
It is also possible to set the connectstring for all nodes in the cluster at once by placing it in a
[mysql_cluster]section in the management server'smy.cnffile.For backward compatibility, two other options are available, using the same syntax:
Set the
NDB_CONNECTSTRINGenvironment variable to contain the connectstring.Write the connectstring for each executable into a text file named
Ndb.cfgand place this file in the executable's startup directory.
However, these are now deprecated and should not be used for new installations.
The recommended method for specifying the connectstring is to
set it on the command line or in the my.cnf
file for each executable.
The maximum length of a connectstring is 1024 characters.
The [computer] section has no real
significance other than serving as a way to avoid the need of
defining host names for each node in the system. All parameters
mentioned here are required.
The [ndb_mgmd] section is used to configure
the behavior of the management server. [mgm]
can be used as an alias; the two section names are equivalent.
All parameters in the following list are optional and assume
their default values if omitted.
Note
If neither the ExecuteOnComputer nor the
HostName parameter is present, the default
value localhost will be assumed for both.
Each node in the cluster has a unique identity. For a management node, this is represented by an integer value in the range 1 to 63 inclusive (previous to MySQL Cluster NDB 6.1.1), or in the range 1 to 255 inclusive (MySQL Cluster NDB 6.1.1 and later). This ID is used by all internal cluster messages for addressing the node, and so must be unique for each MySQL Cluster node, regardless of the type of node.
Note
Data node IDs must be less than 49, regardless of the MySQL Cluster version used. If you plan to deploy a large number of data nodes, it is a good idea to limit the node IDs for management nodes (and API nodes) to values greater than 48.
This refers to the
Idset for one of the computers defined in a[computer]section of theconfig.inifile.This is the port number on which the management server listens for configuration requests and management commands.
Specifying this parameter defines the hostname of the computer on which the management node is to reside. To specify a hostname other than
localhost, either this parameter orExecuteOnComputeris required.This parameter specifies where to send cluster logging information. There are three options in this regard —
CONSOLE,SYSLOG, andFILE— withFILEbeing the default:CONSOLEoutputs the log tostdout:CONSOLE
SYSLOGsends the log to asyslogfacility, possible values being one ofauth,authpriv,cron,daemon,ftp,kern,lpr,mail,news,syslog,user,uucp,local0,local1,local2,local3,local4,local5,local6, orlocal7.Note
Not every facility is necessarily supported by every operating system.
SYSLOG:facility=syslog
FILEpipes the cluster log output to a regular file on the same machine. The following values can be specified:filename: The name of the log file.maxsize: The maximum size (in bytes) to which the file can grow before logging rolls over to a new file. When this occurs, the old log file is renamed by appending.Nto the file name, whereNis the next number not yet used with this name.maxfiles: The maximum number of log files.
FILE:filename=cluster.log,maxsize=1000000,maxfiles=6
The default value for the
FILEparameter isFILE:filename=ndb_, wherenode_id_cluster.log,maxsize=1000000,maxfiles=6node_idis the ID of the node.
It is possible to specify multiple log destinations separated by semicolons as shown here:
CONSOLE;SYSLOG:facility=local0;FILE:filename=/var/log/mgmd
This parameter is used to define which nodes can act as arbitrators. Only management nodes and SQL nodes can be arbitrators.
ArbitrationRankcan take one of the following values:0: The node will never be used as an arbitrator.1: The node has high priority; that is, it will be preferred as an arbitrator over low-priority nodes.2: Indicates a low-priority node which be used as an arbitrator only if a node with a higher priority is not available for that purpose.
Normally, the management server should be configured as an arbitrator by setting its
ArbitrationRankto 1 (the default value) and that of all SQL nodes to 0.Beginning with MySQL 5.1.16 and MySQL Cluster NDB 6.1.3, it is possible to disable arbitration completely by setting
ArbitrationRankto 0 on all management and SQL nodes.An integer value which causes the management server's responses to arbitration requests to be delayed by that number of milliseconds. By default, this value is 0; it is normally not necessary to change it.
This specifies the directory where output files from the management server will be placed. These files include cluster log files, process output files, and the daemon's process ID (PID) file. (For log files, this location can be overridden by setting the
FILEparameter forLogDestinationas discussed previously in this section.)The default value for this parameter is the directory in which ndb_mgmd is located.
This parameter is available beginning with MySQL Cluster NDB 6.4.0. It is used to determine the total amount of memory to allocate on this node for shared send buffer memory among all configured transporters.
If this parameter is set, its minimum allowed value is 256K; the maxmimum is 4294967039. For more detailed information about the behavior and use of
TotalSendBufferMemoryand configuring send buffer memory parameters in MySQL Cluster NDB 6.4.0 and later, see Section 17.3.7, “Configuring MySQL Cluster Send Buffer Parameters”.
Note
After making changes in a management node's configuration, it is necessary to perform a rolling restart of the cluster in order for the new configuration to take effect.
To add new management servers to a running MySQL Cluster, it
is also necessary to perform a rolling restart of all cluster
nodes after modifying any existing
config.ini files. For more information
about issues arising when using multiple management nodes, see
Section 17.12.10, “Limitations Relating to Multiple MySQL Cluster Nodes”.
The [ndbd] and [ndbd
default] sections are used to configure the behavior
of the cluster's data nodes.
[ndbd] and [ndbd default]
are always used as the section names whether you are using
ndbd or (in MySQL Cluster NDB 6.4.0 and
later) ndbmtd binaries for the data node
processes.
There are many parameters which control buffer sizes, pool sizes, timeouts, and so forth. The only mandatory parameters are:
Either
ExecuteOnComputerorHostName, which must be defined in the local[ndbd]section.The parameter
NoOfReplicas, which must be defined in the[ndbd default]section, as it is common to all Cluster data nodes.
Most data node parameters are set in the [ndbd
default] section. Only those parameters explicitly
stated as being able to set local values are allowed to be
changed in the [ndbd] section. Where present,
HostName, Id and
ExecuteOnComputer must
be defined in the local [ndbd] section, and
not in any other section of config.ini. In
other words, settings for these parameters are specific to one
data node.
For those parameters affecting memory usage or buffer sizes, it
is possible to use K, M,
or G as a suffix to indicate units of 1024,
1024×1024, or 1024×1024×1024. (For example,
100K means 100 × 1024 = 102400.)
Parameter names and values are currently case-sensitive.
Information about configuration parameters specific to MySQL Cluster Disk Data tables can be found later in this section.
Beginning with MySQL Cluster NDB 6.4.0, all of these parameters
also apply to ndbmtd (the multi-threaded
version of ndbd). An additional data node
configuration parameter
MaxNoOfExecutionThreads applies to
ndbmtd only, and has no effect when used with
ndbd. For a description of this parameter and
its use, see Section 17.6.3, “ndbmtd — The MySQL Cluster Data Node Daemon (Multi-Threaded)”.
Identifying data nodes.
The Id value (that is, the data node
identifier) can be allocated on the command line when the node
is started or in the configuration file.
This is the node ID used as the address of the node for all cluster internal messages. For data nodes, this is an integer in the range 1 to 48 inclusive. Each node in the cluster must have a unique identifier.
This refers to the
Idset for one of the computers defined in a[computer]section.Specifying this parameter defines the hostname of the computer on which the data node is to reside. To specify a hostname other than
localhost, either this parameter orExecuteOnComputeris required.Each node in the cluster uses a port to connect to other nodes. This port is used also for non-TCP transporters in the connection setup phase. The default port is allocated dynamically in such a way as to ensure that no two nodes on the same computer receive the same port number, so it should not normally be necessary to specify a value for this parameter.
Setting this parameter to
TRUEor1bindsIP_ADDR_ANYso that connections can be made from anywhere (for autogenerated connections). The default isFALSE(0).This parameter was added in MySQL Cluster NDB 6.2.0.
This parameter can be used to assign a data node to a specific node group. It is read only when the cluster is started for the first time, and cannot be used to reassign a data node to a different node group online. It is generally not desirable to use this parameter in the
[ndbd default]section of theconfig.inifile, and care must be taken not to assign nodes to node groups in such a way that an invalid numbers of nodes are assigned to any node groups.The
NodeGroupparameter is chiefly intended for use in adding a new node group to a running MySQL Cluster without having to perform a rolling restart. For this purpose, you should set it to 65535 (the maximum value). You are not required to set aNodeGroupvalue for all cluster data nodes, only for those nodes which are to be started and added to the cluster as a new node group at a later time. For more information, see Section 17.7.8.3, “Adding MySQL Cluster Data Nodes Online: Detailed Example”.This parameter was added in MySQL Cluster NDB 6.4.0.
This global parameter can be set only in the
[ndbd default]section, and defines the number of replicas for each table stored in the cluster. This parameter also specifies the size of node groups. A node group is a set of nodes all storing the same information.Node groups are formed implicitly. The first node group is formed by the set of data nodes with the lowest node IDs, the next node group by the set of the next lowest node identities, and so on. By way of example, assume that we have 4 data nodes and that
NoOfReplicasis set to 2. The four data nodes have node IDs 2, 3, 4 and 5. Then the first node group is formed from nodes 2 and 3, and the second node group by nodes 4 and 5. It is important to configure the cluster in such a manner that nodes in the same node groups are not placed on the same computer because a single hardware failure would cause the entire cluster to fail.If no node IDs are provided, the order of the data nodes will be the determining factor for the node group. Whether or not explicit assignments are made, they can be viewed in the output of the management client's
SHOWcommand.There is no default value for
NoOfReplicas; the maximum possible value is 4. Currently, only the values 1 and 2 are actually supported (see Bug#18621).Important
Setting
NoOfReplicasto 1 means that there is only a single copy of all Cluster data; in this case, the loss of a single data node causes the cluster to fail because there are no additional copies of the data stored by that node.The value for this parameter must divide evenly into the number of data nodes in the cluster. For example, if there are two data nodes, then
NoOfReplicasmust be equal to either 1 or 2, since 2/3 and 2/4 both yield fractional values; if there are four data nodes, thenNoOfReplicasmust be equal to 1, 2, or 4.This parameter specifies the directory where trace files, log files, pid files and error logs are placed.
The default is the data node process working directory.
This parameter specifies the directory where all files created for metadata, REDO logs, UNDO logs (for Disk Data tables) and data files are placed. The default is the directory specified by
DataDir.Note
This directory must exist before the ndbd process is initiated.
The recommended directory hierarchy for MySQL Cluster includes
/var/lib/mysql-cluster, under which a directory for the node's file system is created. The name of this subdirectory contains the node ID. For example, if the node ID is 2, this subdirectory is namedndb_2_fs.This parameter specifies the directory in which backups are placed. If omitted, the default backup location is the directory named
BACKUPunder the location specified by theFileSystemPathparameter. (See above.)
Data Memory, Index Memory, and String Memory
DataMemory and IndexMemory
are [ndbd] parameters specifying the size of
memory segments used to store the actual records and their
indexes. In setting values for these, it is important to
understand how DataMemory and
IndexMemory are used, as they usually need to
be updated to reflect actual usage by the cluster:
This parameter defines the amount of space (in bytes) available for storing database records. The entire amount specified by this value is allocated in memory, so it is extremely important that the machine has sufficient physical memory to accommodate it.
The memory allocated by
DataMemoryis used to store both the actual records and indexes. There is a 16-byte overhead on each record; an additional amount for each record is incurred because it is stored in a 32KB page with 128 byte page overhead (see below). There is also a small amount wasted per page due to the fact that each record is stored in only one page.For variable-size table attributes in MySQL 5.1, the data is stored on separate datapages, allocated from
DataMemory. Variable-length records use a fixed-size part with an extra overhead of 4 bytes to reference the variable-size part. The variable-size part has 2 bytes overhead plus 2 bytes per attribute.The maximum record size is currently 8052 bytes.
The memory space defined by
DataMemoryis also used to store ordered indexes, which use about 10 bytes per record. Each table row is represented in the ordered index. A common error among users is to assume that all indexes are stored in the memory allocated byIndexMemory, but this is not the case: Only primary key and unique hash indexes use this memory; ordered indexes use the memory allocated byDataMemory. However, creating a primary key or unique hash index also creates an ordered index on the same keys, unless you specifyUSING HASHin the index creation statement. This can be verified by running ndb_desc -ddb_nametable_namein the management client.The memory space allocated by
DataMemoryconsists of 32KB pages, which are allocated to table fragments. Each table is normally partitioned into the same number of fragments as there are data nodes in the cluster. Thus, for each node, there are the same number of fragments as are set inNoOfReplicas.In addition, due to the way in which new pages are allocated when the capacity of the current page is exhausted, there is an additional overhead of approximately 18.75%. When more
DataMemoryis required, more than one new page is allocated, according to the following formula:number of new pages = FLOOR(number of current pages × 0.1875) + 1
For example, if 15 pages are currently allocated to a given table and an insert to this table requires additional storage space, the number of new pages allocated to the table is
FLOOR(15 × 0.1875) + 1 = FLOOR(2.8125) + 1 = 2 + 1 = 3. Now 15 + 3 = 18 memory pages are allocated to the table. When the last of these 18 pages becomes full,FLOOR(18 × 0.1875) + 1 = FLOOR(3.3750) + 1 = 3 + 1 = 4new pages are allocated, so the total number of pages allocated to the table is now 22.Note
The “18.75% + 1” overhead is no longer required beginning with MySQL Cluster NDB 6.2.3 and MySQL Cluster NDB 6.3.0.
Once a page has been allocated, it is currently not possible to return it to the pool of free pages, except by deleting the table. (This also means that
DataMemorypages, once allocated to a given table, cannot be used by other tables.) Performing a node recovery also compresses the partition because all records are inserted into empty partitions from other live nodes.The
DataMemorymemory space also contains UNDO information: For each update, a copy of the unaltered record is allocated in theDataMemory. There is also a reference to each copy in the ordered table indexes. Unique hash indexes are updated only when the unique index columns are updated, in which case a new entry in the index table is inserted and the old entry is deleted upon commit. For this reason, it is also necessary to allocate enough memory to handle the largest transactions performed by applications using the cluster. In any case, performing a few large transactions holds no advantage over using many smaller ones, for the following reasons:Large transactions are not any faster than smaller ones
Large transactions increase the number of operations that are lost and must be repeated in event of transaction failure
Large transactions use more memory
The default value for
DataMemoryis 80MB; the minimum is 1MB. There is no maximum size, but in reality the maximum size has to be adapted so that the process does not start swapping when the limit is reached. This limit is determined by the amount of physical RAM available on the machine and by the amount of memory that the operating system may commit to any one process. 32-bit operating systems are generally limited to 2–4GB per process; 64-bit operating systems can use more. For large databases, it may be preferable to use a 64-bit operating system for this reason.This parameter controls the amount of storage used for hash indexes in MySQL Cluster. Hash indexes are always used for primary key indexes, unique indexes, and unique constraints. Note that when defining a primary key and a unique index, two indexes will be created, one of which is a hash index used for all tuple accesses as well as lock handling. It is also used to enforce unique constraints.
The size of the hash index is 25 bytes per record, plus the size of the primary key. For primary keys larger than 32 bytes another 8 bytes is added.
The default value for
IndexMemoryis 18MB. The minimum is 1MB.This parameter determines how much memory is allocated for strings such as table names, and is specified in an
[ndbd]or[ndbd default]section of theconfig.inifile. A value between0and100inclusive is interpreted as a percent of the maximum default value, which is calculated based on a number of factors including the number of tables, maximum table name size, maximum size of.FRMfiles,MaxNoOfTriggers, maximum column name size, and maximum default column value. In general it is safe to assume that the maximum default value is approximately 5 MB for a MySQL Cluster having 1000 tables.A value greater than
100is interpreted as a number of bytes.The default value is
5— that is, 5 percent of the default maximum, or roughly 5 KB. (Note that this is a change from previous versions of MySQL Cluster.)Under most circumstances, the default value should be sufficient, but when you have a great many Cluster tables (1000 or more), it is possible to get Error 773 Out of string memory, please modify StringMemory config parameter: Permanent error: Schema error, in which case you should increase this value.
25(25 percent) is not excessive, and should prevent this error from recurring in all but the most extreme conditions.
The following example illustrates how memory is used for a table. Consider this table definition:
CREATE TABLE example ( a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, PRIMARY KEY(a), UNIQUE(b) ) ENGINE=NDBCLUSTER;
For each record, there are 12 bytes of data plus 12 bytes
overhead. Having no nullable columns saves 4 bytes of overhead.
In addition, we have two ordered indexes on columns
a and b consuming roughly
10 bytes each per record. There is a primary key hash index on
the base table using roughly 29 bytes per record. The unique
constraint is implemented by a separate table with
b as primary key and a as
a column. This other table consumes an additional 29 bytes of
index memory per record in the example table
as well 8 bytes of record data plus 12 bytes of overhead.
Thus, for one million records, we need 58MB for index memory to handle the hash indexes for the primary key and the unique constraint. We also need 64MB for the records of the base table and the unique index table, plus the two ordered index tables.
You can see that hash indexes takes up a fair amount of memory space; however, they provide very fast access to the data in return. They are also used in MySQL Cluster to handle uniqueness constraints.
Currently, the only partitioning algorithm is hashing and ordered indexes are local to each node. Thus, ordered indexes cannot be used to handle uniqueness constraints in the general case.
An important point for both IndexMemory and
DataMemory is that the total database size is
the sum of all data memory and all index memory for each node
group. Each node group is used to store replicated information,
so if there are four nodes with two replicas, there will be two
node groups. Thus, the total data memory available is 2 ×
DataMemory for each data node.
It is highly recommended that DataMemory and
IndexMemory be set to the same values for all
nodes. Data distribution is even over all nodes in the cluster,
so the maximum amount of space available for any node can be no
greater than that of the smallest node in the cluster.
DataMemory and IndexMemory
can be changed, but decreasing either of these can be risky;
doing so can easily lead to a node or even an entire MySQL
Cluster that is unable to restart due to there being
insufficient memory space. Increasing these values should be
acceptable, but it is recommended that such upgrades are
performed in the same manner as a software upgrade, beginning
with an update of the configuration file, and then restarting
the management server followed by restarting each data node in
turn.
Updates do not increase the amount of index memory used. Inserts take effect immediately; however, rows are not actually deleted until the transaction is committed.
Transaction parameters.
The next three [ndbd] parameters that we
discuss are important because they affect the number of
parallel transactions and the sizes of transactions that can
be handled by the system.
MaxNoOfConcurrentTransactions sets the
number of parallel transactions possible in a node.
MaxNoOfConcurrentOperations sets the number
of records that can be in update phase or locked
simultaneously.
Both of these parameters (especially
MaxNoOfConcurrentOperations) are likely
targets for users setting specific values and not using the
default value. The default value is set for systems using small
transactions, to ensure that these do not use excessive memory.
Each cluster data node requires a transaction record for each active transaction in the cluster. The task of coordinating transactions is distributed among all of the data nodes. The total number of transaction records in the cluster is the number of transactions in any given node times the number of nodes in the cluster.
Transaction records are allocated to individual MySQL servers. Each connection to a MySQL server requires at least one transaction record, plus an additional transaction object per table accessed by that connection. This means that a reasonable minimum for this parameter is
MaxNoOfConcurrentTransactions = (maximum number of tables accessed in any single transaction + 1) * number of cluster SQL nodesFor example, suppose that there are 4 SQL nodes using the cluster. A single join involving 5 tables requires 6 transaction records; if there are 5 such joins in a transaction, then 5 * 6 = 30 transaction records are required for this transaction, per MySQL server, or 30 * 4 = 120 transaction records total.
This parameter must be set to the same value for all cluster data nodes. This is due to the fact that, when a data node fails, the oldest surviving node re-creates the transaction state of all transactions that were ongoing in the failed node.
Changing the value of
MaxNoOfConcurrentTransactionsrequires a complete shutdown and restart of the cluster.The default value is 4096.
It is a good idea to adjust the value of this parameter according to the size and number of transactions. When performing transactions of only a few operations each and not involving a great many records, there is no need to set this parameter very high. When performing large transactions involving many records need to set this parameter higher.
Records are kept for each transaction updating cluster data, both in the transaction coordinator and in the nodes where the actual updates are performed. These records contain state information needed to find UNDO records for rollback, lock queues, and other purposes.
This parameter should be set to the number of records to be updated simultaneously in transactions, divided by the number of cluster data nodes. For example, in a cluster which has four data nodes and which is expected to handle 1,000,000 concurrent updates using transactions, you should set this value to 1000000 / 4 = 250000.
Read queries which set locks also cause operation records to be created. Some extra space is allocated within individual nodes to accommodate cases where the distribution is not perfect over the nodes.
When queries make use of the unique hash index, there are actually two operation records used per record in the transaction. The first record represents the read in the index table and the second handles the operation on the base table.
The default value is 32768.
This parameter actually handles two values that can be configured separately. The first of these specifies how many operation records are to be placed with the transaction coordinator. The second part specifies how many operation records are to be local to the database.
A very large transaction performed on an eight-node cluster requires as many operation records in the transaction coordinator as there are reads, updates, and deletes involved in the transaction. However, the operation records of the are spread over all eight nodes. Thus, if it is necessary to configure the system for one very large transaction, it is a good idea to configure the two parts separately.
MaxNoOfConcurrentOperationswill always be used to calculate the number of operation records in the transaction coordinator portion of the node.It is also important to have an idea of the memory requirements for operation records. These consume about 1KB per record.
By default, this parameter is calculated as 1.1 ×
MaxNoOfConcurrentOperations. This fits systems with many simultaneous transactions, none of them being very large. If there is a need to handle one very large transaction at a time and there are many nodes, it is a good idea to override the default value by explicitly specifying this parameter.
Transaction temporary storage.
The next set of [ndbd] parameters is used
to determine temporary storage when executing a statement that
is part of a Cluster transaction. All records are released
when the statement is completed and the cluster is waiting for
the commit or rollback.
The default values for these parameters are adequate for most situations. However, users with a need to support transactions involving large numbers of rows or operations may need to increase these values to enable better parallelism in the system, whereas users whose applications require relatively small transactions can decrease the values to save memory.
MaxNoOfConcurrentIndexOperationsFor queries using a unique hash index, another temporary set of operation records is used during a query's execution phase. This parameter sets the size of that pool of records. Thus, this record is allocated only while executing a part of a query. As soon as this part has been executed, the record is released. The state needed to handle aborts and commits is handled by the normal operation records, where the pool size is set by the parameter
MaxNoOfConcurrentOperations.The default value of this parameter is 8192. Only in rare cases of extremely high parallelism using unique hash indexes should it be necessary to increase this value. Using a smaller value is possible and can save memory if the DBA is certain that a high degree of parallelism is not required for the cluster.
The default value of
MaxNoOfFiredTriggersis 4000, which is sufficient for most situations. In some cases it can even be decreased if the DBA feels certain the need for parallelism in the cluster is not high.A record is created when an operation is performed that affects a unique hash index. Inserting or deleting a record in a table with unique hash indexes or updating a column that is part of a unique hash index fires an insert or a delete in the index table. The resulting record is used to represent this index table operation while waiting for the original operation that fired it to complete. This operation is short-lived but can still require a large number of records in its pool for situations with many parallel write operations on a base table containing a set of unique hash indexes.
The memory affected by this parameter is used for tracking operations fired when updating index tables and reading unique indexes. This memory is used to store the key and column information for these operations. It is only very rarely that the value for this parameter needs to be altered from the default.
The default value for
TransactionBufferMemoryis 1MB.Normal read and write operations use a similar buffer, whose usage is even more short-lived. The compile-time parameter
ZATTRBUF_FILESIZE(found inndb/src/kernel/blocks/Dbtc/Dbtc.hpp) set to 4000 × 128 bytes (500KB). A similar buffer for key information,ZDATABUF_FILESIZE(also inDbtc.hpp) contains 4000 × 16 = 62.5KB of buffer space.Dbtcis the module that handles transaction coordination.
Scans and buffering.
There are additional [ndbd] parameters in
the Dblqh module (in
ndb/src/kernel/blocks/Dblqh/Dblqh.hpp)
that affect reads and updates. These include
ZATTRINBUF_FILESIZE, set by default to
10000 × 128 bytes (1250KB) and
ZDATABUF_FILE_SIZE, set by default to
10000*16 bytes (roughly 156KB) of buffer space. To date, there
have been neither any reports from users nor any results from
our own extensive tests suggesting that either of these
compile-time limits should be increased.
This parameter is used to control the number of parallel scans that can be performed in the cluster. Each transaction coordinator can handle the number of parallel scans defined for this parameter. Each scan query is performed by scanning all partitions in parallel. Each partition scan uses a scan record in the node where the partition is located, the number of records being the value of this parameter times the number of nodes. The cluster should be able to sustain
MaxNoOfConcurrentScansscans concurrently from all nodes in the cluster.Scans are actually performed in two cases. The first of these cases occurs when no hash or ordered indexes exists to handle the query, in which case the query is executed by performing a full table scan. The second case is encountered when there is no hash index to support the query but there is an ordered index. Using the ordered index means executing a parallel range scan. The order is kept on the local partitions only, so it is necessary to perform the index scan on all partitions.
The default value of
MaxNoOfConcurrentScansis 256. The maximum value is 500.Specifies the number of local scan records if many scans are not fully parallelized. If the number of local scan records is not provided, it is calculated as the product of
MaxNoOfConcurrentScansand the number of data nodes in the system. The minimum value is 32.This parameter is used to calculate the number of lock records used to handle concurrent scan operations.
The default value is 64; this value has a strong connection to the
ScanBatchSizedefined in the SQL nodes.This is an internal buffer used for passing messages within individual nodes and between nodes. Although it is highly unlikely that this would need to be changed, it is configurable. In MySQL Cluster NDB 6.4.3 and earlier, the default is 1MB; beginning with MySQL Cluster NDB 7.0.4, it is 4MB.
This is the maximum size of the memory unit to use when
allocating memory for tables. In cases where
NDB gives Out of
memory errors, but it is evident by examining the
cluster logs or the output of DUMP 1000 (see
DUMP 1000) that all
available memory has not yet been used, you can increase the
value of this parameter (or MaxNoOfTables, or
both) in order to cause NDB to make
sufficient memory available.
This parameter was introduced in MySQL 5.1.20, MySQL Cluster NDB 6.1.12 and MySQL Cluster NDB 6.2.3.
The following [ndbd] parameters control log
and checkpoint behavior.
This parameter sets the number of REDO log files for the node, and thus the amount of space allocated to REDO logging. Because the REDO log files are organized in a ring, it is extremely important that the first and last log files in the set (sometimes referred to as the “head” and “tail” log files, respectively) do not meet. When these approach one another too closely, the node begins aborting all transactions encompassing updates due to a lack of room for new log records.
A
REDOlog record is not removed until the required number of local checkpoints has been completed since that log record was inserted (prior to MySQL Cluster NDB 6.3.8, this was 3 local checkpoints; in later versions of MySQL Cluster, only 2 local checkpoints are necessary). Checkpointing frequency is determined by its own set of configuration parameters discussed elsewhere in this chapter.How these parameters interact and proposals for how to configure them are discussed in Section 17.3.6, “Configuring MySQL Cluster Parameters for Local Checkpoints”.
The default parameter value is 16, which by default means 16 sets of 4 16MB files for a total of 1024MB. Beginning with MySQL Cluster NDB 6.1.1, the size of the individual log files is configurable using the
FragmentLogFileSizeparameter; more information about this parameter can be found here. In scenarios requiring a great many updates, the value forNoOfFragmentLogFilesmay need to be set as high as 300 or even higher to provide sufficient space for REDO logs.If the checkpointing is slow and there are so many writes to the database that the log files are full and the log tail cannot be cut without jeopardizing recovery, all updating transactions are aborted with internal error code 410 (
Out of log file space temporarily). This condition prevails until a checkpoint has completed and the log tail can be moved forward.Important
This parameter cannot be changed “on the fly”; you must restart the node using
--initial. If you wish to change this value for all data nodes in a running cluster, you can do so via a rolling node restart (using--initialwhen starting each data node).Setting this parameter allows you to control directly the size of redo log files. This can be useful in situations when MySQL Cluster is operating under a high load and it is unable to close fragment log files quickly enough before attempting to open new ones (only 2 fragment log files can be open at one time); increasing the size of the fragment log files gives the cluster more time before having to open each new fragment log file. The default value for this parameter is 16M.
FragmentLogFileSizewas added in MySQL Cluster NDB 6.1.11.For more information about fragment log files, see the description of the NoOfFragmentLogFiles parameter.
By default, fragment log files are created sparsely when performing an initial start of a data node — that is, depending on the operating system and file system in use, not all bytes are necessarily written to disk. Beginning with MySQL Cluster NDB 6.3.19, it is possible to override this behavior and force all bytes to be written regardless of the platform and file system type being used by mean of this parameter.
InitFragmentLogFilestakes one of two values:SPARSE. Fragment log files are created sparsely. This is the default value.FULL. Force all bytes of the fragment log file to be written to disk.
Depending on your operating system and file system, setting
InitFragmentLogFiles=FULLmay help eliminate I/O errors on writes to the REDO log.This parameter sets a ceiling on how many internal threads to allocate for open files. Any situation requiring a change in this parameter should be reported as a bug.
The default value is 0. (Prior to MySQL 5.1.16, the default was 40.) However, the minimum value to which this parameter can be set is 20.
This parameter sets the initial number of internal threads to allocate for open files.
The default value is 27.
This parameter sets the maximum number of trace files that are kept before overwriting old ones. Trace files are generated when, for whatever reason, the node crashes.
The default is 25 trace files.
In parallel data node recovery (supported in MySQL Cluster NDB 6.3.8 and later), only table data is actually copied and synchronized in parallel; synchronization of metadata such as dictionary and checkpoint information is done in a serial fashion. In addition, recovery of dictionary and checkpoint information cannot be executed in parallel with performing of local checkpoints. This means that, when starting or restarting many data nodes concurrently, data nodes may be forced to wait while a local checkpoint is performed, which can result in longer node recovery times.
Beginning with MySQL Cluster NDB 6.3.23 and MySQL Cluster NDB 6.4.3, it is possible to force a delay in the local checkpoint to allow more (and possibly all) data nodes to complete metadata synchronization; once each data node's metadata synchronization is complete, all of the data nodes can recover table data in parallel, even while the local checkpoint is being executed.
To force such a delay, you can set
MaxLCPStartDelay, which determines the number of seconds the cluster can wait to begin a local checkpoint while data nodes continue to synchronize metadata. This parameter should be set in the[ndbd default]section of theconfig.inifile, so that it is the same for all data nodes. The maximum value is 600; the default is 0.
Metadata objects.
The next set of [ndbd] parameters defines
pool sizes for metadata objects, used to define the maximum
number of attributes, tables, indexes, and trigger objects
used by indexes, events, and replication between clusters.
Note that these act merely as “suggestions” to
the cluster, and any that are not specified revert to the
default values shown.
Defines the number of attributes that can be defined in the cluster.
The default value is 1000, with the minimum possible value being 32. The maximum is 4294967039. Each attribute consumes around 200 bytes of storage per node due to the fact that all metadata is fully replicated on the servers.
When setting
MaxNoOfAttributes, it is important to prepare in advance for anyALTER TABLEstatements that you might want to perform in the future. This is due to the fact, during the execution ofALTER TABLEon a Cluster table, 3 times the number of attributes as in the original table are used, and a good practice is to allow double this amount. For example, if the MySQL Cluster table having the greatest number of attributes (greatest_number_of_attributes) has 100 attributes, a good starting point for the value ofMaxNoOfAttributeswould be6 *.greatest_number_of_attributes= 600You should also estimate the average number of attributes per table and multiply this by
MaxNoOfTables. If this value is larger than the value obtained in the previous paragraph, you should use the larger value instead.Assuming that you can create all desired tables without any problems, you should also verify that this number is sufficient by trying an actual
ALTER TABLEafter configuring the parameter. If this is not successful, increaseMaxNoOfAttributesby another multiple ofMaxNoOfTablesand test it again.A table object is allocated for each table, unique hash index, and ordered index. This parameter sets the maximum number of table objects for the cluster as a whole.
For each attribute that has a
BLOBdata type an extra table is used to store most of theBLOBdata. These tables also must be taken into account when defining the total number of tables.The default value of this parameter is 128. The minimum is 8 and the maximum is 1600. Each table object consumes approximately 20KB per node.
For each ordered index in the cluster, an object is allocated describing what is being indexed and its storage segments. By default, each index so defined also defines an ordered index. Each unique index and primary key has both an ordered index and a hash index.
MaxNoOfOrderedIndexessets the total number of hash indexes that can be in use in the system at any one time.The default value of this parameter is 128. Each hash index object consumes approximately 10KB of data per node.
For each unique index that is not a primary key, a special table is allocated that maps the unique key to the primary key of the indexed table. By default, an ordered index is also defined for each unique index. To prevent this, you must specify the
USING HASHoption when defining the unique index.The default value is 64. Each index consumes approximately 15KB per node.
Internal update, insert, and delete triggers are allocated for each unique hash index. (This means that three triggers are created for each unique hash index.) However, an ordered index requires only a single trigger object. Backups also use three trigger objects for each normal table in the cluster.
Replication between clusters also makes use of internal triggers.
This parameter sets the maximum number of trigger objects in the cluster.
The default value is 768.
This parameter is deprecated in MySQL 5.1; you should use
MaxNoOfOrderedIndexesandMaxNoOfUniqueHashIndexesinstead.This parameter is used only by unique hash indexes. There needs to be one record in this pool for each unique hash index defined in the cluster.
The default value of this parameter is 128.
Boolean parameters.
The behavior of data nodes is also affected by a set of
[ndbd] parameters taking on boolean values.
These parameters can each be specified as
TRUE by setting them equal to
1 or Y, and as
FALSE by setting them equal to
0 or N.
For a number of operating systems, including Solaris and Linux, it is possible to lock a process into memory and so avoid any swapping to disk. This can be used to help guarantee the cluster's real-time characteristics.
Beginning with MySQL 5.1.15 and MySQL Cluster NDB 6.1.1, this parameter takes one of the integer values
0,1, or2, which act as follows:0: Disables locking. This is the default value.1: Performs the lock after allocating memory for the process.2: Performs the lock before memory for the process is allocated.
Previously, this parameter was a Boolean.
0orfalsewas the default setting, and disabled locking.1ortrueenabled locking of the process after its memory was allocated.Important
Beginning with MySQL 5.1.15 and MySQL Cluster NDB 6.1.1, it is no longer possible to use
trueorfalsefor the value of this parameter; when upgrading from a previous version, you must change the value to0,1, or2.This parameter specifies whether an ndbd process should exit or perform an automatic restart when an error condition is encountered.
This feature is enabled by default.
It is possible to specify MySQL Cluster tables as diskless, meaning that tables are not checkpointed to disk and that no logging occurs. Such tables exist only in main memory. A consequence of using diskless tables is that neither the tables nor the records in those tables survive a crash. However, when operating in diskless mode, it is possible to run ndbd on a diskless computer.
Important
This feature causes the entire cluster to operate in diskless mode.
When this feature is enabled, Cluster online backup is disabled. In addition, a partial start of the cluster is not possible.
Disklessis disabled by default.Enabling this parameter causes
NDBto attempt usingO_DIRECTwrites for LCP, backups, and redo logs, often lowering kswapd and CPU usage. When using MySQL Cluster on Linux, enableODirectif you are using a 2.6 or kernel.This parameter was added in the following releases:
MySQL 5.1.20
MySQL Cluster NDB 6.1.11
MySQL Cluster NDB 6.2.3
MySQL Cluster NDB 6.3.0
ODirectis disabled by default.This feature is accessible only when building the debug version where it is possible to insert errors in the execution of individual blocks of code as part of testing.
This feature is disabled by default.
Setting this parameter to
1causes backup files to be compressed. The compression used is equivalent to gzip --fast, and can save 50% or more of the space required on the data node to store uncompressed backup files. Compressed backups can be enabled for individual data nodes, or for all data nodes (by setting this parameter in the[ndbd default]section of theconfig.inifile).Important
You cannot restore a compressed backup to a cluster running a MySQL version that does not support this feature.
The default value is
0(disabled).This parameter was introduced in MySQL Cluster NDB 6.3.7.
Setting this parameter to
1causes local checkpoint files to be compressed. The compression used is equivalent to gzip --fast, and can save 50% or more of the space required on the data node to store uncompressed checkpoint files. Compressed LCPs can be enabled for individual data nodes, or for all data nodes (by setting this parameter in the[ndbd default]section of theconfig.inifile).Important
You cannot restore a compressed local checkpoint to a cluster running a MySQL version that does not support this feature.
The default value is
0(disabled).This parameter was introduced in MySQL Cluster NDB 6.3.7.
Controlling Timeouts, Intervals, and Disk Paging
There are a number of [ndbd] parameters
specifying timeouts and intervals between various actions in
Cluster data nodes. Most of the timeout values are specified in
milliseconds. Any exceptions to this are mentioned where
applicable.
To prevent the main thread from getting stuck in an endless loop at some point, a “watchdog” thread checks the main thread. This parameter specifies the number of milliseconds between checks. If the process remains in the same state after three checks, the watchdog thread terminates it.
This parameter can easily be changed for purposes of experimentation or to adapt to local conditions. It can be specified on a per-node basis although there seems to be little reason for doing so.
The default timeout is 6000 milliseconds (6 seconds).
TimeBetweenWatchDogCheckInitialThis is similar to the
TimeBetweenWatchDogCheckparameter, except thatTimeBetweenWatchDogCheckInitialcontrols the amount of time that passes between execution checks inside a database node in the early start phases during which memory is allocated.The default timeout is 6000 milliseconds (6 seconds).
This parameter was added in MySQL 5.1.20.
This parameter specifies how long the Cluster waits for all data nodes to come up before the cluster initialization routine is invoked. This timeout is used to avoid a partial Cluster startup whenever possible.
The default value is 30000 milliseconds (30 seconds). 0 disables the timeout, in which case the cluster may start only if all nodes are available.
If the cluster is ready to start after waiting for
StartPartialTimeoutmilliseconds but is still possibly in a partitioned state, the cluster waits until this timeout has also passed.The default timeout is 60000 milliseconds (60 seconds).
If a data node has not completed its startup sequence within the time specified by this parameter, the node startup fails. Setting this parameter to 0 (the default value) means that no data node timeout is applied.
For nonzero values, this parameter is measured in milliseconds. For data nodes containing extremely large amounts of data, this parameter should be increased. For example, in the case of a data node containing several gigabytes of data, a period as long as 10–15 minutes (that is, 600000 to 1000000 milliseconds) might be required to perform a node restart.
One of the primary methods of discovering failed nodes is by the use of heartbeats. This parameter states how often heartbeat signals are sent and how often to expect to receive them. After missing three heartbeat intervals in a row, the node is declared dead. Thus, the maximum time for discovering a failure through the heartbeat mechanism is four times the heartbeat interval.
The default heartbeat interval is 1500 milliseconds (1.5 seconds). This parameter must not be changed drastically and should not vary widely between nodes. If one node uses 5000 milliseconds and the node watching it uses 1000 milliseconds, obviously the node will be declared dead very quickly. This parameter can be changed during an online software upgrade, but only in small increments.
Each data node sends heartbeat signals to each MySQL server (SQL node) to ensure that it remains in contact. If a MySQL server fails to send a heartbeat in time it is declared “dead,” in which case all ongoing transactions are completed and all resources released. The SQL node cannot reconnect until all activities initiated by the previous MySQL instance have been completed. The three-heartbeat criteria for this determination are the same as described for
HeartbeatIntervalDbDb.The default interval is 1500 milliseconds (1.5 seconds). This interval can vary between individual data nodes because each data node watches the MySQL servers connected to it, independently of all other data nodes.
This parameter is an exception in that it does not specify a time to wait before starting a new local checkpoint; rather, it is used to ensure that local checkpoints are not performed in a cluster where relatively few updates are taking place. In most clusters with high update rates, it is likely that a new local checkpoint is started immediately after the previous one has been completed.
The size of all write operations executed since the start of the previous local checkpoints is added. This parameter is also exceptional in that it is specified as the base-2 logarithm of the number of 4-byte words, so that the default value 20 means 4MB (4 × 220) of write operations, 21 would mean 8MB, and so on up to a maximum value of 31, which equates to 8GB of write operations.
All the write operations in the cluster are added together. Setting
TimeBetweenLocalCheckpointsto 6 or less means that local checkpoints will be executed continuously without pause, independent of the cluster's workload.When a transaction is committed, it is committed in main memory in all nodes on which the data is mirrored. However, transaction log records are not flushed to disk as part of the commit. The reasoning behind this behavior is that having the transaction safely committed on at least two autonomous host machines should meet reasonable standards for durability.
It is also important to ensure that even the worst of cases — a complete crash of the cluster — is handled properly. To guarantee that this happens, all transactions taking place within a given interval are put into a global checkpoint, which can be thought of as a set of committed transactions that has been flushed to disk. In other words, as part of the commit process, a transaction is placed in a global checkpoint group. Later, this group's log records are flushed to disk, and then the entire group of transactions is safely committed to disk on all computers in the cluster.
This parameter defines the interval between global checkpoints. The default is 2000 milliseconds.
This parameter defines the interval between synchronisation epochs for MySQL Cluster Replication. The default value is 100 milliseconds.
TimeBetweenEpochsis part of the implementation of “micro-GCPs”, which can be used to improve the performance of MySQL Cluster Replication. This parameter was introduced in MySQL Cluster NDB 6.2.5 and MySQL Cluster NDB 6.3.2.This parameter defines a timeout for synchronisation epochs for MySQL Cluster Replication. If a node fails to participate in a global checkpoint within the time determined by this parameter, the node is shut down. The default value is 4000 milliseconds.
TimeBetweenEpochsTimeoutis part of the implementation of “micro-GCPs”, which can be used to improve the performance of MySQL Cluster Replication. This parameter was introduced in MySQL Cluster NDB 6.2.7 and MySQL Cluster NDB 6.3.4.The number of unprocessed epochs by which a subscribing node can lag behind. Exceeding this number causes a lagging subscriber to be disconnected.
The default value of 100 is sufficient for most normal operations. If a subscribing node does lag enough to cause disconnections, it is usually due to network or scheduling issues with regard to processes or threads. (In rare circumstances, the problem may be due to a bug in the
NDBclient.) It may be desirable to set the value lower than the default when epochs are longer.Disconnection prevents client issues from affecting the data node service, running out of memory to buffer data, and eventually shutting down. Instead, only the client is affected as a result of the disconnect (by, for example gap events in the binlog), forcing the client to reconnect or restart the process.
TimeBetweenInactiveTransactionAbortCheckTimeout handling is performed by checking a timer on each transaction once for every interval specified by this parameter. Thus, if this parameter is set to 1000 milliseconds, every transaction will be checked for timing out once per second.
The default value is 1000 milliseconds (1 second).
This parameter states the maximum time that is permitted to lapse between operations in the same transaction before the transaction is aborted.
The default for this parameter is zero (no timeout). For a real-time database that needs to ensure that no transaction keeps locks for too long, this parameter should be set to a relatively small value. The unit is milliseconds.
TransactionDeadlockDetectionTimeoutWhen a node executes a query involving a transaction, the node waits for the other nodes in the cluster to respond before continuing. A failure to respond can occur for any of the following reasons:
The node is “dead”
The operation has entered a lock queue
The node requested to perform the action could be heavily overloaded.
This timeout parameter states how long the transaction coordinator waits for query execution by another node before aborting the transaction, and is important for both node failure handling and deadlock detection. In MySQL 5.1.10 and earlier versions, setting it too high could cause undesirable behavior in situations involving deadlocks and node failure. Beginning with MySQL 5.1.11, active transactions occurring during node failures are actively aborted by the MySQL Cluster Transaction Coordinator, and so high settings are no longer an issue with this parameter.
The default timeout value is 1200 milliseconds (1.2 seconds).
Prior to MySQL Cluster NDB versions 6.2.18, 6.3.24, and 7.0.5, the effective minimum for this parameter was 100 milliseconds. (Bug#44099) Beginning with these versions, the actual minimum is 50 milliseconds.
This is the maximum number of bytes to store before flushing data to a local checkpoint file. This is done in order to prevent write buffering, which can impede performance significantly. This parameter is not intended to take the place of
TimeBetweenLocalCheckpoints.Note
When
ODirectis enabled, it is not necessary to setDiskSyncSize; in fact, in such cases its value is simply ignored.The default value is 4M (4 megabytes).
This parameter was added in MySQL 5.1.12.
The amount of data,in bytes per second, that is sent to disk during a local checkpoint.
The default value is 10M (10 megabytes per second).
This parameter was added in MySQL 5.1.12.
The amount of data,in bytes per second, that is sent to disk during a local checkpoint as part of a restart operation.
The default value is 100M (100 megabytes per second).
This parameter was added in MySQL 5.1.12.
NoOfDiskPagesToDiskAfterRestartTUPWhen executing a local checkpoint, the algorithm flushes all data pages to disk. Merely doing so as quickly as possible without any moderation is likely to impose excessive loads on processors, networks, and disks. To control the write speed, this parameter specifies how many pages per 100 milliseconds are to be written. In this context, a “page” is defined as 8KB. This parameter is specified in units of 80KB per second, so setting
NoOfDiskPagesToDiskAfterRestartTUPto a value of20entails writing 1.6MB in data pages to disk each second during a local checkpoint. This value includes the writing of UNDO log records for data pages. That is, this parameter handles the limitation of writes from data memory. (See the entry forIndexMemoryfor information about index pages.)In short, this parameter specifies how quickly to execute local checkpoints. It operates in conjunction with
NoOfFragmentLogFiles,DataMemory, andIndexMemory.For more information about the interaction between these parameters and possible strategies for choosing appropriate values for them, see Section 17.3.6, “Configuring MySQL Cluster Parameters for Local Checkpoints”.
The default value is 40 (3.2MB of data pages per second).
Note
This parameter is deprecated as of MySQL 5.1.6. For MySQL 5.1.12 and later versions, use DiskCheckpointSpeed and DiskSyncSize instead.
NoOfDiskPagesToDiskAfterRestartACCThis parameter uses the same units as
NoOfDiskPagesToDiskAfterRestartTUPand acts in a similar fashion, but limits the speed of writing index pages from index memory.The default value of this parameter is 20 (1.6MB of index memory pages per second).
Note
This parameter is deprecated as of MySQL 5.1.6. For MySQL 5.1.12 and later versions, use DiskCheckpointSpeed and DiskSyncSize.
NoOfDiskPagesToDiskDuringRestartTUPThis parameter is used in a fashion similar to
NoOfDiskPagesToDiskAfterRestartTUPandNoOfDiskPagesToDiskAfterRestartACC, only it does so with regard to local checkpoints executed in the node when a node is restarting. A local checkpoint is always performed as part of all node restarts. During a node restart it is possible to write to disk at a higher speed than at other times, because fewer activities are being performed in the node.This parameter covers pages written from data memory.
The default value is 40 (3.2MB per second).
Note
This parameter is deprecated as of MySQL 5.1.6. For MySQL 5.1.12 and later versions, use DiskCheckpointSpeedInRestart and DiskSyncSize.
NoOfDiskPagesToDiskDuringRestartACCControls the number of index memory pages that can be written to disk during the local checkpoint phase of a node restart.
As with
NoOfDiskPagesToDiskAfterRestartTUPandNoOfDiskPagesToDiskAfterRestartACC, values for this parameter are expressed in terms of 8KB pages written per 100 milliseconds (80KB/second).The default value is 20 (1.6MB per second).
Note
This parameter is deprecated as of MySQL 5.1.6. For MySQL 5.1.12 and later versions, use DiskCheckpointSpeedInRestart and DiskSyncSize.
This parameter specifies how long data nodes wait for a response from the arbitrator to an arbitration message. If this is exceeded, the network is assumed to have split.
The default value is 1000 milliseconds (1 second).
Buffering and logging.
Several [ndbd] configuration parameters
enable the advanced user to have more control over the
resources used by node processes and to adjust various buffer
sizes at need.
These buffers are used as front ends to the file system when
writing log records to disk. If the node is running in diskless
mode, these parameters can be set to their minimum values
without penalty due to the fact that disk writes are
“faked” by the NDB
storage engine's file system abstraction layer.
The UNDO index buffer, whose size is set by this parameter, is used during local checkpoints. The
NDBstorage engine uses a recovery scheme based on checkpoint consistency in conjunction with an operational REDO log. To produce a consistent checkpoint without blocking the entire system for writes, UNDO logging is done while performing the local checkpoint. UNDO logging is activated on a single table fragment at a time. This optimization is possible because tables are stored entirely in main memory.The UNDO index buffer is used for the updates on the primary key hash index. Inserts and deletes rearrange the hash index; the NDB storage engine writes UNDO log records that map all physical changes to an index page so that they can be undone at system restart. It also logs all active insert operations for each fragment at the start of a local checkpoint.
Reads and updates set lock bits and update a header in the hash index entry. These changes are handled by the page-writing algorithm to ensure that these operations need no UNDO logging.
This buffer is 2MB by default. The minimum value is 1MB, which is sufficient for most applications. For applications doing extremely large or numerous inserts and deletes together with large transactions and large primary keys, it may be necessary to increase the size of this buffer. If this buffer is too small, the NDB storage engine issues internal error code 677 (
Index UNDO buffers overloaded).Important
It is not safe to decrease the value of this parameter during a rolling restart.
This parameter sets the size of the UNDO data buffer, which performs a function similar to that of the UNDO index buffer, except the UNDO data buffer is used with regard to data memory rather than index memory. This buffer is used during the local checkpoint phase of a fragment for inserts, deletes, and updates.
Because UNDO log entries tend to grow larger as more operations are logged, this buffer is also larger than its index memory counterpart, with a default value of 16MB.
This amount of memory may be unnecessarily large for some applications. In such cases, it is possible to decrease this size to a minimum of 1MB.
It is rarely necessary to increase the size of this buffer. If there is such a need, it is a good idea to check whether the disks can actually handle the load caused by database update activity. A lack of sufficient disk space cannot be overcome by increasing the size of this buffer.
If this buffer is too small and gets congested, the NDB storage engine issues internal error code 891 (Data UNDO buffers overloaded).
Important
It is not safe to decrease the value of this parameter during a rolling restart.
All update activities also need to be logged. The REDO log makes it possible to replay these updates whenever the system is restarted. The NDB recovery algorithm uses a “fuzzy” checkpoint of the data together with the UNDO log, and then applies the REDO log to play back all changes up to the restoration point.
RedoBuffersets the size of the buffer in which the REDO log is written. In MySQL Cluster NDB 6.4.3 and earlier, the default value is 8MB; beginning with MySQL Cluster NDB 7.0.4, the default is 32MB. The minimum value is 1MB.If this buffer is too small, the NDB storage engine issues error code 1221 (
REDO log buffers overloaded).Important
It is not safe to decrease the value of this parameter during a rolling restart.
Controlling log messages.
In managing the cluster, it is very important to be able to
control the number of log messages sent for various event
types to stdout. For each event category,
there are 16 possible event levels (numbered 0 through 15).
Setting event reporting for a given event category to level 15
means all event reports in that category are sent to
stdout; setting it to 0 means that there
will be no event reports made in that category.
By default, only the startup message is sent to
stdout, with the remaining event reporting
level defaults being set to 0. The reason for this is that these
messages are also sent to the management server's cluster log.
An analogous set of levels can be set for the management client to determine which event levels to record in the cluster log.
The reporting level for events generated during startup of the process.
The default level is 1.
The reporting level for events generated as part of graceful shutdown of a node.
The default level is 0.
The reporting level for statistical events such as number of primary key reads, number of updates, number of inserts, information relating to buffer usage, and so on.
The default level is 0.
The reporting level for events generated by local and global checkpoints.
The default level is 0.
The reporting level for events generated during node restart.
The default level is 0.
The reporting level for events generated by connections between cluster nodes.
The default level is 0.
The reporting level for events generated by errors and warnings by the cluster as a whole. These errors do not cause any node failure but are still considered worth reporting.
The default level is 0.
The reporting level for events generated by congestion. These errors do not cause node failure but are still considered worth reporting.
The default level is 0.
The reporting level for events generated for information about the general state of the cluster.
The default level is 0.
This parameter controls how often data node memory usage reports are recorded in the cluster log; it is an integer value representing the number of seconds between reports.
Each data node's data memory and index memory usage is logged as both a percentage and a number of 32 KB pages of the
DataMemoryandIndexMemory, respectively, set in theconfig.inifile. For example, ifDataMemoryis equal to 100 MB, and a given data node is using 50 MB for data memory storage, the corresponding line in the cluster log might look like this:2006-12-24 01:18:16 [MgmSrvr] INFO -- Node 2: Data usage is 50%(1280 32K pages of total 2560)
MemReportFrequencyis not a required parameter. If used, it can be set for all cluster data nodes in the[ndbd default]section ofconfig.ini, and can also be set or overridden for individual data nodes in the corresponding[ndbd]sections of the configuration file. The minimum value — which is also the default value — is 0, in which case memory reports are logged only when memory usage reaches certain percentages (80%, 90%, and 100%), as mentioned in the discussion of statistics events in Section 17.7.4.2, “MySQL Cluster Log Events”.This parameter was added in MySQL Cluster 5.1.16 and MySQL Cluster NDB 6.1.0.
Backup parameters.
The [ndbd] parameters discussed in this
section define memory buffers set aside for execution of
online backups.
In creating a backup, there are two buffers used for sending data to the disk. The backup data buffer is used to fill in data recorded by scanning a node's tables. Once this buffer has been filled to the level specified as
BackupWriteSize(see below), the pages are sent to disk. While flushing data to disk, the backup process can continue filling this buffer until it runs out of space. When this happens, the backup process pauses the scan and waits until some disk writes have completed freed up memory so that scanning may continue.In MySQL Cluster NDB 6.4.3 and earlier, the default value is 2MB; in MySQL Cluster NDB 7.0.4 and later, it is 16MB.
The backup log buffer fulfills a role similar to that played by the backup data buffer, except that it is used for generating a log of all table writes made during execution of the backup. The same principles apply for writing these pages as with the backup data buffer, except that when there is no more space in the backup log buffer, the backup fails. For that reason, the size of the backup log buffer must be large enough to handle the load caused by write activities while the backup is being made. See Section 17.7.3.3, “Configuration for MySQL Cluster Backups”.
The default value for this parameter should be sufficient for most applications. In fact, it is more likely for a backup failure to be caused by insufficient disk write speed than it is for the backup log buffer to become full. If the disk subsystem is not configured for the write load caused by applications, the cluster is unlikely to be able to perform the desired operations.
It is preferable to configure cluster nodes in such a manner that the processor becomes the bottleneck rather than the disks or the network connections.
In MySQL Cluster NDB 6.4.3 and earlier, the default value is 2MB; in MySQL Cluster NDB 7.0.4 and later, it is 16MB.
This parameter is simply the sum of
BackupDataBufferSizeandBackupLogBufferSize.In MySQL Cluster NDB 6.4.3 and earlier, the default value was 2MB + 2MB = 4MB; in MySQL Cluster NDB 7.0.4 and later, it is 16MB + 16MB = 32MB.
Important
If
BackupDataBufferSizeandBackupLogBufferSizetaken together exceed the default value forBackupMemory, then this parameter must be set explicitly in theconfig.inifile to their sum.This parameter controls how often backup status reports are issued in the management client during a backup, as well as how often such reports are written to the cluster log (provided cluster event logging is configured to allow it — see Section 17.3.4.6, “Defining MySQL Cluster Data Nodes”).
BackupReportFrequencyrepresents the time in seconds between backup status reports.The default value is 0.
This parameter was added in MySQL Cluster NDB 6.2.3.
This parameter specifies the default size of messages written to disk by the backup log and backup data buffers.
In MySQL Cluster 6.4.3 and earlier, the default value for this parameter was 32KB; beginning with MySQL Cluster NDB 7.0.4, it is 256KB.
This parameter specifies the maximum size of messages written to disk by the backup log and backup data buffers.
In MySQL Cluster 6.4.3 and earlier, the default value for this parameter was 256KB; beginning with MySQL Cluster NDB 7.0.4, it is 1MB.
Important
When specifying these parameters, the following relationships must hold true. Otherwise, the data node will be unable to start:
BackupDataBufferSize >= BackupWriteSize + 188KBBackupLogBufferSize >= BackupWriteSize + 16KBBackupMaxWriteSize >= BackupWriteSize
Realtime Performance Parameters
The [ndbd] parameters discussed in this
section are used in scheduling and locking of threads to
specific CPUs on multiprocessor data node hosts. They were
introduced in MySQL Cluster NDB 6.3.4.
Previous to MySQL Cluster NDB 7.0. This parameter specifies the ID of the CPU assigned to handle the
NDBCLUSTERexecution thread. The value of this parameter is an integer in the range 0 to 65535 (inclusive). The default is 65535.MySQL Cluster NDB 7.0 and later (beginning with MySQL Cluster NDB 6.4.0). When used with ndbd, this parameter (now a string) specifies the ID of the CPU assigned to handle the
NDBCLUSTERexecution thread. When used with ndbmtd, the value of this parameter is a comma-separated list of CPU IDs assigned to handle execution threads. Each CPU ID in the list should be an integer in the range 0 to 65535 (inclusive). The number of IDs specified should match the number of execution threads determined byMaxNoOfExecutionThreads. There is no default value.This parameter specifies the ID of the CPU assigned to handle
NDBCLUSTERmaintenance threads.The value of this parameter is an integer in the range 0 to 65535 (inclusive). This parameter was added in MySQL Cluster NDB 6.3.4. Prior to MySQL Cluster NDB 6.4.0, the default is 65535; in MySQL Cluster NDB 7.0 and later MySQL Cluster release series, there is no default value.
Setting this parameter to 1 enables real-time scheduling of
NDBCLUSTERthreads.The default is 0 (scheduling disabled).
This parameter specifies the time in microseconds for threads to be executed in the scheduler before being sent. Setting it to 0 minimizes the response time; to achieve higher throughput, you can increase the value at the expense of longer response times.
The default is 50 μsec, which our testing shows to increase throughput slightly in high-load cases without materially delaying requests.
This parameter was added in MySQL Cluster NDB 6.3.4.
This parameter specifies the time in microseconds for threads to be executed in the scheduler before sleeping.
The default value is 0.
Disk Data Configuration Parameters. Configuration parameters affecting Disk Data behavior include the following:
This determines the amount of space used for caching pages on disk, and is set in the
[ndbd]or[ndbd default]section of theconfig.inifile. It is measured in bytes. Each page takes up 32 KB. This means that Cluster Disk Data storage always usesN* 32 KB memory whereNis some nonnegative integer.The default value for this parameter is
64M(2000 pages of 32 KB each).This parameter was added in MySQL 5.1.6.
This determines the amount of memory that is used for log buffers, disk operations (such as page requests and wait queues), and metadata for tablespaces, log file groups,
UNDOfiles, and data files. It can be set in the[ndbd]or[ndbd default]section of theconfig.iniconfiguration file, and is measured in bytes.The default value is
20M.This parameter was added in MySQL 5.1.6.
This parameter determines the number of unbound threads used for Disk Data file access. Currently, it applies to Disk Data I/O threads only, but we plan in the future to make the number of such threads configurable for in-memory data as well.
The optimum value for this parameter depends on your hardware and configuration, and includes these factors:
Physical distribution of Disk Data files. You can obtain better performance by placing data files, undo log files, and the data node filesystem on separate physical disks. If you do this with some or all of these sets of files, then you can set
DiskIOThreadPoolhigher to allow separate threads to handle the files on each disk.Disk performance and types. The number of threads that can be accommodated for Disk Data file handling is also dependent on the speed and throughput of the disks. Faster disks and higher throughput allow for more disk I/O threads. Our test results indicate that solid-state disk drives can handle many more disk I/O threads than conventional disks, and thus higher values for
DiskIOThreadPool.
This parameter was added in MySQL Cluster NDB 6.4.0. Previous to MySQL Cluster NDB 6.4.3, it was named
ThreadPool. The default value is 8Disk Data filesystem parameters. The parameters in the following list were added in MySQL Cluster NDB 6.2.17, 6.3.22, and 6.4.3 to make it easier to place MySQL Cluster Disk Data files in specific directories.
If this parameter is specified, then MySQL Cluster Disk Data data files and undo log files are placed in the indicated directory. This can be overridden for data files, undo log files, or both, by specifying values for
FileSystemPathDataFiles,FileSystemPathUndoFiles, or both, as explained for these parameters. It can also be overridden for data files by specifying a path in theADD DATAFILEclause of aCREATE TABLESPACEorALTER TABLESPACEstatement, and for undo log files by specifying a path in theADD UNDOFILEclause of aCREATE LOGFILE GROUPorALTER LOGFILE GROUPstatement. IfFileSystemPathDDis not specified, thenFileSystemPathis used.If a
FileSystemPathDDdirectory is specified for a given data node (including the case where the parameter is specified in the[ndbd default]section of theconfig.inifile), then starting that data node with--initialcauses all files in the directory to be deleted.If this parameter is specified, then MySQL Cluster Disk Data data files are placed in the indicated directory. This overrides any value set for
FileSystemPathDD. This parameter can be overridden for a given data file by specifying a path in theADD DATAFILEclause of aCREATE TABLESPACEorALTER TABLESPACEstatement used to create that data file. IfFileSystemPathDataFilesis not specified, thenFileSystemPathDDis used (orFileSystemPath, ifFileSystemPathDDhas also not been set).If a
FileSystemPathDataFilesdirectory is specified for a given data node (including the case where the parameter is specified in the[ndbd default]section of theconfig.inifile), then starting that data node with--initialcauses all files in the directory to be deleted.If this parameter is specified, then MySQL Cluster Disk Data undo log files are placed in the indicated directory. This overrides any value set for
FileSystemPathDD. This parameter can be overridden for a given data file by specifying a path in theADD UNDOclause of aCREATE LOGFILE GROUPorCREATE LOGFILE GROUPstatement used to create that data file. IfFileSystemPathUndoFilesis not specified, thenFileSystemPathDDis used (orFileSystemPath, ifFileSystemPathDDhas also not been set).If a
FileSystemPathUndoFilesdirectory is specified for a given data node (including the case where the parameter is specified in the[ndbd default]section of theconfig.inifile), then starting that data node with--initialcauses all files in the directory to be deleted.
For more information, see Section 17.10.1, “MySQL Cluster Disk Data Objects”.
Disk Data object creation parameters. The next two parameters enable you — when starting the cluster for the first time — to cause a Disk Data log file group, tablespace, or both, to be created without the use of SQL statements.
This parameter can be used to specify a log file group that is created when performing an initial start of the cluster.
InitialLogFileGroupis specified as shown here:InitialLogFileGroup = [name=
name;] [undobuffer_size=size;]file-specification-listfile-specification-list:file-specification[;file-specification[; ...]]file-specification:filename:sizeThe
nameof the log file group is optional and defaults toDEFAULT_LG. Theundobuffer_sizeis also optional; if omitted, it defaults to256M(256 megabytes). Eachfile-specificationcorresponds to an undo log file, and at least one must be specified in thefile-specification-list. Undo log files are placed according to any values that have been set forFileSystemPath,FileSystemPathDD, andFileSystemPathUndoFiles, just as if they had been created as the result of aCREATE LOGFILE GROUPorALTER LOGFILE GROUPstatement.Consider the following example:
InitialLogFileGroup = name=LG1; undobuffer_size=128M; undo1.log:250M; undo2.log:150M
This is equivalent to the following SQL statements:
CREATE LOGFILE GROUP LG1 ADD UNDOFILE 'undo1.log' INITIAL_SIZE 250M UNDO_BUFFER_SIZE 128M ENGINE NDBCLUSTER; ALTER LOGFILE GROUP LG1 ADD UNDOFILE 'undo2.log' INITIAL_SIZE 150M ENGINE NDBCLUSTER;This logfile group is created when the data nodes are started with
--initial.This parameter, if used, should always be set in the
[ndbd default]section of theconfig.inifile. The behavior of a MySQL Cluster when different values are set on different data nodes is not defined.This parameter can be used to specify a MySQL Cluster Disk Data tablespace that is created when performing an initial start of the cluster.
InitialTablespaceis specified as shown here:InitialTablespace = [name=
name;] [extent_size=size;] [logfile_group=lg-name;]file-specification-listThe
nameof the tablespace is optional and defaults toDEFAULT_TS. Theextent_sizeis also optional; it defaults to1M(1 megabyte). Thelogfile_groupis also optional, and defaults toDEFAULT_LG. Thefile-specification-listuses the same syntax as shown with theInitialLogfileGroupparameter, the only difference being that eachfile-specificationused withInitialTablespacecorresponds to a data file. At least one must be specified in thefile-specification-list. Data files are placed according to any values that have been set forFileSystemPath,FileSystemPathDD, andFileSystemPathDataFiles, just as if they had been created as the result of aCREATE TABLESPACEorALTER TABLESPACEstatement.For example, consider the following line specifying
InitialTablespacein the[ndbd default]section of theconfig.inifile (as withInitialLogfileGroup, this parameter should always be set in the[ndbd default]section, as the behavior of a MySQL Cluster when different values are set on different data nodes is not defined):InitialTablespace = name=TS1; extent_size=8M; logfile_group=LG1; data1.dat:2G; data2.dat:4G
This is equivalent to the following SQL statements:
CREATE TABLESPACE TS1 ADD DATAFILE 'data1.dat' USE LOGFILE GROUP LG1 EXTENT_SIZE 8M INITIAL_SIZE 2G ENGINE NDBCLUSTER; ALTER TABLESPACE TS1 ADD UNDOFILE 'data2.dat' INITIAL_SIZE 4G ENGINE NDBCLUSTER;This tablespace is created when the data nodes are started with
--initial, and can be used whenever creating MySQL Cluster Disk Data tables thereafter.
Disk Data and GCP Stop errors.
Errors encountered when using Disk Data tables such as
Node nodeid killed this
node because GCP stop was detected (error 2303)
are often referred to as “CGP stop errors”. Such
errors are usually due to slow disks and insufficient disk
throughput. You can help prevent these errors from occurring
by using faster disks, and by adjusting the cluster
configuration as discussed here:
MySQL Cluster NDB 6.2 and 6.3. When working with large amounts of data on disk under high load, the default value for
DiskPageBufferMemorymay not be large enough. In such cases, you should increase its value to include most of the memory available to the data nodes after accounting for index memory, data memory, internal buffers, and memory needed by the data node host operating system. You can use this formula as a guide:DiskPageBufferMemory = 0.8 x ( [total memory] - ([operating system memory] + [buffer memory] + DataMemory + IndexMemory) )Once you have established that sufficient memory is reserved for
DataMemory,IndexMemory, NDB internal buffers, and operating system overhead, it is possible (and sometimes desirable) to allocate more than the above amount of the remainder toDiskPageBufferMemory.MySQL Cluster NDB 6.4 and 7.X. In addition to the considerations given for
DiskPageBufferMemoryas explained in the previous item, it is also very important that theDiskIOThreadPoolconfiguration parameter be set correctly; havingDiskIOThreadPoolset too high is very likely to cause GCP stop errors (Bug#37227).
Parameters for configuring send buffer memory allocation (MySQL Cluster
NDB 7.0).
Beginning with MySQL Cluster NDB 6.4.0, send buffer memory is
allocated dynamically from a memory pool shared between all
transporters, which means that the size of the send buffer can
be adjusted as necessary. (Previously, the NDB kernel used a
fixed-size send buffer for every node in the cluster, which
was allocated when the node started and could not be changed
while the node was running.) The following data node
configuration parameters were added in MySQL Cluster NDB 6.4.0
to permit the setting of limits on this memory allocation;
this change is reflected by the addition of the configuration
parameters TotalSendBufferMemory,
ReservedSendBufferMemory, and
OverLoadLimit, as well as a change in how
the existing SendBufferMemory configuration
parameter is used. For more information, see
Section 17.3.7, “Configuring MySQL Cluster Send Buffer Parameters”.
This parameter is available beginning with MySQL Cluster NDB 6.4.0. It is used to determine the total amount of memory to allocate on this node for shared send buffer memory among all configured transporters.
If this parameter is set, its minimum allowed value is 256K; the maxmimum is 4294967039.
This optional parameter is available beginning with MySQL Cluster NDB 6.4.0. If set, it reserves an amount of memory (in bytes) for connections between data nodes, and that cannot be allocated for send buffers to be used for management or API nodes. This helps prevent API nodes from using excess send buffer memory and thereby causing communications failures in the NDB kernel.
If this parameter is set, its minimum allowed value is 256K; the maxmimum is 4294967039.
For more detailed information about the behavior and use of
TotalSendBufferMemory and
ReservedSendBufferMemory, and about
configuring send buffer memory parameters in MySQL Cluster NDB
6.4.0 and later, see
Section 17.3.7, “Configuring MySQL Cluster Send Buffer Parameters”.
Note
Previous to MySQL Cluster NDB 7.0, to add new data nodes to a
MySQL Cluster, it is necessary to shut down the cluster
completely, update the config.ini file,
and then restart the cluster (that is, you must perform a
system restart). All data node processes must be started with
the --initial option.
Beginning with MySQL Cluster NDB 7.0, it is possible to add new data node groups to a running cluster online. See Section 17.7.8, “Adding MySQL Cluster Data Nodes Online”, for more information.
The [mysqld] and [api]
sections in the config.ini file define the
behavior of the MySQL servers (SQL nodes) and other applications
(API nodes) used to access cluster data. None of the parameters
shown is required. If no computer or host name is provided, any
host can use this SQL or API node.
Generally speaking, a [mysqld] section is
used to indicate a MySQL server providing an SQL interface to
the cluster, and an [api] section is used for
applications other than mysqld processes
accessing cluster data, but the two designations are actually
synonomous; you can, for instance, list parameters for a MySQL
server acting as an SQL node in an [api]
section.
Note
For a discussion of MySQL server options for MySQL Cluster, see Section 17.4.2, “mysqld Command Options for MySQL Cluster”; for information about MySQL server system variables relating to MySQL Cluster, see Section 17.4.3, “MySQL Cluster System Variables”.
The
Idis an integer value used to identify the node in all cluster internal messages. Prior to MySQL Cluster NDB 6.1.1, the permitted range of values for this parameter was 1 to 63 inclusive. Beginning with MySQL Cluster NDB 6.1.1, the permitted range is 1 to 255 inclusive. This value must be unique for each node in the cluster, regardless of the type of node.Note
Data node IDs must be less than 49, regardless of the MySQL Cluster version used. If you plan to deploy a large number of data nodes, it is a good idea to limit the node IDs for API nodes (and management nodes) to values greater than 48.
This refers to the
Idset for one of the computers (hosts) defined in a[computer]section of the configuration file.Specifying this parameter defines the hostname of the computer on which the SQL node (API node) is to reside. To specify a hostname, either this parameter or
ExecuteOnComputeris required.If no
HostNameorExecuteOnComputeris specified in a given[mysql]or[api]section of theconfig.inifile, then an SQL or API node may connect using the corresponding “slot” from any host which can establish a network connection to the management server host machine. This differs from the default behavior for data nodes, wherelocalhostis assumed forHostNameunless otherwise specified.This parameter defines which nodes can act as arbitrators. Both MGM nodes and SQL nodes can be arbitrators. A value of 0 means that the given node is never used as an arbitrator, a value of 1 gives the node high priority as an arbitrator, and a value of 2 gives it low priority. A normal configuration uses the management server as arbitrator, setting its
ArbitrationRankto 1 (the default) and those for all SQL nodes to 0.Beginning with MySQL 5.1.16 and MySQL Cluster NDB 6.1.3, it is possible to disable arbitration completely by setting
ArbitrationRankto 0 on all management and SQL nodes.Setting this parameter to any other value than 0 (the default) means that responses by the arbitrator to arbitration requests will be delayed by the stated number of milliseconds. It is usually not necessary to change this value.
For queries that are translated into full table scans or range scans on indexes, it is important for best performance to fetch records in properly sized batches. It is possible to set the proper size both in terms of number of records (
BatchSize) and in terms of bytes (BatchByteSize). The actual batch size is limited by both parameters.The speed at which queries are performed can vary by more than 40% depending upon how this parameter is set. In future releases, MySQL Server will make educated guesses on how to set parameters relating to batch size, based on the query type.
This parameter is measured in bytes and by default is equal to 32KB.
This parameter is measured in number of records and is by default set to 64. The maximum size is 992.
The batch size is the size of each batch sent from each data node. Most scans are performed in parallel to protect the MySQL Server from receiving too much data from many nodes in parallel; this parameter sets a limit to the total batch size over all nodes.
The default value of this parameter is set to 256KB. Its maximum size is 16MB.
This parameter is available beginning with MySQL Cluster NDB 6.4.0. It is used to determine the total amount of memory to allocate on this node for shared send buffer memory among all configured transporters.
If this parameter is set, its minimum allowed value is 256K; the maxmimum is 4294967039. For more detailed information about the behavior and use of
TotalSendBufferMemoryand configuring send buffer memory parameters in MySQL Cluster NDB 6.4.0 and later, see Section 17.3.7, “Configuring MySQL Cluster Send Buffer Parameters”.
You can obtain some information from a MySQL server running as a
Cluster SQL node using SHOW
STATUS in the mysql client, as
shown here:
mysql> SHOW STATUS LIKE 'ndb%';
+-----------------------------+---------------+
| Variable_name | Value |
+-----------------------------+---------------+
| Ndb_cluster_node_id | 5 |
| Ndb_config_from_host | 192.168.0.112 |
| Ndb_config_from_port | 1186 |
| Ndb_number_of_storage_nodes | 4 |
+-----------------------------+---------------+
4 rows in set (0.02 sec)
For information about these Cluster system status variables, see Section 5.1.7, “Server Status Variables”.
Note
To add new SQL or API nodes to the configuration of a running
MySQL Cluster, it is necessary to perform a rolling restart of
all cluster nodes after adding new [mysqld]
or [api] sections to the
config.ini file (or files, if you are
using more than one management server). This must be done
before the new SQL or API nodes can connect to the cluster.
It is not necessary to perform any restart of the cluster if new SQL or API nodes can employ previously unused API slots in the cluster configuration to connect to the cluster.
TCP/IP is the default transport mechanism for all connections between nodes in a MySQL Cluster. Normally it is not necessary to define TCP/IP connections; MySQL Cluster automatically sets up such connections for all data nodes, management nodes, and SQL or API nodes.
Note
For an exception to this rule, see Section 17.3.4.9, “MySQL Cluster TCP/IP Connections Using Direct Connections”.
To override the default connection parameters, it is necessary
to define a connection using one or more
[tcp] sections in the
config.ini file. Each
[tcp] section explicitly defines a TCP/IP
connection between two MySQL Cluster nodes, and must contain at
a minimum the parameters NodeId1 and
NodeId2, as well as any connection parameters
to override.
It is also possible to change the default values for these
parameters by setting them in the [tcp
default] section.
Important
Any [tcp] sections in the
config.ini file should be listed
last, following all other sections in the
file. However, this is not required for a [tcp
default] section. This requirement is a known issue
with the way in which the config.ini file
is read by the MySQL Cluster management server.
Connection parameters which can be set in
[tcp] and [tcp default]
sections of the config.ini file are listed
here:
To identify a connection between two nodes it is necessary to provide their node IDs in the
[tcp]section of the configuration file. These are the same uniqueIdvalues for each of these nodes as described in Section 17.3.4.7, “Defining SQL and Other API Nodes in a MySQL Cluster”.Beginning in MySQL Cluster NDB 6.4.0, this parameter can be used to determine the amount of unsent data that must be present in the send buffer before the connection is considered overloaded. See Section 17.3.7, “Configuring MySQL Cluster Send Buffer Parameters”, for more information.
TCP transporters use a buffer to store all messages before performing the send call to the operating system. When this buffer reaches 64KB its contents are sent; these are also sent when a round of messages have been executed. To handle temporary overload situations it is also possible to define a bigger send buffer.
Prior to MySQL Cluster NDB 7.0, this parameter determined a fixed amount of memory allocated at startup for each configured TCP connection. Beginning with MySQL Cluster NDB 6.4.0, memory is not dedicated to each transporter. Instead, the value denotes the hard limit for how much memory (out of the total available memory — that is,
TotalSendBufferMemory) that may be used by a single transporter. For more information about configuring dynamic transporter send buffer memory allocation in MySQL Cluster NDB 7.0 and later, see Section 17.3.7, “Configuring MySQL Cluster Send Buffer Parameters”.In MySQL Cluster NDB 6.4.3 and earlier, the default size of the send buffer was 256 KB; in MySQL Cluster NDB 7.0.4 and later, it is 2MB, which is the size recommended in most situations. The minimum size is 64 KB; the theoretical maximum is 4 GB.
To be able to retrace a distributed message datagram, it is necessary to identify each message. When this parameter is set to
Y, message IDs are transported over the network. This feature is disabled by default in production builds, and enabled in-debugbuilds.This parameter is a boolean parameter (enabled by setting it to
Yor1, disabled by setting it toNor0). It is disabled by default. When it is enabled, checksums for all messages are calculated before they placed in the send buffer. This feature ensures that messages are not corrupted while waiting in the send buffer, or by the transport mechanism.This formerly specified the port number to be used for listening for connections from other nodes. This parameter should no longer be used.
Specifies the size of the buffer used when receiving data from the TCP/IP socket.
In MySQL Cluster NDB 6.4.3 and earlier, the default value of this parameter was 64 KB; beginning with MySQL Cluster NDB 7.0.4, 2MB is the default. The minimum possible value is 16KB; the theoretical maximum is 4GB.
Setting up a cluster using direct connections between data nodes
requires specifying explicitly the crossover IP addresses of the
data nodes so connected in the [tcp] section
of the cluster config.ini file.
In the following example, we envision a cluster with at least
four hosts, one each for a management server, an SQL node, and
two data nodes. The cluster as a whole resides on the
172.23.72.* subnet of a LAN. In addition to
the usual network connections, the two data nodes are connected
directly using a standard crossover cable, and communicate with
one another directly using IP addresses in the
1.1.0.* address range as shown:
# Management Server [ndb_mgmd] Id=1 HostName=172.23.72.20 # SQL Node [mysqld] Id=2 HostName=172.23.72.21 # Data Nodes [ndbd] Id=3 HostName=172.23.72.22 [ndbd] Id=4 HostName=172.23.72.23 # TCP/IP Connections [tcp] NodeId1=3 NodeId2=4 HostName1=1.1.0.1 HostName2=1.1.0.2
The HostName
parameter, where NN is an integer, is
used only when specifying direct TCP/IP connections.
The use of direct connections between data nodes can improve the cluster's overall efficiency by allowing the data nodes to bypass an Ethernet device such as a switch, hub, or router, thus cutting down on the cluster's latency. It is important to note that to take the best advantage of direct connections in this fashion with more than two data nodes, you must have a direct connection between each data node and every other data node in the same node group.
MySQL Cluster attempts to use the shared memory transporter and
configure it automatically where possible.
[shm] sections in the
config.ini file explicitly define
shared-memory connections between nodes in the cluster. When
explicitly defining shared memory as the connection method, it
is necessary to define at least NodeId1,
NodeId2 and ShmKey. All
other parameters have default values that should work well in
most cases.
Important
SHM functionality is considered experimental only. It is not officially supported in any current MySQL Cluster release, and testing results indicate that SHM performance is not appreciably greater than when using TCP/IP for the transporter.
For these reasons, you must determine for yourself or by using our free resources (forums, mailing lists) whether SHM can be made to work correctly in your specific case.
To identify a connection between two nodes it is necessary to provide node identifiers for each of them, as
NodeId1andNodeId2.When setting up shared memory segments, a node ID, expressed as an integer, is used to identify uniquely the shared memory segment to use for the communication. There is no default value.
Each SHM connection has a shared memory segment where messages between nodes are placed by the sender and read by the reader. The size of this segment is defined by
ShmSize. The default value is 1MB.To retrace the path of a distributed message, it is necessary to provide each message with a unique identifier. Setting this parameter to
Ycauses these message IDs to be transported over the network as well. This feature is disabled by default in production builds, and enabled in-debugbuilds.This parameter is a boolean (
Y/N) parameter which is disabled by default. When it is enabled, checksums for all messages are calculated before being placed in the send buffer.This feature prevents messages from being corrupted while waiting in the send buffer. It also serves as a check against data being corrupted during transport.
When using the shared memory transporter, a process sends an operating system signal to the other process when there is new data available in the shared memory. Should that signal conflict with with an existing signal, this parameter can be used to change it. This is a possibility when using SHM due to the fact that different operating systems use different signal numbers.
The default value of
SigNumis 0; therefore, it must be set to avoid errors in the cluster log when using the shared memory transporter. Typically, this parameter is set to 10 in the[shm default]section of theconfig.inifile.
[sci] sections in the
config.ini file explicitly define SCI
(Scalable Coherent Interface) connections between cluster nodes.
Using SCI transporters in MySQL Cluster is supported only when
the MySQL binaries are built using
--with-ndb-sci=.
The /your/path/to/SCIpath should point to a directory
that contains at a minimum lib and
include directories containing SISCI
libraries and header files. (See
Section 17.11, “Using High-Speed Interconnects with MySQL Cluster” for more
information about SCI.)
In addition, SCI requires specialized hardware.
It is strongly recommended to use SCI Transporters only for communication between ndbd processes. Note also that using SCI Transporters means that the ndbd processes never sleep. For this reason, SCI Transporters should be used only on machines having at least two CPUs dedicated for use by ndbd processes. There should be at least one CPU per ndbd process, with at least one CPU left in reserve to handle operating system activities.
To identify a connection between two nodes it is necessary to provide node identifiers for each of them, as
NodeId1andNodeId2.This identifies the SCI node ID on the first Cluster node (identified by
NodeId1).It is possible to set up SCI Transporters for failover between two SCI cards which then should use separate networks between the nodes. This identifies the node ID and the second SCI card to be used on the first node.
This identifies the SCI node ID on the second Cluster node (identified by
NodeId2).When using two SCI cards to provide failover, this parameter identifies the second SCI card to be used on the second node.
Each SCI transporter has a shared memory segment used for communication between the two nodes. Setting the size of this segment to the default value of 1MB should be sufficient for most applications. Using a smaller value can lead to problems when performing many parallel inserts; if the shared buffer is too small, this can also result in a crash of the ndbd process.
A small buffer in front of the SCI media stores messages before transmitting them over the SCI network. By default, this is set to 8KB. Our benchmarks show that performance is best at 64KB but 16KB reaches within a few percent of this, and there was little if any advantage to increasing it beyond 8KB.
To trace a distributed message it is necessary to identify each message uniquely. When this parameter is set to
Y, message IDs are transported over the network. This feature is disabled by default in production builds, and enabled in-debugbuilds.This parameter is a boolean value, and is disabled by default. When
Checksumis enabled, checksums are calculated for all messages before they are placed in the send buffer. This feature prevents messages from being corrupted while waiting in the send buffer. It also serves as a check against data being corrupted during transport.
The next three sections provide summary tables of MySQL Cluster
configuration parameters used in the
config.ini file to govern the cluster's
functioning. Each table lists the parameters for one of the
Cluster node process types (ndbd,
ndb_mgmd, and mysqld), and
includes the parameter's type as well as its default, mimimum, and
maximum values as applicable.
It is also stated what type of restart is required (node restart
or system restart) — and whether the restart must be done
with --initial — to change the value of a
given configuration parameter. This information is provided in
each table's Restart Type column,
which contains one of the values shown in this list:
N: Node RestartIN: Initial Node RestartS: System RestartIS: Initial System Restart
When performing a node restart or an initial node restart, all of
the cluster's data nodes must be restarted in turn (also referred
to as a rolling restart). It is possible to
update cluster configuration parameters marked
N or IN online — that
is, without shutting down the cluster — in this fashion. An
initial node restart requires restarting each
ndbd process with the
--initial option.
A system restart requires a complete shutdown and restart of the entire cluster. An initial system restart requires taking a backup of the cluster, wiping the cluster file system after shutdown, and then restoring from the backup following the restart.
In any cluster restart, all of the cluster's management servers must be restarted in order for them to read the updated configuration parameter values.
Important
Values for numeric cluster parameters can generally be increased without any problems, although it is advisable to do so progressively, making such adjustments in relatively small increments. However, decreasing the values of such parameters — particularly those relating to memory usage and disk space — is not to be undertaken lightly, and it is recommended that you do so only following careful planning and testing. In addition, it is the generally the case that parameters relating to memory and disk usage which can be raised using a simple node restart require an initial node restart to be lowered.
Because some of these parameters can be used for configuring more than one type of cluster node, they may appear in more than one of the tables.
Note
4294967039 — which often appears as a
maximum value in these tables — is defined in the
NDBCLUSTER sources as
MAX_INT_RNIL and is equal to
0xFFFFFEFF, or
232 –
28 – 1.
The following table provides information about parameters used
in the [ndbd] or [ndbd
default] sections of a config.ini
file for configuring MySQL Cluster data nodes. For detailed
descriptions and other additional information about each of
these parameters, see
Section 17.3.4.6, “Defining MySQL Cluster Data Nodes”.
Beginning with MySQL Cluster NDB 6.4.0, these parameters also apply to ndbmtd, which is a multi-threaded version of ndbd. For more information, see Section 17.6.3, “ndbmtd — The MySQL Cluster Data Node Daemon (Multi-Threaded)”.
Restart Type Column Values
N: Node RestartIN: Initial Node RestartS: System RestartIS: Initial System Restart
See Section 17.3.5, “Overview of MySQL Cluster Configuration Parameters”, for additional explanations of these abbreviations.
Table 17.1. MySQL Cluster Data Node Configuration Parameters
| Parameter Name | Type/Units | Default Value | Minimum Value | Maximum Value | Restart Type |
ArbitrationTimeout | milliseconds | 3000 | 10 | 4294967039 | N |
BackupDataBufferSize | bytes | MySQL Cluster 6.4.3 and earlier: 2M; MySQL Cluster NDB 7.0.4 and later: 16M | 0 | 4294967039 | N |
BackupDataDir | string | | N/A | N/A | IN |
BackupLogBufferSize | bytes | MySQL Cluster 6.4.3 and earlier: 2M; MySQL Cluster NDB 7.0.4 and later: 16M | 0 | 4294967039 | N |
BackupMemory | bytes | MySQL Cluster 6.4.3 and earlier: 4M; MySQL Cluster NDB 7.0.4 and later: 32M | 0 | 4294967039 | N |
BackupReportFrequency
(Added in MySQL Cluster NDB 6.2.3) | seconds | 0 | 0 | 4294967039 | N |
BackupWriteSize | bytes | MySQL Cluster 6.4.3 and earlier: 32K; MySQL Cluster NDB 7.0.4 and later: 256K | 2K | 4294967039 | N |
BackupMaxWriteSize | bytes | MySQL Cluster 6.4.3 and earlier: 256K; MySQL Cluster NDB 7.0.4 and later: 1M | 2K | 4294967039 | N |
BatchSizePerLocalScan | integer | 64 | 1 | 992 | N |
CompressedBackup
(Added in MySQL Cluster NDB 6.3.7) | boolean | 0 | 0 | 1 | N |
CompressedLCP
(Added in MySQL Cluster NDB 6.3.7) | boolean | 0 | 0 | 1 | N |
DataDir | string | . | N/A | N/A | IN |
DataMemory | bytes | 80M | 1M | 1024G (subject to available system RAM and size of
IndexMemory) | N |
DiskCheckpointSpeed
(added in MySQL 5.1.12) | integer (number of bytes per second) | 10M | 1M | 4294967039 | N |
DiskCheckpointSpeedInRestart
(added in MySQL 5.1.12) | integer (number of bytes per second) | 100M | 1M | 4294967039 | N |
DiskIOThreadPool
(Added in MySQL Cluster NDB 6.4.0; named
ThreadPool prior to MySQL Cluster NDB
6.4.3) | integer | 8 | 0 | 4294967039 | N |
Diskless | true|false (1|0) | 0 | 0 | 1 | IS |
DiskPageBufferMemory
(added in MySQL 5.1.6) | bytes | 64M | 4M | 1024G | N |
DiskSyncSize
(added in MySQL 5.1.12) | integer (number of bytes) | 4M | 32K | 4294967039 | N |
ExecuteOnComputer | integer | ||||
FileSystemPath
(Added in MySQL Cluster NDB 6.1.11) | string (directory path) | value specified for DataDir | N/A | N/A | IN |
FileSystemPathDD
(Added in MySQL Cluster NDB 6.2.17, 6.3.22, and 6.4.3) | string (directory path) | value specified for FilesystemPath, if set;
otherwise, value of DataDir | N/A | N/A | IN |
FileSystemPathDataFiles
(Added in MySQL Cluster NDB 6.2.17, 6.3.22, and 6.4.3) | string (directory path) | value specified for FilesystemPathDD, if set;
otherwise, value specified for
FilesystemPath, if set; otherwise,
value of DataDir | N/A | N/A | IN |
FileSystemPathUndoFiles
(Added in MySQL Cluster NDB 6.2.17, 6.3.22, and 6.4.3) | string (directory path) | value specified for FilesystemPathDD, if set;
otherwise, value specified for
FilesystemPath, if set; otherwise,
value of DataDir | N/A | N/A | IN |
FragmentLogFileSize | integer (bytes) | 16M | 4M | 1G | IN |
HeartbeatIntervalDbApi | milliseconds | 1500 | 100 | 4294967039 | N |
HeartbeatIntervalDbDb | milliseconds | 1500 | 10 | 4294967039 | N |
HostName | string | localhost | N/A | N/A | S |
Id | integer | None | 1 | 48 | IS |
IndexMemory | bytes | 18M | 1M | 1024G (subject to available system RAM and size of
DataMemory) | N |
InitFragmentLogFiles
(Added in MySQL Cluster NDB 6.3.19) | string | full | sparse | sparse | IN |
InitialLogFileGroup
(Added in MySQL Cluster NDB 6.2.17, 6.3.22, and 6.4.3) | string (see description for details) | none | N/A | N/A | S |
InitialNoOfOpenFiles | integer | 27 | 20 | 4294967039 | N |
InitialTablespace
(Added in MySQL Cluster NDB 6.2.17, 6.3.22, and 6.4.3) | string (see description for details) | none | N/A | N/A | S |
LockExecuteThreadToCPU
(Added in MySQL Cluster NDB 6.3.4; changed in MySQL
Cluster NDB 7.0) | MySQL Cluster NDB 6.3 and earlier: integer; MySQL Cluster NDB 7.0 and later: string | MySQL Cluster NDB 6.4.3 and earlier: 65535; MySQL Cluster NDB 7.0 and later: N/A | MySQL Cluster NDB 6.4.3 and earlier: 0; MySQL Cluster NDB 7.0 and later: N/A | MySQL Cluster NDB 6.4.3 and earlier: 65535; MySQL Cluster NDB 7.0 and later: N/A | N |
LockMaintThreadsToCPU
(Added in MySQL Cluster NDB 6.3.4) | integer | MySQL Cluster NDB 6.3: 65535; MySQL Cluster NDB 7.0 and later: N/A | 0 | 65535 | N |
LockPagesInMainMemory | As of MySQL 5.1.15 and MySQL Cluster NDB 6.1.1:
integer; previously: true|false
(1|0) | 0 | 0 | As of MySQL 5.1.15 and MySQL Cluster NDB 6.1.1: 2; previously: 1 | N |
LogLevelCheckpoint | integer | 0 | 0 | 15 | IN |
LogLevelCongestion | integer | 0 | 0 | 15 | N |
LogLevelConnection | integer | 0 | 0 | 15 | N |
LogLevelError | integer | 0 | 0 | 15 | N |
LogLevelInfo | integer | 0 | 0 | 15 | N |
LogLevelNodeRestart | integer | 0 | 0 | 15 | N |
LogLevelShutdown | integer | 0 | 0 | 15 | N |
LogLevelStartup | integer | 1 | 0 | 15 | N |
LogLevelStatistic | integer | 0 | 0 | 15 | N |
LongMessageBuffer | bytes | 1M | MySQL Cluster 6.4.3 and earlier: 1M; MySQL Cluster NDB 7.0.4 and later: 4M | 4294967039 | N |
MaxAllocate
(Added in MySQL Cluster NDB 6.1.12 and MySQL Cluster NDB
6.2.3) | integer (bytes) | 32M | 1M | 1G | N |
MaxBufferedEpochs
(Added in MySQL Cluster NDB 6.2.14) | integer | 100 | 0 | 100000 | N |
MaxLCPStartDelay
(Added in MySQL Cluster NDB 6.3.23 and MySQL Cluster NDB
6.4.3) | integer (seconds) | 0 | 0 | 600 | N |
MaxNoOfAttributes | integer | 1000 | 32 | 4294967039 | N |
MaxNoOfConcurrentIndexOperations | integer | 8K | 0 | 4294967039 | N |
MaxNoOfConcurrentOperations | integer | 32768 | 32 | 4294967039 | N |
MaxNoOfConcurrentScans | integer | 256 | 2 | 500 | N |
MaxNoOfConcurrentTransactions | integer | 4096 | 32 | 4294967039 | S |
MaxNoOfExecutionThreads
(added in MySQL Cluster NDB 6.4.0; applies to
ndbmtd only) | integer | (as of MySQL Cluster NDB 7.0.4:) 2 (previously: none) | 2 | 8 | N |
MaxNoOfFiredTriggers | integer | 4000 | 0 | 4294967039 | N |
MaxNoOfIndexes
(DEPRECATED — use
MaxNoOfOrderedIndexes or
MaxNoOfUniqueHashIndexes instead) | integer | 128 | 0 | 4294967039 | N |
MaxNoOfLocalOperations | integer | UNDEFINED | 32 | 4294967039 | N |
MaxNoOfLocalScans | integer | UNDEFINED (see
description) | 32 | 4294967039 | N |
MaxNoOfOpenFiles | integer | 0 (prior to MySQL 5.1.16: 40) | 20 | 4294967039 | N |
MaxNoOfOrderedIndexes | integer | 128 | 0 | 4294967039 | N |
MaxNoOfSavedMessages | integer | 25 | 0 | 4294967039 | N |
MaxNoOfTables | integer | 128 | 8 | 4294967039 | N |
MaxNoOfTriggers | integer | 768 | 0 | 4294967039 | N |
MaxNoOfUniqueHashIndexes | integer | 64 | 0 | 4294967039 | N |
MemReportFrequency
(Added in MySQL 5.1.16 and MySQL Cluster NDB 6.1.0) | integer (seconds) | 0 | 0 | 4294967039 | N |
NodeGroup
(Added in MySQL Cluster NDB 6.4.0) | integer | UNDEFINED (normally determined by management server) | 0 | 65535 | SI |
NoOfDiskPagesToDiskAfterRestartACC
(DEPRECATED as of MySQL 5.1.6) | integer (number of 8KB pages per 100 milliseconds) | 20 (= 20 * 80KB = 1.6MB/second) | 1 | 4294967039 | N |
NoOfDiskPagesToDiskAfterRestartTUP
(DEPRECATED as of MySQL 5.1.6) | integer (number of 8KB pages per 100 milliseconds) | 40 (= 40 * 80KB = 3.2MB/second) | 1 | 4294967039 | N |
NoOfDiskPagesToDiskDuringRestartACC
(DEPRECATED as of MySQL 5.1.6) | integer (number of 8KB pages per 100 milliseconds) | 20 (= 20 * 80KB = 1.6MB/second) | 1 | 4294967039 | N |
NoOfDiskPagesToDiskDuringRestartTUP
(DEPRECATED as of MySQL 5.1.6) | integer (number of 8KB pages per 100 milliseconds) | 40 (= 40 * 80KB = 3.2MB/second) | 1 | 4294967039 | N |
NoOfFragmentLogFiles | integer | 16 | 3 | 4294967039 | IN |
NoOfReplicas | integer | None | 1 | 4 (theoretical); 2 (supported) | IS |
ODirect | boolean | 0 | 0 | 1 | N |
RealTimeScheduler
(Added in MySQL Cluster NDB 6.3.4) | boolean | 0 | 0 | 1 | N |
RedoBuffer | bytes | MySQL Cluster 6.4.3 and earlier: 8M; MySQL Cluster NDB 7.0.4 and later: 32M | 1M | 4294967039 | N |
ReservedSendBufferMemory
(added in MySQL Cluster NDB 6.4.0) | bytes | None | 256K | 4294967039 | N |
RestartOnErrorInsert
(DEBUG BUILDS ONLY) | true|false (1|0) | 0 | 0 | 1 | N |
SchedulerExecutionTimer
(added in MySQL Cluster NDB 6.3.4) | μseconds (integer) | 50 | 0 | 11000 | N |
SchedulerSpinTimer
(added in MySQL Cluster NDB 6.3.4) | μseconds (integer) | 0 | 0 | 500 | N |
ServerPort
(OBSOLETE) | integer | 1186 | 0 | 4294967039 | N |
SharedGlobalmemory
(added in MySQL 5.1.6) | bytes | 20M | 0 | 65536G | N |
StartFailureTimeout | milliseconds | 0 | 0 | 4294967039 | N |
StartPartialTimeout | milliseconds | 30000 | 0 | 4294967039 | N |
StartPartitionedTimeout | milliseconds | 60000 | 0 | 4294967039 | N |
StopOnError | true|false (1|0) | 1 | 0 | 1 | N |
StringMemory | integer or percentage (see description for details) | 0 | 0 | 4294967039 | S |
TcpBind_INADDR_ANY
(Added in MySQL Cluster NDB 6.2.0) | true|false (1|0) | 1 | 0 | 0 | N |
TimeBetweenEpochs
(Added in MySQL Cluster NDB 6.2.5 and MySQL Cluster NDB
6.3.2) | milliseconds | 100 | 0 | 32000 | N |
TimeBetweenEpochsTimeout
(Added in MySQL Cluster NDB 6.2.7 and MySQL Cluster NDB
6.3.4) | milliseconds | 4000 | 0 | 32000 | N |
TimeBetweenGlobalCheckpoints | milliseconds | 2000 | 10 | 32000 | N |
TimeBetweenInactiveTransactionAbortCheck | milliseconds | 1000 | 1000 | 4294967039 | N |
TimeBetweenLocalCheckpoints | integer (number of 4-byte words as a base-2 logarithm) | 20 (= 4 * 220 = 4MB write
operations) | 0 | 31 | N |
TimeBetweenWatchDogCheck | milliseconds | 6000 | 70 | 4294967039 | N |
TimeBetweenWatchDogCheckInitial
(added in MySQL 5.1.20) | milliseconds | 6000 | 70 | 4294967039 | N |
TotalSendBufferMemory
(added in MySQL Cluster NDB 6.4.0) | bytes | None | 256K | 4294967039 | N |
TransactionBufferMemory | bytes | 1M | 1K | 4294967039 | N |
TransactionDeadlockDetectionTimeout | milliseconds | 1200 | 50 (Note: Prior to MySQL Cluster NDB 6.2.18/6.3.24/7.0.5, 100 was the effective minimum.) | 4294967039 | N |
TransactionInactiveTimeout | milliseconds | 0 | 0 | 4294967039 | N |
UndoDataBuffer
(OBSOLETE) | bytes | 16M | 1M | 4294967039 | N |
UndoIndexBuffer
(OBSOLETE) | bytes | 2M | 1M | 4294967039 | N |
Note
To add new data nodes to a MySQL Cluster, it is necessary to
shut down the cluster completely, update the
config.ini file, and then restart the
cluster (that is, you must perform a system restart). All data
node processes must be started with the
--initial option.
Beginning in MySQL Cluster NDB 7.0, it is possible to add new data node groups to a running cluster online. For more information, see Section 17.7.8, “Adding MySQL Cluster Data Nodes Online”.
The following table provides information about parameters used
in the [ndb_mgmd] or [mgm]
sections of a config.ini file for
configuring MySQL Cluster management nodes. For detailed
descriptions and other additional information about each of
these parameters, see
Section 17.3.4.5, “Defining a MySQL Cluster Management Server”.
Restart Type Column Values
N: Node RestartIN: Initial Node RestartS: System RestartIS: Initial System Restart
See Section 17.3.5, “Overview of MySQL Cluster Configuration Parameters”, for additional explanations of these abbreviations.
Table 17.2. MySQL Cluster Management Node Configuration Parameters
| Parameter Name | Type/Units | Default Value | Minimum Value | Maximum Value | Restart Type |
ArbitrationDelay | milliseconds | 0 | 0 | 4294967039 | N |
ArbitrationRank | integer | 1 | 0 | 2 | N |
DataDir | string | ./ (ndb_mgmd directory) | N/A | N/A | IN |
ExecuteOnComputer | integer | ||||
HostName | string | localhost | N/A | N/A | IN |
Id | integer | None | 1 | (MySQL Cluster NDB 6.1.0 and earlier:) 63; (MySQL Cluster NDB 6.1.1 and later:) 255 | IS |
LogDestination | CONSOLE, SYSLOG, or
FILE | FILE (see
Section 17.3.4.5, “Defining a MySQL Cluster Management Server”) | N/A | N/A | N |
PortNumber | integer | 1186 | 1 | 65535 | S |
TotalSendBufferMemory
(added in MySQL Cluster NDB 6.4.0) | bytes | None | 256K | 4294967039 | N |
Note
After making changes in a management node's configuration, it is necessary to perform a rolling restart of the cluster in order for the new configuration to take effect. See Section 17.3.4.5, “Defining a MySQL Cluster Management Server”, for more information.
To add new management servers to a running MySQL Cluster, it
is also necessary perform a rolling restart of all cluster
nodes after modifying any existing
config.ini files. For more information
about issues arising when using multiple management nodes, see
Section 17.12.10, “Limitations Relating to Multiple MySQL Cluster Nodes”.
The following table provides information about parameters used
in the [SQL] and [api]
sections of a config.ini file for
configuring MySQL Cluster SQL nodes and API nodes. For detailed
descriptions and other additional information about each of
these parameters, see
Section 17.3.4.7, “Defining SQL and Other API Nodes in a MySQL Cluster”.
Note
For a discussion of MySQL server options for MySQL Cluster, see Section 17.4.2, “mysqld Command Options for MySQL Cluster”; for information about MySQL server system variables relating to MySQL Cluster, see Section 17.4.3, “MySQL Cluster System Variables”.
Restart Type Column Values
N: Node RestartIN: Initial Node RestartS: System RestartIS: Initial System Restart
See Section 17.3.5, “Overview of MySQL Cluster Configuration Parameters”, for additional explanations of these abbreviations.
Table 17.3. MySQL Cluster SQL Node and API Node Configuration Parameters
| Parameter Name | Type/Units | Default Value | Minimum Value | Maximum Value | Restart Type |
ArbitrationDelay | milliseconds | 0 | 0 | 4294967039 | N |
ArbitrationRank | integer | 0 | 0 | 2 | N |
BatchByteSize | bytes | 32K | 1K | 1M | N |
BatchSize | integer | 64 | 1 | 992 | N |
ExecuteOnComputer | integer | ||||
HostName | string | none | N/A | N/A | IN |
Id | integer | None | 1 | (MySQL Cluster NDB 6.1.0 and earlier:) 63; (MySQL Cluster NDB 6.1.1 and later:) 255 | IS |
MaxScanBatchSize | bytes | 256K | 32K | 16M | N |
TotalSendBufferMemory
(added in MySQL Cluster NDB 6.4.0) | bytes | None | 256K | 4294967039 | N |
Note
To add new SQL or API nodes to the configuration of a running
MySQL Cluster, it is necessary to perform a rolling restart of
all cluster nodes after adding new [mysqld]
or [api] sections to the
config.ini file (or files, if you are
using more than one management server). This must be done
before the new SQL or API nodes can connect to the cluster.
It is not necessary to perform any restart of the cluster if new SQL or API nodes can employ previously unused API slots in the cluster configuration to connect to the cluster.
The parameters discussed in
Logging
and Checkpointing and in
Data
Memory, Index Memory, and String Memory that are used to
configure local checkpoints for a MySQL Cluster do not exist in
isolation, but rather are very much interdepedent on each other.
In this section, we illustrate how these parameters —
including DataMemory,
IndexMemory,
NoOfDiskPagesToDiskAfterRestartTUP,
NoOfDiskPagesToDiskAfterRestartACC, and
NoOfFragmentLogFiles — relate to one
another in a working Cluster.
Important
The parameters
NoOfDiskPagesToDiskAfterRestartTUP and
NoOfDiskPagesToDiskAfterRestartACC were
deprecated in MySQL 5.1.6. From MySQL 5.1.6 through 5.1.11, disk
writes during LCPs took place at the maximum speed possible.
Beginning with MySQL 5.1.12, the speed and throughput for LCPs
are controlled using the parameters
DiskSyncSize,
DiskCheckpointSpeed, and
DiskCheckpointSpeedInRestart. See
Section 17.3.4.6, “Defining MySQL Cluster Data Nodes”.
In this example, we assume that our application performs the following numbers of types of operations per hour:
50000 selects
15000 inserts
15000 updates
15000 deletes
We also make the following assumptions about the data used in the application:
We are working with a single table having 40 columns.
Each column can hold up to 32 bytes of data.
A typical
UPDATErun by the application affects the values of 5 columns.No
NULLvalues are inserted by the application.
A good starting point is to determine the amount of time that should elapse between local checkpoints (LCPs). It is worth noting that, in the event of a system restart, it takes 40-60 percent of this interval to execute the REDO log — for example, if the time between LCPs is 5 minutes (300 seconds), then it should take 2 to 3 minutes (120 to 180 seconds) for the REDO log to be read.
The maximum amount of data per node can be assumed to be the size
of the DataMemory parameter. In this example,
we assume that this is 2 GB. The
NoOfDiskPagesToDiskAfterRestartTUP parameter
represents the amount of data to be checkpointed per unit time
— however, this parameter is actually expressed as the
number of 8K memory pages to be checkpointed per 100 milliseconds.
2 GB per 300 seconds is approximately 6.8 MB per second, or 700 KB
per 100 milliseconds, which works out to roughly 85 pages per 100
milliseconds.
Similarly, we can calculate
NoOfDiskPagesToDiskAfterRestartACC in terms of
the time for local checkpoints and the amount of memory required
for indexes — that is, the IndexMemory.
Assuming that we allow 512 MB for indexes, this works out to
approximately 20 8-KB pages per 100 milliseconds for this
parameter.
Next, we need to determine the number of REDO log files required
— that is, fragment log files — the corresponding
parameter being NoOfFragmentLogFiles. We need
to make sure that there are sufficient REDO log files for keeping
records for at least 3 local checkpoints (in MySQL Cluster NDB
6.3.8 and later, we need only allow for 2 local checkpoints). In a
production setting, there are always uncertainties — for
instance, we cannot be sure that disks always operate at top speed
or with maximum throughput. For this reason, it is best to err on
the side of caution, so we double our requirement and calculate a
number of fragment log files which should be enough to keep
records covering 6 local checkpoints (in MySQL Cluster NDB 6.3.8
and later, a number of fragment log files accommodating 4 local
checkpoints should be sufficient).
It is also important to remember that the disk also handles writes
to the REDO log, so if you find that the amount of data being
written to disk as determined by the values of
NoOfDiskPagesToDiskAfterRestartACC and
NoOfDiskPagesToDiskAfterRestartTUP is
approaching the amount of disk bandwidth available, you may wish
to increase the time between local checkpoints.
Given 5 minutes (300 seconds) per local checkpoint, this means that we need to support writing log records at maximum speed for 6 * 300 = 1800 seconds (MySQL Cluster NDB 6.3.8 and later: 4 * 300 = 1200 seconds). The size of a REDO log record is 72 bytes plus 4 bytes per updated column value plus the maximum size of the updated column, and there is one REDO log record for each table record updated in a transaction, on each node where the data reside. Using the numbers of operations set out previously in this section, we derive the following:
50000 select operations per hour yields 0 log records (and thus 0 bytes), since
SELECTstatements are not recorded in the REDO log.15000
DELETEstatements per hour is approximately 5 delete operations per second. (Since we wish to be conservative in our estimate, we round up here and in the following calculations.) No columns are updated by deletes, so these statements consume only 5 operations * 72 bytes per operation = 360 bytes per second.15000
UPDATEstatements per hour is roughly the same as 5 updates per second. Each update uses 72 bytes, plus 4 bytes per column * 5 columns updated, plus 32 bytes per column * 5 columns — this works out to 72 + 20 + 160 = 252 bytes per operation, and multiplying this by 5 operation per second yields 1260 bytes per second.15000
INSERTstatements per hour is equivalent to 5 insert operations per second. Each insert requires REDO log space of 72 bytes, plus 4 bytes per record * 40 columns, plus 32 bytes per column * 40 columns, which is 72 + 160 + 1280 = 1512 bytes per operation. This times 5 operations per second yields 7560 bytes per second.
So the total number of REDO log bytes being written per second is
approximately 0 + 360 + 1260 + 7560 = 9180 bytes. Multiplied by
1800 seconds, this yields 16524000 bytes required for REDO
logging, or approximately 15.75 MB. The unit used for
NoOfFragmentLogFiles represents a set of 4
16-MB log files — that is, 64 MB. Thus, the minimum value
(3) for this parameter is sufficient for the scenario envisioned
in this example, since 3 times 64 = 192 MB, or about 12 times what
is required; the default value of 8 (or 512 MB) is more than ample
in this case.
Formerly, the NDB kernel used a send buffer whose size was fixed at 2MB for every node in the cluster, which was allocated when the node started. Because the size of this buffer could not be changed after the cluster was started, it was necessary to make it large enough in advance to accomodate the maximum possible load on any transporter socket. However, this was an inefficient use of memory, since much of it often went unused, and could result in large amounts of resources being wasted when scaling up to many API nodes.
Beginning with MySQL Cluster NDB 7.0, this problem is solved by employing a unified send buffer whose memory is allocated dynamically from a pool shared by all transporters. This means that the size of the send buffer can be adjusted as necessary. Configuration of the unified send buffer can accomplished by setting the following parameters:
TotalSendBufferMemory. This parameter can be set for all types of MySQL Cluster nodes — that is, it can be set in the[ndbd],[mgm], and[api](or[mysql]) sections of theconfig.inifile. It represents the total amount of memory (in bytes) to be allocated by each node for which it is set for use among all configured transporters. If set, its minimum is 256K; the maximum is 4294967039.In order to be backward-compatible with existing configurations, this parameter takes as its default value the sum of the maximum send buffer sizes of all configured transporters, plus an additional 32KB (one page) per transporter. The maximum depends on the type of transporter, as shown in the following table:
Transporter Maxmimum Send Buffer Size (bytes) TCP SendBufferMemory(default = 2M)SCI SendLimit(default = 8K) plus 16KSHM 20K This allows existing configurations to function in close to the same way as they did with MySQL Cluster NDB 6.3 and earlier, with the same amount of memory and send buffer space available to each transporter. However, memory that is unused by one transporter is not available to other transporters.
ReservedSendBufferMemory. This optional data node parameter, if set, gives an amount of memory (in bytes) that is reserved for connections between data nodes; this memory is not allocated to send buffers used for communications with management servers or API nodes. This provides a way to protect the cluster against misbehaving API nodes that use excess send memory and thus cause failures in communications internally in the NDB kernel. If set, its the minimum permitted value for this parameters is 256K; the maximum is 4294967039.OverloadLimit. This parameter is used in theconfig.inifile[tcp]section, and denotes the amount of unsent data (in bytes) that must be present in the send buffer before the connection is considered overloaded. When such an overload condition occurs, transactions that affect the overloaded connection fail with NDB API Error 1218 (Send Buffers overloaded in NDB kernel) until the overload status passes. The default value is 0; there is no defined maximum value for this parameter.SendBufferMemory. In MySQL Cluster NDB 6.3 and earlier, this TCP configuration parameter represented the amount of memory allocated at startup for each configured TCP connection. Beginning with MySQL Cluster NDB 7.0, this value denotes a hard limit for how much memory (out of the total available — that is,TotalSendBufferMemory) that may be used by a single transporter. However, the sum ofTotalSendBufferMemoryfor all configured transporters may be greater thanSendBufferMemory. This is a way to save memory when many nodes are in use, as long as the maximum amount of memory is never required by all transporters at the same time.
This section provides information about MySQL server options, server and status variables that are specific to MySQL Cluster. For general information on using these, and for other options and variables not specific to MySQL Cluster, see Section 5.1, “The MySQL Server”.
For MySQL Cluster configuration parameters used in the cluster
confiuration file (usually named config.ini),
see Section 17.3, “MySQL Cluster Configuration”.
The following table provides a list of the command-line options,
server and status variables applicable within
mysqld when it is running as an SQL node in a
MySQL Cluster. For a table showing all
command-line options, server and status variables available for
use with mysqld, see
Section 5.1.1, “Server Option and Variable Reference”.
Table 17.4. mysqld Command Options for MySQL Cluster
This section provides descriptions of mysqld server options relating to MySQL Cluster. For information about mysqld options not specific to MySQL Cluster, and for general information about the use of options with mysqld, see Section 5.1.2, “Server Command Options”.
For information about command-line options used with other MySQL
Cluster processes (ndbd,
ndb_mgmd, and ndb_mgm), see
Section 17.6.23, “Options Common to MySQL Cluster Programs”. For
information about command-line options used with
NDB utility programs (such as
ndb_desc, ndb_size.pl, and
ndb_show_tables), see
Section 17.6, “MySQL Cluster Programs”.
Version Introduced 5.1.23-ndb-6.3.8 Command Line Format --ndb-batch-sizeConfig File Format ndb-batch-sizeVariable Name ndb_batch_sizeVariable Scope Global Dynamic Variable No Value Set Type numericDefault 32768Range 0-31536000This sets the size in bytes that is used for NDB transaction batches.
--ndb-cluster-connection-pool=#Version Introduced 5.1.19-ndb-6.2.2 Command Line Format --ndb-cluster-connection-poolConfig File Format ndb-cluster-connection-poolVariable Name Ndb_cluster_connection_poolVariable Scope Global Dynamic Variable No Value Set Type numericDefault 1Range 1-63By setting this option to a value greater than 1 (the default), a mysqld process can use multiple connections to the cluster, effectively mimicking several SQL nodes. Each connection requires its own
[api]or[mysqld]section in the cluster configuration (config.ini) file, and counts against the maximum number of API connections supported by the cluster.For example, suppose that you have 2 cluster host computers, each running an SQL node whose mysqld process was started with
--ndb-cluster-connection-pool=4; this means that the cluster must have 8 API slots available for these connections (instead of 2). All of these connections are set up when the SQL node connects to the cluster, and are allocated to threads in a round-robin fashion.This option is useful only when running mysqld on host machines having multiple CPUs, multiple cores, or both. For best results, the value should be smaller than the total number of cores available on the host machine. Setting it to a value greater than this is likely to degrade performance severely.
Important
Because each SQL node using connection pooling occupies multiple API node slots — each slot having its own node ID in the cluster — you must not use a node ID as part of the cluster connect string when starting any mysqld process that employs connection pooling.
Setting a node ID in the connect string when using the
--ndb-cluster-connection-pooloption causes node ID allocation errors when the SQL node attempts to connect to the cluster.This option was introduced in MySQL Cluster NDB 6.2.2. Beginning with MySQL Cluster NDB 6.2.16 and MySQL Cluster NDB 6.3.13, the value used for this option is available as a global status variable (Bug#35573).
--ndb-connectstring=connect_stringCommand Line Format --ndb-connectstringConfig File Format ndb-connectstringValue Set Type stringWhen using the
NDBCLUSTERstorage engine, this option specifies the management server that distributes cluster configuration data. See Section 17.3.4.3, “The MySQL Cluster Connectstring”, for syntax.Command Line Format --ndbclusterConfig File Format ndbclusterValue Set Type booleanDefault FALSEThe
NDBCLUSTERstorage engine is necessary for using MySQL Cluster. If a mysqld binary includes support for theNDBCLUSTERstorage engine, the engine is disabled by default. Use the--ndbclusteroption to enable it. Use--skip-ndbclusterto explicitly disable the engine.Version Introduced 5.1.15 Command Line Format --ndb-nodeid=#Config File Format ndb-nodeidVariable Name Ndb_cluster_node_idVariable Scope Global Dynamic Variable No Value Set (>= 5.1.5) Type numericRange 1-255Set this MySQL server's node ID in a MySQL Cluster. This can be used instead of specifying the node ID as part of the connectstring or in the
config.inifile, or allowing the cluster to determine an arbitrary node ID. If you use this option, then--ndb-nodeidmust be specified before--ndb-connectstring. If--ndb-nodeidis used and a node ID is specified in the connectstring, then the MySQL server will not be able to connect to the cluster. In addition, if--nodeidis used, then either a matching node ID must be found in a[mysqld]or[api]section ofconfig.ini, or there must be an “open”[mysqld]or[api]section in the file (that is, a section without anIdparameter specified).Regardless of how the node ID is determined, its is shown as the value of the global status variable
Ndb_cluster_node_idin the output ofSHOW STATUS, and ascluster_node_idin theconnectionrow of the output ofSHOW ENGINE NDBCLUSTER STATUS.For more information about node IDs for MySQL Cluster SQL nodes, see Section 17.3.4.7, “Defining SQL and Other API Nodes in a MySQL Cluster”.
Command Line Format --skip-ndbclusterConfig File Format skip-ndbclusterDisable the
NDBCLUSTERstorage engine. This is the default for binaries that were built withNDBCLUSTERstorage engine support; the server allocates memory and other resources for this storage engine only if the--ndbclusteroption is given explicitly. See Section 17.3.3, “Quick Test Setup of MySQL Cluster”, for an example.
This section provides detailed information about MySQL server
system variables that are specific to MySQL Cluster and the
NDB storage engine. For system
variables not specific to MySQL Cluster, see
Section 5.1.4, “Server System Variables”. For general information
on using system variables, see
Section 5.1.6, “Using System Variables”.
Variable Name have_ndbclusterVariable Scope Global Dynamic Variable No Value Set Type booleanYESif mysqld supportsNDBCLUSTERtables.DISABLEDif--skip-ndbclusteris used.Command Line Format --multi_range_count=#Config File Format multi_range_countOption Sets Variable Yes, multi_range_countVariable Name multi_range_countVariable Scope Both Dynamic Variable Yes Value Set Type numericDefault 256Range 1-4294967295The maximum number of ranges to send to a table handler at once during range selects. The default value is 256. Sending multiple ranges to a handler at once can improve the performance of certain selects dramatically. This is especially true for the
NDBCLUSTERtable handler, which needs to send the range requests to all nodes. Sending a batch of those requests at once reduces communication costs significantly.This variable is deprecated in MySQL 5.1, and is no longer supported in MySQL 6.0, in which arbitrarily long lists of ranges can be processed.
Command Line Format --ndb_autoincrement_prefetch_szConfig File Format ndb_autoincrement_prefetch_szOption Sets Variable Yes, ndb_autoincrement_prefetch_szVariable Name ndb_autoincrement_prefetch_szVariable Scope Both Dynamic Variable Yes Value Set (<= 5.1.22) Type numericDefault 32Range 1-256Value Set (>= 5.1.23)