安裝rabbitmq 之后可以通過默認的15672端口訪問web界面進行管理,rabbitmq一些默認端口如下:
- 4369: epmd, a peer discovery service used by RabbitMQ nodes and CLI tools
- 5672, 5671: used by AMQP 0-9-1 and 1.0 clients without and with TLS
- 25672: used by Erlang distribution for inter-node and CLI tools communication and is allocated from a dynamic range (limited to a single port by default, computed as AMQP port + 20000). See networking guide for details.
- 15672: HTTP API clients and rabbitmqadmin (only if the management plugin is enabled)
- 61613, 61614: STOMP clients without and with TLS (only if the STOMP plugin is enabled)
- 1883, 8883: (MQTT clients without and with TLS, if the MQTT plugin is enabled
- 15674: STOMP-over-WebSockets clients (only if the Web STOMP plugin is enabled)
- 15675: MQTT-over-WebSockets clients (only if the Web MQTT plugin is enabled)
如果默認15672端口頁面無法訪問,先檢查一下防火牆,添加端口或者關閉防火牆,centos6.5 關閉防火牆:
[root@localhost ~]#servcie iptables stop --臨時關閉防火牆,重啟后復原
[root@localhost ~]#chkconfig iptables off --永久關閉防火牆,重啟后不會復原
[root@localhost ~]# service iptables status 查看防火牆狀態
若關閉防火牆之后還是無法訪問,則是由於在3.3.1和之后的版本,出於安全的考慮,guest這個默認的用戶只能通過http://localhost:15672 登錄,無法直接使用遠程ip登錄訪問,需要進行配置,在配置之前先創建一個admin賬號,並進行授權:
查看用戶 :rabbitmqctl list_users
創建一個admin用戶:rabbitmqctl add_user admin admin
用戶授權 :rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions -p / asdf ".*" ".*" ".*"
創建用戶之后需要進行配置,若使用rpm安裝,則修改配置/etc/rabbitmq/rabbitmq.config,配置內容大致如下:
[
{rabbit,
[%%
%% Network Connectivity
%% ====================
%%
%% By default, RabbitMQ will listen on all interfaces, using
%% the standard (reserved) AMQP port.
%%
{tcp_listeners, [5672]},
{loopback_users, ["admin"]}
]}
].
配置之后,如果rabbitmq無法正常啟動,出現錯誤:
init terminating in do_boot () Crash dump is being written to: erl_crash.dump...done
此時有可能是配置文件配置有問題,確保配置文件沒問題之后,重啟即可。