5.1 在线帮助和信息命令

MySQL Cluster Manager 客户端中的联机帮助可用于 MySQL Cluster Manager 客户端命令。客户端可以提供一般信息和特定于命令的信息。此外,您可以获得有关 独立于 MySQL 服务器的mysql客户端命令的信息,因此在连接到 MySQL Cluster Manager 代理时也可以使用。

列出 MySQL Cluster Manager 客户端命令。  要获得包含简要说明的所有命令的列表,请使用 list commands命令,如下所示:

mcm> list commands;
+---------------------------------------------------------------------------+
| Help                                                                      |
+---------------------------------------------------------------------------+
| COMMANDS                                                                  |
|                                                                           |
| abort backup           Abort an ongoing cluster backup.                   |
| add hosts              Add hosts to site.                                 |
| add package            Add a package alias.                               |
| add process            Add cluster process.                               |
| autotune               Autotune a cluster to given use-case template.     |
| backup agents          Backup the agents repository and metadata.         |
| backup cluster         Backup a cluster.                                  |
| change log-level       Change the log-level                               |
| change process         Change process type.                               |
| collect logs           Collect log files.                                 |
| create cluster         Create a cluster.                                  |
| create site            Create a site.                                     |
| delete cluster         Delete a cluster.                                  |
| delete package         Delete a package.                                  |
| delete site            Delete a site.                                     |
| get                    Get configuration variables.                       |
| import cluster         Import a running cluster.                          |
| import config          Import the configuration of a running cluster.     |
| list backups           List backup images.                                |
| list clusters          List all clusters.                                 |
| list commands          List the help text.                                |
| list hosts             List hosts in site.                                |
| list nextnodeids       List next nodeids to be allocated.                 |
| list packages          List all packages.                                 |
| list processes         List processes.                                    |
| list sites             List all sites.                                    |
| remove hosts           Remove hosts from site.                            |
| remove process         Remove a cluster process.                          |
| reset                  Reset configuration variables.                     |
| restart cluster        Restart a cluster.                                 |
| restore cluster        Restore a cluster.                                 |
| rotate log             Rotate the mcmd log.                               |
| set                    Set configuration variables.                       |
| show settings          Show agent settings.                               |
| show status            Show cluster, process, operation or backup status. |
| start cluster          Start a cluster.                                   |
| start process          Start a cluster process.                           |
| stop agents            Stop agents in site.                               |
| stop cluster           Stop a cluster.                                    |
| stop process           Stop a cluster process.                            |
| upgrade cluster        Upgrade a cluster.                                 |
| version                Print version information.                         |
|                                                                           |
| GLOBAL OPTIONS                                                            |
| Options that can be used with all commands                                |
|                                                                           |
|     --help|-?              Print detailed help.                           |
|                                                                           |
| Use '<COMMAND> --help' to see verbose help for individual commands.       |
+---------------------------------------------------------------------------+
51 rows in set (0.03 sec)

获取有关特定 MySQL Cluster Manager 客户端命令的信息。  要获取特定于给定命令的更详细帮助,请使用该选项调用该命令 --help,如本例所示:

mcm> create site --help;
+----------------------------------------------------------------+
| Help                                                           |
+----------------------------------------------------------------+
|                                                                |
| create site [options] <sitename>                               |
|                                                                |
|     Creates a site from the hosts listed in --hosts.           |
|                                                                |
|     Required options:                                          |
|     --hosts|-h             Comma separated list of hostnames.  |
|                            Format: --hosts = <host>[,<host>]*. |
|                                                                |
+----------------------------------------------------------------+
9 rows in set (0.00 sec)

对于任何 MySQL Cluster Manager 客户端命令,该 --help选项可以缩写为 -?

mcm> list processes -?;
+-------------------------------------------------------------+
| Help                                                        |
+-------------------------------------------------------------+
|                                                             |
| list processes <sitename>                                   |
|                                                             |
|       Lists all processes defined in the specified cluster. |
+-------------------------------------------------------------+
4 rows in set (0.00 sec)

正如本手册其他地方提到的(参见 第 5 章,MySQL Cluster Manager 客户端命令),许多其他 MySQL Cluster Manager 命令选项也有缩写形式。这些都包含在每个命令的文档中。--help您还可以通过使用或 -?选项 调用它来找出给定命令的这些内容 。

您可以从命令的输出中获取正在使用的MySQL Cluster Manager软件的发布版本version

