欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

RabbitMQ 常用命令

程序员文章站 2022-07-13 12:09:09
...
给centos安装epel yum 源

# rpm -ivh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
安装erlang运行环境
# yum install erlang
安装rabbitmq server
# rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
# rpm -ivh http://www.rabbitmq.com/releases/rabbitmq-server/v3.0.0/rabbitmq-server-3.0.0-1.noarch.rpm
打开server
# chkconfig rabbitmq-server on
# rabbitmqctl status
会报异常:

# rabbitmqctl status
Status of node rabbit@devnote ...
Error: unable to connect to node rabbit@devnote: nodedown

DIAGNOSTICS
===========

nodes in question: [rabbit@devnote]

hosts, their running nodes and ports:
- devnote: [{rabbitmqctl24923,51045}]

current node details:
- node name: rabbitmqctl24923@devnote
- home dir: /var/lib/rabbitmq
- cookie hash: TblHThacrBHJzl5Vt7Y4Ww==
执行命令:

# /sbin/service rabbitmq-server stop
# /sbin/service rabbitmq-server start
# rabbitmqctl status 测试正确

查看所有队列信息

# rabbitmqctl list_queues
关闭应用

# rabbitmqctl stop_app
启动应用,和上述关闭命令配合使用,达到清空队列的目的

# rabbitmqctl start_app
清除所有队列

# rabbitmqctl reset
更多用法及参数,可以执行如下命令查看

# rabbitmqctl

(1)首先关闭rabbitmq: rabbitmqctl stop_app

(2)还原: rabbitmqctl reset

(3)启动: rabbitmqctl start_app

(4)添加用户: rabbitmqctl add_user root root

(5)设置权限:rabbitmqctl set_permissions -p / root ".*" ".*" ".*"

(6)查看用户: rabbitmqctl list_users
相关标签: mq