消息型中間件之RabbitMQ基礎使用

  一、概念node

  RabbitMQ是AMQP(高級消息隊列協議)協議的實現主要功能用於分佈式應用當中的各組件間解耦。在傳統C/S架構中,若是客戶端發送一個請求消息,服務端必須得在線,有了中間件,客戶端不是非得要服務端在線纔可發送請求,客戶端只需將請求消息發送給中間件,中間件負責存儲和轉發請求消息,此時若是服務端不在線,依然不妨礙客戶端的請求能夠發出,而客戶端的請求此時有可能還會被正常服務;而對於消息型中間件最核心的組件有3個,分別是exchange(交換器)、binding(綁定器)、queue(隊列);其中交換器的做用是把消息發出一方(簡稱生產者)發出的消息,經過交換器把消息發送給綁定器,綁定器根據匹配路由規則把消息路由給後端隊列,而後訂閱者再到對應的隊列上取出消息進行消費,一般一個訂閱者(消息消費者,或者叫用戶也行)對應一個或多個隊列;而訂閱者與隊列之間的信道(傳遞消息的通道)咱們稱之爲channel(頻道);也就說訂閱者能夠訂閱一個或多個頻道,一旦對應頻道有消息產生,對應訂閱者都會收到;一個消息該如何發送到對應的隊列,這取決於咱們的路由模式,路由模式一般咱們經過綁定器進行定義;也就是說綁定器的主要做用就是用來定義交換器收到消息後該把消息發送到那個給隊列;而對於路由模式來說,它有多種,常見的有direct(點到點的直接路由)、topic(話題型過濾)、fan-out(刪除)、headers(基於消息首部過濾);這些路由模式主要是用來過濾消息的,把符合咱們定義的路由規則的消息過濾出來,發送到指定隊列,因此咱們也能夠把路由模式稱之爲消息過濾器;簡單點講路由規則就是把交換器上的某一類消息綁定一個或多個隊列;對於AMQP來說,除了上面的4中路由模式之外,它還定義一個virtualhost的概念,所謂virtualhost就是虛擬主機,這裏的虛擬主機主要是用來應用隔離,一個虛擬主機內部能夠有exchange、binding、queue;它至關於一個單獨broker,因此虛擬主機它能夠將一個物理的broker劃分紅多個不一樣應用的broker;linux

  二、RabbitMQ架構git

  提示:上圖主要描述了生產者把消息經過交換器匹配路由規則(綁定器)把不一樣類型的消息經過綁定器把消息路由到不一樣的隊列上,而後消費者根據自身訂閱的頻道,到不一樣頻道對應的隊列上取出消息進行消費的一個過程;程序員

  三、RabbitMQ的安裝配置web

  在centos7上rabbitmq的安裝很是簡單,咱們只須要配置好epel源,而後yum安裝便可;docker

[root@node1 ~]# yum repolist
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
源標識                                       源名稱                                                              狀態
!base/7/x86_64                               CentOS-7 - Base - mirrors.aliyun.com                                10,070
!docker-ce-stable/x86_64                     Docker CE Stable - x86_64                                               79
!epel/x86_64                                 Extra Packages for Enterprise Linux 7 - x86_64                      13,426
!extras/7/x86_64                             CentOS-7 - Extras - mirrors.aliyun.com                                 413
!updates/7/x86_64                            CentOS-7 - Updates - mirrors.aliyun.com                              1,112
repolist: 25,100
[root@node1 ~]# yum install rabbitmq-server
已加載插件:fastestmirror, langpacks
base                                                                                            | 3.6 kB  00:00:00     
docker-ce-stable                                                                                | 3.5 kB  00:00:00     
epel                                                                                            | 4.7 kB  00:00:00     
extras                                                                                          | 2.9 kB  00:00:00     
updates                                                                                         | 2.9 kB  00:00:00     
(1/2): epel/x86_64/updateinfo                                                                   | 1.0 MB  00:00:00     
(2/2): epel/x86_64/primary_db                                                                   | 6.9 MB  00:00:01     
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解決依賴關係
--> 正在檢查事務
---> 軟件包 rabbitmq-server.noarch.0.3.3.5-34.el7 將被 安裝
--> 正在處理依賴關係 erlang-erts >= R12B-3,它被軟件包 rabbitmq-server-3.3.5-34.el7.noarch 須要
……省略部份內容……
已安裝:
  rabbitmq-server.noarch 0:3.3.5-34.el7                                                                                

做爲依賴被安裝:
  erlang-asn1.x86_64 0:R16B-03.18.el7                      erlang-compiler.x86_64 0:R16B-03.18.el7                    
  erlang-crypto.x86_64 0:R16B-03.18.el7                    erlang-erts.x86_64 0:R16B-03.18.el7                        
  erlang-hipe.x86_64 0:R16B-03.18.el7                      erlang-inets.x86_64 0:R16B-03.18.el7                       
  erlang-kernel.x86_64 0:R16B-03.18.el7                    erlang-mnesia.x86_64 0:R16B-03.18.el7                      
  erlang-os_mon.x86_64 0:R16B-03.18.el7                    erlang-otp_mibs.x86_64 0:R16B-03.18.el7                    
  erlang-public_key.x86_64 0:R16B-03.18.el7                erlang-runtime_tools.x86_64 0:R16B-03.18.el7               
  erlang-sasl.x86_64 0:R16B-03.18.el7                      erlang-sd_notify.x86_64 0:0.1-1.el7                        
  erlang-snmp.x86_64 0:R16B-03.18.el7                      erlang-ssl.x86_64 0:R16B-03.18.el7                         
  erlang-stdlib.x86_64 0:R16B-03.18.el7                    erlang-syntax_tools.x86_64 0:R16B-03.18.el7                
  erlang-tools.x86_64 0:R16B-03.18.el7                     erlang-xmerl.x86_64 0:R16B-03.18.el7                       

完畢!
[root@node1 ~]# 

  提示:rabbitmq是erlang語言研發,因此安裝rabbitmq-server這個包,它會依賴不少erlang包,而這些包都來自epel倉庫,因此安裝以前必定要先配置好epel源;數據庫

  查看rabbitmq-server安裝生成了哪些文件windows

