RabbitMQ(一):CentOS 7 安装 RabbitMQ 3.7

CentOS 7.5 安装 RabbitMQ 3.7

通过yum命令在线安装RabbitMQ
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
版本信息:
OS: CentOS-7.5
Erlang: erlang-20.3.1
RabbitMQ: rabbitmq-3.7

1.安装Erlang环境

RabbitMQ由Erlang语言开发,所以需要Erlang环境支持

1.1)下载rpm安装包
官方地址:http://www.erlang.org/downloads

wget --content-disposition https://packagecloud.io/rabbitmq/erlang/packages/el/7/erlang-20.3-1.el7.centos.x86_64.rpm/download.rpm

1.2)安装Erlang

yum install erlang-20.3-1.el7.centos.x86_64.rpm

1.3)检查Erlang是否安装成功

[root@localhost ~]# erl -version
Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 9.3

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@VM_0_5_centos ~]# rabbitmqctl status
Status of node rabbit@VM_0_5_centos ...
[{pid,12866},
 {running_applications,
     [{rabbitmq_management,"RabbitMQ Management Console","3.7.4"},
      {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.7.4"},
      {cowboy,"Small, fast, modern HTTP server.","2.2.2"},
      {rabbitmq_management_agent,"RabbitMQ Management Agent","3.7.4"},
      {amqp_client,"RabbitMQ AMQP Client","3.7.4"},
      {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"},
      {ranch_proxy_protocol,"Ranch Proxy Protocol Transport","1.4.4"},
      {ranch,"Socket acceptor pool for TCP protocols.","1.4.0"},
      {ssl,"Erlang/OTP SSL application","8.2.4"},
      {public_key,"Public key infrastructure","1.5.2"},
      {crypto,"CRYPTO","4.2.1"},
      {asn1,"The Erlang ASN1 compiler version 5.0.5","5.0.5"},
      {xmerl,"XML parser","1.3.16"},
      {inets,"INETS  CXC 138 49","6.5"},
      {recon,"Diagnostic tools for production use","2.3.2"},
      {jsx,"a streaming, evented json parsing toolkit","2.8.2"},
      {os_mon,"CPO  CXC 138 46","2.4.4"},
      {mnesia,"MNESIA  CXC 138 12","4.15.3"},
      {lager,"Erlang logging framework","3.5.1"},
      {goldrush,"Erlang event stream processor","0.1.9"},
      {compiler,"ERTS  CXC 138 10","7.1.5"},
      {syntax_tools,"Syntax tools","2.1.4"},
      {sasl,"SASL  CXC 138 11","3.1.1"},
      {stdlib,"ERTS  CXC 138 10","3.4.4"},
      {kernel,"ERTS  CXC 138 10","5.4.3"}]},
 {os,{unix,linux}},
 {erlang_version,
     "Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:64] [hipe] [kernel-poll:true]\n"},
 {memory,
     [{connection_readers,0},
      {connection_writers,0},
      {connection_channels,0},
      {connection_other,2840},
      {queue_procs,0},
      {queue_slave_procs,0},
      {plugins,1358120},
      {other_proc,22233232},
      {metrics,195128},
      {mgmt_db,172520},
      {mnesia,78128},
      {other_ets,2198840},
      {binary,348552},
      {msg_index,58272},
      {code,28428350},
      {atom,1123529},
      {other_system,9634585},
      {allocated_unused,20343648},
      {reserved_unallocated,0},
      {strategy,rss},
      {total,[{erlang,65832096},{rss,78278656},{allocated,86175744}]}]},
 {alarms,[]},
 {listeners,[{clustering,25672,"::"},{amqp,5672,"::"},{http,15672,"::"}]},
 {vm_memory_calculation_strategy,rss},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,415919308},
 {disk_free_limit,50000000},
 {disk_free,47063674880},
 {file_descriptors,
     [{total_limit,924},{total_used,4},{sockets_limit,829},{sockets_used,0}]},
 {processes,[{limit,1048576},{used,373}]},
 {run_queue,0},
 {uptime,17333},
 {kernel,{net_ticktime,60}}]
[root@VM_0_5_centos ~]# 

若输出信息与上有异,则需要先执行启动命令再查看状态即可!

3.关于服务

启动服务:

方式1:systemctl start rabbitmq-server.service
方式2:rabbitmq-server start &

停止服务:

方式1:systemctl stop rabbitmq-server.service
方式2:rabbitmq-server stop_app

设置开机启动:

systemctl enable rabbitmq-server.service

停止开机启动:

systemctl disable rabbitmq-server.service

重新启动服务:

systemctl restart rabbitmq-server.service

查看服务当前状态:

方式1:systemctl status rabbitmq-server.service
方式2:rabbitmqctl status

查看所有已启动服务:

systemctl list-units --type=service

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)角色说明

  • none(普通用户)

    没有控制台操作权限。

  • management(普通管理员)

    可以查看当前用户的queues, exchanges和bindings。
    可以查看和关闭当前用户的channels和connections。
    可以查看当前用户的virtual hosts的统计信息。

  • policymaker(策略管理员)

    具有management权限及查看、创建和删除当前用户的policies和parameters。

  • monitoring(监控管理员)

    具有management权限
    查看所有virtual hosts及全局的统计信息
    查看所有用户的connections和channels
    查看所有节点数据,如clustering和memory使用情况

  • administrator(超级管理员)

    具有policymaker、monitoring权限
    查看、创建、删除所有virtual hosts
    查看、创建、删除所有users
    查看、创建、删除所有permissions
    可以关闭所有用户的connections

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://localhost:15672/
在这里插入图片描述

默认Username:guest
默认Password:guest

来自:https://www.cnblogs.com/skychenjiajun/p/8930147.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值