RabbitMQ3.8.4安装和配置

安装和配置RabbitMQ


一、安装环境

名称版本
虚拟机软件VMWare 12
操作系统CentOS Linux release 7.7.1908
Erlangerlang-23.0.2-1.el7.x86_64
RabbitMQrabbitmq-server-3.8.4-1.el7.noarch

说明
RabbitMQ的安装需要首先安装Erlang,因为它是基于Erlang的VM运行的。
RabbitMQ需要的依赖:socat和logrotate,logrotate操作系统中已经存在了,只需要安装socat就可以了。

注意
RabbitMQ与Erlang的兼容关系详见:https://www.rabbitmq.com/which-erlang.html

在这里插入图片描述


二、环境搭建

1、安装依赖

	yum install socat -y 

在这里插入图片描述

2、安装Erlang

	erlang-23.0.2-1.el7.x86_64.rpm下载地址:
		https://github.com/rabbitmq/erlang-rpm/releases/download/v23.0.2/erlang-23.0.2-1.el7.x86_64.rpm
	
	首先将erlang-23.0.2-1.el7.x86_64.rpm上传至服务器,然后执行下述命令:
	rpm -ivh erlang-23.0.2-1.el7.x86_64.rpm

在这里插入图片描述

3、安装RabbitMQ

	rabbitmq-server-3.8.4-1.el7.noarch.rpm下载地址:
		https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.5/rabbitmq-server-3.8.5-1.el7.noarch.rpm
	
	首先将rabbitmq-server-3.8.4-1.el7.noarch.rpm上传至服务器,然后执行下述命令:
	rpm -ivh rabbitmq-server-3.8.4-1.el7.noarch.rpm

在这里插入图片描述

4、启用RabbitMQ的管理插件

	rabbitmq-plugins enable rabbitmq_management 

在这里插入图片描述

查看插件状态
在这里插入图片描述
帮助命令:查看相关命令和参数

[root@RabbitMQ ~]# rabbitmqctl help
Error:

Usage

rabbitmqctl [--node <node>] [--timeout <timeout>] [--longnames] [--quiet] <command> [<command options>]

Available commands:

Help:

   help                          Displays usage information for a command
   version                       Displays CLI tools version

Nodes:

   await_startup                 Waits for the RabbitMQ application to start on the target node
   reset                         Instructs a RabbitMQ node to leave the cluster and return to its virgin state
   rotate_logs                   Instructs the RabbitMQ node to perform internal log rotation
   shutdown                      Stops RabbitMQ and its runtime (Erlang VM). Monitors progress for local nodes. Does not require a PID file path.
   start_app                     Starts the RabbitMQ application but leaves the runtime (Erlang VM) running
   stop                          Stops RabbitMQ and its runtime (Erlang VM). Requires a local node pid file path to monitor progress.
   stop_app                      Stops the RabbitMQ application, leaving the runtime (Erlang VM) running
   wait                          Waits for RabbitMQ node startup by monitoring a local PID file. See also 'rabbitmqctl await_online_nodes'

Cluster:

   await_online_nodes            Waits for <count> nodes to join the cluster
   change_cluster_node_type      Changes the type of the cluster node
   cluster_status                Displays all the nodes in the cluster grouped by node type, together with the currently running nodes
   force_boot                    Forces node to start even if it cannot contact or rejoin any of its previously known peers
   force_reset                   Forcefully returns a RabbitMQ node to its virgin state
   forget_cluster_node           Removes a node from the cluster
   join_cluster                  Instructs the node to become a member of the cluster that the specified node is in
   rename_cluster_node           Renames cluster nodes in the local database
   update_cluster_nodes          Instructs a cluster member node to sync the list of known cluster members from <seed_node>

Replication:

   cancel_sync_queue             Instructs a synchronising mirrored queue to stop synchronising itself
   sync_queue                    Instructs a mirrored queue with unsynchronised mirrors (follower replicas) to synchronise them

Users:

   add_user                      Creates a new user in the internal database
   authenticate_user             Attempts to authenticate a user. Exits with a non-zero code if authentication fails.
   change_password               Changes the user password
   clear_password                Clears (resets) password and disables password login for a user
   delete_user                   Removes a user from the internal database. Has no effect on users provided by external backends such as LDAP
   list_users                    List user names and tags
   set_user_tags                 Sets user tags

Access Control:

   clear_permissions             Revokes user permissions for a vhost
   clear_topic_permissions       Clears user topic permissions for a vhost or exchange
   list_permissions              Lists user permissions in a virtual host
   list_topic_permissions        Lists topic permissions in a virtual host
   list_user_permissions         Lists permissions of a user across all virtual hosts
   list_user_topic_permissions   Lists user topic permissions
   list_vhosts                   Lists virtual hosts
   set_permissions               Sets user permissions for a vhost
   set_topic_permissions         Sets user topic permissions for an exchange

Monitoring, observability and health checks:

   environment                   Displays the name and value of each variable in the application environment for each running application
   list_bindings                 Lists all bindings on a vhost
   list_channels                 Lists all channels in the node
   list_ciphers                  Lists cipher suites supported by encoding commands
   list_connections              Lists AMQP 0.9.1 connections for the node
   list_consumers                Lists all consumers for a vhost
   list_exchanges                Lists exchanges
   list_hashes                   Lists hash functions supported by encoding commands
   list_queues                   Lists queues and their properties
   list_unresponsive_queues      Tests queues to respond within timeout. Lists those which did not respond
   ping                          Checks that the node OS process is up, registered with EPMD and CLI tools can authenticate with it
   report                        Generate a server status report containing a concatenation of all server status information for support purposes
   schema_info                   Lists schema database tables and their properties
   status                        Displays status of a node