[root@node1 ~]# rpm -ql rabbitmq-server
/etc/logrotate.d/rabbitmq-server
/etc/rabbitmq
/etc/rabbitmq/rabbitmq.config
/usr/lib/ocf/resource.d/rabbitmq/rabbitmq-server
/usr/lib/rabbitmq/bin
/usr/lib/rabbitmq/bin/rabbitmq-defaults
/usr/lib/rabbitmq/bin/rabbitmq-env
/usr/lib/rabbitmq/bin/rabbitmq-plugins
/usr/lib/rabbitmq/bin/rabbitmq-server
/usr/lib/rabbitmq/bin/rabbitmqctl
/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5
/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/ebin
/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/ebin/app_utils.beam
/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/ebin/background_gc.beam
/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/ebin/credit_flow.beam
/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/ebin/delegate.beam
/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/ebin/delegate_sup.beam
……省略部份內容……
/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/sbin
/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/sbin/rabbitmq-defaults
/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/sbin/rabbitmq-env
/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/sbin/rabbitmq-plugins
/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/sbin/rabbitmq-server
/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/sbin/rabbitmqctl
/usr/lib/systemd/system/rabbitmq-server.service
/usr/lib/tmpfiles.d/rabbitmq-server.conf
/usr/sbin/rabbitmq-plugins
/usr/sbin/rabbitmq-server
/usr/sbin/rabbitmqctl
……省略部份內容……
/var/log/rabbitmq
/var/run/rabbitmq
[root@node1 ~]# 

  提示:/usr/sbin/rabbitmqctl 這個工具是命令行工具,主要用來管理rabbitmq;/usr/sbin/rabbitmq-plugins用來管理rabbitmq插件的命令行工具;/usr/sbin/rabbitmq-server服務器二進制主程序;/usr/lib/systemd/system/rabbitmq-server.service這個文件是它的基於systemd啓動的unit file;/usr/lib/rabbitmq/bin/rabbitmq-defaults這個文件用於定義默認環境變量配置;/var/log/rabbitmq用於存放rabbitmq日誌目錄;/etc/rabbitmq/rabbitmq.config這個是rabbitmq的主配置文件,主要定義個組件訪問權限,資源限制,插件及集羣相關配置;rabbitmq的配置方式分3中,第一種是環境變量的方式,該方式主要用來定義網絡參數以及配置文件路徑相關配置;其次是配置文件的方式,配置文件主要定義服務器各組件間的訪問權限,資源限制,插件以及集羣相關配置;最後一種是運行時參數,這種方式主要用於定義rabbitmq集羣的運行時參數;後端

  比較經常使用的環境變量centos

    RABBITMQ_BASE:用來指定rabbitmq的安裝目錄,這個目錄主要存放rabbitmq數據庫和日誌相關文件。(通常用於windows,類unix上不經常使用)

    RABBITMQ_CONFIG_FILE:用於指定配置文件路徑;

    RABBITMQ_LOGS:用於單獨指定日誌文件;

    RABBITMQ_NODE_IP_ADDRESS:用於指定節點監聽的ip地址;

    RABBITMQ_NODE_PORT:用於指定節點監聽的端口;

    RABBITMQ_NODE_NAME:用於指定節點名稱;

    RABBITMQ_PLUGINS_DIR:用於指定插件目錄;

  rabbitmq默認配置文件相關變量說明

    auth_mechanisms:用於定義rabbitmq的認證機制;

    default_user:定義默認用戶;默認是guest;

    default_pass:定義默認用戶的默認密碼;默認是guest;

    default_premission:定義默認用戶的默認權限;默認是".*" ".*" ".*";

    default_user_tags:定義默認用戶的標籤,默認是administrator;

    default_vhost:定義默認虛擬主機;默認是「/」;

    disk_free_limit:定義磁盤最少預留空間;默認50M;

    hearbeat:定義檢測各組件存活的消息時長(心跳值);默認600秒;

    hipe_compile:用於指定是否使用hipe編譯器編譯程序;默認是true,表示使用hipe編譯器;

    log_levels:用於指定日誌級別,這裏的日誌級別只有四種,分別是none,error,warning,info;

    tcp_listeners:定義監聽的地址和端口;默認是本機的全部地址的5672;

    ssl_listeners:定義基於ssl協議通訊監聽的地址和端口;默認是本機的全部地址的5672;

    vm_memory_high_watermark:定義內存的高水位標記,所謂高水位標記,就是用來指定內存的最少空閒內存空間;

  啓動rabbitmq-server

  提示:以默認配置文件啓動rabbitmq,它會監聽5672和25672,25672是用來集羣通訊的端口;5672是rabbitmq的管理接口;除了這兩個端口,若是開啓了rabbitmq-management插件,它還會監聽15672;rabbitmq-management這個插件主要提供了web圖形化管理界面;

  四、rabbitmqctl使用

  rabbitmqctl幫助信息

[root@node1 ~]# rabbitmqctl -h
Error: could not recognise command
Usage:
rabbitmqctl [-n <node>] [-q] <command> [<command options>] 

Options:
    -n node
    -q

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.

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

Commands:
    stop [<pid_file>]
    stop_app
    start_app
    wait <pid_file>
    reset
    force_reset
    rotate_logs <suffix>

    join_cluster <clusternode> [--ram]
    cluster_status
    change_cluster_node_type disc | ram
    forget_cluster_node [--offline]
    update_cluster_nodes clusternode
    sync_queue queue
    cancel_sync_queue queue
    set_cluster_name name

    add_user <username> <password>
    delete_user <username>
    change_password <username> <newpassword>
    clear_password <username>
    set_user_tags <username> <tag> ...
    list_users

    add_vhost <vhostpath>
    delete_vhost <vhostpath>
    list_vhosts [<vhostinfoitem> ...]
    set_permissions [-p <vhostpath>] <user> <conf> <write> <read>
    clear_permissions [-p <vhostpath>] <username>
    list_permissions [-p <vhostpath>]
    list_user_permissions <username>

    set_parameter [-p <vhostpath>] <component_name> <name> <value>
    clear_parameter [-p <vhostpath>] <component_name> <key>
    list_parameters [-p <vhostpath>]

    set_policy [-p <vhostpath>] [--priority <priority>] [--apply-to <apply-to>] 
<name> <pattern>  <definition>
    clear_policy [-p <vhostpath>] <name>
    list_policies [-p <vhostpath>]

    list_queues [-p <vhostpath>] [<queueinfoitem> ...]
    list_exchanges [-p <vhostpath>] [<exchangeinfoitem> ...]
    list_bindings [-p <vhostpath>] [<bindinginfoitem> ...]
    list_connections [<connectioninfoitem> ...]
    list_channels [<channelinfoitem> ...]
    list_consumers [-p <vhostpath>]
    status
    environment
    report
    eval <expr>

    close_connection <connectionpid> <explanation>
    trace_on [-p <vhost>]
    trace_off [-p <vhost>]
    set_vm_memory_high_watermark <fraction>

