2.3.2.1 将 MySQL Cluster Manager 代理安装为 Windows 服务

将 MySQL Cluster Manager 代理安装为 Windows 服务后,您可以使用 Windows 服务管理器启动和停止代理。安装还将代理配置为在 Windows 启动时自动启动,并在 Windows 关闭时安全关闭。

笔记

Windows 服务仅可用于控制 MySQL Cluster Manager 代理在单个主机上的运行。要关闭多个主机上的代理,可以使用stop agentsMySQL Cluster Manager 客户端中的命令。

使用命令提示符 ( cmd.exe ) 执行安装;与安装或删除任何 Windows 服务一样,也必须以具有足够权限的用户身份(例如系统管理员帐户)来完成。

如果您当前使用的帐户具有管理员权限,您只需启动 cmd.exe即可。否则,您必须以管理员身份运行命令提示符程序。为此,首先找到命令提示符的快捷方式。在大多数 Windows 系统上,您可以使用“开始”菜单执行此操作。查找 程序(或所有程序,在某些 Windows 版本中),然后导航至附件。在 附件下,右键单击 命令提示符菜单项。从出现的上下文菜单中,选择以管理员身份运行. 您可以在下图中看到它在典型 Windows 系统上的外观。

图 2.10 将 MySQL Cluster Manager Agent 安装为 Windows 服务:命令提示符

内容在周围的文字中描述。

如果出现引用 cmd.exe的 Windows UAC 对话框,请单击 “是”以允许命令提示符以管理员身份运行并继续。您现在应该在桌面上打开一个命令提示符窗口,以管理员权限运行会话。

要将 MySQL Cluster Manager 代理安装为服务,我们使用 SC CREATE命令。此命令允许我们指定服务的名称(用于SC STARTSC STOPNET START以及NET STOP命令)、显示名称(显示在服务管理器中)、启动模式(自动或手动启动)以及可执行文件的路径作为服务运行。(使用mcmd-svc.exe 而不是mcmd.exe作为可执行文件。)路径还必须包括程序所需的任何参数;对于 MySQL 集群管理器, 必须使用该 选项告知mcmd-svc.exe在哪里可以找到其配置文件。--defaults-file这两条路径都必须是绝对路径。

重要的

Installation of the MySQL Cluster Manager agent as a service is recommended. However, you should not install MySQL Cluster processes (ndb_mgmd.exe, ndbd.exe, ndbmtd.exe, mysqld.exe) as services on Windows hosts to be used as MySQL Cluster nodes under management by MySQL Cluster Manager, since the MySQL Cluster Manager agent itself controls MySQL Cluster nodes independently of the Windows Service Manager.

Assume that you have installed MySQL Cluster Manager to the default location for 64-bit Windows systems C:\Program Files (x86)\MySQL\MySQL Cluster Manager 1.3.6\ (C:\Program Files\MySQL\MySQL Cluster Manager 1.3.6\ on 32-bit Windows systems), and that its configuration file is located in C:\Program Files (x86)\MySQL\MySQL Cluster Manager 1.3.6\etc. Then the following command installs MySQL Cluster Manager as a service named mcm, with the display name MySQL Cluster Manager 1.3.6:

C:\> SC CREATE
  "MCM" DisplayName= "MySQL Cluster Manager 1.3.6" Start= "auto"
  BinPath= "C:\Program Files (x86)\MySQL\MySQL Cluster Manager 1.3.6\bin\mcmd-svc.exe
  --defaults-file=\"C:\Program Files (x86)\MySQL\MySQL Cluster Manager 1.3.6\etc\mcmd.ini\""
[SC] CreateService SUCCESS
C:\>

This command can be quite long. For enhanced legibility, we have broken it across several lines, but you should always enter it on a single line, allowing it to wrap naturally, similar to what is shown here:

Figure 2.11 Installing the MySQL Cluster Manager Agent as a Windows Service: Command

内容在周围的文字中描述。

In addition, you should keep in mind that the spaces after the equal signs following the DisplayName, Start, and BinPath arguments are required.

Starting and stopping the MySQL Cluster Manager agent Windows service.  After installing the service successfully, you can start and stop the service manually, if the need arises, with the SC START and SC STOP commands.

C:\>SC START MCM
C:\>SC STOP MCM

Alternatively, use the NET START and NET STOP commands:

C:\Windows\system32>NET START MCM
C:\Windows\system32>NET STOP MCM

Once the service is installed, the MySQL Cluster Manager agent starts automatically whenever Windows is started. You can verify that the service is running with the Windows Task Manager. Open the Task Manager, and switch to the Services tab if it is not already displayed. If the MySQL Cluster Manager agent is running, you can find it in the list of services under MCM in the Name, column and MySQL Cluster Manager 1.3.6 in the Description column, as shown here:

Figure 2.12 Installing the MySQL Cluster Manager Agent as a Windows Service: Services Tab

内容在周围的文字中描述。

You can also verify if the service is running using the Windows Service Manager, as shown here:

Figure 2.13 Installing the MySQL Cluster Manager Agent as a Windows Service: Service Manager

Windows 服务管理器显示 MySQL 集群管理器已作为服务启动。

The Service Manager also allows you to start, stop, or pause the MySQL Cluster Manager agent service manually using a GUI.

Note

When first installing the MySQL Cluster Manager agent as a service, the service is not started automatically until Windows is started. If you do not wish to restart Windows, then you must start the service manually using either SC START or NET START on the command line or the graphical control provided in the Windows Service Manager.

You can remove the service using the SC DELETE command and the name of the service—in this case MCM—that was used in the SC CREATE command, as shown here:

Figure 2.14 Removing the MySQL Cluster Manager Agent from Windows Services

内容在周围的文字中描述。

If the service is running at the time that SC DELETE is executed, the removal of the service takes effect the next time the service is stopped. In such a case, you must stop the previous instance of the service manually, and allow it to be removed, before you can reinstall the service.

安装 MySQL Cluster Manager 代理并且服务正常运行后,您就可以使用 MySQL Cluster Manager 客户端连接到它了。有关如何执行此操作的信息, 请参阅第 3.3 节,“启动 MySQL Cluster Manager 客户端” 。