MySQL Cluster core concept

Source: Internet
Author: User
Tags failover memcached object model

MySQL Cluster Core Concepts

NDBCLUSTER(also known as NDB ) is an in-memory storage engine offering high-availability and data-persistence features.

Ndbcluster (also known as NDB) is an in-memory storage engine that provides high availability and data persistence characteristics.

NDBCLUSTERthe storage engine can be configured with a range of failover and load-balancing options, but it's easiest to start With the storage engine on the cluster level. MySQL Cluster ' s NDB storage engine contains a complete set of data, dependent only on other data within the Cluster Itsel F.

The Ndbcluster storage engine is capable of configuring a range of failover and load balancing functions, but it is also the easiest storage engine to start at the cluster level. The NDB storage engine for the MySQL cluster contains a complete set of data that relies only on other data in 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 are considered to be anode.

The cluster part of the MySQL cluster is configured independently on the MySQL service. In a MySQL cluster, each part of the cluster is considered to be a node.


Note

In many contexts, the term "node" was used to indicate a computer, but when discussing MySQL Cluster it m EANs aprocess. It is possible to run multiple nodes on a single computer; For a computer in which one or more cluster nodes is being run we use the termcluster host.


Annotations:

In most cases, the term node is used to represent a computer, but when discussing a MySQL cluster, it means a process. The ability to run multiple node nodes on a single PC, and one or more cluster nodes that are running on a PC, we often refer to him as a cluster host (cluster host).

There is three types of cluster nodes, and in a minimal MySQL cluster configuration, there would be is at least three nodes, One of each of these types:

There are three types of nodes in a cluster, and in a minimal MySQL cluster configuration, each type of node must have a minimum of three nodes:

    • Management node: The role of this type of node was 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 a NY other node. An MGM node was started with the commandNDB_MGMD.

Management nodes (Management node): The task of this node is primarily to manage other nodes in the MySQL cluster. Perform functions such as providing configuration data, opening nodes, shutting down nodes, running backups, and so on. Because this type of node manages the configuration of other nodes, the node should be started before other nodes. A MGM node is started by the NDB_MGMD command.


  • data node : This type of node stores cluster Data. There is as many data nodes as there is replicas, times the number of fragments (seesection 18.1.2, "MySQL Cluster Nodes, Node Groups, replicas, and partitions "). For example, with the replicas, each has a fragments, you need four data nodes. One replica is sufficient for data storage, but provides no redundancy; Therefore, it is recommended to has 2 (or more) replicas to provide redundancy, and thus high availability. A Data node is started with the Command ndbd (see section 18.4.1, " span class= "command" > ndbd -the MySQL Cluster Data Node Daemon ") or NDBMTD (See section 18.4.3, " NDBMTD -the MySQL Cluster Data Node Daemon ( Multi-threaded) ").

    MySQL Cluster tables be normally stored completely in memory rather than on disk (this is what we refer to MySQL Cluster a S anin-memory database). 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 of the data nodes have copies of them, which is one-fold of the segment. For example, there are two replicas per two segments, and you need four data nodes. For a data store, a copy is sufficient, 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 by using the NDBD or NDBMTD command.

MySQL cluster tables are usually completely stored in memory, not on the hard disk (which is why we refer to the MySQL cluster as an in-memory database). However, there are some MySQL cluster data that can be stored on the hard disk.

  • SQL node: This was a node that accesses the cluster data. In the case of MySQL Cluster, an SQL node is a traditional MySQL server that uses the NDBCLUSTER storage engine. An SQL node was a mysqld process started --ndbcluster --ndb-connectstring with the and options, which was explained elsewhere in this CH Apter, possibly with additional MySQL server options as well.

    An SQL node was actually just a specialized type of API node, which designates any application which accesses MYSQ L Cluster data. Another example of a API node is thendb_restore utility, that's used to restore a cluster backup. It is a possible to write such applications using the NDB API. For basic information on the NDB API, Seegetting Started with the NDB API.

SQL node: This node is used to access the cluster data. For a MySQL cluster, a SQL node is a traditional MySQL service that uses the Ndbcluster storage engine. A SQL node is a process that starts with the--ndbcluster and--ndb-connectstring parameters of the mysqld command, which is explained elsewhere in this chapter and can be done with other MySQL service options.