<vhostinfoitem> must be a member of the list [name, tracing].

The list_queues, list_exchanges and list_bindings commands accept an optional 
virtual host parameter for which to display results. The default value is "/".

<queueinfoitem> must be a member of the list [name, durable, auto_delete, 
arguments, policy, pid, owner_pid, exclusive_consumer_pid, 
exclusive_consumer_tag, messages_ready, messages_unacknowledged, messages, 
consumers, consumer_utilisation, memory, slave_pids, synchronised_slave_pids, 
status].

<exchangeinfoitem> must be a member of the list [name, type, durable, 
auto_delete, internal, arguments, policy].

<bindinginfoitem> must be a member of the list [source_name, source_kind, 
destination_name, destination_kind, routing_key, arguments].

<connectioninfoitem> must be a member of the list [pid, name, port, host, 
peer_port, peer_host, ssl, ssl_protocol, ssl_key_exchange, ssl_cipher, 
ssl_hash, peer_cert_subject, peer_cert_issuer, peer_cert_validity, state, 
channels, protocol, auth_mechanism, user, vhost, timeout, frame_max, 
channel_max, client_properties, recv_oct, recv_cnt, send_oct, send_cnt, 
send_pend].

<channelinfoitem> must be a member of the list [pid, connection, name, number, 
user, vhost, transactional, confirm, consumer_count, messages_unacknowledged, 
messages_uncommitted, acks_uncommitted, messages_unconfirmed, prefetch_count, 
global_prefetch_count].


[root@node1 ~]# 

  提示:從上面的幫助信息能夠了解到rabbitmqctl這個工具備不少子命令;主要有對應用到管理相關子命令,對虛擬主機相關管理的,權限,用戶,集羣,策略等等;

  stop [<pid_file>]:中止rabbitmq-server;

[root@node1 ~]# rabbitmqctl stop
Stopping and halting node rabbit@node1 ...
...done.
[root@node1 ~]# ss -tnl
State       Recv-Q Send-Q              Local Address:Port                             Peer Address:Port              
LISTEN      0      5                   192.168.122.1:53                                          *:*                  
LISTEN      0      128                             *:22                                          *:*                  
LISTEN      0      128                     127.0.0.1:631                                         *:*                  
LISTEN      0      100                     127.0.0.1:25                                          *:*                  
LISTEN      0      100                     127.0.0.1:64667                                       *:*                  
LISTEN      0      128                             *:8000                                        *:*                  
LISTEN      0      128                             *:8001                                        *:*                  
LISTEN      0      5                       127.0.0.1:8010                                        *:*                  
LISTEN      0      128                             *:111                                         *:*                  
LISTEN      0      128                             *:80                                          *:*                  
LISTEN      0      128                            :::22                                         :::*                  
LISTEN      0      128                           ::1:631                                        :::*                  
LISTEN      0      100                           ::1:25                                         :::*                  
LISTEN      0      128                            :::111                                        :::*                  
LISTEN      0      128                            :::80                                         :::*                  
[root@node1 ~]# 

  提示:rabbitmqctl stop 就至關於把rabbitmq服務給殺死,中止服務;

  stop_app:中止rabbitmq-server上的全部應用;

[root@node1 ~]# rabbitmqctl status   
Status of node rabbit@node1 ...
[{pid,18223},
 {running_applications,[{rabbit,"RabbitMQ","3.3.5"},
                        {os_mon,"CPO  CXC 138 46","2.2.14"},
                        {mnesia,"MNESIA  CXC 138 12","4.11"},
                        {xmerl,"XML parser","1.3.6"},
                        {sasl,"SASL  CXC 138 11","2.3.4"},
                        {stdlib,"ERTS  CXC 138 10","1.19.4"},
                        {kernel,"ERTS  CXC 138 10","2.16.4"}]},
 {os,{unix,linux}},
 {erlang_version,"Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:30] [hipe] [kernel-poll:true]\n"},
 {memory,[{total,36262168},
          {connection_procs,2800},
          {queue_procs,5600},
          {plugins,0},
          {other_proc,13729216},
          {mnesia,60144},
          {mgmt_db,0},
          {msg_index,21880},
          {other_ets,756824},
          {binary,19048},
          {code,16707498},
          {atom,602729},
          {other_system,4356429}]},
 {alarms,[]},
 {listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,1581588480},
 {disk_free_limit,50000000},
 {disk_free,39834275840},
 {file_descriptors,[{total_limit,924},
                    {total_used,3},
                    {sockets_limit,829},
                    {sockets_used,1}]},
 {processes,[{limit,1048576},{used,127}]},
 {run_queue,0},
 {uptime,367}]
...done.
[root@node1 ~]# rabbitmqctl stop_app
Stopping node rabbit@node1 ...
...done.
[root@node1 ~]# rabbitmqctl status  
Status of node rabbit@node1 ...
[{pid,18223},
 {running_applications,[{xmerl,"XML parser","1.3.6"},
                        {sasl,"SASL  CXC 138 11","2.3.4"},
                        {stdlib,"ERTS  CXC 138 10","1.19.4"},
                        {kernel,"ERTS  CXC 138 10","2.16.4"}]},
 {os,{unix,linux}},
 {erlang_version,"Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:30] [hipe] [kernel-poll:true]\n"},
 {memory,[{total,35566624},
          {connection_procs,0},
          {queue_procs,0},
          {plugins,0},
          {other_proc,13300856},
          {mnesia,0},
          {mgmt_db,0},
          {msg_index,0},
          {other_ets,607888},
          {binary,12600},
          {code,16707498},
          {atom,602729},
          {other_system,4335053}]},
 {alarms,[]},
 {listeners,[]},
 {processes,[{limit,1048576},{used,46}]},
 {run_queue,0},
 {uptime,384}]
