首頁 > 軟體

設定與管理RabbitMQ

2020-06-16 17:29:17

管理RabbitMQ

RabbitMQ 預設有一個根VHOST 當然一般情況下我們都會建立屬於某個應用程式的vhost 去方便管理。在個節點當中vhost 與 vhost 之間是互相隔離的,所以在多個不同的vhost當中可以建立相同名稱的 交換器(exchange) 佇列(queue)。這個概念就像是資料庫一樣,mysql當中有個多個不同的資料庫,多個資料庫當中可以使用相同的表名的概念一樣。

接下來我們就來開始寫一下如何建立vhost~

建立Vhost
MacBook-Pro:rabbitmq Tony$ /usr/local/sbin/rabbitmqctl add_vhost APP_A
Creating vhost "APP_A" ...
刪除Vhost
MacBook-Pro:rabbitmq Tony$ /usr/local/sbin/rabbitmqctl delete_vhost APP_A
Deleting vhost "APP_A" ...
檢視節點上的Vhost
MacBook-Pro:rabbitmq Tony$ /usr/local/sbin/rabbitmqctl list_vhosts
Listing vhosts ...
/
APP_A
APP_B
Java用戶端中連結相應的vhost
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("127.0.0.1");  //伺服器地址
factory.setUsername("guest");  //預設使用者名稱
factory.setPassword("guest"); //預設密碼
factory.setVirtualHost("APP_A"); //vhost名稱
factory.setPort(5672); //預設埠

啟動和停止RabbitMQ RabbitMQ啟動的方式比較簡單,但是關閉會有幾種方式去個關閉,而且關閉的情況各有不同。

啟動RabbitMQ
MacBook-Pro:~ Tony$ /usr/local/sbin/rabbitmq-server 

              RabbitMQ 3.5.6. Copyright (C) 2007-2015 Pivotal Software, Inc.
  ##  ##      Licensed under the MPL.  See http://www.rabbitmq.com/
  ##  ##
  ##########  Logs: /usr/local/var/log/rabbitmq/rabbit@localhost.log
  ######  ##        /usr/local/var/log/rabbitmq/rabbit@localhost-sasl.log
  ##########
              Starting broker... completed with 10 plugins.

我不建議,直接在這裡使用ctrl+C的方法直接結束應用程式,我這裡推薦以下方式去關閉RabbitMQ。使用這種方式有效乾淨關閉,並且保護好持久化的佇列。

關閉RabbitMQ
MacBook-Pro:rabbitmq Tony$ /usr/local/sbin/rabbitmqctl stop
Stopping and halting node rabbit@localhost ...

當然也可以使用 -n rabbit@[hostname]來關閉其他遠端節點。這個會在介紹群集的時候在貼出程式碼

檢視RabbitMQ 狀態
MacBook-Pro:lib Tony$ /usr/local/sbin/rabbitmqctl status

