Rabbitmqctl
https://www.rabbitmq.com/docs/3.13/man/rabbitmqctl.8#version
Nodes
start_app
Starts the RabbitMQ application.
This command is typically run after performing other management actions that require the RabbitMQ application to be stopped, e.g. reset
.
For example, to instruct the RabbitMQ node to start the RabbitMQ application:
stop
[pid_file]
Stops the Erlang node on which RabbitMQ is running. To restart the node follow the instructions for "Running the Server" in the installation guide.
If a pid_file is specified, also waits for the process specified there to terminate. See the description of the wait
command for details on this file.
For example, to instruct the RabbitMQ node to terminate:
rabbitmqctl stop
stop_app
Stops the RabbitMQ application, leaving the runtime (Erlang VM) running.
This command is typically run before performing other management actions that require the RabbitMQ application to be stopped, e.g. reset
.
For example, to instruct the RabbitMQ node to stop the RabbitMQ application:
rabbitmqctl stop_app
shutdown
Shuts down the node, both RabbitMQ and its runtime. The command is blocking and will return after the runtime process exits. If RabbitMQ fails to stop, it will return a non-zero exit code. This command infers the OS PID of the target node and therefore can only be used to shut down nodes running on the same host (or broadly speaking, in the same operating system, e.g. in the same VM or container)
Unlike the stop command, the shutdown command:
- does not require a pid_file to wait for the runtime process to exit
- returns a non-zero exit code if the RabbitMQ node is not running
For example, this will shut down a local RabbitMQ node running with the default node name:
rabbitmqctl shutdown
reset
Returns 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, to reset the RabbitMQ node:
rabbitmqctl reset
User Management
Note that all user management commands rabbitmqctl
only can manage users in the internal RabbitMQ database. Users from any alternative authentication backends such as LDAP cannot be inspected or managed with those commands. rabbitmqctl
.
add_user
username password
-
username
The name of the user to create.
-
password
The password the created user will use to log in to the broker.
For example, this command instructs the RabbitMQ broker to create a (non-administrative) user named "janeway" with (initial) password "changeit":
rabbitmqctl add_user janeway changeit
authenticate_user
username password
-
username
The name of the user.
-
password
The password of the user.
For example, this command instructs the RabbitMQ broker to authenticate the user named "janeway" with the password "verifyit":
rabbitmqctl authenticate_user janeway verifyit
delete_user
username
-
username
The name of the user to delete.
For example, this command instructs the RabbitMQ broker to delete the user named "janeway":
rabbitmqctl delete_user janeway
set_user_tags
username [tag ...]
-
username
The name of the user whose tags are to be set.
-
tag
Zero, one or more tags to set. Any existing tags will be removed.
For example, this command instructs the RabbitMQ broker to ensure the user named "janeway" is an administrator:
rabbitmqctl set_user_tags janeway administrator
This has no effect when the user authenticates using a messaging protocol, but can be used to permit the user to manage users, virtual hosts and permissions when the user logs in via some other means (for example with the management plugin).
This command instructs the RabbitMQ broker to remove any tags from the user named "janeway":
rabbitmqctl set_user_tags janeway
rabbitmq-server
https://www.rabbitmq.com/docs/3.13/man/rabbitmq-server.8
NAME
rabbitmq-server
— starts a RabbitMQ node
SYNOPSIS
rabbitmq-server | [-detached ] |
---|---|
DESCRIPTION
RabbitMQ is an open source multi-protocol messaging broker.
Running rabbitmq-server
starts a RabbitMQ node in the foreground. The node will display a startup banner and report when startup is complete. To shut down the server, use service management tools or rabbitmqctl(8).
ENVIRONMENT
-
Defaults to /etc/rabbitmq/rabbitmq.conf. Node configuration file path. To learn more, see the RabbitMQ Configuration guide
-
Defaults to /var/lib/rabbitmq/mnesia. Node data directory will be located (or created) in this directory. To learn more, see the RabbitMQ File and Directory guide
-
Defaults to /var/log/rabbitmq. Log files generated by the server will be placed in this directory. To learn more, see the RabbitMQ Logging guide
-
Defaults to "rabbit@". followed by the computed hostname. Can be used to run multiple nodes on the same host. Every node in a cluster must have a unique
RABBITMQ_NODENAME
To learn more, see the RabbitMQ Clustering guide -
By default RabbitMQ will bind to all IPv6 and IPv4 interfaces available. This variable limits the node to one network interface or address family. To learn more, see the RabbitMQ Networking guide
-
AMQP 0-9-1 and AMQP 1.0 port. Defaults to 5672. To learn more, see the RabbitMQ Networking guide
OPTIONS
-
Start the server process in the background. Note that this will cause the pid not to be written to the pid file.For example, runs RabbitMQ AMQP server in the background:
rabbitmq-server -detached
rabbitmq-env.conf
https://www.rabbitmq.com/docs/3.13/man/rabbitmq-env.conf.5
NAME
rabbitmq-env.conf
— environment variables used by RabbitMQ server
DESCRIPTION
rabbitmq-env.conf
contains environment variables that override the defaults built in to the RabbitMQ scripts and CLI tools.
The file is interpreted by the system shell, and so should consist of a sequence of shell environment variable definitions. Normal shell syntax is permitted (since the file is sourced using the shell "." operator), including line comments starting with "#".
In order of preference, the startup scripts get their values from the environment, from rabbitmq-env.conf
and finally from the built-in default values. For example, for the RABBITMQ_NODENAME
setting, RABBITMQ_NODENAME
from the environment is checked first. If it is absent or equal to the empty string, then NODENAME
from rabbitmq-env.conf
is checked. If it is also absent or set equal to the empty string then the default value from the startup script is used.
The variable names in rabbitmq-env.conf
are always equal to the environment variable names, with the "RABBITMQ_" prefix removed: RABBITMQ_NODE_PORT
from the environment becomes NODE_PORT
in rabbitmq-env.conf
.
EXAMPLES
Below is an example of a minimalistic rabbitmq-env.conf
file that overrides the default node name prefix from "rabbit" to "hare".
# I am a complete rabbitmq-env.conf file.
# Comment lines start with a hash character.
# This is a /bin/sh script file - use ordinary envt var syntax
NODENAME=hare
In the below rabbitmq-env.conf
file RabbitMQ configuration file location is changed to "/data/services/rabbitmq/rabbitmq.conf".
# I am a complete rabbitmq-env.conf file.
# Comment lines start with a hash character.
# This is a /bin/sh script file - use ordinary envt var syntax
CONFIG_FILE=/data/services/rabbitmq/rabbitmq.conf
Queue
# 展示queue列表
rabbitmqctl list_queues -p xuyi-dev
rabbitmqctl delete_queue mqtt-subscription-5c4zw0ba_1qos0 -p xuyi-dev
# 批量删除queue
rabbitmqctl list_queues -p xuyi-dev| grep ^mqtt | awk '{print $1}' | xargs -n1 rabbitmqctl delete_queue -p xuyi-dev