10bet网址
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr)- 41.6Mb
PDF (A4)- 41.7Mb
Man Pages (TGZ)- 262.1Kb
Man Pages (Zip)- 372.1Kb
Info (Gzip)- 4.0Mb
Info (Zip)- 4.0Mb
Excerpts from this Manual

23.6.9 MySQL Server Usage for NDB Cluster

mysqldis the traditional MySQL server process. To be used with NDB Cluster,mysqldneeds to be built with support for theNDBstorage engine, as it is in the precompiled binaries available from//www.delbede.com/downloads/。If you build MySQL from source, you must invokeCMakewith the-DWITH_NDBCLUSTER=1option to include support forNDB

For more information about compiling NDB Cluster from source, seeSection 23.3.1.4, “Building NDB Cluster from Source on Linux”, andSection 23.3.2.2, “Compiling and Installing NDB Cluster from Source on Windows”

(For information aboutmysqldoptions and variables, in addition to those discussed in this section, which are relevant to NDB Cluster, seeSection 23.4.3.9, “MySQL Server Options and Variables for NDB Cluster”。)

If themysqldbinary has been built with Cluster support, theNDBCLUSTERstorage engine is still disabled by default. You can use either of two possible options to enable this engine:

  • Use--ndbclusteras a startup option on the command line when startingmysqld

  • Insert a line containingndbclusterin the[mysqld]section of yourmy.cnffile.

An easy way to verify that your server is running with theNDBCLUSTERstorage engine enabled is to issue the显示引擎statement in the MySQL Monitor (mysql). You should see the valueYESas theSupportvalue in the row forNDBCLUSTER。If you seeNOin this row or if there is no such row displayed in the output, you are not running anNDB-enabled version of MySQL. If you seeDISABLEDin this row, you need to enable it in either one of the two ways just described.

To read cluster configuration data, the MySQL server requires at a minimum three pieces of information:

  • The MySQL server's own cluster node ID

  • The host name or IP address for the management server

  • The number of the TCP/IP port on which it can connect to the management server

Node IDs can be allocated dynamically, so it is not strictly necessary to specify them explicitly.

Themysqldparameterndb-connectstring使用to specify the connection string either on the command line when startingmysqldor inmy.cnf。The connection string contains the host name or IP address where the management server can be found, as well as the TCP/IP port it uses.

In the following example,ndb_mgmd.mysql.comis the host where the management server resides, and the management server listens for cluster messages on port 1186:

shell> mysqld --ndbcluster --ndb-connectstring=ndb_mgmd.mysql.com:1186

SeeSection 23.4.3.3, “NDB Cluster Connection Strings”, for more information on connection strings.

Given this information, the MySQL server can act as a full participant in the cluster. (We often refer to amysqldprocess running in this manner as an SQL node.) It is fully aware of all cluster data nodes as well as their status, and establishes connections to all data nodes. In this case, it is able to use any data node as a transaction coordinator and to read and update node data.

You can see in themysqlclient whether a MySQL server is connected to the cluster usingSHOW PROCESSLIST。如果连接到MySQL服务器集群,and you have thePROCESSprivilege, then the first row of the output is as shown here:

mysql> SHOW PROCESSLIST \G *************************** 1. row *************************** Id: 1 User: system user Host: db: Command: Daemon Time: 1 State: Waiting for event from ndbcluster Info: NULL
Important

To participate in an NDB Cluster, themysqldprocess must be started withboththe options--ndbclusterand--ndb-connectstring(or their equivalents inmy.cnf). Ifmysqldis started with only the--ndbclusteroption, or if it is unable to contact the cluster, it is not possible to work withNDBtables,nor is it possible to create any new tables regardless of storage engine。The latter restriction is a safety measure intended to prevent the creation of tables having the same names asNDBtables while the SQL node is not connected to the cluster. If you wish to create tables using a different storage engine while themysqldprocess is not participating in an NDB Cluster, you must restart the serverwithoutthe--ndbclusteroption.