...done.
[root@node1 ~]# ss -tnl
State       Recv-Q Send-Q              Local Address:Port                             Peer Address:Port              
LISTEN      0      5                   192.168.122.1:53                                          *:*                  
LISTEN      0      128                             *:22                                          *:*                  
LISTEN      0      128                     127.0.0.1:631                                         *:*                  
LISTEN      0      100                     127.0.0.1:25                                          *:*                  
LISTEN      0      100                     127.0.0.1:64667                                       *:*                  
LISTEN      0      128                             *:8000                                        *:*                  
LISTEN      0      128                             *:8001                                        *:*                  
LISTEN      0      128                             *:25672                                       *:*                  
LISTEN      0      5                       127.0.0.1:8010                                        *:*                  
LISTEN      0      128                             *:111                                         *:*                  
LISTEN      0      128                             *:80                                          *:*                  
LISTEN      0      128                             *:4369                                        *:*                  
LISTEN      0      128                            :::22                                         :::*                  
LISTEN      0      128                           ::1:631                                        :::*                  
LISTEN      0      100                           ::1:25                                         :::*                  
LISTEN      0      128                            :::111                                        :::*                  
LISTEN      0      128                            :::80                                         :::*                  
LISTEN      0      128                            :::4369                                       :::*                  
[root@node1 ~]# 

  提示:rabbitmqctl stop_app這個命令只是中止rabbitmq上的應用,而非中止rabbitmq服務;因此監聽的端口信息都還在;rabbitmqctl status是查看rabbitmq的狀態信息;

  start_app:啓動已有應用;

[root@node1 ~]# rabbitmqctl status
Status of node rabbit@node1 ...
[{pid,18223},
 {running_applications,[{xmerl,"XML parser","1.3.6"},
                        {sasl,"SASL  CXC 138 11","2.3.4"},
                        {stdlib,"ERTS  CXC 138 10","1.19.4"},
                        {kernel,"ERTS  CXC 138 10","2.16.4"}]},
 {os,{unix,linux}},
 {erlang_version,"Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:30] [hipe] [kernel-poll:true]\n"},
 {memory,[{total,35564488},
          {connection_procs,0},
          {queue_procs,0},
          {plugins,0},
          {other_proc,13299600},
          {mnesia,0},
          {mgmt_db,0},
          {msg_index,0},
          {other_ets,607888},
          {binary,12600},
          {code,16707498},
          {atom,602729},
          {other_system,4334173}]},
 {alarms,[]},
 {listeners,[]},
 {processes,[{limit,1048576},{used,46}]},
 {run_queue,0},
 {uptime,495}]
...done.
[root@node1 ~]# rabbitmqctl start_app
Starting node rabbit@node1 ...
...done.
[root@node1 ~]# rabbitmqctl status   
Status of node rabbit@node1 ...
[{pid,18223},
 {running_applications,[{rabbit,"RabbitMQ","3.3.5"},
                        {os_mon,"CPO  CXC 138 46","2.2.14"},
                        {mnesia,"MNESIA  CXC 138 12","4.11"},
                        {xmerl,"XML parser","1.3.6"},
                        {sasl,"SASL  CXC 138 11","2.3.4"},
                        {stdlib,"ERTS  CXC 138 10","1.19.4"},
                        {kernel,"ERTS  CXC 138 10","2.16.4"}]},
 {os,{unix,linux}},
 {erlang_version,"Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:30] [hipe] [kernel-poll:true]\n"},
 {memory,[{total,36211968},
          {connection_procs,2800},
          {queue_procs,5600},
          {plugins,0},
          {other_proc,13678784},
          {mnesia,60144},
          {mgmt_db,0},
          {msg_index,21928},
          {other_ets,756792},
          {binary,19048},
          {code,16707530},
          {atom,602729},
          {other_system,4356613}]},
 {alarms,[]},
 {listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,1581588480},
 {disk_free_limit,50000000},
 {disk_free,39833972736},
 {file_descriptors,[{total_limit,924},
                    {total_used,3},
                    {sockets_limit,829},
                    {sockets_used,1}]},
 {processes,[{limit,1048576},{used,127}]},
 {run_queue,0},
 {uptime,513}]
...done.
[root@node1 ~]# 

  提示:能夠看到application中多了mnesia,rabbit,os_mon這3個app的信息;

  reset:重置;

  force_reset:強制重置;

  用戶管理相關子命令

    list_users:查看用戶列表;

[root@node1 ~]# rabbitmqctl list_users
Listing users ...
guest   [administrator]
...done.
[root@node1 ~]# 

  提示:默認只有grest用戶,這個用戶的標籤是administrator,表示這是一個管理員;

    add_user <username> <password>:添加用戶;

[root@node1 ~]# rabbitmqctl add_user qiuhom test
Creating user "qiuhom" ...
...done.
[root@node1 ~]# rabbitmqctl list_users          
Listing users ...
guest   [administrator]
qiuhom  []
...done.
[root@node1 ~]# 

  提示:添加用戶必須指定用戶名和密碼;默認添加到用戶都是普通用戶,就是沒有任何標籤的用戶;

    delete_user <username>:刪除指定用戶;

[root@node1 ~]# rabbitmqctl delete_user qiuhom
Deleting user "qiuhom" ...
...done.
[root@node1 ~]# rabbitmqctl list_users        
Listing users ...
guest   [administrator]
...done.
[root@node1 ~]# 

  提示:刪除用戶只需指定用戶名便可;

    change_password <username> <newpassword>:修改指定用戶密碼;

[root@node1 ~]# rabbitmqctl change_password guest admin
Changing password for user "guest" ...
...done.
[root@node1 ~]# 

  提示:以上表示修改guest用戶的命名爲admin;若是咱們開啓了web管理界面就能夠來測試guest用戶的密碼,若是使用admin可以登陸到管理界面說明密碼修改爲功了,不能說明沒有修改爲功,guest用戶的默認密碼是guest;

  驗證:開啓rabbitmq-mangerment插件,看看對應guest用戶的密碼是否更改了?

[root@node1 ~]# rabbitmq-plugins list
[ ] amqp_client                       3.3.5
[ ] cowboy                            0.5.0-rmq3.3.5-git4b93c2d
[ ] eldap                             3.3.5-gite309de4
[ ] mochiweb                          2.7.0-rmq3.3.5-git680dba8
[ ] rabbitmq_amqp1_0                  3.3.5
[ ] rabbitmq_auth_backend_ldap        3.3.5
[ ] rabbitmq_auth_mechanism_ssl       3.3.5
[ ] rabbitmq_consistent_hash_exchange 3.3.5
[ ] rabbitmq_federation               3.3.5
[ ] rabbitmq_federation_management    3.3.5
[ ] rabbitmq_management               3.3.5
[ ] rabbitmq_management_agent         3.3.5
[ ] rabbitmq_management_visualiser    3.3.5
[ ] rabbitmq_mqtt                     3.3.5
[ ] rabbitmq_shovel                   3.3.5
[ ] rabbitmq_shovel_management        3.3.5
[ ] rabbitmq_stomp                    3.3.5
[ ] rabbitmq_test                     3.3.5
[ ] rabbitmq_tracing                  3.3.5
[ ] rabbitmq_web_dispatch             3.3.5
[ ] rabbitmq_web_stomp                3.3.5
[ ] rabbitmq_web_stomp_examples       3.3.5
[ ] sockjs                            0.3.4-rmq3.3.5-git3132eb9
[ ] webmachine                        1.10.3-rmq3.3.5-gite9359c7
[root@node1 ~]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
  mochiweb
  webmachine
  rabbitmq_web_dispatch
  amqp_client
  rabbitmq_management_agent
  rabbitmq_management
