Win7安装与配置RabbitMQ

1.安装
下载Erlang,地址:http://www.erlang.org/download/otp_win32_R15B.exe,双击安装即可(首先装)
下载RabbitMQ,地址:http://www.rabbitmq.com/releases/rabbitmq-server/v3.3.4/rabbitmq-server-3.3.4.exe ,双击安装即可
下载rabbit-client.jar,地址:http://www.rabbitmq.com/releases/rabbitmq-java-client/v3.3.4/rabbitmq-java-client-bin-3.3.4.zip
安装完成后,在RabbitMQ的安装目录的sbin会有:rabbitmq-server.bat


2.环境变量配置
设置erlang环境变量:
ERLANG_HOME=D:\software\erl9.2
然后添加到PATH


设置RABBITMQ环境变量:
RABBITMQ_SERVER=D:\software\RabbitMQServer\rabbitmq_server-3.7.2
添加到PATH:
%RABBITMQ_SERVER%\sbin;


3.进入%RABBITMQ_SERVER%\sbin目录以管理员身份运行rabbitmq-plugins.bat:
rabbitmq-plugins.bat enable rabbitmq_management
安装完成之后以管理员身份重新启动rabbitmq-service.bat,执行下面三个命令:
rabbitmq-service.bat stop
rabbitmq-service.bat install
rabbitmq-service.bat start


4.打开web监控页面:
http://localhost:15672
默认账号:guest  密码:guest


5.Rabbit查看自带监控功能:
cmd进到sbin目录,键入rabbitmq-plugins enable rabbitmq_management启用监控管理,然后重启Rabbitmq服务器。 
打开网址:
http://localhost:55672
用户名和密码都是guest


6.增加用户和角色,及权限:
进入目录:D:\software\RabbitMQServer\rabbitmq_server-3.7.2\sbin
执行下面命令,查看当前用户列表:
rabbitmqctl list_users
其他操作:
1)新增一个用户:
rabbitmqctl add_user admin admin
再看下当前用户列表:
rabbitmqctl alist_users
结果:
Listing users ...
admin   []
guest   [administrator]


2)给新增用户admin增加“超级管理员” 角色:
执行:
rabbitmqctl set_user_tags admin administrator
再看下当前用户列表:
rabbitmqctl alist_users
Listing users ...
admin   [administrator]
guest   [administrator]
除了上面的administrator 还有 monitoring、policymaker、management、自定义名称 ,对应上面介绍到的不同的角色。


3)更改guest密码,执行下面命令:
rabbitmqctl change_password guest guest123


4)删除某个用户命令:
rabbitmqctl delete_user someuser


5)给用户admin授权:
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"


6)查看用户admin权限:
rabbitmqctl list_user_permissions admin


7)清除用户admin的权限信息:
rabbitmqctl clear_permissions admin


=====================================================================================================================
容易出错的问题:
执行查看状态命令报错:
D:\software\RabbitMQServer\rabbitmq_server-3.7.2\sbin>rabbitmqctl status
部分错误信息截取:
rabbit@LAPTOP-SDG10LIN:
  * connected to epmd (port 4369) on LAPTOP-SDG10LIN
  * epmd reports node 'rabbit' uses port 25672 for inter-node and CLI tool traffic
  * TCP connection succeeded but Erlang distribution failed
  * Authentication failed (rejected by the remote node), please check the Erlang cookie
解决办法: 
网上提供的两种方法: 
1、重装RabbitMQ服务。我试了,没成功 
2、官网提供的解决方法
Synchronise Erlang Cookies (when running a manually installedWindows Service) Erlang Security Cookies used by the service account and the userrunning rabbitmqctl.bat must besynchronised for rabbitmqctl.bat tofunction.
To ensure Erlang cookie files contain the same string, copy the.erlang.cookie file from the Windowsdirectory (normallyC:\WINDOWS\.erlang.cookie) to replace the user.erlang.cookie. The user cookie will bein the user's home directory (%HOMEDRIVE%%HOMEPATH%),e.g.C:\Documents and Settings\%USERNAME%\.erlang.cookie or C:\Users\%USERNAME%\.erlang.cookie (Windows Vista andlater).


即:使C:\Windows\.erlang.cookie 和C:\User\lujie\.erlang.cookie两个文件内容一致。 
但是我的C:\Windows下没有这个文件,我开始是直接把lujie下的文件拷贝到C:\Windows下,但是还是报同样的错误。 
然后我用搜索工具对电脑文件系统进行检索,找到C:\Windows\System32\config\systemprofile下有个.erlang.cookie文件,内容与C:\User\lujie\.erlang.cookie不一样,后来修改其中一个文件的内容,使两个文件内容一样:
再次执行命令rabbitmqctl status,成功!
C:\Windows\System32\config\systemprofile\.erlang.cookie
C:\Users\Administrator\.erlang.cookie
=====================================================================================================================

你可能感兴趣的:(RabbitMQ,Win7,Rabbitmq安装与配置)