首先安裝Erlang20.2
安裝準(zhǔn)備
- 創(chuàng)建Yum源
#創(chuàng)建yum源
vi /etc/yum.repos.d/rabbitmq-erlang.repo
#文件內(nèi)容
# In /etc/yum.repos.d/rabbitmq-erlang.repo
[rabbitmq-erlang]
name=rabbitmq-erlang
baseurl=https://dl.bintray.com/rabbitmq-erlang/rpm/erlang/20/el/6
gpgcheck=1
gpgkey=https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc
repo_gpgcheck=0
enabled=1
Erlang安裝
- 安裝
yum install erlang
- 驗(yàn)證
#進(jìn)入erlang命令行表示成功
erl
RabbitMQ安裝
安裝準(zhǔn)備
- 安裝 socat
yum install socat
安裝并啟動(dòng)
- RPM安裝
官網(wǎng)下載地址:https://www.rabbitmq.com/install-rpm.html
rpm -Uvh https://dl.bintray.com/rabbitmq/all/rabbitmq-server/3.7.3/rabbitmq-server-3.7.3-1.el7.noarch.rpm
- 啟動(dòng)RabbitMQ服務(wù)
#啟動(dòng)服務(wù)
systemctl start rabbitmq-server
#查看狀態(tài)
systemctl status rabbitmq-server
#設(shè)置為開(kāi)機(jī)啟動(dòng)
systemctl enable rabbitmq-server
RabbitMQ配置
- 添加用戶并授權(quán)
添加用戶
rabbitmqctl add_user root root
#設(shè)置用戶角色
rabbitmqctl set_user_tags root administrator
#設(shè)置用戶權(quán)限(接受來(lái)自所有Host的所有操作)
rabbitmqctl set_permissions -p "/" root '.*' '.*' '.*'
#查看用戶權(quán)限
rabbitmqctl list_user_permissions root
- 啟用web管理后臺(tái)插件
rabbitmq-plugins enable rabbitmq_management
然后就可以用剛才創(chuàng)建的root賬戶登錄郭膛。
RabbitMQ 常用命令
# 添加用戶
rabbitmqctl add_user <username> <password>
# 刪除用戶
rabbitmqctl delete_user <username>
# 修改用戶密碼
rabbitmqctl change_password <username> <newpassword>
# 清除用戶密碼(該用戶將不能使用密碼登陸,但是可以通過(guò)SASL登陸如果配置了SASL認(rèn)證)
rabbitmqctl clear_password <username>
# 設(shè)置用戶tags(相當(dāng)于角色跋炕,包含administrator克锣,monitoring茵肃,policymaker,management)
rabbitmqctl set_user_tags <username> <tag>
# 列出所有用戶
rabbitmqctl list_users
# 創(chuàng)建一個(gè)vhosts
rabbitmqctl add_vhost <vhostpath>
# 刪除一個(gè)vhosts
rabbitmqctl delete_vhost <vhostpath>
# 列出vhosts
rabbitmqctl list_vhosts [<vhostinfoitem> ...]
# 針對(duì)一個(gè)vhosts給用戶賦予相關(guān)權(quán)限袭祟;
rabbitmqctl set_permissions [-p <vhostpath>] <user> <conf> <write> <read>
# 清除一個(gè)用戶對(duì)vhosts的權(quán)限验残;
rabbitmqctl clear_permissions [-p <vhostpath>] <username>
# 列出哪些用戶可以訪問(wèn)該vhosts;
rabbitmqctl list_permissions [-p <vhostpath>]
# 列出用戶訪問(wèn)權(quán)限巾乳;
rabbitmqctl list_user_permissions <username>