MySQL Cluster Core concept _ MySQL

Source: Internet
Author: User
MySQL Cluster Core concept Mysql Cluster

NDBCLUSTER(Also knownNDB) Is an in-memory storage engine offering high-availability and data-persistence features.

NDBCLUSTER (also called NDB) is a memory storage engine that provides high availability and data persistence features.

TheNDBCLUSTERStorage 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'sNDBStorage engine contains a complete set of data, dependent only on other data within the cluster itself.

The NDBCLUSTER storage engine can be configured with a series of failover and load balancing functions. However, it is also the most easy-to-start storage engine at the cluster level. The NDB storage engine of the MySQL Cluster contains a complete set of datasets, which only depends on other data in the cluster.

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 beNode.

The Cluster of the MySQL Cluster is independently configured on the MySQL service. In a MySQL Cluster, each part of the cluster is considered asNode).

Note

In our contexts, the term "node" is used to indicate a computer, but when discussing MySQL Cluster it meansProcess. 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 termCluster host.

Note:

In most cases, the term "node" is used to represent a computer, but when discussing a MySQL Cluster, it means a process. Multiple node nodes can be run on a single PC. one or more cluster nodes running on the PC are calledCluster 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:

There are three types of nodes in the cluster. in the minimal MySQL Cluster configuration, each type of node must have one or at least three nodes:

  • Management node: The role of this type of node is to manage the other nodes within the MySQL Cluster, please Ming 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 shoshould be started first, before any other node. an MGM node is started with the commandNdb_mgmd.

Management node): The task of this node is to manage other nodes in the MySQL Cluster. Execute functions such as providing configuration data, opening nodes, closing nodes, and running backups. This type of node manages the configurations of other nodes, so the node should be started before other nodes. An MGM node is started using the ndb_mgmd command.

  • Data node: This type of node stores cluster data. there are as your data nodes as there are replicas, times the number of fragments (seeSection 18.1.2, "MySQL Cluster Nodes, Node Groups, Replicas, and Partitions "). 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 commandNdbd(SeeSection 18.4.1,"Ndbd-The MySQL Cluster Data Node Daemon ") orNdbmtd(SeeSection 18.4.3,"Ndbmtd-The MySQL Cluster Data Node Daemon (Multi-Threaded )").

    MySQL Cluster tables are normally stored completely in memory rather than on disk (this is why we refer to MySQL Cluster asIn-memoryDatabase). However, some MySQL Cluster data can be stored on disk; seeSection 18.5.12, "MySQL Cluster Disk Data Tables", for more information.

Data node ):This type of node is used to store cluster data. Many data nodes have their copies, which is twice the size of the segment. For example, if two segments have two copies, you need four data nodes. A copy is sufficient for data storage, but it does not provide redundancy. Therefore, we recommend using two (or more) copies to provide redundancy for high availability. A data node is started using the ndbd or ndbmtd command.

MySQL Cluster tables are usually completely stored in the memory, rather than on the hard disk (that is why we call a MySQL Cluster A memory-based database ). However, some MySQL Cluster data can be stored on the hard disk.

  • 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 usesNDBCLUSTERStorage engine. An SQL node isMysqldProcess started with--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 typeAPI node, Which designates any application which accesses MySQL Cluster data. Another example of an API node isNdb_restoreUtility 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, seeGetting Started with the ndb api.

SQL node ):This type of node is used to access cluster data. For a MySQL Cluster, an SQL node is a traditional MySQL service that uses the NDBCLUSTER storage engine. An SQL node is a process started using the -- ndbcluster and -- ndb-connectstring parameters of the mysqld command. this option is explained elsewhere in this chapter, other MySQL service options can also be used.

An SQL node is actually justAPI nodeThis type of node specifies any application that can access MySQL Cluster data. Another example of API node is the node_restore function, which can be used to restore a cluster backup. It is possible to use NDB APIs to write applications. for basic information about NDB APIs, see Getting Started with the ndb api.

Important

It is not realistic to perform CT to employ a three-node setup in a production environment. such a configuration provides no redundancy; 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.

Importance:

It is unrealistic to set three nodes in the production environment. For example, to provide a non-redundant configuration; to make full use of the high availability of the MySQL Cluster, you must use multiple data and multi-SQL nodes. The use of multiple management nodes is also strongly recommended.

For a brief introduction to the relationships between nodes, node groups, replicas, and partitions in MySQL Cluster, seeSection 18.1.2, "MySQL Cluster Nodes, Node Groups, Replicas, and Partitions ".

For a brief introduction to the relationship between Nodes, Node Groups, Replicas, and Partitions in a MySQL Cluster, see Section 18.1.2, "MySQL Cluster Nodes, Node Groups, Replicas, and Partitions ".

Configuration of a cluster involves grouping each inpidual node in the cluster and setting up inpidual 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.

In a cluster, the cluster configuration includes configuring each individual node and setting a separate communication link between nodes. MySQL clusters are designed to evenly distribute data nodes based on the processor power, memory space, and bandwidth. In addition, for a single node that provides configuration, all the configuration data in the cluster is stored in a configuration file as a whole.

