当前位置:   article > 正文

RabbitMQ--安装/配置/使用_rabbitmq 配置

rabbitmq 配置

原文网址:RabbitMQ--安装/配置/使用_IT利刃出鞘的博客-CSDN博客

简介

本文介绍RabbitMQ的安装及配置方法及其常用操作。

下载与安装

Windows安装:Windows安装RabbitMQ的方法_IT利刃出鞘的博客-CSDN博客

Docker安装

使用综述

官方教程:Getting started with RabbitMQ — RabbitMQ

管理MQ(WEB页面)

新增用户

给新增的用户授权

启动报错

org.springframework.amqp.AmqpIOException: java.io.IOException….

问题原因

 解决方法(给rabbitmq新增的用户授权)

1.打开RabbitMq web管理界面,进入该页面,点击用户名称

2.点击 set premission 按钮,就ok了

再去本地启动一下项目,使用这个用户。发现不报错了。

删除队列

        开发的过程中,有些事件会因为代码的不完善消费失败,然后就会一直消费,然后一直报错。当bug修复,把正确的代码上传到开发环境,原先遗留的问题消息任然存在,并且会阻塞队列,让之后的正常的消息无法让系统正常的消费。

法1:通过网页删除(消息多时会报错)

访问网址:http://localhost:15672

找到指定队列

在下方的 Delete / Purge 中点击 Delete 或者是 Purge 都可以达到效果(delete:删除消息与队列;purge:只删消息)

缺点:消息多的时候点击,页面会卡死。即使没有卡死也会出现如下对话框:

网上也没有搜索到什么有用的答案。只找到一句话,来自:https://blog.csdn.net/u011973...

如果队列的主节点不可用,则非镜像队列的行为取决于其持久性。在节点恢复正常之前,持久化队列将不可用。在集群中其他节点上对主节点不可用的持久化队列进行任何操作都将失败

法2:重置RabbitMQ

  1. rabbitmqctl stop_app
  2. rabbitmqctl reset
  3. rabbitmqctl start_app

执行了一次之后确实是有效的。重启的RabbitMq,然后里面的消息也确实清空了。

缺点:不仅会清空消息,还会清空所有配置信息。

法3:命令删除指定的队列

下边三个都可以

rabbitmqctl purge_queue ${queue_name} 
rabbitmqctl purge_queue ${queue_name}
rabbitmqctl -p ${vhostpath} purge_queue ${queue_name} 

也可以使用rabbitmqadmin

rabbitmqadmin delete queue name='queuename'

rabbitmqctl

其他网址

记一次删除 RabbitMQ 消息的经历 - 个人文章 - SegmentFault 思否

