CentOS在线安装RabbitMQ3.7
一、通过yum命令在线安装RabbitMQ
yum在线安装,简单、快捷、自动安装相关依赖包。
1.安装Erlang环境(RabbitMQ由Erlang语言开发)
1.1)下载rpm安装包
官方地址:http://www.erlang.org/downloads
wget -O erlang-20.3.4-1.el7.centos.x86_64.rpm https://bintray.com/rabbitmq/rpm/download_file?file_path=erlang%2F20%2Fel%2F7%2Fx86_64%2Ferlang-20.3.4-1.el7.centos.x86_64.rpm
1.2)安装Erlang
yum install -y erlang-20.3.4-1.el7.centos.x86_64.rpm
1.3)检查Erlang是否安装成功
[root@localhost ~]# erl -version
Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 9.3
[root@localhost ~]#
2.安装RabbitMQ
2.1)下载rpm安装包
官方地址:http://www.rabbitmq.com/download.html
wget https://dl.bintray.com/rabbitmq/all/rabbitmq-server/3.7.4/rabbitmq-server-3.7.4-1.el7.noarch.rpm
2.2)安装RabbitMQ
yum install -y rabbitmq-server-3.7.4-1.el7.noarch.rpm
2.3)检查RabbitMQ是否安装成功
复制代码
[root@localhost ~]# rabbitmqctl status
Status of node rabbit@localhost …
[{pid,14618},
{running_applications,
[{rabbitmq_management,“RabbitMQ Management Console”,“3.7.4”},
{rabbitmq_management_agent,“RabbitMQ Management Agent”,“3.7.4”},
{amqp_client,“RabbitMQ AMQP Client”,“3.7.4”},
{rabbitmq_web_dispatch,“RabbitMQ Web Dispatcher”,“3.7.4”},
{cowboy,“Small, fast, modern HTTP server.”,“2.2.2”},
{cowlib,“Support library for manipulating Web protocols.”,“2.1.0”},
{rabbit,“RabbitMQ”,“3.7.4”},
{rabbit_common,
“Modules shared by rabbitmq-server and rabbitmq-erlang-client”,
“3.7.4”},
…
复制代码
3.关于服务
3.1)启动服务
service rabbitmq-server start
3.2)停止服务
service rabbitmq-server stop
3.3)设置开机启动
chkconfig rabbitmq-server on
4.用户管理
4.1)查看用户列表
[root@localhost ~]# rabbitmqctl list_users
Listing users …
guest [administrator]
[root@localhost ~]#
4.2)添加用户
rabbitmqctl add_user 用户名 密码
[root@localhost ~]# rabbitmqctl add_user admin 123456
Adding user “admin” …
[root@localhost ~]#
4.3)删除用户
rabbitmqctl delete_user 用户名
[root@localhost ~]# rabbitmqctl delete_user admin
Deleting user “admin” …
[root@localhost ~]#
4.4)修改用户密码
rabbitmqctl change_password 用户名 新密码
[root@localhost ~]# rabbitmqctl change_password admin 666666
Changing password for user “admin” …
[root@localhost ~]#
5.角色管理
5.1)角色说明
View Code
5.2)查看用户角色
rabbitmqctl list_users 用户名
[root@localhost ~]# rabbitmqctl list_users
Listing users …
admin [administrator]
guest [administrator]
[root@localhost ~]#
5.3)设置用户角色
rabbitmqctl set_user_tags admin 角色名称(支持同时设置多个角色)
[root@localhost ~]# rabbitmqctl set_user_tags admin administrator
Setting tags for user “admin” to [administrator] …
[root@localhost ~]#
6.权限管理
用户权限是指用户对exchange,queue的操作权限,包括配置权限,读写权限。配置权限会影响到exchange,queue的声明和删除。读写权限会影响到queue的读写消息、exchange发送消息以及queue和exchange的绑定操作。
6.1)查看用户权限
rabbitmqctl list_user_permissions 用户名
[root@localhost ~]# rabbitmqctl list_user_permissions guest
Listing permissions for user “guest” …
/ .* .* .*
[root@localhost ~]#
6.2)设置用户权限
rabbitmqctl set_permissions -p 虚拟主机名称 用户名
[root@localhost ~]# rabbitmqctl set_permissions -p / admin ‘.’ '.’ ‘.*’
Setting permissions for user “admin” in vhost “/” …
[root@localhost ~]#
7.虚拟主机管理
为什么需要虚拟主机(vhost)?因为RabbitMQ只能在虚拟主机的粒度上进行权限控制。每个vhost本质上是一个mini版的RabbitMQ服务器,拥有自己的队列、交换器和绑定等。
7.1)查看虚拟主机
[root@localhost ~]# rabbitmqctl list_vhosts
Listing vhosts …
/
[root@localhost ~]#
7.2)添加虚拟主机
rabbitmqctl add_vhost 虚拟主机名称
[root@localhost ~]# rabbitmqctl add_vhost coreSystem
Adding vhost “coreSystem” …
[root@localhost ~]#
7.3)删除虚拟主机
rabbitmqctl delete_vhost 虚拟主机名称
[root@localhost ~]# rabbitmqctl delete_vhost coreSystem
Deleting vhost “coreSystem” …
[root@localhost ~]#
8.web后台管理
8.1)启用后台管理插件
复制代码
[root@localhost ~]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been configured:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
Applying plugin configuration to rabbit@localhost…
The following plugins have been enabled:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
started 3 plugins.
[root@localhost ~]#
复制代码
8.2)登录
浏览器输入:http://服务器Ip:15672/