The management server 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.

The service manager manages cluster configuration files and logs. Every node in the cluster retrieves configuration data from the service manager. Therefore, you need to determine the location of the service manager in one way. When we focus on the events on the data node, for the service manager, the data node will transmit information about these events and then write the information to the cluster log.

In addition, there can be any number of cluster client processes or applications. These include standard MySQL clients,NDB-Specific API programs, and management clients. These are described in the next few paragraphs.

In addition, there are many cluster client processes or applications. They contain standard MySQL clients, NDB-specific API programs, and management clients. These will be described in the following sections.

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.

Standard MySQL client:The MySQL Cluster can be used with existing MySQL applications implemented in PHP, Perl, C, C ++, Java, Python, Ruby, and other languages. For example, if the client sends an SQL statement and receives a response from the MySQL server that uses the MySQL Cluster node as the proxy, the node interacts independently with the MySQL server in the same way.

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 usejdbc:mysql:loadbalance://URLs (improved in Connector/J 5.1.7) to achieve load balancing transparently; for more information about using Connector/J with MySQL Cluster, seeUsing Connector/J with MySQL Cluster.

The MySQL client uses the MySQL Cluster as a data source and uses its ability to be modified to achieve load balancing and failover with multiple MySQL servers. For example, the Java client uses ctor/J 5.0.6 and later jdbc: mysql: loadbalance: // URLs (improved in Connector/J 5.1.7) to achieve load balancing; for more information about Using ctor/J for MySQL clusters, see Using Connector/J with MySQL Cluster.

NDBClient programs.Client programs can be written that access MySQL Cluster data directly fromNDBCLUSTERStorage engine, bypassing any MySQL Servers that may be connected to the cluster, usingNDB API, A high-level C ++ API. Such applications may be useful for specialized purposes where an SQL interface to the data is not needed. For more information, seeThe NDB API.

NDB client program:The client program can be written to access MySQL Cluster data directly from the NDBCLUSTER storage engine, bypassing many MySQL servers that can connect to the cluster, usingNDB API, A high-level C ++ API.

Such an application is not required for the data. it may be useful for such a specific purpose. For more information, see The ndb api.

NDB-Specific Java applications can also be written for MySQL Cluster usingMySQL Cluster Connector for Java. This MySQL Cluster Connector includesClusterJ, A high-level database API similar to object-relational mapping persistence frameworks such as Hibernate and JPA that connect directlyNDBCLUSTER, And so does not require access to a MySQL Server. Support is also provided in MySQL Cluster NDB 7.1 and laterClusterJPA, An OpenJPA implementation for MySQL Cluster that leverages the strengths of ClusterJ and JDBC; ID lookups and other fast operations are running Med using ClusterJ (bypassing the MySQL Server ), while more complex queries that can benefit from MySQL's query optimizer are sent through the MySQL Server, using JDBC. seeJava and MySQL Cluster, andThe ClusterJ API and Data Object Model, for more information.

Java applications with NDB features can also useMySQL Cluster Connector forJavaCompile the MySQL Cluster. This MySQL Cluster connector includesClusterJA high-level database API directly connected to NDBCLUSTER, similar to the object-relational persistence layer framework of Hibernate and JPA, so it does not need to access the MySQL service. ForClusterJPAIt is also supported in MySQLCluster NDB 7.1 and later versions. OpenJPA utilizes the advantages of ClusterJ and JDBC to implement MySQL clusters. ID search and other quick operations are performed through ClusterJ (not through MySQLServer ), the more complex query is the benefit of the MySQL Query optimizer's sending operation through the MySQL service using JDBC. See Javaand MySQL Cluster, and The ClusterJ API and Data Object Model for more information.

MySQL Cluster NDB 7.3 also supports applications written in JavaScript using Node. js. The MySQL Connector for JavaScript des adapters for direct access toNDBStorage engine and as well as for the MySQL Server. applications using this Connector are typically event-driven and use a domain object model similar in ways to that employed by ClusterJ. for more information, seeMySQL NoSQL Connector for JavaScript.

MySQL Cluster NDB 7.3 also supports writing JavaScript using Node. js in applications. For JavaScript, the MySQL Connector contains an adapter that can directly access the NDB storage engine and MySQL service. Applications using this connector are generally event-driven and use a similar domain object model in multiple ways of the ClusterJ service. For more information, see MySQL NoSQL Connector for JavaScript.

The Memcache API for MySQL Cluster, implemented as the loadable NdbmemcacheStorage engine for memcached version 1.6 and later, can be used to provide a persistent MySQL Cluster data store, accessed using the memcache protocol.

For MySQL clusters, Memcached 1.6 and later versions can be loadedNdbmemcacheStorage Engine, which can be used to provide a persistent MySQL Cluster data storage and access through memcache protocol.

The standard MemcachedCaching engine is already Ded in the MySQL Cluster NDB 7.3 distribution. Each MemcachedServer has direct access to data stored in MySQL Cluster, but is also able to cache data locally and to serve (some) requests from this local cache.

