windows 下 rabbitMQ 的下载安装配置文档

本贴最后更新于 2214 天前,其中的信息可能已经事过景迁

一.安装 Erlang

在安装 rabbitMQ 之前,需要先安装 Erlang 。
官网链接:http://www.erlang.org/downloads
本文安装的是 otp_win64_18.1.exe,安装目录为 E:\erl7.1
查看系统环境变量是否已添加:
ERLANG_HOME=E:\erl7.1

二.安装 RabbitMQ

官网链接:http://www.rabbitmq.com/download.html
默认安装的 RabbitMQ 监听端口是 5672
本文安装的是 rabbitmq-server-3.6.5.exe,安装目录为 E:\RabbitMQ Server
最好添加在环境变量 Path 中添加上 E:\RabbitMQ Server\rabbitmq_server-3.6.5\sbin 路径,方便后续执行命令。

三.配置

3.1 基本步骤

在安装目录下找到 sbin 文件夹,如 E:\RabbitMQ Server\rabbitmq_server-3.6.5\sbin,此文件夹存放了 rabbitmq 的操作脚本文件。
在此文件夹中使用 cmd 打开命令窗口。
运行以下命令查看是否安装成功:

rabbitmqctl status

出现以下内容:


Status of node 'rabbit@PC-20160802JFII' ...
[{pid,2800},
 {running_applications,
   [{rabbitmq_management,"RabbitMQ Management Console","3.6.5"},
  {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.6.5"},
  {webmachine,"webmachine","1.10.3"},
  {mochiweb,"MochiMedia Web Server","2.13.1"},
  {ssl,"Erlang/OTP SSL application","7.1"},
  {public_key,"Public key infrastructure","1.0.1"},
  {crypto,"CRYPTO","3.6.1"},
  {asn1,"The Erlang ASN1 compiler version 4.0","4.0"},
  {rabbitmq_management_agent,"RabbitMQ Management Agent","3.6.5"},
  {rabbit,"RabbitMQ","3.6.5"},
  {ranch,"Socket acceptor pool for TCP protocols.","1.2.1"},
  {syntax_tools,"Syntax tools","1.7"},
  {amqp_client,"RabbitMQ AMQP Client","3.6.5"},
  {rabbit_common,[],"3.6.5"},
  {xmerl,"XML parser","1.3.8"},
  {compiler,"ERTS  CXC 138 10","6.0.1"},
  {mnesia,"MNESIA  CXC 138 12","4.13.1"},
  {os_mon,"CPO  CXC 138 46","2.4"},
  {inets,"INETS  CXC 138 49","6.0.1"},
  {sasl,"SASL  CXC 138 11","2.6"},
  {stdlib,"ERTS  CXC 138 10","2.6"},
  {kernel,"ERTS  CXC 138 10","4.1"}]},
 {os,{win32,nt}},
 {erlang_version,
 "Erlang/OTP 18 [erts-7.1] [64-bit] [smp:4:4] [async-threads:64]\n"},

说明 RabbitMQ 处于成功运行状态。

激活 RabbitMQ's Management Plugin(RabbitMQ 管理插件)
使用 RabbitMQ 管理插件,可以更好的可视化方式查看 Rabbit MQ 服务器实例的状态。
输入以下命令:

rabbitmq-plugins enable rabbitmq_management

安装好插件之后,需要使用系统管理员重启服务:

net stop RabbitMQ && net start RabbitMQ 
或使用 
rabbitmq-server restart

此时访问 http://localhost:15672 ,即可看到如下界面:
0417b579ada84350a101b5645c3ac02d-image.png

初始账号为:guest;初始密码为:guest;

3.2 常见错误处理

3.2.1 运行 rabbitmqctl status 报错

错误 1:
若显示如下错误:


系统找不到指定的路径。

******************************
ERLANG_HOME not set correctly.
******************************

Please either set ERLANG_HOME to point to your Erlang installation or place the
RabbitMQ server distribution in the Erlang lib folder.

解决方法:
针对以上错误,需要将 Erlang 的安装目录加入 ERLANG_HOME 环境变量。

错误 2:
若显示如下错误:


Status of node 'rabbit@PC-20160802JFII' ...
Error: unable to connect to node 'rabbit@PC-20160802JFII': nodedown

DIAGNOSTICS
===========

attempted to contact: ['rabbit@PC-20160802JFII']

rabbit@PC-20160802JFII:
  * connected to epmd (port 4369) on PC-20160802JFII
  * epmd reports: node 'rabbit' not running at all
				  no other nodes on PC-20160802JFII
  * suggestion: start the node

current node details:
- node name: 'rabbitmq-cli-71@PC-20160802JFII'
- home dir: C:\Users\Administrator
- cookie hash: dNaminTztSUTXnrGzjTMlg==

解决方法:

  1. 节点 rabbit 未启动,执行 rabbitmq-server restart 启动 rabbit 服务。再另外打开一个命令行窗口使用 rabbitmqctl status 查看状态。
  2. 主机名原因,使用命令 hostname 查看主机名是否与上文"rabbit@ 主机名"部分的主机名相同,若不相同,重启服务器,或修改主机名即可。
    笔者是通过方法 1 解决的。

错误 3:
若显示如下错误:


Status of node 'rabbit@PC-20160802JFII' ...
Error: unable to connect to node 'rabbit@PC-20160802JFII': nodedown

DIAGNOSTICS
===========

attempted to contact: ['rabbit@PC-20160802JFII']

rabbit@PC-20160802JFII:
  * connected to epmd (port 4369) on PC-20160802JFII
  * 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-92@PC-20160802JFII'
- home dir: C:\Users\Administrator
- cookie hash: 8EjkxpRyt7k15b4Za2LWDg==

解决方法:
C:\Windows\.erlang.cookie 复制一份,拷贝到 C:\Users\%USERNAME%\.erlang.cookie 目录下,点击替换即可。

3.2.2 运行 rabbitmq-server restart 报错

错误 1:
若显示如下错误:


BOOT FAILED
===========

Error description:
   "Found lock file at ~s.\n            Either previous upgrade is in progress o
r has failed.\n            Database backup path: ~s"

Log files (may contain more information):
   C:/Users/ADMINI~1/AppData/Roaming/RabbitMQ/log/RABBIT~1.LOG
   C:/Users/ADMINI~1/AppData/Roaming/RabbitMQ/log/RABBIT~3.LOG

Stack trace:
   [{rabbit_upgrade,ensure_backup_taken,
					["c:/Users/ADMINI~1/AppData/Roaming/RabbitMQ/db/RABBIT~1/sch
ema_upgrade_lock",
					 "c:/Users/ADMINI~1/AppData/Roaming/RabbitMQ/db/RABBIT~1-upg
rade-backup"],
					[{file,"src/rabbit_upgrade.erl"},{line,101}]},
	{rabbit_upgrade,maybe_upgrade_mnesia,0,
					[{file,"src/rabbit_upgrade.erl"},{line,144}]},
	{rabbit,'-boot/0-fun-0-',0,[{file,"src/rabbit.erl"},{line,271}]},
	{rabbit,start_it,1,[{file,"src/rabbit.erl"},{line,403}]},
	{init,start_it,1,[{file,"init.erl"},{line,1054}]},
	{init,start_em,1,[{file,"init.erl"},{line,1034}]}]

{"init terminating in do_boot","Found lock file at ~s.\n            Either previ
ous upgrade is in progress or has failed.\n            Database backup path: ~s"
}

Crash dump is being written to: erl_crash.dump...done
init terminating in do_boot (Found lock file at ~s.
			Either previous upgrade is in progress or has failed.
			Database backup path: ~s)

解决方法:
查看报错中 db 所在位置,即可找到文件夹 C:\Users\Administrator\AppData\Roaming\RabbitMQ,删除该文件夹,重新运行 rabbitmq-server restart 即可。

3.3 创建用户,密码,绑定角色

(1) 查看已有用户及用户的角色:
rabbitmqctl list_users
(2) 新增一个用户:
rabbitmqctl add_user username password
(3) 设置用户角色:
rabbitmqctl set_user_tags username 角色1 角色2 角色3
(4) 修改用户密码:
rabbitmqctl change_password userName newPassword
(5) 删除用户:
rabbitmqctl delete_user username

也可在可视化网页中进行相关操作。

3.4 权限设置

权限相关命令为:
(1) 设置用户权限
rabbitmqctl  set_permissions  -p  VHostPath  User  ConfP  WriteP  ReadP
(2) 查看(指定hostpath)所有用户的权限信息
rabbitmqctl  list_permissions  [-p  VHostPath]
(3) 查看指定用户的权限信息
rabbitmqctl  list_user_permissions  User
(4)  清除用户的权限信息
rabbitmqctl  clear_permissions  [-p VHostPath]  User

也可在可视化网页中进行相关操作。

部分内容参考:http://www.cnblogs.com/ericli-ericli/p/5902270.html

  • RabbitMQ

    RabbitMQ 是一个开源的 AMQP 实现,服务器端用 Erlang 语言编写,支持多种语言客户端,如:Python、Ruby、.NET、Java、C、PHP、ActionScript 等。用于在分布式系统中存储转发消息,在易用性、扩展性、高可用性等方面表现不俗。

    49 引用 • 60 回帖 • 361 关注

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...