Status of node rabbit@localhost ...
[{pid,10780},
 {running_applications,
     [{rabbitmq_management_visualiser,"RabbitMQ Visualiser","3.5.6"},
      {rabbitmq_management,"RabbitMQ Management Console","3.5.6"},
      {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.5.6"},
      {webmachine,"webmachine","1.10.3-rmq3.5.6-gite9359c7"},
      {mochiweb,"MochiMedia Web Server","2.7.0-rmq3.5.6-git680dba8"},
      {rabbitmq_mqtt,"RabbitMQ MQTT Adapter","3.5.6"},
      {rabbitmq_stomp,"Embedded Rabbit Stomp Adapter","3.5.6"},
      {rabbitmq_management_agent,"RabbitMQ Management Agent","3.5.6"},
      {rabbitmq_amqp1_0,"AMQP 1.0 support for RabbitMQ","3.5.6"},
      {rabbit,"RabbitMQ","3.5.6"},
      {os_mon,"CPO  CXC 138 46","2.3.1"},
      {inets,"INETS  CXC 138 49","5.10.6"},
      {mnesia,"MNESIA  CXC 138 12","4.12.5"},
      {amqp_client,"RabbitMQ AMQP Client","3.5.6"},
      {xmerl,"XML parser","1.3.7"},
      {sasl,"SASL  CXC 138 11","2.4.1"},
      {stdlib,"ERTS  CXC 138 10","2.4"},
      {kernel,"ERTS  CXC 138 10","3.2"}]},
 {os,{unix,darwin}},
 {erlang_version,
     "Erlang/OTP 17 [erts-6.4] [source] [64-bit] [smp:4:4] [async-threads:64] [hipe] [kernel-poll:true]n"},
 {memory,
     [{total,43180016},
      {connection_readers,0},
      {connection_writers,0},
      {connection_channels,0},
      {connection_other,5616},
      {queue_procs,19712},
      {queue_slave_procs,0},
      {plugins,868704},
      {other_proc,13887864},
      {mnesia,72792},
      {mgmt_db,234672},
      {msg_index,47824},
      {other_ets,1275216},
      {binary,19872},
      {code,20760734},
      {atom,711569},
      {other_system,5275441}]},
 {alarms,[]},
 {listeners,
     [{clustering,25672,"::"},
      {amqp,5672,"127.0.0.1"},
      {stomp,61613,"::"},
      {mqtt,1883,"::"}]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,1401384140},
 {disk_free_limit,50000000},
 {disk_free,8082620416},
 {file_descriptors,
     [{total_limit,156},{total_used,5},{sockets_limit,138},{sockets_used,3}]},
 {processes,[{limit,1048576},{used,198}]},
 {run_queue,0},
 {uptime,8267}]

再看看 RabbitMQ的組態檔

首先 看看 rabbitmq-env.conf 由於本人也沒有碰過 rabbitmq-env.conf 這個檔案所以我也 翻了一下官網,看看這個檔案是怎麼一回事,因為在參考的學習的書本 rabbitmq in action 中的管理rabbit 的章節當中,並沒有提及到 rabbitmq-env.conf 檔案 只有提及 rabbitma.config 。以下是官網對 rabbitmq-env.conf 檔案的介紹 我這裡就參照一下。

Name

rabbitmq-env.conf — default settings for RabbitMQ AMQP server

Description

/etc/rabbitmq/rabbitmq-env.conf contains variable settings that override the defaults built in to the RabbitMQ startup scripts.

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 /etc/rabbitmq/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 /etc/rabbitmq/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 /etc/rabbitmq/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 the /etc/rabbitmq/rabbitmq-env.conf file, etc.

英文跟我一樣一般般的看這裡,我解釋一下:

其實就是說 一般情況下RabbitMQ會有所有環境變數的預設值,他會檢查rabbitmq-env.conf這個檔案並且如果缺失的引數或者引數為空字串都會以預設的引數值為準。其實看看官方的英文解析對以後學習很大幫助 我也是努力地去看。

這是官方給出來???example

# I am a complete /etc/rabbitmq/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

但是我在我的MacBook 上尋找了非常多的方法,也無法讓設定生效,由於我是用brew命令進行安裝的rabbitmq 固然我看了一下文件 不應該在 /etc/rabbitmq/這個目錄下去建立這個變數檔案,所有我就開始鬱悶了。我看了一下文件是這樣去寫那個位置的:

Generic UNIX - $RABBITMQ_HOME/etc/rabbitmq/rabbitmq-env.conf
Debian - /etc/rabbitmq/rabbitmq-env.conf
RPM - /etc/rabbitmq/rabbitmq-env.conf
Mac OS X (Homebrew) - ${install_prefix}/etc/rabbitmq/rabbitmq-env.conf, the Homebrew prefix is usually /usr/local
Windows - %APPDATA%RabbitMQrabbitmq-env-conf.bat

說明組態檔應該在那個目前當中去建立,最終我找到安裝的目錄:

MacBook-Pro:rabbitmq Tony$ ls -al /usr/local/sbin/
total 48
drwxrwxrwx   8 root  wheel  272 10 27 11:16 .
drwxr-xr-x  25 root  wheel  850 10 27 11:13 ..
lrwxr-xr-x   1 Tony  wheel   47 10 27 11:16 rabbitmq-defaults -> ../Cellar/rabbitmq/3.5.6/sbin/rabbitmq-defaults
lrwxr-xr-x   1 Tony  wheel   42 10 27 11:16 rabbitmq-env -> ../Cellar/rabbitmq/3.5.6/sbin/rabbitmq-env
lrwxr-xr-x   1 Tony  wheel   46 10 27 11:16 rabbitmq-plugins -> ../Cellar/rabbitmq/3.5.6/sbin/rabbitmq-plugins
lrwxr-xr-x   1 Tony  wheel   45 10 27 11:16 rabbitmq-server -> ../Cellar/rabbitmq/3.5.6/sbin/rabbitmq-server
lrwxr-xr-x   1 Tony  wheel   43 10 27 11:16 rabbitmqadmin -> ../Cellar/rabbitmq/3.5.6/sbin/rabbitmqadmin
lrwxr-xr-x   1 Tony  wheel   41 10 27 11:16 rabbitmqctl -> ../Cellar/rabbitmq/3.5.6/sbin/rabbitmqctl

看到這裡應該知道他的具體位置了吧~

MacBook-Pro:rabbitmq Tony$ pwd
/usr/local/Cellar/rabbitmq/3.5.6/etc/rabbitmq
MacBook-Pro:rabbitmq Tony$ ls
rabbitmq-env.conf   rabbitmq.config.example

然後我建立 rabbitmq-env.conf 之後 是然並卵的~ 我修改了一下埠號,結果還是沒有生效。我就差重新啟動電腦了。我目前在按照一台linux的rabbitmq 一會在 LINUX下測試一下。 後面補充一下:在LINUX環境當中測試的確沒有任何問題,WHAT THE FUCK 為什麼mac os上沒有生效~? LINUX的組態檔位置 /etc/rabbitmq/rabbitmq-env.conf

關於環境設定 參照一下 官網:

關於設定的官方文件,你不點選一下看看嗎?

好再說說rabbitmq.config 哎喲,好沒有底氣啊。測試不出來,算了吧··· 一會再嘗試一下 linux 看看可不可以。

官方提出的最小設定如下:

  [
    {rabbit, [{tcp_listeners, [5673]}]}
  ].

其實設定上非常像 JSON 只要仔細觀察就能分析出它的編寫格式~ 遺憾的是經過測試也是沒有生效。之後後面慢慢檢視原因了。

後面補充在LINUX 上同樣生效,就是不知道為什麼mac上不生效。

以下就是官方提供的組態檔位置:

  • Generic UNIX - $RABBITMQ_HOME/etc/rabbitmq/
  • Debian - /etc/rabbitmq/
  • RPM - /etc/rabbitmq/
  • Mac OS X (Homebrew) - ${install_prefix}/etc/rabbitmq/, the Homebrew prefix is usually /usr/local
  • Windows - %APPDATA%RabbitMQ

由於目前我已經在linux之中安裝好rabbitMQ,我要拋棄mac 的rabbitMQ了。但是在遠端存取rabbitMQ會出錯,因為guest使用者只能在回環地址中使用,也就是說你只能在本地使用。 然後我給出一下JAVA 遠端連線時的錯誤log

Exception in thread "main" com.rabbitmq.client.PossibleAuthenticationFailureException: Possibly caused by authentication failure
    at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:355)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:516)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:533)
    at com.maxfunner.Consumer.createConnectionAndChannel(Consumer.java:35)
    at com.maxfunner.Consumer.main(Consumer.java:67)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: com.rabbitmq.client.ShutdownSignalException: connection error; reason: java.net.SocketException: Connection reset
    at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:67)
    at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:33)
    at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:343)
    at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:216)
    at com.rabbitmq.client.impl.AMQChannel.rpc(AMQChannel.java:202)
    at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:347)
    ... 9 more
