1、安装erlang环境
yum install erlang
2、安装RabbitMQ需要的rpm
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.6/rabbitmq-server-3.6.6-1.el7.noarch.rpm
3、安装RabbitMQ
yum install rabbitmq-server-3.6.6-1.el7.noarch.rpm
//启动
service rabbitmq-server start
//查看状态
service rabbitmq-server status
//关闭
service rabbitmq-server stop
image.png
4、添加管理插件
rabbitmq-plugins enable rabbitmq_management
image.png
5、配置远程访问
#添加用户
rabbitmqctl add_user admin password
#设置用户标签
rabbitmqctl set_user_tags admin administrator
#tag(administrator,monitoring,policymaker,management)
#设置用户权限(接受来自所有Host的所有操作)
rabbitmqctl set_permissions -p "/" admin '.*' '.*' '.*'
#查看用户权限
rabbitmqctl list_user_permissions admin
vim /etc/rabbitmq/rabbitmq.config
#保存以下内容
[
{rabbit, [{tcp_listeners, [5672]}, {loopback_users, ["admin"]}]}
].
6、基本操作
# 添加用户
rabbitmqctl add_user <username> <password>
# 删除用户
rabbitmqctl delete_user <username>
# 修改用户密码
rabbitmqctl change_password <username> <newpassword>
# 清除用户密码(该用户将不能使用密码登陆,但是可以通过SASL登陆如果配置了SASL认证)
rabbitmqctl clear_password <username>
# 设置用户tags(相当于角色,包含administrator,monitoring,policymaker,management)
rabbitmqctl set_user_tags <username> <tag>
# 列出所有用户
rabbitmqctl list_users
# 创建一个vhosts
rabbitmqctl add_vhost <vhostpath>
# 删除一个vhosts
rabbitmqctl delete_vhost <vhostpath>
# 列出vhosts
rabbitmqctl list_vhosts [<vhostinfoitem> ...]
# 针对一个vhosts给用户赋予相关权限;
rabbitmqctl set_permissions [-p <vhostpath>] <user> <conf> <write> <read>
# 清除一个用户对vhosts的权限;
rabbitmqctl clear_permissions [-p <vhostpath>] <username>
# 列出哪些用户可以访问该vhosts;
rabbitmqctl list_permissions [-p <vhostpath>]
# 列出用户访问权限;
rabbitmqctl list_user_permissions <username>
参考链接:
https://blog.csdn.net/liang_henry/article/details/79584843
https://www.cnblogs.com/uptothesky/p/6094357.html
网友评论