RabbitMQ在Ubuntu 16.04下的安裝與配置
由於rabbitMq需要erlang語言的支持,在安裝rabbitMq之前需要安裝erlang,執行命令:
sudo apt-get install erlang-nox
安裝rabbitMq命令:
2.$ sudo apt-get update
3.$ sudo apt-get install rabbitmq-server
啟動、停止、重啟、狀態rabbitMq命令:
啟動:sudo rabbitmq-server start
關閉: sudo rabbitmq-server stop
重啟: sudo rabbitmq-server restart
查看狀態:sudo rabbitmqctl status
復制代碼
hongdada@ubuntu:~$ ps -ef|grep rabbit
rabbitmq 7991 1 0 00:12 ? 00:00:00 /bin/sh /usr/sbin/rabbitmq-server
rabbitmq 7999 7991 0 00:12 ? 00:00:00 /bin/sh -e /usr/lib/rabbitmq/bin/rabbitmq-server
rabbitmq 8077 1 0 00:12 ? 00:00:00 /usr/lib/erlang/erts-7.3/bin/epmd -daemon
rabbitmq 8257 8256 0 00:12 ? 00:00:00 inet_gethost 4
hongdada 8631 6788 0 00:18 pts/18 00:00:00 grep --color=auto rabbit
hongdada@ubuntu:~$ cd /usr/lib/rabbitmq/bin/
復制代碼
看起來沒有問題,現在進入安裝文件夾查看Rabbit的狀態:
復制代碼
hongdada@ubuntu:~$ cd /usr/lib/rabbitmq/bin/
hongdada@ubuntu:/usr/lib/rabbitmq/bin$ sudo ./rabbitmqctl status
Status of node rabbit@ubuntu ...
Error: unable to connect to node rabbit@ubuntu: nodedown
DIAGNOSTICS
attempted to contact: [rabbit@ubuntu]
rabbit@ubuntu:
- connected to epmd (port 4369) on ubuntu
- epmd reports node ‘rabbit‘ running on port 25672
- TCP connection succeeded but Erlang distribution failed
- suggestion: hostname mismatch?
- suggestion: is the cookie set correctly?
- suggestion: is the Erlang distribution using TLS?
current node details:
- node name: ‘rabbitmq-cli-8673@ubuntu‘
- home dir: /home/hongdada
- cookie hash: 0PRVafcTz6WKsC1GZlmK7Q==
復制代碼
有錯誤,要修改配置,先停止服務
復制代碼
hongdada@ubuntu:/usr/lib/rabbitmq/bin$ invoke-rc.d rabbitmq-server stop
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
需要通過認證才能停止“rabbitmq-server.service”。
Authenticating as: hongda,,, (hongdada)
Password:
==== AUTHENTICATION COMPLETE ===
復制代碼
進入安裝文件夾/usr/lib/rabbitmq/bin
修改rabbitmqctl文件
添加一行Home配置:加紅色的地方
復制代碼
#!/bin/sh -e
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License
at http://www.mozilla.org/MPL/
##
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and
limitations under the License.
##
The Original Code is RabbitMQ.
##
The Initial Developer of the Original Code is GoPivotal, Inc.
Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
##
Get default settings with user overrides for (RABBITMQ_)<var_name>
Non-empty defaults should be set in rabbitmq-env
. dirname $0
/rabbitmq-env
We specify Mnesia dir and sasl error logger since some actions
(e.g. forget_cluster_node --offline) require us to impersonate the
real node.
RABBITMQ_USE_LONGNAME=${RABBITMQ_USE_LONGNAME} \
HOME=/var/lib/rabbitmq \
exec ${ERL_DIR}erl \
-pa "${RABBITMQ_HOME}/ebin" \
-noinput \
-hidden \
${RABBITMQ_CTL_ERL_ARGS} \
-boot "${CLEAN_BOOT_FILE}" \
-sasl errlog_type error \
-mnesia dir "\"${RABBITMQ_MNESIA_DIR}\"" \
-s rabbit_control_main \
-nodename $RABBITMQ_NODENAME \
-extra "$@"
復制代碼
啟用web管理臺:
復制代碼
hongdada@ubuntu:/usr/lib/rabbitmq/bin$ sudo ./rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
mochiweb
webmachine
rabbitmq_web_dispatch
amqp_client
rabbitmq_management_agent
rabbitmq_management
Applying plugin configuration to rabbit@ubuntu... failed.
- Could not contact node rabbit@ubuntu.
Changes will take effect at broker restart. - Options: --online - fail if broker cannot be contacted.
--offline - do not try to contact broker.
復制代碼
查看web管理器
127.0.0.1:15672
http://blog.csdn.net/sharetop/article/details/50523081
打開管理頁面
sudo rabbitmq-plugins enable rabbitmq_management
查看安裝的插件
sudo rabbitmqctl list_users
查看用戶
sudo rabbitmqctl list_users
新增管理員用戶
sudo rabbitmqctl add_user admin admin
sudo rabbitmqctl set_user_tags admin administrator
用剛設置的賬戶登錄管理頁面
http://127.0.0.1:15672
地圖大數據雲平臺 www.favxu.com
三維地球雲平臺 3d.favxu.com
地圖雲平臺交流合作 QQ:63747667
RabbitMQ在Ubuntu 16.04下的安裝與配置