Caused by: java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:209)
    at java.net.SocketInputStream.read(SocketInputStream.java:141)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:265)
    at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:288)
    at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:95)
    at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:131)
    at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:515)

“guest” user can only connect via localhost

By default, the guest user is prohibited from connecting to the broker remotely; it can only connect over a > loopback interface (i.e. localhost). This applies both to AMQP and to any other protocols enabled via plugins. Any > other users you create will not (by default) be restricted in this way.

如果我們希望在遠端的地方使用到guest使用者我們可以修改設定

[root@CentOSFrist ~]# vim /etc/rabbitmq/rabbitmq.config 

[
    {rabbit, [
                {tcp_listeners, [5673]},
                {loopback_users,[]}
        ]}      
].

重新啟動一下服務就生效了,目前的設定是 rabbit節點上 埠號為5673 loopback使用者為空。

[root@centOSFrist ~]# systemctl restart rabbitmq-server.service 

啟動之後便能夠連線到遠端的rabbitmq當中 。


先看看如何去建立使用者:

MacBook-Pro:sbin Tony$ ./rabbitmqctl add_user tony tonypwd 
Creating user "tony" ...

成功建立了一個使用者名稱為tony 密碼為tonypwd 的使用者。

刪除使用者:

MacBook-Pro:sbin Tony$ ./rabbitmqctl delete_user tony
Deleting user "tony" ...

