25.3.2.1 在 Windows 上安装 NDB Cluster from a Binary Release
This section describes a basic installation of NDB Cluster on Windows using a binary “no-install” NDB Cluster release provided by Oracle, using the same 4-node setup outlined in the beginning of this section (see Section 25.3, “NDB Cluster Installation”), as shown in the following table:
As on other platforms, the NDB Cluster host computer running an SQL node must have installed on it a MySQL Server binary (mysqld.exe). You should also have the MySQL client (mysql.exe) on this host. For management nodes and data nodes, it is not necessary to install the MySQL Server binary; however, each management node requires the management server daemon (ndb_mgmd.exe); each data node requires the data node daemon (ndbd.exe or ndbmtd.exe). For this example, we refer to ndbd.exe as the data node executable, but you can install ndbmtd.exe, the multithreaded version of this program, instead, in exactly the same way. You should also install the management client (ndb_mgm.exe) on the management server host. This section covers the steps necessary to install the correct Windows binaries for each type of NDB Cluster node.
As with other Windows programs, NDB Cluster executables are named with the .exe
file extension. However, it is not necessary to include the .exe
extension when invoking these programs from the command line. Therefore, we often simply refer to these programs in this documentation as mysqld, mysql, ndb_mgmd, and so on. You should understand that, whether we refer (for example) to mysqld or mysqld.exe, either name means the same thing (the MySQL Server program).
For setting up an NDB Cluster using Oracles's no-install
binaries, the first step in the installation process is to download the latest NDB Cluster Windows ZIP binary archive from https://dev.mysql.com/downloads/cluster/. This archive has a filename of the mysql-cluster-gpl-
, where ver
-winarch
.zipver
is the NDB
storage engine version (such as 8.4.0
), and arch
is the architecture (32
for 32-bit binaries, and 64
for 64-bit binaries). For example, the NDB Cluster 8.4.0 archive for 64-bit Windows systems is named mysql-cluster-gpl-8.4.0-win64.zip
.
You can run 32-bit NDB Cluster binaries on both 32-bit and 64-bit versions of Windows; however, 64-bit NDB Cluster binaries can be used only on 64-bit versions of Windows. If you are using a 32-bit version of Windows on a computer that has a 64-bit CPU, then you must use the 32-bit NDB Cluster binaries.
To minimize the number of files that need to be downloaded from the Internet or copied between machines, we start with the computer where you intend to run the SQL node.
SQL node. We assume that you have placed a copy of the archive in the directory C:\Documents and Settings\
on the computer having the IP address 198.51.100.20, where username
\My Documents\Downloadsusername
is the name of the current user. (You can obtain this name using ECHO %USERNAME%
on the command line.) To install and run NDB Cluster executables as Windows services, this user should be a member of the Administrators
group.
Extract all the files from the archive. The Extraction Wizard integrated with Windows Explorer is adequate for this task. (If you use a different archive program, be sure that it extracts all files and directories from the archive, and that it preserves the archive's directory structure.) When you are asked for a destination directory, enter C:\
, which causes the Extraction Wizard to extract the archive to the directory C:\mysql-cluster-gpl-
. Rename this directory to ver
-winarch
C:\mysql
.
It is possible to install the NDB Cluster binaries to directories other than C:\mysql\bin
; however, if you do so, you must modify the paths shown in this procedure accordingly. In particular, if the MySQL Server (SQL node) binary is installed to a location other than C:\mysql
or C:\Program Files\MySQL\MySQL Server 8.4
, or if the SQL node's data directory is in a location other than C:\mysql\data
or C:\Program Files\MySQL\MySQL Server 8.4\data
, extra configuration options must be used on the command line or added to the my.ini
or my.cnf
file when starting the SQL node. For more information about configuring a MySQL Server to run in a nonstandard location, see Section 2.3.3, “Configuration: Manually”.
For a MySQL Server with NDB Cluster support to run as part of an NDB Cluster, it must be started with the options --ndbcluster
and --ndb-connectstring
. While you can specify these options on the command line, it is usually more convenient to place them in an option file. To do this, create a new text file in Notepad or another text editor. Enter the following configuration information into this file:
[mysqld]
# Options for mysqld process:
ndbcluster # run NDB storage engine
ndb-connectstring=198.51.100.10 # location of management server
You can add other options used by this MySQL Server if desired (see Section 2.3.3.2, “Creating an Option File”), but the file must contain the options shown, at a minimum. Save this file as C:\mysql\my.ini
. This completes the installation and setup for the SQL node.
Data nodes. An NDB Cluster data node on a Windows host requires only a single executable, one of either ndbd.exe or ndbmtd.exe. For this example, we assume that you are using ndbd.exe, but the same instructions apply when using ndbmtd.exe. On each computer where you wish to run a data node (the computers having the IP addresses 198.51.100.30 and 198.51.100.40), create the directories C:\mysql
, C:\mysql\bin
, and C:\mysql\cluster-data
; then, on the computer where you downloaded and extracted the no-install
archive, locate ndbd.exe
in the C:\mysql\bin
directory. Copy this file to the C:\mysql\bin
directory on each of the two data node hosts.
To function as part of an NDB Cluster, each data node must be given the address or hostname of the management server. You can supply this information on the command line using the --ndb-connectstring
or -c
option when starting each data node process. However, it is usually preferable to put this information in an option file. To do this, create a new text file in Notepad or another text editor and enter the following text:
[mysql_cluster]
# Options for data node process:
ndb-connectstring=198.51.100.10 # location of management server
Save this file as C:\mysql\my.ini
on the data node host. Create another text file containing the same information and save it on as C:mysql\my.ini
on the other data node host, or copy the my.ini file from the first data node host to the second one, making sure to place the copy in the second data node's C:\mysql
directory. Both data node hosts are now ready to be used in the NDB Cluster, which leaves only the management node to be installed and configured.
Management node. The only executable program required on a computer used for hosting an NDB Cluster management node is the management server program ndb_mgmd.exe. However, in order to administer the NDB Cluster once it has been started, you should also install the NDB Cluster management client program ndb_mgm.exe on the same machine as the management server. Locate these two programs on the machine where you downloaded and extracted the no-install
archive; this should be the directory C:\mysql\bin
on the SQL node host. Create the directory C:\mysql\bin
on the computer having the IP address 198.51.100.10, then copy both programs to this directory.
You should now create two configuration files for use by ndb_mgmd.exe
:
-
A local configuration file to supply configuration data specific to the management node itself. Typically, this file needs only to supply the location of the NDB Cluster global configuration file (see item 2).
To create this file, start a new text file in Notepad or another text editor, and enter the following information:
[mysql_cluster] # Options for management node process config-file=C:/mysql/bin/config.ini
Save this file as the text file
C:\mysql\bin\my.ini
. -
A global configuration file from which the management node can obtain configuration information governing the NDB Cluster as a whole. At a minimum, this file must contain a section for each node in the NDB Cluster, and the IP addresses or hostnames for the management node and all data nodes (
HostName
configuration parameter). It is also advisable to include the following additional information:-
The IP address or hostname of any SQL nodes
-
The data memory and index memory allocated to each data node (
DataMemory
andIndexMemory
configuration parameters) -
The number of fragment replicas, using the
NoOfReplicas
configuration parameter (see Section 25.2.2, “NDB Cluster Nodes, Node Groups, Fragment Replicas, and Partitions”) -
The directory where each data node stores it data and log file, and the directory where the management node keeps its log files (in both cases, the
DataDir
configuration parameter)
Create a new text file using a text editor such as Notepad, and input the following information:
[ndbd default] # Options affecting ndbd processes on all data nodes: NoOfReplicas=2 # Number of fragment replicas DataDir=C:/mysql/cluster-data # Directory for each data node's data files # Forward slashes used in directory path, # rather than backslashes. This is correct; # see Important note in text DataMemory=80M # Memory allocated to data storage IndexMemory=18M # Memory allocated to 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. [ndb_mgmd] # Management process options: HostName=198.51.100.10 # Hostname or IP address of management node DataDir=C:/mysql/bin/cluster-logs # Directory for management node log files [ndbd] # Options for data node "A": # (one [ndbd] section per data node) HostName=198.51.100.30 # Hostname or IP address [ndbd] # Options for data node "B": HostName=198.51.100.40 # Hostname or IP address [mysqld] # SQL node options: HostName=198.51.100.20 # Hostname or IP address
Save this file as the text file
C:\mysql\bin\config.ini
. -
A single backslash character (\
) cannot be used when specifying directory paths in program options or configuration files used by NDB Cluster on Windows. Instead, you must either escape each backslash character with a second backslash (\\
), or replace the backslash with a forward slash character (/
). For example, the following line from the [ndb_mgmd]
section of an NDB Cluster config.ini
file does not work:
DataDir=C:\mysql\bin\cluster-logs
Instead, you may use either of the following:
DataDir=C:\\mysql\\bin\\cluster-logs # Escaped backslashes
DataDir=C:/mysql/bin/cluster-logs # Forward slashes
For reasons of brevity and legibility, we recommend that you use forward slashes in directory paths used in NDB Cluster program options and configuration files on Windows.