1、RabbitMQ是采用Erlang语言开发的,所以系统环境必须提供Erlang环境。
brew install rabbitmq
前提必须是mac安装了HomeBrew(软件包管理系统),以下都是基于mac版本的。
等大概十几分钟
brew services start rabbitmq;
RabbitMQWeb管理界面及授权操作
rabbitmq-plugins enable rabbitmq_management
如果出现command no find 说明环境变量没配置
配置mac的环境变量后,命令也可以使用了
2、基本命令
  #brew启动
    brew services start rabbitmq;
  #前台运行
    rabbitmq-server
  # 后台运行
    rabbitmq-server -detached
  #新建用户
    rabbitmqctl add_user 账号 密码
  #给用户分配操作权限
    rabbitmqctl set_user_tags 账号 administrator
  #修改密码
    rabbitmqctl change_password Username Newpassword 修改密码
  #删除用户
    rabbitmqctl delete_user Username 删除用户
  #查看所有用户
    rabbitmqctl list_users 查看用户清单
  #为用户设置访问权限
    rabbitmqctl set_permissions -p / 用户名 ".*" ".*" ".*" 
    rabbitmqctl set_permissions -p / root ".*" ".*" ".*"
3、我启动后出现错误
  Error: unable to perform an operation on node 'rabbit@localhost'. 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@localhost
 * If target node is configured to use long node names, don't forget to use --longnames with CLI tools
DIAGNOSTICS
===========
attempted to contact: [rabbit@localhost]
rabbit@localhost:
  * connected to epmd (port 4369) on localhost
  * epmd reports: node 'rabbit' not running at all
              no other nodes on localhost
  * suggestion: start the node
Current node details:
 * node name: 'rabbitmqcli-18-rabbit@localhost'
 * effective user's home directory: /Users/XXXX
 * Erlang cookie hash: CJKrd1APSSyKxnmLKSA77g==
因为我的 host配置错了,重新配置host,重启电脑即可(不重启电脑仍可能错误)

image.png
4、
| 端口 | 说明 | 
|---|---|
| 5672 | RabbitMQ的通讯端口 | 
| 25672 | RabbitMQ的节点间的CLI通讯端口 | 
| 15672 | RabbitMQ HTTP_API的端口,管理员用户才能访问,用于管理RabbitMQ,需要启动Management插件 | 
| 1883、8883 | MQTT插件启动时的端口 | 
| 61613、61614 | STOMP客户端插件启用的时候的端口 | 
| 15674、15675 | 基于webscoket的STOMP端口和MOTT端口 | 
5、用户权限
| 角色 | 权限 | 
|---|---|
| administrator | 可以登录控制台、查看所有信息、可以对rabbitmq进行管理 | 
| monitoring | 监控者,登录控制台,查看所有信息 | 
| policymaker | 策略制定者,登录控制台,指定策略 | 
| managment | 普通管理员,登录控制台 | 
出发了。。



