刪除一個使用者名稱為tony 的使用者

我們可以使用命令去檢視使用者資訊

MacBook-Pro:sbin Tony$ ./rabbitmqctl list_users
Listing users ...
guest   [administrator]
tony    []

目前有兩個使用者 一個是 guest 還有就是 tony 然而guest 是 administrator

接下來我們來修改一下密碼,注意如果刪除了使用者連同使用者的許可權也會同樣刪除。

MacBook-Pro:sbin Tony$ ./rabbitmqctl change_password tony 123456
Changing password for user "tony" ...

修改了使用者名稱為tony的密碼,現在的密碼被修改為123456

然後說重點,許可權。這個是開發的過程之中用的應該最為常見。
RabbitMQ的許可權也是非常容易讓人理解的,傳統的ACL風格。

讀許可權:有關消費訊息的任何操作,包括 清除 整個佇列。

寫許可權:發布訊息

設定許可權:佇列和交換器的建立和刪除。

注意:許可權是沒有辦法跨越vhost的,如果你想某個使用者擁有兩個vhost的許可權,你必須指定兩條ACL。

先賦予tony使用者對vhost 名稱為 APP_A 的全部許可權。

[root@centOSFrist ~]# rabbitmqctl set_permissions -p APP_A tony ".*" ".*" ".*"
Setting permissions for user "tony" in vhost "APP_A" ...
  • -p APP_AP –> 指定許可權所對應的vhost,這裡所寫的vhost為APP_A
  • tony –> 跟在vhost 引數後面的是 對應的使用者名稱稱 這裡所指定的使用者名稱稱為tony
  • 第一個 “.*” –> 設定許可權的正規表示式【最討厭正規表示式】
  • 第二個 “.*” –> 寫入許可權的正規表示式
  • 第三個 “.*” –> 讀許可權的正規表示式

然後我們可以嘗試修改一下tony這個使用者的許可權

[root@centOSFrist ~]# rabbitmqctl set_permissions -p APP_A tony  
> "tony-.*" "tony-.*" ".*"
Setting permissions for user "tony" in vhost "APP_A" ...

tony 使用者目前可以對APP_A 這個vhost 設定tony-開頭的交換器/佇列 同時可以在tony-開頭的交換器或者佇列發布訊息 可以訂閱所有訊息。

在JAVA 應用程式中測試一下(擷取重點程式碼,以及錯誤LOG)

        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("192.168.0.21");  
        factory.setUsername("tony");  
        factory.setPassword("tonypwd");
        factory.setVirtualHost("APP_A");
        factory.setPort(5673); 

建立交換器和佇列:


private static final String EXCHANGE_NAME = "MY_EXCHANGE";


        this.channel.exchangeDeclare(EXCHANGE_NAME,"direct",false,true,null); //最好也建立一下交換器,反正已經建立也沒有關係

        this.channel.queueDeclare("QUEUE_A",false,false,true,null);

        this.channel.queueBind("QUEUE_A",EXCHANGE_NAME,"KEY_A");

由於我目前建立的交換器名稱為 MY_EXCHANGE 所以就出現了錯誤的LOG:


Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason:
{#method<channel.close>(reply-code=403, reply-text=ACCESS_REFUSED - 
access to exchange 'MY_EXCHANGE' in vhost 'APP_A' refused for user 'tony',
class-id=40, method-id=10), null, ""}

    at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:67)
    at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:33)
    at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:343)
    at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:216)
    at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:118)
    ... 10 more