StandardMemcachedThe cache engine is included in the MySQLCluster NDB 7.3 Distribution. In a MySQL ClusterMemcachedServices can directly access the stored data, but they can also request localized cache data and (some) services from the local cache.

For more information, see ndbmemcache-Memcache API for MySQL Cluster.

For more information, seendbmemcache-Memcache API for MySQL Cluster.

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. an example of this type of program is Ndb_mgmManagement client supplied with MySQL Cluster (seeSection 18.4.5," Ndb_mgm-The MySQL Cluster Management Client "). Such applications can be written using MGM API, A C-language API that communicates directly with one or more MySQL Cluster management servers. For more information, seeThe mgm api.

Management client:These clients connected to the management server provide commands for starting and stopping nodes, starting and stopping information tracing (debug version only), displaying node versions and statuses, starting and stopping backups, and so on. For example, a certain type of program provides the ndb_mgm management client in the MySQL Cluster (see Section 18.4.5,"Ndb_mgm-The MySQL ClusterManagement Client "). This program can useMGM APIA c language API can directly interact with one or more MySQL Cluster management servers. For more information, see The mgm api.

Oracle also makes available MySQL Cluster Manager, which provides an advanced command-line interface simplifying extends complex MySQL Cluster management tasks, such restarting a MySQL Cluster with a large number of nodes. the MySQL Cluster Manager client also supports commands for getting and setting the values of most node configuration parameters as wellMysqldServer options and variables relating to MySQL Cluster. MySQL Cluster Manager 1.1 provides support for adding data nodes online. See theMySQL Cluster Manager User Manual, for more information.

Oracle also provides the MySQL Cluster Manager, which provides an advanced command line interface to simplify complex MySQL Cluster management tasks, such as restarting a MySQL Cluster with a large number of nodes. The MySQL Cluster management client also supports commands to set and obtain the parameter values andMysqldService options and variables related to the MySQL Cluster. MySQL Cluster Manager Version 1.1 provides support for adding online data nodes. For more information, see MySQL Cluster Manager User Manual.

Event logs.MySQL Cluster logs events by category (startup, shutdown, errors, checkpoints, and so on), priority, and severity. A complete listing of all reportable events may be found inSection 18.5.6, "Event Reports Generated in MySQL Cluster ". event logs are of the two types listed here:

  • Cluster log: Keeps a record of all desired reportable events for the cluster as a whole.

  • Node log: A separate log which is also kept for each inpidual node.

Event Log:The MySQL Cluster generates logs by type (startup, shutdown, error, checkpoint, and so on), priority and severity events. You can find a complete listener for reporting events in Section 18.5.6, "Event Reports Generated in MySQL Cluster. There are two types of event logs:

LCluster log:For clusters, the cluster stores an expected Report event record as a whole.

LNode log:A single log maintains every single node.

Note

Under normal circumstances, it is necessary and sufficient to keep and examine only the cluster log. The node logs need be consulted only for application development and debugging purposes.

Note:

Generally, it is necessary to fully save and check cluster logs. Node logs are only checked for development and debugging purposes.

Checkpoint.Generally speaking, when data is saved to disk, it is said thatCheckpointHas been reached. More specific to MySQL Cluster, a checkpoint is a point in time where all committed transactions are stored on disk. With regard toNDBStorage engine, there are two types of checkpoints which work together to ensure that a consistent view of the cluster's data is maintained. These are shown in the following list:

Checkpoint:Generally, when the data is stored on the hard disk, the Checkpoint already exists. For MySQL clusters, a checkpoint is a point that stores transactions on the hard disk in a timely manner. For the NDB storage engine, these two types of checkpoints work together and ensure that the consistency view of cluster data is maintained. These are displayed in the following list:

Local Checkpoint (LCP): This is a checkpoint that is specific to a single node; however, LCPs take place for all nodes in the cluster more or less concurrently. an LCP involves saving all of a node's data to disk, and so usually occurs every few minutes. the precise interval varies, and depends upon the amount of data stored by the node, the level of cluster activity, and other factors.

LLocal checkpoint (LCP): This is a special checkpoint for a single node. However, LCPs occurs more or less simultaneously on all nodes of the cluster. An LCP involves all the data nodes on the hard disk, so it usually happens every few minutes. The precise time interval varies, and the node depends on a large amount of data stored. the cluster level is active or other factors.

Global Checkpoint (GCP): A gcp occurs every few seconds, when transactions for all nodes are synchronized and the redo-log is flushed to disk.

LGlobal checkpoint (GCP ):A gcp occurs every few seconds. at this time, transactions on all nodes are synchronized, and the overwritten logs are refreshed to the hard disk.

For more information about the files and directories created by local checkpoints and global checkpoints, seeMySQL Cluster Data NodeFileSystemDirFiles.

For more information about the files and directories created through local check points and global check points, see MySQL Cluster Data NodeFileSystemDirFiles

This article from http://dev.mysql.com/doc/refman/5.6/en/mysql-cluster-basics.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.