rabbitmqctl命令详解

This is the manual page for rabbitmqctl(1).

See a list of all manual pages.

For more general documentation, please see the administrator's guide.

Name

rabbitmqctl — command line tool for managing a RabbitMQ broker

Synopsis

rabbitmqctl [-n node] [-q] {command} [command options...]

Description

RabbitMQ is an implementation of AMQP, the emerging standard for high performance enterprise messaging. The RabbitMQ server is a robust and scalable implementation of an AMQP broker.

rabbitmqctl is a command line tool for managing a RabbitMQ broker. It performs all actions by connecting to one of the broker's nodes.

Options

[-n node]

Default node is "rabbit@server", where server is the local host. On a host named "server.example.com", the node name of the RabbitMQ Erlang node will usually be rabbit@server (unless RABBITMQ_NODENAME has been set to some non-default value at broker startup time). The output of hostname -s is usually the correct suffix to use after the "@" sign. See rabbitmq-server(1) for details of configuring the RabbitMQ broker.

[-q]

Quiet output mode is selected with the "-q" flag. Informational messages are suppressed when quiet mode is in effect.

Commands

Application and Cluster Management

stop

Stops the Erlang node on which RabbitMQ is running. To restart the node follow the instructions for Running the Server in theinstallation guide.

For example:

rabbitmqctl stop

This command instructs the RabbitMQ node to terminate.

stop_app

Stops the RabbitMQ application, leaving the Erlang node running.

This command is typically run prior to performing other management actions that require the RabbitMQ application to be stopped, e.g.reset.

For example:

rabbitmqctl stop_app

This command instructs the RabbitMQ node to stop the RabbitMQ application.

start_app

Starts the RabbitMQ application.

This command is typically run after performing other management actions that required the RabbitMQ application to be stopped, e.g.reset.

For example:

rabbitmqctl start_app

This command instructs the RabbitMQ node to start the RabbitMQ application.

wait

Wait for the RabbitMQ application to start.

This command will wait for the RabbitMQ application to start at the node. As long as the Erlang node is up but the RabbitMQ application is down it will wait indefinitely. If the node itself goes down, or takes more than five seconds to come up, it will fail.

For example:

rabbitmqctl wait

This command will return when the RabbitMQ node has started up.

status

Displays various information about the RabbitMQ broker, such as whether the RabbitMQ application on the current node, its version number, what nodes are part of the broker, which of these are running.

For example:

rabbitmqctl status

This command displays information about the RabbitMQ broker.

reset

Return a RabbitMQ node to its virgin state.

Removes the node from any cluster it belongs to, removes all data from the management database, such as configured users and vhosts, and deletes all persistent messages.

For reset and force_reset to succeed the RabbitMQ application must have been stopped, e.g. with stop_app.

For example:

rabbitmqctl reset

This command resets the RabbitMQ node.

force_reset

Forcefully return a RabbitMQ node to its virgin state.

The force_reset command differs from reset in that it resets the node unconditionally, regardless of the current management database state and cluster configuration. It should only be used as a last resort if the database or cluster configuration has been corrupted.

For reset and force_reset to succeed the RabbitMQ application must have been stopped, e.g. with stop_app.

For example:

rabbitmqctl force_reset

This command resets the RabbitMQ node.

rotate_logs {suffix}

Instruct the RabbitMQ node to rotate the log files.

The RabbitMQ broker will attempt to append the current contents of the log file to the file with name composed of the original name and the suffix. It will create a new file if such a file does not already exist. When no suffix is specified, the empty log file is simply created at the original location; no rotation takes place.

When an error occurs while appending the contents of the old log file, the operation behaves in the same way as if no suffix was specified.

This command might be helpful when you are e.g. writing your own logrotate script and you do not want to restart the RabbitMQ node.

For example:

rabbitmqctl rotate_logs .1

This command instructs the RabbitMQ node to append the current content of the log files to the files with names consisting of the original logs' names and ".1" suffix, e.g. rabbit.log.1. Finally, the old log files are reopened.

Cluster management

cluster {clusternode ...}

clusternode

Subset of the nodes of the cluster to which this node should be connected.

Instruct the node to become member of a cluster with the specified nodes. To cluster with currently offline nodes, use force_cluster.

Cluster nodes can be of two types: disk or ram. Disk nodes replicate data in ram and on disk, thus providing redundancy in the event of node failure and recovery from global events such as power failure across all nodes. Ram nodes replicate data in ram only and are mainly used for scalability. A cluster must always have at least one disk node.

If the current node is to become a disk node it needs to appear in the cluster node list. Otherwise it becomes a ram node. If the node list is empty or only contains the current node then the node becomes a standalone, i.e. non-clustered, (disk) node.

After executing the cluster command, whenever the RabbitMQ application is started on the current node it will attempt to connect to the specified nodes, thus becoming an active node in the cluster comprising those nodes (and possibly others).

The list of nodes does not have to contain all the cluster's nodes; a subset is sufficient. Also, clustering generally succeeds as long as at least one of the specified nodes is active. Hence adjustments to the list are only necessary if the cluster configuration is to be altered radically.

For this command to succeed the RabbitMQ application must have been stopped, e.g. with stop_app. Furthermore, turning a standalone node into a clustered node requires the node be reset first, in order to avoid accidental destruction of data with the cluster command.

For more details see the clustering guide.

For example:

rabbitmqctl cluster rabbit@tanto hare@elena

This command instructs the RabbitMQ node to join the cluster with nodes rabbit@tanto and hare@elena. If the node is one of these then it becomes a disk node, otherwise a ram node.

force_cluster {clusternode ...}

clusternode

Subset of the nodes of the cluster to which this node should be connected.

Instruct the node to become member of a cluster with the specified nodes. This will succeed even if the specified nodes are offline. For a more detailed description, see cluster.

Note that this variant of the cluster command just ignores the current status of the specified nodes. Clustering may still fail for a variety of other reasons.

Closing individual connections

close_connection {connectionpid} {explanation}

connectionpid

Id of the Erlang process associated with the connection to close.

explanation

Explanation string.

Instruct the broker to close the connection associated with the Erlang process id connectionpid (see also the list_connectionscommand), passing the explanation string to the connected client as part of the AMQP connection shutdown protocol.

For example:

rabbitmqctl close_connection "<[email protected]>" "go away"

This command instructs the RabbitMQ broker to close the connection associated with the Erlang process id <[email protected]>, passing the explanation go away to the connected client.

你可能感兴趣的:(erlang,Access,UP,performance,Go)