Plugin configuration has changed. Restart RabbitMQ for changes to take effect.
[root@node1 ~]# rabbitmq-plugins list
[e] amqp_client                       3.3.5
[ ] cowboy                            0.5.0-rmq3.3.5-git4b93c2d
[ ] eldap                             3.3.5-gite309de4
[e] mochiweb                          2.7.0-rmq3.3.5-git680dba8
[ ] rabbitmq_amqp1_0                  3.3.5
[ ] rabbitmq_auth_backend_ldap        3.3.5
[ ] rabbitmq_auth_mechanism_ssl       3.3.5
[ ] rabbitmq_consistent_hash_exchange 3.3.5
[ ] rabbitmq_federation               3.3.5
[ ] rabbitmq_federation_management    3.3.5
[E] rabbitmq_management               3.3.5
[e] rabbitmq_management_agent         3.3.5
[ ] rabbitmq_management_visualiser    3.3.5
[ ] rabbitmq_mqtt                     3.3.5
[ ] rabbitmq_shovel                   3.3.5
[ ] rabbitmq_shovel_management        3.3.5
[ ] rabbitmq_stomp                    3.3.5
[ ] rabbitmq_test                     3.3.5
[ ] rabbitmq_tracing                  3.3.5
[e] rabbitmq_web_dispatch             3.3.5
[ ] rabbitmq_web_stomp                3.3.5
[ ] rabbitmq_web_stomp_examples       3.3.5
[ ] sockjs                            0.3.4-rmq3.3.5-git3132eb9
[e] webmachine                        1.10.3-rmq3.3.5-gite9359c7
[root@node1 ~]# 

  提示:啓用插件須要用rabbitmq-plugins命令,enable表示啓用指定插件,disable表示禁用指定插件,list表示列出插件列表;其中列出插件列表前邊中括號中的大寫E表示手動開啓的插件,小寫e表示手動開啓插件依賴的插件,自動開啓的;

  重啓rabbitmq-server服務

  提示:啓用了插件,必需要重啓服務纔可以正常使用插件,從上的信息能夠看到咱們啓用了rabbitmq-mangement插件,重啓rabbitmq-server服務後,對應的15672端口就處於監聽狀態了;

  登陸宿主機的15672端口,訪問web管理界面

  提示:用guest用戶使用admin密碼是可以登陸到管理界面,說明咱們更改密碼成功了;其實不少命令行可以管理的,咱們均可以基於這個web管理界面進行管理;

    set_user_tags <username> <tag> ...:設置指定用戶的標籤;

[root@node1 ~]# rabbitmqctl add_user qiuhom test
Creating user "qiuhom" ...
...done.
[root@node1 ~]# rabbitmqctl list_users
Listing users ...
guest   [administrator]
qiuhom  []
...done.
[root@node1 ~]# rabbitmqctl set_user_tags qiuhom administrator
Setting tags for user "qiuhom" to [administrator] ...
...done.
[root@node1 ~]# rabbitmqctl list_users
Listing users ...
guest   [administrator]
qiuhom  [administrator]
...done.
[root@node1 ~]# rabbitmqctl set_user_tags qiuhom 
Setting tags for user "qiuhom" to [] ...
...done.
[root@node1 ~]# rabbitmqctl list_users           
Listing users ...
guest   [administrator]
qiuhom  []
...done.
[root@node1 ~]# 

  提示:若是用戶名後面不指定任何標籤,至關於把原有的標籤信息清空;標籤爲administrator的用戶擁有登陸web管理界面的權限;

    clear_password <username>:清空指定用戶的密碼;

[root@node1 ~]# rabbitmqctl clear_password qiuhom
Clearing password for user "qiuhom" ...
...done.
[root@node1 ~]#

  虛擬主機相關管理子命令

    list_vhosts [<vhostinfoitem> ...]:列出虛擬主機列表;

[root@node1 ~]# rabbitmqctl list_vhosts
Listing vhosts ...
/
...done.
[root@node1 ~]#

  提示:默認只有「/」這個虛擬主機;

    add_vhost <vhostpath>:添加虛擬主機;

[root@node1 ~]# rabbitmqctl add_vhost /qiuhom/test
Creating vhost "/qiuhom/test" ...
...done.
[root@node1 ~]# rabbitmqctl list_vhosts           
Listing vhosts ...
/
/qiuhom/test
...done.
[root@node1 ~]# 

    delete_vhost <vhostpath>:刪除虛擬主機;

[root@node1 ~]# rabbitmqctl delete_vhost /qiuhom/test
Deleting vhost "/qiuhom/test" ...
...done.
[root@node1 ~]# rabbitmqctl list_vhosts              
Listing vhosts ...
/
...done.
[root@node1 ~]# 

  權限相關管理子命令

    list_permissions [-p <vhostpath>]:列出指定虛擬主機權限,不指定表示查看默認虛擬主機的權限(這個是以虛擬主機查看權限);

[root@node1 ~]# rabbitmqctl list_permissions
Listing permissions in vhost "/" ...
guest   .*      .*      .*
...done.
[root@node1 ~]# rabbitmqctl add_vhost /qiuhom/test
Creating vhost "/qiuhom/test" ...
...done.
[root@node1 ~]# rabbitmqctl list_permissions      
Listing permissions in vhost "/" ...
guest   .*      .*      .*
...done.
[root@node1 ~]# rabbitmqctl list_permissions -p /qiuhom/test
Listing permissions in vhost "/qiuhom/test" ...
...done.
[root@node1 ~]# 

  提示:默認虛擬主機上「/」,guest用戶對「/」這個虛擬主機如下的全部組件有訪問權限;其中第一個.*表示配置文件,第二個.*表示寫權限,第三個是讀權限;

    list_user_permissions <username>:列出指定用戶的權限(可以對那些虛擬主機進行哪些操做,這個是以用戶名去查看權限)