rabbitmqctl --help

  1. Error:
  2. [Usage]
  3. rabbitmqctl [--node <node>] [--timeout <timeout>] [--longnames] [--quiet] <command> [<command options>]
  4. Available commands:
  5. [Help]
  6. help Displays usage information for a command
  7. version Displays CLI tools version
  8. [Nodes]
  9. await_startup Waits for the RabbitMQ application to start on the target node
  10. reset Instructs a RabbitMQ node to leave the cluster and return to its virgin state
  11. rotate_logs Instructs the RabbitMQ node to perform internal log rotation
  12. shutdown Stops RabbitMQ and its runtime (Erlang VM). Monitors progress for local nodes. Does not require a PID file path.
  13. start_app Starts the RabbitMQ application but leaves the runtime (Erlang VM) running
  14. stop Stops RabbitMQ and its runtime (Erlang VM). Requires a local node pid file path to monitor progress.
  15. stop_app Stops the RabbitMQ application, leaving the runtime (Erlang VM) running
  16. wait Waits for RabbitMQ node startup by monitoring a local PID file. See also 'rabbitmqctl await_online_nodes'
  17. [Cluster]
  18. await_online_nodes Waits for <count> nodes to join the cluster
  19. change_cluster_node_type Changes the type of the cluster node
  20. cluster_status Displays all the nodes in the cluster grouped by node type, together with the currently running nodes
  21. force_boot Forces node to start even if it cannot contact or rejoin any of its previously known peers
  22. force_reset Forcefully returns a RabbitMQ node to its virgin state
  23. forget_cluster_node Removes a node from the cluster
  24. join_cluster Instructs the node to become a member of the cluster that the specified node is in
  25. rename_cluster_node Renames cluster nodes in the local database
  26. update_cluster_nodes Instructs a cluster member node to sync the list of known cluster members from <seed_node>
  27. [Replication]
  28. cancel_sync_queue Instructs a synchronising mirrored queue to stop synchronising itself
  29. sync_queue Instructs a mirrored queue with unsynchronised mirrors (follower replicas) to synchronise them
  30. [Users]
  31. add_user Creates a new user in the internal database
  32. authenticate_user Attempts to authenticate a user. Exits with a non-zero code if authentication fails.
  33. change_password Changes the user password
  34. clear_password Clears (resets) password and disables password login for a user
  35. delete_user Removes a user from the internal database. Has no effect on users provided by external backends such as LDAP
  36. list_users List user names and tags
  37. set_user_tags Sets user tags
  38. [Access Control]
  39. clear_permissions Revokes user permissions for a vhost
  40. clear_topic_permissions Clears user topic permissions for a vhost or exchange
  41. list_permissions Lists user permissions in a virtual host
  42. list_topic_permissions Lists topic permissions in a virtual host
  43. list_user_permissions Lists permissions of a user across all virtual hosts
  44. list_user_topic_permissions Lists user topic permissions
  45. list_vhosts Lists virtual hosts
  46. set_permissions Sets user permissions for a vhost
  47. set_topic_permissions Sets user topic permissions for an exchange
  48. [Monitoring, observability and health checks]
  49. environment Displays the name and value of each variable in the application environment for each running application
  50. list_bindings Lists all bindings on a vhost
  51. list_channels Lists all channels in the node
  52. list_ciphers Lists cipher suites supported by encoding commands
  53. list_connections Lists AMQP 0.9.1 connections for the node
  54. list_consumers Lists all consumers for a vhost
  55. list_exchanges Lists exchanges
  56. list_hashes Lists hash functions supported by encoding commands
  57. list_queues Lists queues and their properties
  58. list_unresponsive_queues Tests queues to respond within timeout. Lists those which did not respond
  59. node_health_check Performs several opinionated health checks of the target node
  60. ping Checks that the node OS process is up, registered with EPMD and CLI tools can authenticate with it
  61. report Generate a server status report containing a concatenation of all server status information for support purposes
  62. schema_info Lists schema database tables and their properties
  63. status Displays status of a node
  64. [Parameters]
  65. clear_global_parameter Clears a global runtime parameter
  66. clear_parameter Clears a runtime parameter.
  67. list_global_parameters Lists global runtime parameters
  68. list_parameters Lists runtime parameters for a virtual host
  69. set_global_parameter Sets a runtime parameter.
  70. set_parameter Sets a runtime parameter.
  71. [Policies]
  72. clear_operator_policy Clears an operator policy
  73. clear_policy Clears (removes) a policy
  74. list_operator_policies Lists operator policy overrides for a virtual host
  75. list_policies Lists all policies in a virtual host
  76. set_operator_policy Sets an operator policy that overrides a subset of arguments in user policies
  77. set_policy Sets or updates a policy
  78. [Virtual hosts]
  79. add_vhost Creates a virtual host
  80. clear_vhost_limits Clears virtual host limits
  81. delete_vhost Deletes a virtual host
  82. list_vhost_limits Displays configured virtual host limits
  83. restart_vhost Restarts a failed vhost data stores and queues
  84. set_vhost_limits Sets virtual host limits
  85. trace_off
  86. trace_on
  87. [Node configuration]
  88. decode Decrypts an encrypted configuration value
  89. encode Encrypts a sensitive configuration value
  90. set_cluster_name Sets the cluster name
  91. set_disk_free_limit Sets the disk_free_limit setting
  92. set_log_level Sets log level in the running node
  93. set_vm_memory_high_watermark Sets the vm_memory_high_watermark setting
  94. [Definitions]
  95. export_definitions Exports definitions in JSON or compressed Erlang Term Format.
  96. import_definitions Imports definitions in JSON or compressed Erlang Term Format.
  97. [Feature flags]
  98. enable_feature_flag Enables a feature flag on target node
  99. list_feature_flags Lists feature flags
  100. [Operations]
  101. close_all_connections Instructs the broker to close all connections for the specified vhost or entire RabbitMQ node
  102. close_connection Instructs the broker to close the connection associated with the Erlang process id
  103. eval Evaluates a snippet of Erlang code on the target node
  104. exec Evaluates a snippet of Elixir code on the CLI node
  105. force_gc Makes all Erlang processes on the target node perform/schedule a full sweep garbage collection
  106. hipe_compile Only exists for backwards compatibility. HiPE support has been dropped starting with Erlang 22. Do not use
  107. [Queues]
  108. delete_queue Deletes a queue
  109. purge_queue Purges a queue (removes all messages in it)
  110. Use 'rabbitmqctl help <command>' to learn more about a specific command

