rabbitmq rabbitmqadmin基本操作

一、下载管理命令

http://192.168.56.12:15672/cli/rabbitmqadmin

二、上传到mq对应服务器并添加权限

chmod +x  /usr/locat/sbin/rabbitmqadmin

三、具体使用

队列操作

1、查询队列

python /usr/local/sbin/rabbitmqadmin --vhost=vhost --username=username --password=123456  list queues

2、添加队列

python /usr/local/sbin/rabbitmqadmin --vhost=/nde --username=user --password=1234  declare queue name=队列名称

3、删除队列

python /usr/local/sbin/rabbitmqadmin --vhost=/nde --username=user --password=1234  delete queue name=队列名称

其他相关操作请参照第四大点相关命令参数选项

交换操作

1、查询exchange

python /usr/local/sbin/rabbitmqadmin --vhost=vhost --username=username --password=123456  list exchange

2、添加exchange 

python /usr/local/sbin/rabbitmqadmin --vhost=vhost --username=user --password=password  declare exchange name=exchange_name type=fanout


类型有四种:
direct:所有发送到Direct Exchange的消息被转发到RouteKey中指定的Queue。Direct模式,可以使用rabbitMQ自带的Exchange:default Exchange 。所以不需要将Exchange进行任何绑定(binding)操作 。
消息传递时,RouteKey必须完全匹配,才会被队列接收,否则该消息会被抛弃。
headers:官网未做说明

fanout:所有发送到Fanout Exchange的消息都会被转发到与该Exchange 绑定(Binding)的所有Queue上。Fanout Exchange  不需要处理RouteKey 。只需要简单的将队列绑定到exchange 上。
这样发送到exchange的消息都会被转发到与该交换机绑定的所有队列上。类似子网广播,每台子网内的主机都获得了一份复制的消息。所以,Fanout Exchange 转发消息是最快的。


topic:所有发送到Topic Exchange的消息被转发到所有关心RouteKey中指定Topic的Queue上,Exchange 将RouteKey 和某Topic 进行模糊匹配。此时队列需要绑定一个Topic。可以使用通配符进行模糊匹配,
符号“#”匹配一个或多个词,符号“*”匹配不多不少一个词。因此“log.#”能够匹配到“log.info.oa”,但是“log.*” 只会匹配到“log.error”。所以,Topic Exchange 使用非常灵活。

3、删除exchange

python /usr/local/sbin/rabbitmqadmin --vhost=/nde --username=user --password=1234  delete exchange name=exchange名称

四、帮助文档

# python /usr/local/sbin/rabbitmqadmin    help subcommands 
Usage
=====
  rabbitmqadmin [options] subcommand

  where subcommand is one of:

Display
=======

  list users [<column>...]
  list vhosts [<column>...]
  list connections [<column>...]
  list exchanges [<column>...]
  list bindings [<column>...]
  list permissions [<column>...]
  list channels [<column>...]
  list parameters [<column>...]
  list consumers [<column>...]
  list queues [<column>...]
  list policies [<column>...]
  list nodes [<column>...]
  show overview [<column>...]

Object Manipulation
===================

  declare queue name=... [node=... auto_delete=... durable=... arguments=...]
  declare vhost name=... [tracing=...]
  declare user name=... password=... tags=...
  declare exchange name=... type=... [auto_delete=... internal=... durable=... arguments=...]
  declare policy name=... pattern=... definition=... [priority=... apply-to=...]
  declare parameter component=... name=... value=...
  declare permission vhost=... user=... configure=... write=... read=...
  declare binding source=... destination=... [arguments=... routing_key=... destination_type=...]
  delete queue name=...
  delete vhost name=...
  delete user name=...
  delete exchange name=...
  delete policy name=...
  delete parameter component=... name=...
  delete permission vhost=... user=...
  delete binding source=... destination_type=... destination=... properties_key=...
  close connection name=...
  purge queue name=...

  

posted @ 2019-08-22 11:28  凉生墨客  阅读(4132)  评论(0编辑  收藏  举报