MySQL Cluster Manager 客户端中的mysql客户端命令。  您还可以在 MySQL Cluster Manager 客户端中使用大多数标准的MySQL客户端命令(但不是SQL 语句,这取决于连接到 MySQL 服务器),例如promptquitstatus。例如,当连接到 MySQL Cluster Manager 代理时,状态命令的输出看起来像这样(取决于您使用的客户端和代理的确切版本以及可能的其他因素):

mcm> status
--------------
./bin/mcm  Ver 8.0.31 for Linux on x86_64 (MySQL Enterprise Server - Commercial)

Connection id:	      3
Current database:	   <n/a>
Current user:	       mcmd
SSL:			   Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	    ;
Server version:	     8.0.31 MySQL Cluster Manager
Protocol version:	   10
Connection:       	  127.0.0.1 via TCP/IP
Server characterset:	latin1
Db     characterset:	latin1
Client characterset:	latin1
Conn.  characterset:	latin1
TCP port:		     1862
Binary data as:	     Hexadecimal
Uptime:			4 hours 11 min 54 sec

Agent no: 0  Connections: 1  Max msg id: {658358e0 102 0}
--------------
笔记

您可以将命令分隔符与mysql 客户端命令一起使用,但您不是必须这样做。例如,假设使用的分隔符是默认的分号 ( ;) 字符,我们可以status像这样执行命令:

mcm> status;
--------------
/home/jon/bin/mcm/cluster/bin/mysql  Ver 14.14 Distrib 8.0.31,...

您还可以与mcm一起使用 的一个特别有用的mysql客户端命令是 command(缩写形式 :) ,您可以使用它来执行包含 MySQL Cluster Manager 客户端命令的脚本。在 Linux 系统上,您的主目录中可能有一个名为 的文本文件 ,其内容如下所示: source\.get-attributes.mcm

get :ndb_mgmd mycluster\G
get :ndbd mycluster\G
get :mysqld mycluster\G

假设你已经创建了一个名为 的集群 mycluster,你可以在客户端运行这个脚本;结果根据该集群的实际配置方式而有所不同,但应该与此类似:

mcm> \. ~/get-attributes.mcm
mcm> get :ndb_mgmd mycluster\G
*************************** 1. row ***************************
    Name: DataDir
   Value: /home/jon/bin/mcm/mcm_data/clusters/mycluster/49/data
Process1: ndb_mgmd
 NodeId1: 49
Process2:
 NodeId2:
   Level:
 Comment:
*************************** 2. row ***************************
    Name: HostName
   Value: flundra
Process1: ndb_mgmd
 NodeId1: 49
Process2:
 NodeId2:
   Level:
 Comment: Read only
*************************** 3. row ***************************
    Name: NodeId
   Value: 49
Process1: ndb_mgmd
 NodeId1: 49
Process2:
 NodeId2:
   Level:
 Comment: Read only
*************************** 4. row ***************************
    Name: PortNumber
   Value: 1186
Process1: ndb_mgmd
 NodeId1: 49
Process2:
 NodeId2:
   Level: Process
 Comment:
4 rows in set (0.09 sec)

mcm> get :ndbd mycluster\G
*************************** 1. row ***************************
    Name: DataDir
   Value: /home/jon/bin/mcm/mcm_data/clusters/mycluster/1/data
Process1: ndbd
 NodeId1: 1
Process2:
 NodeId2:
   Level:
 Comment:
*************************** 2. row ***************************
    Name: HostName
   Value: tonfisk
Process1: ndbd
 NodeId1: 1
Process2:
 NodeId2:
   Level:
 Comment: Read only
*************************** 3. row ***************************
    Name: NodeId
   Value: 1
Process1: ndbd
 NodeId1: 1
Process2:
 NodeId2:
   Level:
 Comment: Read only
*************************** 4. row ***************************
    Name: DataDir
   Value: /home/jon/bin/mcm/mcm_data/clusters/mycluster/2/data
Process1: ndbd
 NodeId1: 2
Process2:
 NodeId2:
   Level:
 Comment:
*************************** 5. row ***************************
    Name: HostName
   Value: grindval
Process1: ndbd
 NodeId1: 2
Process2:
 NodeId2:
   Level:
 Comment: Read only
*************************** 6. row ***************************
    Name: NodeId
   Value: 2
Process1: ndbd
 NodeId1: 2
Process2:
 NodeId2:
   Level:
 Comment: Read only
6 rows in set (0.10 sec)