rabbitmqadmin

其他网址

rabbitmqadmin安装与使用 - aaron_agu - 博客园
如何让RabbitMQ管理命令行工具在Windows上运行 - Thinbug
RabbitMQ windows 管理工具_DqWong的专栏-CSDN博客_rabbitmq客户端工具

简介

在windows下使用rabbitmqadmin 比较麻烦,需要用python运行,例如:python rabbitmqadmin list users。

rabbitmqadmin使用方法

以下步骤的前提是管理插件management pluin已安装好

1. 在浏览器中输入 (“server-name”为你rabbitmq的hostname)

http://server-name:15672/cli/    //本机使用默认的localhost,在浏览器中输入http://localhost:15672/cli/

2. 按照页面提示,右键保存下载链接,浏览器会下载rabbitmqadmin文件,并且自动加上后缀名txt,这个rabbitmqadmin.txt其实是一个python内容的文件,所以需要用python解析,确保你电脑有python2.x,不支持3.x

3. 将rabbitmqadmin.txt放到和python.exe同个路径,并把后缀txt去掉,然后通过下面的方式去调用rabbitmqadmin

python.exe rabbitmqadmin

4. 使用下面的命令可以查看使用说明

python.exe rabbitmqadmin --help
基本功能和网页版插件一样,包括:
- 查看exchanges, queues, bindings, vhosts, users, permissions, connections和channels.
- overview信息查看
- 声明,删除exchanges, queues, bindings, vhosts, users 和 permissions
- 发布或获取消息
- 关闭连接,释放队列
- 导入导出配置

5. rabbitmqadmin支持bash shell用tab键自动补齐,查看bash自动补齐脚本可以调用一下命令

python.exe rabbitmqadmin --bash-completion

命令

命令解释
rabbitmqadmin list users查看所有用户 User
rabbitmqadmin list users name查看所有用户名 Username
rabbitmqadmin list users tags查看所有用户角色
rabbitmqadmin list vhosts查看所有虚拟主机
rabbitmqadmin list connections查看所有连接
rabbitmqadmin list exchanges查看所有路由 Exchange
rabbitmqadmin list bindings查看所有路由与队列的关系绑定 Binding
rabbitmqadmin list permissions查看所有角色的权限 Permission
rabbitmqadmin list channels查看所有通道 Channel
rabbitmqadmin list consumers查看所有消费者 Consumer
rabbitmqadmin list queues查看所有消息队列 Queue
rabbitmqadmin list nodes查看所有节点 Node
rabbitmqadmin show overview概览 Overview
rabbitmqadmin list bindings source destination_type destination properties_key查看所有路由与队列的关系绑定的详细信息 Binding
rabbitmqadmin declare queue name=test durable=true定义一个队列queue,durable=true代表持久化打开。
rabbitmqadmin declare exchange name=my.fanout type=fanout定义一个Fanout路由
rabbitmqadmin declare exchange name=my.direct type=direct定义一个Direct路由
rabbitmqadmin declare exchange name=my.topic type=topic定义一个Topic路由
rabbitmqadmin declare binding source=my.fanout destination=test routing_key=first定义 binding
rabbitmqadmin publish routing_key=test payload="hello world"发布一条消息
rabbitmqadmin publish routing_key=my.test exchange=my.topic payload="hello world"使用路由转发消息
rabbitmqadmin get queue=test requeue=true查看消息,不消费
rabbitmqadmin get queue=test requeue=false查看消息,并消费
rabbitmqadmin purge queue name=test删除队列中的所有消息
rabbitmqadmin delete queue name=hello删除消息队列 Queue
rabbitmqadmin delete user name=test删除用户 User
rabbitmqadmin delete exchange name=test删除路由器 Exchange
rabbitmqadmin delete binding source='kk' destination_type=queue destination=test properties_key=test删除路由器与消息队列的关系绑定 Binding
rabbitmqadmin -f raw_json list usersraw_json 格式化输出
rabbitmqadmin -f long list users格式化输出
rabbitmqadmin -f pretty_json list userspretty_json 格式化输出
rabbitmqadmin -f kvp list users格式化输出
rabbitmqadmin -f tsv list users格式化输出
rabbitmqadmin -f table list userstable 格式化输出
rabbitmqadmin -f bash list usersbash 格式化输出

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/空白诗007/article/detail/788153
推荐阅读
相关标签
  

闽ICP备14008679号