安装包下载
安装问题描述
版本保持一致
安装时确认当前系统对应的RabbitMQ版本以及Erlang版本,否则需要卸载重新安装。
安装完成后问题
RabbitMQ安装完成后,默认账户guest/guest 只能通过localhost:15672 访问,因此需要添加其他用户。
添加用户
- 创建一个test用户:rabbitmqctl add_user admin 123456
- 设置该用户为administrator角色:rabbitmqctl set_user_tags admin administrator
- 设置权限: rabbitmqctl set_permissions -p ‘/’ admin ‘.’ ‘.’ ‘.’
- 重启rabbitmq服务:service rabbitmq-server restart
在添加用户 或者 执行 rabbitmqctl status 会报如下错误
[root@master ~]# service rabbitmq-server start
Redirecting to /bin/systemctl start rabbitmq-server.service
[root@master ~]# rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@Master:
rabbitmq_management
The following plugins have been configured:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
Applying plugin configuration to rabbit@Master...
Plugin configuration unchanged.
[root@master ~]# rabbitmqctl status
Error: unable to perform an operation on node 'rabbit@Master'. Please see diagnostics information and suggestions below.
Most common reasons for this are:
* Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues)
* CLI tool fails to authenticate with the server (e.g. due to CLI tool's Erlang cookie not matching that of the server)
* Target node is not running
In addition to the diagnostics info below:
* See the CLI, clustering and networking guides on https://rabbitmq.com/documentation.html to learn more
* Consult server logs on node rabbit@Master
* If target node is configured to use long node names, don't forget to use --longnames with CLI tools
DIAGNOSTICS
===========
attempted to contact: [rabbit@Master]
rabbit@Master:
* connected to epmd (port 4369) on Master
* epmd reports node 'rabbit' uses port 25672 for inter-node and CLI tool traffic
* TCP connection succeeded but Erlang distribution failed
* Node name (or hostname) mismatch: node "rabbit@master" believes its node name is not "rabbit@master" but something else.
All nodes and CLI tools must refer to node "rabbit@master" using the same name the node itself uses (see its logs to find out what it is)
Current node details:
* node name: 'rabbitmqcli-1615-rabbit@Master'
* effective user's home directory: /var/lib/rabbitmq
* Erlang cookie hash: CboyRUQ/qmU7NxRQNqiUKg==
处理方式:
- 关闭防火墙
- 查看 .erlang.cookie 是否一致
不一致执行:
cp /var/lib/rabbitmq/.erlang.cookie /root/.erlang.cookie
3.查看/etc/hosts 下host名称 和 /etc/hostname 名称是否一致
备注:本人就是因为 hostname 为master 大小写不一致导致一直出现该错误!
务必保持一致!务必保持一致!务必保持一致!