mcm> get :mysqld mycluster\G
*************************** 1. row ***************************
    Name: datadir
   Value: /home/jon/bin/mcm/mcm_data/clusters/mycluster/50/data
Process1: mysqld
 NodeId1: 50
Process2:
 NodeId2:
   Level:
 Comment:
*************************** 2. row ***************************
    Name: HostName
   Value: haj
Process1: mysqld
 NodeId1: 50
Process2:
 NodeId2:
   Level:
 Comment: Read only
*************************** 3. row ***************************
    Name: log_error
   Value: /home/jon/bin/mcm/mcm_data/clusters/mycluster/50/data/mysqld_50_out.err
Process1: mysqld
 NodeId1: 50
Process2:
 NodeId2:
   Level:
 Comment:
*************************** 4. row ***************************
    Name: ndb_nodeid
   Value: 50
Process1: mysqld
 NodeId1: 50
Process2:
 NodeId2:
   Level:
 Comment: Read only
*************************** 5. row ***************************
    Name: ndbcluster
   Value:
Process1: mysqld
 NodeId1: 50
Process2:
 NodeId2:
   Level:
 Comment: Read only
*************************** 6. row ***************************
    Name: NodeId
   Value: 50
Process1: mysqld
 NodeId1: 50
Process2:
 NodeId2:
   Level:
 Comment: Read only
*************************** 7. row ***************************
    Name: port
   Value: 3306
Process1: mysqld
 NodeId1: 50
Process2:
 NodeId2:
   Level:
 Comment:
*************************** 8. row ***************************
    Name: socket
   Value: /tmp/mysql.mycluster.50.sock
Process1: mysqld
 NodeId1: 50
Process2:
 NodeId2:
   Level:
 Comment:
*************************** 9. row ***************************
    Name: tmpdir
   Value: /home/jon/bin/mcm/mcm_data/clusters/mycluster/50/data/tmp
Process1: mysqld
 NodeId1: 50
Process2:
 NodeId2:
   Level:
 Comment:
*************************** 10. row ***************************
    Name: datadir
   Value: /home/jon/bin/mcm/mcm_data/clusters/mycluster/51/data
Process1: mysqld
 NodeId1: 51
Process2:
 NodeId2:
   Level:
 Comment:
*************************** 11. row ***************************
    Name: HostName
   Value: torsk
Process1: mysqld
 NodeId1: 51
Process2:
 NodeId2:
   Level:
 Comment: Read only
*************************** 12. row ***************************
    Name: log_error
   Value: /home/jon/bin/mcm/mcm_data/clusters/mycluster/51/data/mysqld_51_out.err
Process1: mysqld
 NodeId1: 51
Process2:
 NodeId2:
   Level:
 Comment:
*************************** 13. row ***************************
    Name: ndb_nodeid
   Value: 51
Process1: mysqld
 NodeId1: 51
Process2:
 NodeId2:
   Level:
 Comment: Read only
*************************** 14. row ***************************
    Name: ndbcluster
   Value:
Process1: mysqld
 NodeId1: 51
Process2:
 NodeId2:
   Level:
 Comment: Read only
*************************** 15. row ***************************
    Name: NodeId
   Value: 51
Process1: mysqld
 NodeId1: 51
Process2:
 NodeId2:
   Level:
 Comment: Read only
*************************** 16. row ***************************
    Name: port
   Value: 3307
Process1: mysqld
 NodeId1: 51
Process2:
 NodeId2:
   Level:
 Comment:
*************************** 17. row ***************************
    Name: socket
   Value: /tmp/mysql.mycluster.51.sock
Process1: mysqld
 NodeId1: 51
Process2:
 NodeId2:
   Level:
 Comment:
*************************** 18. row ***************************
    Name: tmpdir
   Value: /home/jon/bin/mcm/mcm_data/clusters/mycluster/51/data/tmp
Process1: mysqld
 NodeId1: 51
Process2:
 NodeId2:
   Level:
 Comment:
18 rows in set (0.05 sec)

mcm>
笔记

在脚本执行完毕之前,您不会返回到客户端提示符。

同样,在 Windows 上,您可以使用记事本或其他文本编辑器创建批处理文件,将 get前面显示的相同命令复制到其中,并将其保存get-attributes.bat在方便的位置,例如 Windows 桌面。

您可以使用命令查看可用的mysql客户端命令列表help。有关这些的更多信息,请查看help输出或参阅MySQL 手册中的mysql 客户端命令