An SQL node is really just a dedicated type of API node that specifies any application that can access MySQL cluster data. Another example of API node is the Node_restore feature, which can be used to restore a cluster backup. It is possible to write an application using the NDB API, with 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; 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 use three nodes to set up in a production environment. For example, to provide a configuration that is not redundant, you must use multi-data and multi-SQL nodes to realize the benefits of high availability for MySQL clusters. 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, Seese Ction 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 the MySQL cluster, see section 18.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 communicatio n links between nodes. MySQL Cluster is currently designed with the intention that data nodes be 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 are located in O NE configuration file.

In a cluster, the configuration of the cluster consists of configuring each individual node and the need to set up separate communication links between the nodes. The current design intent of the MySQL cluster is to distribute the data nodes evenly based on processor power, memory space, and bandwidth. In addition, for a single node that provides configuration, all configuration data in the cluster is present as a whole on a configuration file.


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-to determine W Here the Management server resides. When interesting events occur in the data nodes, the nodes transfer information on these events to the management serve R, which then writes the information to the cluster log.

The Service Manager manages the configuration files and logs for the cluster. Each node in the cluster retrieves the configuration data from the Service Manager, so you need a way to determine where the service Manager is located. When we focus on events that occur on the data node, the data node transmits information about the events to the Service Manager, and then writes the information to the cluster log.


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

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

Standard MySQL clients. MySQL Cluster can 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-a-they interact with standalone MySQL servers.

standard MySQL client: The MySQL cluster can be used with existing MySQL applications implemented in languages such as Php,perl,c,c++,java,python,ruby. A client sends a SQL statement and receives a response from a MySQL server that is acting as a MySQL cluster node, which in the same way interacts with the MySQL server independently.


MySQL clients using a MySQL Cluster as a data source can be modified-take advantage of the ability-connect with mult Iple 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 L Oad balancing transparently; For more information about using the connector/j with MySQL Cluster, seeusing connector/j with MySQL Cluster.

The MySQL client uses the MySQL cluster as a data source, leveraging its ability to be modified to work with multiple MySQL servers to achieve load balancing and failover. For example, Java clients can use connector/j 5.0.6 and later use of jdbc:mysql:loadbalance://URLs (improved in connector/j 5.1.7) to realize load balancing For more information about using CONNECTOR/J with MySQL cluster, see Using connector/j with MySQL Cluster.


NDB client programs. Client programs can written that access MySQL Cluster data directly from NDBCLUSTER the storage engine and bypassing any MySQL S Ervers. Connected to the cluster, using theNDB API, a high-level C + + API. Such applications may being useful for specialized purposes where a SQL interface to the data are 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, using the NDB API, a high-level C + + API.

Such an application, for the data that the SQL interface is not required, may be useful through this specific purpose. To learn more, see the NDB API.


ndb -specific Java applications can also be written for MySQL Cluster using Themysql Cluster Connector for Java . This MySQL Cluster Connector includesclusterj , a high-level database API similar to Object-rel Ational mapping persistence frameworks such as Hibernate and JPA that connect directly tondbcluster< /code>, and so does not require access to a MySQL Server. Also provided in MySQL Cluster NDB 7.1 and later forclusterjpa , an OpenJPA implement ation for MySQL Cluster that leverages the strengths of CLUSTERJ and JDBC; ID lookups and other fast operations is performed using CLUSTERJ (bypassing the MySQL Server), while more complex queries That can benefit from MySQL ' s query optimizer is sent through the MySQL Server, using JDBC. Seejava and MySQL Cluster, and the Clusterj API and Data Object Model, for more information.

Java applications with the NDB feature can also use mysql Cluster Connector forjava to write MySQL clusters. This MySQL cluster connector includes Clusterj, a high-level database API that directly connects the Ndbcluster-like Hibernate and JPA Object-relational persistence layer framework, so it does not need to access the MySQL service. For CLUSTERJPA, the same support in Mysqlcluster NDB 7.1 and later releases, OPENJPA leverages the advantages of CLUSTERJ and JDBC to implement MySQL clusters. ID lookups and other quick actions are performed through CLUSTERJ (not through MySQLServer), while more complex queries are the benefit of the MySQL-based query optimizer's use of JDBC for sending operations through the MySQL service. See Javaand MySQL Cluster, and the Clusterj API and Data Object Model in order to get more information.

MySQL Cluster NDB 7.3 also supports applications written in JavaScript using node. js. The MySQL Connector for JavaScript includes adapters for direct access to the storage engine and as well as for the NDB M Ysql Server. Applications using this Connector is typically Event-driven and use a domain object model similar in many ways to that EM Ployed by Clusterj. For more information, Seemysql NoSQL Connector for JavaScript.

MySQL Cluster NDB 7.3 also supports programming JavaScript in applications with node. js. The Javascript,mysql connector contains adapters that can directly access the NDB storage engine and the MySQL service. Applications that use this connector are typically event-driven and use a similar domain object model in a variety of ways using the CLUSTERJ service. To learn more, 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 is used to provide a persistent MySQL Cluster data store, accessed Using the Memcache protocol.

For MySQL clusters, the Memcached 1.6 and later versions implement a loadable Ndbmemcache storage engine that can be used to provide a persistent MySQL cluster data store and access using the Memcache protocol.


The standard memcachedCaching engine is included in the MySQL Cluster NDB 7.3 distribution. each memcachedServer had direct access to data stored in MySQL Cluster, but was also able to cache data locally and to serve (some) reque STS from the This local cache.

The standard memcached cache engine is included in the Mysqlcluster NDB 7.3 distribution. In a MySQL cluster, each memcached service can access the stored data directly, but it 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, see ndbmemcache -memcache API for MySQL Cluster.


Management clients.These clients connect to the Management Server and provide commands for starting and stopping nodes gracefully, starting a ND stopping message tracing (Debug versions only), showing node versions and status, starting and stopping backups, and so Mnl An example of this type of NDB_MGMManagement client supplied with MySQL Cluster (seesection 18.4.5, " NDB_MGM-the MySQL Cluster Management Client "). Such applications can be written using the MGM API, a c-language API that communicates directly with one or more MySQL Cluster Management Servers. For more information, seethe MGM API.

Manage clients: These connections to clients on the Management Server provide commands for starting and stopping nodes, starting and stopping information tracking (Debug version only), displaying the version and status of the node, starting and stopping backups, and so on. For example, some type of program provides the NDB_MGM management client in the MySQL cluster (see section 18.4.5, "ndb_mgm -the mysql clustermanagement client"). The program can be written using the MGM API , a C-language API that interacts directly with one or more MySQL cluster Management servers. To learn more, see the MGM API.


Oracle also makes available MySQL Cluster Manager, which provides an advanced command-line interface simplifying many comp Lex 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 para meters as well asmysqld server 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 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 for setting and obtaining parameter values for many node configurations and mysqld service options, as well as variables related to 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 is found Insection 18.5.6, "Event Reports Generated in MySQL Cluster". Event logs is of the 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 individual Node.

Event log: The MySQL cluster generates logs by the kind (startup, shutdown, error, checkpoint, and so on), priority and severity events. A listener for a complete, reported event can be found in the section 18.5.6, "Event Reports Generated in MySQL Cluster" article. There are two types of event logs here:

L Cluster log: for cluster, to save an expected report of the event record as a whole.

L node log: A separate log maintains each single node.


Note

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

Attention:

In general, it is necessary to fully save and check the cluster logs. And the node log is only for development and debugging purposes to check.


Checkpoint. Generally speaking, when data was saved to disk, it was said that acheckpoint had been reached. More specific to MySQL Cluster, a checkpoint was a point in time where all committed transactions be stored on disk. NDBwith regard to the storage engine, there is both types of checkpoints which work together to ensure that a consistent View of the cluster ' s data is maintained. These is shown in the following list:

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

Local Checkpoint (LCP): This is a Checkpoint so is specific to a single node; However, LCPs take place for all nodes in the cluster + 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 OT Her factors.

L Local Checkpoint (LCP): This is a special checkpoint for a single node. However, LCPs occurs more or less at the same time in all nodes of the cluster. A LCP involves all the data nodes that are reserved on the hard disk, so it usually happens every few minutes. Exact time intervals vary, and the level of clustering is active, or other factors that need to be dependent on a large amount of data stored by the node.


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

L Global Checkpoint (GCP): A GCP occurs every few seconds, at which time the transactions of all nodes are synchronized, and the rewritten log is flushed to the hard disk.


For more information on the files and directories created by local checkpoints and global checkpoints, Seemysql Cluster Data Node FileSystemDir Files.

For more information on files and directories created with local checkpoints and global checkpoints, see MySQL Cluster Data Node FileSystemDir files


This article was excerpted 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.