启用与下载
启用rabbitmq-plugins enable rabbitmq_management
1.下载rabbitmqadmin并放入/usr/local/bin目录下 curl -LO http://127.0.0.1:15672/cli/rabbitmqadmin mv rabbitmqadmin /usr/local/bin/
2.赋予可执行权限
chmod +x /usr/local/bin/rabbitmqadmin
3.导出数据
rabbitmqadmin -u user -p password export rabbit.definitions.json
4.导入数据
rabbitmqadmin -q import rabbit.definitions.json
rabbitmq常用命令
3. rabbitmqadmin 命令汇总:
登录执行列出所有用户:rabbitmqadmin -u username -p password list users
命令 | 解释 |
---|---|
rabbitmqadmin list users | 查看所有用户 User |
rabbitmqadmin list users name | 查看所有用户名 Username |
rabbitmqadmin list users tags | 查看所有用户角色 |
rabbitmqadmin list vhosts | 查看所有虚拟主机 |
rabbitmqadmin list connections | 查看所有连接 |
rabbitmqadmin list exchanges | 查看所有路由 Exchange |
rabbitmqadmin list bindings | 查看所有路由与队列的关系绑定 Binding |
rabbitmqadmin list permissions | 查看所有角色的权限 Permission |
rabbitmqadmin list channels | 查看所有通道 Channel |
rabbitmqadmin list consumers | 查看所有消费者 Consumer |
rabbitmqadmin list queues | 查看所有消息队列 Queue |
rabbitmqadmin list nodes | 查看所有节点 Node |
rabbitmqadmin show overview | 概览 Overview |
rabbitmqadmin list bindings source destination_type destination properties_key | 查看所有路由与队列的关系绑定的详细信息 Binding |
rabbitmqadmin declare queue name=test durable=true | 定义一个队列queue,durable=true代表持久化打开。 |
rabbitmqadmin declare exchange name=my.fanout type=fanout | 定义一个Fanout路由 |
rabbitmqadmin declare exchange name=my.direct type=direct | 定义一个Direct路由 |
rabbitmqadmin declare exchange name=my.topic type=topic | 定义一个Topic路由 |
rabbitmqadmin declare binding source=my.fanout destination=test routing_key=first | 定义 binding |
rabbitmqadmin publish routing_key=test payload="hello world" | 发布一条消息 |
rabbitmqadmin publish routing_key=my.test exchange=my.topic payload="hello world" | 使用路由转发消息 |
rabbitmqadmin get queue=test requeue=true | 查看消息,不消费 |
rabbitmqadmin get queue=test requeue=false | 查看消息,并消费 |
rabbitmqadmin purge queue name=test | 删除队列中的所有消息 |
rabbitmqadmin delete queue name=hello | 删除消息队列 Queue |
rabbitmqadmin delete user name=test | 删除用户 User |
rabbitmqadmin delete exchange name=test | 删除路由器 Exchange |
rabbitmqadmin delete binding source='kk' destination_type=queue destination=test properties_key=test | 删除路由器与消息队列的关系绑定 Binding |
rabbitmqadmin -f raw_json list users | raw_json 格式化输出 |
rabbitmqadmin -f long list users | 格式化输出 |
rabbitmqadmin -f pretty_json list users | pretty_json 格式化输出 |
rabbitmqadmin -f kvp list users | 格式化输出 |
rabbitmqadmin -f tsv list users | 格式化输出 |
rabbitmqadmin -f table list users | table 格式化输出 |
rabbitmqadmin -f bash list users | bash 格式化输出 |