[root@node1 ~]# rabbitmqctl list_user_permissions guest
Listing permissions for user "guest" ...
/       .*      .*      .*
...done.
[root@node1 ~]# 

  提示:以上表示查看guest這個用戶全部虛擬主機上的權限;這裏須要注意一點虛擬主機都是以/開始的樹狀結構,且支持繼承,所謂繼承就表示一某個虛擬主機開始一下全部子虛擬主機都有相同的權限;以上guest就對全部虛擬主機有訪問權限;

    set_permissions [-p <vhostpath>] <user> <conf> <write> <read>:設置權限,不指定虛擬主機表示給默認虛擬主機設定權限;

[root@node1 ~]# rabbitmqctl list_users
Listing users ...
guest   [administrator]
qiuhom  []
...done.
[root@node1 ~]# rabbitmqctl list_vhosts
Listing vhosts ...
/
/qiuhom/test
...done.
[root@node1 ~]# rabbitmqctl set_permissions qiuhom ".*" ".*" ".*"  
Setting permissions for user "qiuhom" in vhost "/" ...
...done.
[root@node1 ~]# rabbitmqctl list_permissions  
Listing permissions in vhost "/" ...
guest   .*      .*      .*
qiuhom  .*      .*      .*
...done.
[root@node1 ~]# rabbitmqctl set_permissions -p /qiuhom/test qiuhom ".*" ".*" ".*"
Setting permissions for user "qiuhom" in vhost "/qiuhom/test" ...
...done.
[root@node1 ~]# rabbitmqctl list_permissions                                     
Listing permissions in vhost "/" ...
guest   .*      .*      .*
qiuhom  .*      .*      .*
...done.
[root@node1 ~]#rabbitmqctl list_permissions  -p /qiuhom/test
Listing permissions in vhost "/qiuhom/test" ...
qiuhom  .*      .*      .*
...done.
[root@node1 ~]# 

    clear_permissions [-p <vhostpath>] <username>:清空指定用戶對某虛擬主機的權限,默認不指定虛擬主機表示默認虛擬主機;

[root@node1 ~]# rabbitmqctl list_permissions  -p /qiuhom/test
Listing permissions in vhost "/qiuhom/test" ...
qiuhom  .*      .*      .*
...done.
[root@node1 ~]# rabbitmqctl list_user_permissions  qiuhom    
Listing permissions for user "qiuhom" ...
/       .*      .*      .*
/qiuhom/test    .*      .*      .*
...done.
[root@node1 ~]# rabbitmqctl clear_permissions -p / qiuhom
Clearing permissions for user "qiuhom" in vhost "/" ...
...done.
[root@node1 ~]# rabbitmqctl list_user_permissions  qiuhom    
Listing permissions for user "qiuhom" ...
/qiuhom/test    .*      .*      .*
...done.
[root@node1 ~]# rabbitmqctl list_permissions  -p /
Listing permissions in vhost "/" ...
guest   .*      .*      .*
...done.
[root@node1 ~]# rabbitmqctl clear_permissions -p /qiuhom/test qiuhom 
Clearing permissions for user "qiuhom" in vhost "/qiuhom/test" ...
...done.
[root@node1 ~]# rabbitmqctl list_permissions  -p /qiuhom/test       
Listing permissions in vhost "/qiuhom/test" ...
...done.
[root@node1 ~]# 

  組件查看類子命令

    list_queues [-p <vhostpath>] [<queueinfoitem> ...]:列出隊列;

[root@node1 ~]# rabbitmqctl list_queues     
Listing queues ...
...done.
[root@node1 ~]#

    list_exchanges [-p <vhostpath>] [<exchangeinfoitem> ...]:列出交換器;

[root@node1 ~]# rabbitmqctl list_exchanges  
Listing exchanges ...
        direct
amq.direct      direct
amq.fanout      fanout
amq.headers     headers
amq.match       headers
amq.rabbitmq.log        topic
amq.rabbitmq.trace      topic
amq.topic       topic
...done.
[root@node1 ~]#

    list_bindings [-p <vhostpath>] [<bindinginfoitem> ...]:列出綁定器;

[root@node1 ~]# rabbitmqctl list_bindings   
Listing bindings ...
...done.
[root@node1 ~]#

    list_connections [<connectioninfoitem> ...]:列出鏈接列表

[root@node1 ~]# rabbitmqctl list_connections
Listing connections ...
...done.
[root@node1 ~]# 

    list_channels [<channelinfoitem> ...]:列出頻道

[root@node1 ~]# rabbitmqctl list_channels   
Listing channels ...
...done.
[root@node1 ~]#

  提示:上面這些組件咱們除了能夠在命令經過子命令的方式查看,其實在web管理界面也給咱們提供了一個api訪問接口;

  在web界面訪問api接口查看虛擬主機

  在web界面查看用戶列表

  提示:須要查看某類組件的信息,能夠在api後面加上對應組件的名稱做爲rui便可訪問,固然有了這個api接口,程序員就能夠調用這個接口從而對rabbitmq進行操做;具體操做文檔可訪問對應宿主機的15672/api查看示例;

    list_consumers [-p <vhostpath>]:列出消費者

[root@node1 ~]# rabbitmqctl list_consumers  
Listing consumers ...
...done.
[root@node1 ~]# 

    status:查看rabbitmq的狀態信息;

