一、下載管理命令
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=...