當我修改了所有的交換器和佇列的名稱為tony-EXCHANGE tony-QUEUE 之後就一切就正常了,我們可以使用命令檢視目前某個vhost中的設定:

[root@centOSFrist ~]# rabbitmqctl list_permissions
Listing permissions in vhost "/" ...
guest   .*  .*  .*
[root@centOSFrist ~]# rabbitmqctl list_permissions -p APP_A
Listing permissions in vhost "APP_A" ...
tony    tony-.* tony-.* .*

還可以使用命令檢視某個使用者的許可權:

[root@centOSFrist ~]# rabbitmqctl list_user_permissions tony
Listing permissions for user "tony" ...
APP_A   tony-.* tony-.* .*

刪除某一個使用者許可權如下:

[root@centOSFrist ~]# rabbitmqctl clear_permissions -p APP_A tony
Clearing permissions for user "tony" in vhost "APP_A" ...
[root@centOSFrist ~]# rabbitmqctl list_user_permissions tony
Listing permissions for user "tony" ...

處理針對vhost的使用許可權之外還提供,一種角色許可權去管理RabbitMQ。

none、management、policymaker、monitoring、administrator

none :
不能存取 management plugin
management :
可以使用AMQP所有功能
列出自己可以通過AMQP登入VHOST  
檢視自己的vhost中的佇列、交換器、系結
檢視和關閉自己的通道(channel) 和 connection
檢視自己有關的vhost的“全域性”的統計資訊和其他使用者在這些vhost中的活動。
policymaker :
management的所有許可權
對自己的vhost所屬的policies和parameters 進行增刪改查
monitoring  :
management的所有許可權
檢視所有vhost
檢視節點的資料使用情況
所有vhost的全域性的統計資訊
administrator :
什麼都可以乾~

設定使用者角色許可權:

[root@centOSFrist ~]# rabbitmqctl set_user_tags tony  policymaker
Setting tags for user "tony" to [policymaker] ...
[root@centOSFrist ~]# rabbitmqctl list_users
Listing users ...
guest   [administrator]
tony    [policymaker]

這個的許可權的體現具體會在RabbitMQ的web控制台上面介紹。

檢視RabbitMQ的資料資訊

列出佇列和訊息數目
[root@centOSFrist ~]# rabbitmqctl list_queues -p APP_A
Listing queues ...
tony-QUEUE  0
QUEUE_A 6


------------
目前只顯示了 佇列名稱 和對應的 訊息總數,除此之外提供一下引數:

<queueinfoitem> must be a member of the list [name, durable, auto_delete, 
arguments, policy, pid, owner_pid, exclusive, exclusive_consumer_pid, 
exclusive_consumer_tag, messages_ready, messages_unacknowledged, messages, 
messages_ready_ram, messages_unacknowledged_ram, messages_ram, 
messages_persistent, message_bytes, message_bytes_ready, 
message_bytes_unacknowledged, message_bytes_ram, message_bytes_persistent, 
head_message_timestamp, disk_reads, disk_writes, consumers, 
consumer_utilisation, memory, slave_pids, synchronised_slave_pids, state].

[root@centOSFrist ~]# rabbitmqctl list_queues -p APP_A  name durable pid memory
Listing queues ...
tony-QUEUE  false   <rabbit@centOSFrist.2.608.0>    14040
QUEUE_A     false   <rabbit@centOSFrist.2.644.0>    21816
列出交換器和系結
[root@centOSFrist ~]# rabbitmqctl list_exchanges -p APP_A 
Listing exchanges ...
amq.headers         headers
amq.fanout          fanout
amq.direct          direct
amq.match           headers
    direct
amq.topic           topic
amq.rabbitmq.trace  topic
MY_EXCHANGE         direct
tony-EXCHANGE       direct

其他引數如下:
<exchangeinfoitem> must be a member of the list [name, type, durable, 
auto_delete, internal, arguments, policy].

檢視RabbitMQ的紀錄檔