[root@node1 ~]# rabbitmqctl status
Status of node rabbit@node1 ...
[{pid,20202},
 {running_applications,
     [{rabbitmq_management,"RabbitMQ Management Console","3.3.5"},
      {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.3.5"},
      {webmachine,"webmachine","1.10.3-rmq3.3.5-gite9359c7"},
      {mochiweb,"MochiMedia Web Server","2.7.0-rmq3.3.5-git680dba8"},
      {rabbitmq_management_agent,"RabbitMQ Management Agent","3.3.5"},
      {rabbit,"RabbitMQ","3.3.5"},
      {os_mon,"CPO  CXC 138 46","2.2.14"},
      {inets,"INETS  CXC 138 49","5.9.8"},
      {mnesia,"MNESIA  CXC 138 12","4.11"},
      {amqp_client,"RabbitMQ AMQP Client","3.3.5"},
      {xmerl,"XML parser","1.3.6"},
      {sasl,"SASL  CXC 138 11","2.3.4"},
      {stdlib,"ERTS  CXC 138 10","1.19.4"},
      {kernel,"ERTS  CXC 138 10","2.16.4"}]},
 {os,{unix,linux}},
 {erlang_version,
     "Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:30] [hipe] [kernel-poll:true]\n"},
 {memory,
     [{total,40816096},
      {connection_procs,5600},
      {queue_procs,5600},
      {plugins,432624},
      {other_proc,13494248},
      {mnesia,64144},
      {mgmt_db,45376},
      {msg_index,34528},
      {other_ets,1085424},
      {binary,119600},
      {code,20229052},
      {atom,711569},
      {other_system,4588331}]},
 {alarms,[]},
 {listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,1581588480},
 {disk_free_limit,50000000},
 {disk_free,39831085056},
 {file_descriptors,
     [{total_limit,924},{total_used,3},{sockets_limit,829},{sockets_used,1}]},
 {processes,[{limit,1048576},{used,181}]},
 {run_queue,0},
 {uptime,5271}]
...done.
[root@node1 ~]# 

    environment:查看環境變量;

[root@node1 ~]# rabbitmqctl environment
Application environment of node rabbit@node1 ...
[{auth_backends,[rabbit_auth_backend_internal]},
 {auth_mechanisms,['PLAIN','AMQPLAIN']},
 {backing_queue_module,rabbit_variable_queue},
 {channel_max,0},
 {channel_operation_timeout,70000},
 {cluster_nodes,{[],disc}},
 {cluster_partition_handling,ignore},
 {collect_statistics,fine},
 {collect_statistics_interval,5000},
 {default_permissions,[<<".*">>,<<".*">>,<<".*">>]},
 {default_user,<<"guest">>},
 {default_user_tags,[administrator]},
 {default_vhost,<<"/">>},
 {delegate_count,16},
 {disk_free_limit,50000000},
 {enabled_plugins_file,"/etc/rabbitmq/enabled_plugins"},
 {error_logger,{file,"/var/log/rabbitmq/rabbit@node1.log"}},
 {frame_max,131072},
 {halt_on_upgrade_failure,true},
 {heartbeat,580},
 {hipe_compile,false},
 {hipe_modules,[rabbit_reader,rabbit_channel,gen_server2,rabbit_exchange,
                rabbit_command_assembler,rabbit_framing_amqp_0_9_1,
                rabbit_basic,rabbit_event,lists,queue,priority_queue,
                rabbit_router,rabbit_trace,rabbit_misc,rabbit_binary_parser,
                rabbit_exchange_type_direct,rabbit_guid,rabbit_net,
                rabbit_amqqueue_process,rabbit_variable_queue,
                rabbit_binary_generator,rabbit_writer,delegate,gb_sets,lqueue,
                sets,orddict,rabbit_amqqueue,rabbit_limiter,gb_trees,
                rabbit_queue_index,rabbit_exchange_decorator,gen,dict,ordsets,
                file_handle_cache,rabbit_msg_store,array,
                rabbit_msg_store_ets_index,rabbit_msg_file,
                rabbit_exchange_type_fanout,rabbit_exchange_type_topic,mnesia,
                mnesia_lib,rpc,mnesia_tm,qlc,sofs,proplists,credit_flow,pmon,
                ssl_connection,tls_connection,ssl_record,tls_record,gen_fsm,
                ssl]},
 {included_applications,[]},
 {log_levels,[{connection,info}]},
 {loopback_users,[]},
 {msg_store_file_size_limit,16777216},
 {msg_store_index_module,rabbit_msg_store_ets_index},
 {plugins_dir,"/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/sbin/../plugins"},
 {plugins_expand_dir,"/var/lib/rabbitmq/mnesia/rabbit@node1-plugins-expand"},
 {queue_index_max_journal_entries,65536},
 {reverse_dns_lookups,false},
 {sasl_error_logger,{file,"/var/log/rabbitmq/rabbit@node1-sasl.log"}},
 {server_properties,[]},
 {ssl_apps,[asn1,crypto,public_key,ssl]},
 {ssl_cert_login_from,distinguished_name},
 {ssl_listeners,[]},
 {ssl_options,[]},
 {tcp_listen_options,[binary,
                      {packet,raw},
                      {reuseaddr,true},
                      {backlog,128},
                      {nodelay,true},
                      {linger,{true,0}},
                      {exit_on_close,false}]},
 {tcp_listeners,[5672]},
 {trace_vhosts,[]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_high_watermark_paging_ratio,0.5}]
...done.
[root@node1 ~]# 

    report:生成系統狀態報告;

[root@node1 ~]# rabbitmqctl report
Reporting server status on {{2020,8,25},{16,18,8}}

 ...
Status of node rabbit@node1 ...
[{pid,20202},
 {running_applications,
     [{rabbitmq_management,"RabbitMQ Management Console","3.3.5"},
      {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.3.5"},
      {webmachine,"webmachine","1.10.3-rmq3.3.5-gite9359c7"},
      {mochiweb,"MochiMedia Web Server","2.7.0-rmq3.3.5-git680dba8"},
      {rabbitmq_management_agent,"RabbitMQ Management Agent","3.3.5"},
      {rabbit,"RabbitMQ","3.3.5"},
      {os_mon,"CPO  CXC 138 46","2.2.14"},
      {inets,"INETS  CXC 138 49","5.9.8"},
      {mnesia,"MNESIA  CXC 138 12","4.11"},
      {amqp_client,"RabbitMQ AMQP Client","3.3.5"},
      {xmerl,"XML parser","1.3.6"},
      {sasl,"SASL  CXC 138 11","2.3.4"},
      {stdlib,"ERTS  CXC 138 10","1.19.4"},
      {kernel,"ERTS  CXC 138 10","2.16.4"}]},
 {os,{unix,linux}},
 {erlang_version,
     "Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:30] [hipe] [kernel-poll:true]\n"},
 {memory,
     [{total,40510448},
      {connection_procs,5600},
      {queue_procs,5600},
      {plugins,208520},
      {other_proc,13407608},
      {mnesia,64144},
      {mgmt_db,50256},
      {msg_index,34528},
      {other_ets,1085424},
      {binary,119648},
      {code,20229052},
      {atom,711569},
      {other_system,4588499}]},
 {alarms,[]},
 {listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,1581588480},
 {disk_free_limit,50000000},
 {disk_free,39831064576},
 {file_descriptors,
     [{total_limit,924},{total_used,3},{sockets_limit,829},{sockets_used,1}]},
 {processes,[{limit,1048576},{used,181}]},
 {run_queue,0},
 {uptime,5347}]

Cluster status of node rabbit@node1 ...
[{nodes,[{disc,[rabbit@node1]}]},
 {running_nodes,[rabbit@node1]},
 {cluster_name,<<"rabbit@node1">>},
 {partitions,[]}]

Application environment of node rabbit@node1 ...
[{auth_backends,[rabbit_auth_backend_internal]},
 {auth_mechanisms,['PLAIN','AMQPLAIN']},
 {backing_queue_module,rabbit_variable_queue},
 {channel_max,0},
 {channel_operation_timeout,70000},
 {cluster_nodes,{[],disc}},
 {cluster_partition_handling,ignore},
 {collect_statistics,fine},
 {collect_statistics_interval,5000},
 {default_permissions,[<<".*">>,<<".*">>,<<".*">>]},
 {default_user,<<"guest">>},
 {default_user_tags,[administrator]},
 {default_vhost,<<"/">>},
 {delegate_count,16},
 {disk_free_limit,50000000},
 {enabled_plugins_file,"/etc/rabbitmq/enabled_plugins"},
 {error_logger,{file,"/var/log/rabbitmq/rabbit@node1.log"}},
 {frame_max,131072},
 {halt_on_upgrade_failure,true},
 {heartbeat,580},
 {hipe_compile,false},
 {hipe_modules,[rabbit_reader,rabbit_channel,gen_server2,rabbit_exchange,
                rabbit_command_assembler,rabbit_framing_amqp_0_9_1,
                rabbit_basic,rabbit_event,lists,queue,priority_queue,
                rabbit_router,rabbit_trace,rabbit_misc,rabbit_binary_parser,
                rabbit_exchange_type_direct,rabbit_guid,rabbit_net,
                rabbit_amqqueue_process,rabbit_variable_queue,
                rabbit_binary_generator,rabbit_writer,delegate,gb_sets,lqueue,
                sets,orddict,rabbit_amqqueue,rabbit_limiter,gb_trees,
                rabbit_queue_index,rabbit_exchange_decorator,gen,dict,ordsets,
                file_handle_cache,rabbit_msg_store,array,
                rabbit_msg_store_ets_index,rabbit_msg_file,
                rabbit_exchange_type_fanout,rabbit_exchange_type_topic,mnesia,
                mnesia_lib,rpc,mnesia_tm,qlc,sofs,proplists,credit_flow,pmon,
                ssl_connection,tls_connection,ssl_record,tls_record,gen_fsm,
                ssl]},
 {included_applications,[]},
 {log_levels,[{connection,info}]},
 {loopback_users,[]},
 {msg_store_file_size_limit,16777216},
 {msg_store_index_module,rabbit_msg_store_ets_index},
 {plugins_dir,"/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/sbin/../plugins"},
 {plugins_expand_dir,"/var/lib/rabbitmq/mnesia/rabbit@node1-plugins-expand"},
 {queue_index_max_journal_entries,65536},
 {reverse_dns_lookups,false},
 {sasl_error_logger,{file,"/var/log/rabbitmq/rabbit@node1-sasl.log"}},
 {server_properties,[]},
 {ssl_apps,[asn1,crypto,public_key,ssl]},
 {ssl_cert_login_from,distinguished_name},
 {ssl_listeners,[]},
 {ssl_options,[]},
 {tcp_listen_options,[binary,
                      {packet,raw},
                      {reuseaddr,true},
                      {backlog,128},
                      {nodelay,true},
                      {linger,{true,0}},
                      {exit_on_close,false}]},
 {tcp_listeners,[5672]},
 {trace_vhosts,[]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_high_watermark_paging_ratio,0.5}]

Connections:

Channels:

Queues on /qiuhom/test:

Queues on /:

Exchanges on /qiuhom/test:
name    type    durable auto_delete     internal        arguments       policy
        direct  true    false   false   []
amq.direct      direct  true    false   false   []
amq.fanout      fanout  true    false   false   []
amq.headers     headers true    false   false   []
amq.match       headers true    false   false   []
amq.rabbitmq.trace      topic   true    false   true    []
amq.topic       topic   true    false   false   []

Exchanges on /:
name    type    durable auto_delete     internal        arguments       policy
        direct  true    false   false   []
amq.direct      direct  true    false   false   []
amq.fanout      fanout  true    false   false   []
amq.headers     headers true    false   false   []
amq.match       headers true    false   false   []
amq.rabbitmq.log        topic   true    false   true    []
amq.rabbitmq.trace      topic   true    false   true    []
amq.topic       topic   true    false   false   []

Bindings on /qiuhom/test:

Bindings on /:

Consumers on /qiuhom/test:

Consumers on /:

Permissions on /qiuhom/test:

Permissions on /:
user    configure       write   read
guest   .*      .*      .*

Policies on /qiuhom/test:

Policies on /:

Parameters on /qiuhom/test:

Parameters on /:

...done.
[root@node1 ~]# 

  策略相關管理子命令

    list_policies [-p <vhostpath>]:列出指定虛擬主機的策略;默認不指定是列出默認虛擬主機;

    set_policy [-p <vhostpath>] [--priority <priority>] [--apply-to <apply-to>] <name> <pattern> <definition>:對指定虛擬主機設置策略,沒有指定虛擬主機表示默認虛擬主機;

    clear_policy [-p <vhostpath>] <name>:清楚指定虛擬主機的策略,沒有指定虛擬主機表示對默認虛擬主機操做;

  集羣相關子命令

    join_cluster <clusternode> [--ram]:加入指定節點集羣;

    cluster_status:查看集羣狀態

    change_cluster_node_type disc | ram:更改節點存儲類型,disc表示磁盤,ram表示內存;一個集羣中必須有一個節點爲disc類型;

    forget_cluster_node [--offline]:離開集羣;

    update_cluster_nodes clusternode:更新集羣節點;

    sync_queue queue:同步指定隊列;

    cancel_sync_queue queue:取消指定隊列同步

    set_cluster_name name:設置集羣名稱;

  設置參數相關子命令

    list_parameters [-p <vhostpath>]:查看指定虛擬主機運行時參數配置,默認不指定虛擬主機,表示查看默認虛擬主機的參數配置;

    set_parameter [-p <vhostpath>] <component_name> <name> <value>:設置指定參數的配置;不指定虛擬主機表示操做默認虛擬主機;

    clear_parameter [-p <vhostpath>] <component_name> <key>:刪除指定配置項;

  其餘子命令

    eval <expr>:執行erlang表達式

    close_connection <connectionpid> <explanation>:關閉指定鏈接;

    trace_on [-p <vhost>]:開啓指定虛擬主機的追蹤功能;

    trace_off [-p <vhost>]:關閉指定虛擬主機的追蹤功能;

    set_vm_memory_high_watermark <fraction>:設置內存高水位標記;

  以上就是rabbit的簡單介紹和安裝配置相關參數的說明,以及rabbitctl這個工具的經常使用子命令的用法;

相關文章
相關標籤/搜索