一、关于 RabbitMQ
RabbitMQ 是一个 由Erlang语言开发的 AMQP 的开源实现
AMQP:Advanced Message Queue,高级消息队列协议。 它是应用层协议的一个开放标准,为面向消息的中间件设计,基于此协议的客户端与消息中间件可传递消息,并不受产品、开发语言等条件的限制。
二、安装
使用 brew 安装
$ brew install rabbitmq
Warning: Treating rabbitmq as a formula. For the cask, use homebrew/cask/rabbitmq
==> Downloading https://homebrew.bintray.com/bottles/wxmac-3.0.5.1_1.catalina.bottle.tar.gz
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/820b9bbf8989360bae3d657fa524cde0af0135ded191f47f2d3672f710c39a35--wxmac-3.0.5.1_1.catalina.bottle.tar.gz
==> Downloading https://homebrew.bintray.com/bottles/erlang-23.1.1.catalina.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/578b2bcc53bce0ffa5a6fecb37666644786d0b4ecf6d07e30a927fb351721a09?respo
==> Downloading https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.9/rabbitmq-server-generic-unix-3.8.9.tar.xz
==> Downloading from https://github-releases.githubusercontent.com/924551/5e205600-feb3-11ea-84be-6ee44029a3f6?X-Amz-Algorithm=AW
==> Installing dependencies for rabbitmq: wxmac and erlang
==> Installing rabbitmq dependency: wxmac
==> Pouring wxmac-3.0.5.1_1.catalina.bottle.tar.gz
🍺 /usr/local/Cellar/wxmac/3.0.5.1_1: 810 files, 23.0MB
==> Installing rabbitmq dependency: erlang
==> Pouring erlang-23.1.1.catalina.bottle.tar.gz
==> Caveats
Man pages can be found in:
/usr/local/opt/erlang/lib/erlang/man
Access them with `erl -man`, or add this directory to MANPATH.
==> Summary
🍺 /usr/local/Cellar/erlang/23.1.1: 7,963 files, 469.7MB
==> Installing rabbitmq
==> /usr/bin/unzip -qq -j /usr/local/Cellar/rabbitmq/3.8.9_1/plugins/rabbitmq_management-3.8.9.ez rabbitmq_management-3.8.9/priv/
==> Caveats
Management Plugin enabled by default at http://localhost:15672
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
To have launchd start rabbitmq now and restart at login:
brew services start rabbitmq
Or, if you don't want/need a background service you can just run:
rabbitmq-server
==> Summary
🍺 /usr/local/Cellar/rabbitmq/3.8.9_1: 115 files, 23.1MB, built in 7 seconds
==> Caveats
==> erlang
Man pages can be found in:
/usr/local/opt/erlang/lib/erlang/man
Access them with `erl -man`, or add this directory to MANPATH.
==> rabbitmq
Management Plugin enabled by default at http://localhost:15672
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
To have launchd start rabbitmq now and restart at login:
brew services start rabbitmq
Or, if you don't want/need a background service you can just run:
rabbitmq-server
$
rabbitmq 依赖于 erlang ;如果你没有安装 erlang,会顺便给你装上
安装地址为: /usr/local/Cellar/rabbitmq
erlang 安装地址为: /usr/local/Cellar/erlang
查看 erlang
$ erl
Erlang/OTP 23 [erts-11.1.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]
Eshell V11.1.1 (abort with ^G)
1> halt().
$
配置环境变量
如果不想以上述较长的地址来启动 rabbit,你可以配置环境变量:
1、编辑
$ vim ~/.bash_profile
2、添加 rabbitmq 地址
在文本最后追加:
...
PATH_RABBITMQ='/usr/local/Cellar/rabbitmq/3.8.9_1/sbin'
export PATH=$PATH:$PATH_RABBITMQ
3、使配置生效
$ source ~/.bash_profile
三、常见用法
1、启动 rabbitmq
$ rabbitmq-server
Configuring logger redirection
Doc guides: https://rabbitmq.com/documentation.html
Support: https://rabbitmq.com/contact.html
Tutorials: https://rabbitmq.com/getstarted.html
Monitoring: https://rabbitmq.com/monitoring.html
Logs: /usr/local/var/log/rabbitmq/rabbit@localhost.log
/usr/local/var/log/rabbitmq/rabbit@localhost_upgrade.log
Config file(s): (none)
Starting broker... completed with 6 plugins.
如上效果代表启动成功,这时可以访问 http://localhost:15672
初始账号:guest,密码:guest

登入后: 
停止: 1、在启动窗口按键 Control + C
2、执行命令 rabbitmqctl stop
后台运行 RabbitMQ: rabbitmq-server -detached
3、添加用户
如果忘记账号密码,可以新增管理员账号来登入 以下以 添加账号为 shushu, 密码为 123456 为例;你需要改为你自己的
$ rabbitmqctl add_user shushu 123456
Adding user "shushu" ...
$ rabbitmqctl set_user_tags shushu administrator
Setting tags for user "shushu" to [administrator] ...
$ rabbitmqctl set_permissions -p / shushu "." "." ".*"
Setting permissions for user "shushu" in vhost "/" ...
4、查看状态
$ rabbitmqctl status
Status of node rabbit@localhost ...
Runtime
OS PID: 2247
OS: macOS
Uptime (seconds): 1509
Is under maintenance?: false
相关资料
|