RabbitMQ的紀錄檔預設位置在:

[root@centOSFrist ~]# ls -ll /var/log/rabbitmq/
總用量 32
-rw-r--r--. 1 rabbitmq rabbitmq 13247 112 11:37 rabbit@centOSFrist.log
-rw-r--r--. 1 rabbitmq rabbitmq     0 111 17:04 rabbit@centOSFrist-sasl.log
-rw-r--r--. 1 root     root        60 111 17:58 shutdown_err
-rw-r--r--. 1 root     root        49 111 17:58 shutdown_log
-rw-r--r--. 1 root     root        60 111 17:58 startup_err
-rw-r--r--. 1 root     root       355 111 17:58 startup_log

rabbit@centOSFrist.log -> 節點名稱為rabbit 主機為 centOSFrist 的紀錄檔 主要看這個紀錄檔

rabbit@centOSFrist-sasl.log -> 節點名稱為rabbit 主機為 centOSFrist 的系統應用程式支援庫紀錄檔 大部分是關於 Erlang的紀錄檔

可以使用tail 命令檢視實時紀錄檔情況:

[root@centOSFrist ~]# tail -f  /var/log/rabbitmq/rabbit@centOSFrist.log 

=ERROR REPORT==== 2-Nov-2016::11:36:57 ===
Error on AMQP connection <0.626.0> (192.168.0.2:59664 -> 192.168.0.21:5673, user: 'guest', state: opening):
access to vhost 'APP_A' refused for user 'guest'

=INFO REPORT==== 2-Nov-2016::11:36:57 ===
closing AMQP connection <0.626.0> (192.168.0.2:59664 -> 192.168.0.21:5673)

=INFO REPORT==== 2-Nov-2016::11:37:32 ===
accepting AMQP connection <0.632.0> (192.168.0.2:59680 -> 192.168.0.21:5673)

如果紀錄檔需要輪換 可以使用命令進行輪換紀錄檔

[root@centOSFrist ~]# rabbitmqctl rotate_logs 1
Rotating logs to files with suffix "1" ...

[root@centOSFrist ~]# ls -ll /var/log/rabbitmq/
總用量 32
-rw-r--r--. 1 rabbitmq rabbitmq     0 112 11:58 rabbit@centOSFrist.log
-rw-r--r--. 1 rabbitmq rabbitmq 13320 112 11:58 rabbit@centOSFrist.log1
-rw-r--r--. 1 rabbitmq rabbitmq     0 112 11:58 rabbit@centOSFrist-sasl.log
-rw-r--r--. 1 rabbitmq rabbitmq     0 112 11:58 rabbit@centOSFrist-sasl.log1
-rw-r--r--. 1 root     root        60 111 17:58 shutdown_err
-rw-r--r--. 1 root     root        49 111 17:58 shutdown_log
-rw-r--r--. 1 root     root        60 111 17:58 startup_err
-rw-r--r--. 1 root     root       355 111 17:58 startup_log

最後貼下我參考的官網連結:

許可權 : http://www.rabbitmq.com/access-control.html

設定 : http://www.rabbitmq.com/configure.html

rabbitmqctrl : http://www.rabbitmq.com/man/rabbitmqctl.1.man.html

CentOS 5.6 安裝RabbitMQ http://www.linuxidc.com/Linux/2013-02/79508.htm

RabbitMQ用戶端C++安裝詳細記錄 http://www.linuxidc.com/Linux/2012-02/53521.htm

Python嘗試RabbitMQ http://www.linuxidc.com/Linux/2011-12/50653.htm

RabbitMQ叢集環境生產範例部署 http://www.linuxidc.com/Linux/2012-10/72720.htm

CentOS7環境安裝使用專業的訊息佇列產品RabbitMQ http://www.linuxidc.com/Linux/2016-11/13673.htm

在CentOS上安裝RabbitMQ流程 http://www.linuxidc.com/Linux/2011-12/49610.htm

RabbitMQ概念及環境搭建 http://www.linuxidc.com/Linux/2014-12/110449.htm

RabbitMQ入門教學  http://www.linuxidc.com/Linux/2015-02/113983.htm


IT145.com E-mail:sddin#qq.com