Rabbit MQ 的安装
第一步 准备好安装包
第二步 安装
安装顺序分别安装erlang,socat,rabbitmq,如下
[root@localhost packages]# rpm -ivh erlang-18.3-1.el7.centos.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:erlang-18.3-1.el7.centos ################################# [100%]
[root@localhost packages]# rpm -ivh socat-1.7.3.2-1.1.el7.x86_64.rpm
warning: socat-1.7.3.2-1.1.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 87e360b8: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:socat-1.7.3.2-1.1.el7 ################################# [100%]
[root@localhost packages]#
[root@localhost packages]# rpm -ivh rabbitmq-server-3.6.5-1.noarch.rpm
warning: rabbitmq-server-3.6.5-1.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:rabbitmq-server-3.6.5-1 ################################# [100%]
[root@localhost packages]#
第三步 打开管理界面
[root@localhost packages]# 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@localhost... failed.
* Could not contact node rabbit@localhost.
Changes will take effect at broker restart.
* Options: --online - fail if broker cannot be contacted.
--offline - do not try to contact broker.
第四步,修改默认配置信息
vim /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.5/ebin/rabbit.app
将:{loopback_users, [<<”guest”>>]},
改为:{loopback_users, []},
原因:rabbitmq从3.3.0开始禁止使用guest/guest权限通过除localhost外的访问
[root@localhost packages]# vim /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.5/ebin/rabbit.app
第五步 创建配置文件
[root@localhost packages]# cd /usr/share/doc/rabbitmq-server-3.6.5/
[root@localhost rabbitmq-server-3.6.5]# cp rabbitmq.config.example /etc/rabbitmq/rabbitmq.config
[root@localhost rabbitmq-server-3.6.5]# chown allen /etc/rabbitmq/rabbitmq.config
[root@localhost rabbitmq-server-3.6.5]# cd /etc/rabbitmq/
[root@localhost rabbitmq]# ls -la
total 40
drwxr-xr-x. 2 root root 52 May 5 05:47 .
drwxr-xr-x. 140 root root 8192 May 5 05:39 ..
-rw-r--r--. 1 root root 23 May 5 05:41 enabled_plugins
第六步 启动rabbitmq服务
[root@localhost packages]# service rabbitmq-server start
Starting rabbitmq-server (via systemctl): [ OK ]
[root@localhost packages]#
service rabbitmq-server stop # 停止服务
service rabbitmq-server restart # 重启服务
service rabbitmq-server status # 查看状态
查看启动
添加用户,
[root@localhost ebin]# rabbitmqctl add_user admin admin
Creating user "admin" ...
[root@localhost ebin]# rabbitmqctl set_user_tags admin administrator
Setting tags for user "admin" to [administrator] ...
使用用户登录成功
注意,刚开始我试了只能在本机登录,使用其他机器使用ip来连接的时候一直报如下错误。
并且用java客户端连接的时候也报如下错误
PossibleAuthenticationFailureException: Possibly caused by authentication failure
当改完如上的第四步, 问题解决
Rabbit MQ的一些概念: