3.2.1 在 Linux 上启动和停止代理

要在运行 Linux 或类似操作系统的给定主机上启动 MySQL Cluster Manager 代理,您应该运行 mcmd,它位于bin 该主机上管理器安装目录中的目录中。与mcmd一起使用的典型选项如下所示:

mcmd [--defaults-file | --bootstrap] [--log-file] [--log-level]

有关从命令行或在配置文件中 调用mcmd时可以使用的其他选项的信息, 请参阅第 3.1 节,“ mcmd,MySQL Cluster Manager 代理” 。

mcmd通常在前台运行。如果您愿意,您可以使用平台的常用机制来后台处理进程。在 Linux 系统上,您可以通过附加一个与号字符 (&) 来完成此操作,如下所示(不包括可能需要的任何选项):

$> ./bin/mcmd &

默认情况下,代理假定代理配置文件是etc/mcmd.iniMySQL Cluster Manager 安装目录中的。您可以通过将此文件的路径传递给 --defaults-file选项来告诉代理使用不同的配置文件,如下所示:

$> ./bin/mcmd --defaults-file=/home/mcm/mcm-agent.conf

--bootstrap选项使代理程序以默认配置值启动,创建一个名为 的默认单机集群mycluster,然后启动它。此选项仅在尚未创建集群时有效,并且与该 --defaults-file选项互斥。目前,存储在默认集群中的任何数据 mycluster在集群重启之间都不会保留;这是一个已知问题,我们可能会在 MySQL 集群管理器的未来版本中解决。

--bootstrap选项与mcmd的使用显示在具有主机名的系统上torsk,其中 MySQL Cluster Manager 已安装到/home/jon/mcm

$> ./mcmd --bootstrap
MySQL Cluster Manager 1.3.6 started
Connect to MySQL Cluster Manager by running "/home/jon/mcm/bin/mcm" -a torsk:1862
Configuring default cluster 'mycluster'...
Starting default cluster 'mycluster'...
Cluster 'mycluster' started successfully
        ndb_mgmd        torsk:1186
        ndbd            torsk
        ndbd            torsk
        mysqld          torsk:3306
        mysqld          torsk:3307
        ndbapi          *
Connect to the database by running "/home/jon/mcm/cluster/bin/mysql" -h torsk -P 3306 -u root

You can then connect to the agent using the mcm client (see Section 3.3, “Starting the MySQL Cluster Manager Client”), and to either of the MySQL Servers running on ports 3306 and 3307 using mysql or another MySQL client application.

The --log-file option allows you to override the default location for the agent log file (normally mcmd.log, in the MySQL Cluster Manager installation directory).

You can use --log-level option to override the log-level set in the agent configuration file.

See Section 3.1, “mcmd, the MySQL Cluster Manager Agent”, for more information about options that can be used with mcmd.

The MySQL Cluster Manager agent must be started on each host in the MySQL Cluster to be managed.

To stop one or more instances of the MySQL Cluster Manager agent, use the stop agents command in the MySQL Cluster Manager client. If the client is unavailable, you can stop each agent process using the system's standard method for doing so, such as ^C or kill.

您还可以将代理设置为 Linux 和其他类 Unix 系统上的守护进程或服务。(请参阅 第 2.3.1 节,“在 Unix 平台上安装 MySQL Cluster Manager”。)如果您还希望在代理失败并在这种情况下重新启动时启动正在运行的 MySQL Cluster 中的数据节点失败进程,则必须确保这StopOnError是在每个数据节点上设置为 0(而不是默认值 1)。