Parameters:

   clear_global_parameter        Clears a global runtime parameter
   clear_parameter               Clears a runtime parameter.
   list_global_parameters        Lists global runtime parameters
   list_parameters               Lists runtime parameters for a virtual host
   set_global_parameter          Sets a runtime parameter.
   set_parameter                 Sets a runtime parameter.

Policies:

   clear_operator_policy         Clears an operator policy
   clear_policy                  Clears (removes) a policy
   list_operator_policies        Lists operator policy overrides for a virtual host
   list_policies                 Lists all policies in a virtual host
   set_operator_policy           Sets an operator policy that overrides a subset of arguments in user policies
   set_policy                    Sets or updates a policy

Virtual hosts:

   add_vhost                     Creates a virtual host
   clear_vhost_limits            Clears virtual host limits
   delete_vhost                  Deletes a virtual host
   list_vhost_limits             Displays configured virtual host limits
   restart_vhost                 Restarts a failed vhost data stores and queues
   set_vhost_limits              Sets virtual host limits
   trace_off                     
   trace_on                      

Node configuration:

   decode                        Decrypts an encrypted configuration value
   encode                        Encrypts a sensitive configuration value
   set_cluster_name              Sets the cluster name
   set_disk_free_limit           Sets the disk_free_limit setting
   set_log_level                 Sets log level in the running node
   set_vm_memory_high_watermark  Sets the vm_memory_high_watermark setting

Definitions:

   export_definitions            Exports definitions in JSON or compressed Erlang Term Format.
   import_definitions            Imports definitions in JSON or compressed Erlang Term Format.

Deprecated:

   node_health_check             DEPRECATED. Performs intrusive, opinionated health checks on a fully booted node. See https://www.rabbitmq.com/monitoring.html#health-checks instead

Feature flags:

   enable_feature_flag           Enables a feature flag on target node
   list_feature_flags            Lists feature flags

Operations:

   close_all_connections         Instructs the broker to close all connections for the specified vhost or entire RabbitMQ node
   close_connection              Instructs the broker to close the connection associated with the Erlang process id
   eval                          Evaluates a snippet of Erlang code on the target node
   exec                          Evaluates a snippet of Elixir code on the CLI node
   force_gc                      Makes all Erlang processes on the target node perform/schedule a full sweep garbage collection
   hipe_compile                  Only exists for backwards compatibility. HiPE support has been dropped starting with Erlang 22. Do not use

Queues:

   delete_queue                  Deletes a queue
   purge_queue                   Purges a queue (removes all messages in it)

Use 'rabbitmqctl help <command>' to learn more about a specific command

5、开启RabbitMQ

	方式一:systemctl start rabbitmq-server 
	方式二:rabbitmq-server 
	方式三:rabbitmq-server -detached   (后台启动)

在这里插入图片描述
查看插件(此用户只能在本机使用)
在这里插入图片描述

6、添加用户

	rabbitmqctl add_user root 123456

在这里插入图片描述

7、给用户设置标签

	用户的标签和权限:
	rabbitmqctl set_user_tags root administrator 

在这里插入图片描述

使用刚才创建的用户登录/使用新账号登陆,无权访问虚拟主机
在这里插入图片描述

用户的标签和权限

TagCapabilities
(None)没有访问management插件的权限
management可以使用消息协议做任何操作的权限,加上:1. 可以使用AMQP协议登录的虚拟主机的权限 2. 查看它们能登录的所有虚拟主机中所有队列、交换器和绑定的权限 3. 查看和关闭它们自己的通道和连接的权限 4. 查看它们能访问的虚拟主机中的全局统计信息,包括其他用户的活动
policymaker所有management标签可以做的,加上:1. 在它们能通过AMQP协议登录的虚拟主机上,查看、创建和删除策略以及虚拟主机参数的权限
monitoring所有management能做的,加上:1. 列出所有的虚拟主机,包括列出不能使用消息协议访问的虚拟主机的权限2. 查看其他用户连接和通道的权限3. 查看节点级别的数据如内存使用和集群的权限4. 查看真正的全局所有虚拟主机统计数据的权限
administrator所有policymaker和monitoring能做的,加上:1. 创建删除虚拟主机的权限2. 查看、创建和删除用户的权限3. 查看、创建和删除权限的权限4. 关闭其他用户连接的权限

8、给用户添加权限

	给root用户在虚拟主机"/"上的配置、写、读的权限
	rabbitmqctl set_permissions root -p / ".*" ".*" ".*" 

在这里插入图片描述

9、打开浏览器,使用刚才创建的用户登录访问http://<安装了CentOS的VMWare虚拟机IP地址>:15672

在这里插入图片描述

问题1:useradd: cannot open /etc/passwd

解决:

	useradd: cannot open /etc/passwd
	useradd: cannot open /etc/passwd
	chattr -a /etc/shadow
	chattr -a /etc/group

在这里插入图片描述

问题2:reply-text=NOT_ALLOWED - access to vhost ‘/’ refused for user ‘root’

解决:rabbitmqctl set_permissions -p / root ‘.’ '.’ ‘.*’
在这里插入图片描述

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

穿城大饼

你的鼓励将是我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值