消息型web框架之RabbashMQ基础使用

  1、概念

  RabbitMQ是AMQP(高级消息队列协议)协议的实现主要功能用于分布式应用当中的各组件间解耦。在传统C/S架构中,如果客户端发送一个请求消息,服务端必须得在线,有了中间件,客户端不是非得要服务端在线才可发送请求,客户端只需将请求消息发送给中间件,中间件负责存储和转发请求消息,此时如果服务端不在线,依然不妨碍客户端的请求可以发出,而客户端的请求此时有可能还会被正常服务;而对于消息型中间件最核心的组件有3个,分别是exchange(交换器)、binding(绑定器)、queue(队列);其中交换器的作用是把消息发出一方(简称生产者)发出的消息,通过交换器把消息发送给绑定器,绑定器根据匹配路由规则把消息路由给后端队列,然后订阅者再到对应的队列上取出消息进行消费,通常一个订阅者(消息消费者,或者叫用户也行)对应一个或多个队列;而订阅者与队列之间的信道(传递消息的通道)我们称之为channel(频道);也就说订阅者可以订阅一个或多个频道,一旦对应频道有消息产生,对应订阅者都会收到;一个消息该如何发送到对应的队列,这取决于我们的路由模式,路由模式通常我们通过绑定器进行定义;也就是说绑定器的主要作用就是用来定义交换器收到消息后该把消息发送到那个给队列;而对于路由模式来讲,它有多种,常见的有direct(点到点的直接路由)、topic(话题型过滤)、fan-out(删除)、headers(基于消息首部过滤);这些路由模式主要是用来过滤消息的,把符合我们定义的路由规则的消息过滤出来,发送到指定队列,所以我们也可以把路由模式称之为消息过滤器;简单点讲路由规则就是把交换器上的某一类消息绑定一个或多个队列;对于AMQP来讲,除了上面的4中路由模式以外,它还定义一个virtualhost的概念,所谓virtualhost就是虚拟主机,这里的虚拟主机主要是用来应用隔离,一个虚拟主机内部可以有exchange、binding、queue;它相当于一个单独broker,所以虚拟主机它可以将一个物理的broker划分成多个不同应用的broker;

  2、RabbitMQ架构

  提示:上图主要描述了生产者把消息通过交换器匹配路由规则(绑定器)把不同类型的消息通过绑定器把消息路由到不同的队列上,然后消费者根据自身订阅的频道,到不同频道对应的队列上取出消息进行消费的一个过程;

  3、RabbitMQ的安装配置

  在centos7上rabbitmq的安装非常简单,我们只需要配置好epel源,然后yum安装即可;

[root@node1 ~]# yum repolist

已加载插件:fastestmirror, langpacks

Loading mirror speeds from cached hostfile

* base: mirrors.aliyun.com

* extras: mirrors.aliyun.com

* updates: mirrors.aliyun.com

源标识 源名称 状态

!base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,070

!docker-ce-stable/x86_64 Docker CE Stable - x86_64 79

!epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,426

!extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 413

!updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 1,112

repolist: 25,100

[root@node1 ~]# yum install rabbitmq-server

已加载插件:fastestmirror, langpacks

base | 3.6 kB 00:00:00

docker-ce-stable | 3.5 kB 00:00:00

epel | 4.7 kB 00:00:00

extras | 2.9 kB 00:00:00

updates | 2.9 kB 00:00:00

(1/2): epel/x86_64/updateinfo | 1.0 MB 00:00:00

(2/2): epel/x86_64/primary_db | 6.9 MB 00:00:01

Loading mirror speeds from cached hostfile

* base: mirrors.aliyun.com

* extras: mirrors.aliyun.com

* updates: mirrors.aliyun.com

正在解决依赖关系

--> 正在检查事务

---> 软件包 rabbitmq-server.noarch.0.3.3.5-34.el7 将被 安装

--> 正在处理依赖关系 erlang-erts >= R12B-3,它被软件包 rabbitmq-server-3.3.5-34.el7.noarch 需要

……省略部分内容……

已安装:

rabbitmq-server.noarch 0:3.3.5-34.el7

作为依赖被安装:

erlang-asn1.x86_64 0:R16B-03.18.el7 erlang-compiler.x86_64 0:R16B-03.18.el7

erlang-crypto.x86_64 0:R16B-03.18.el7 erlang-erts.x86_64 0:R16B-03.18.el7

erlang-hipe.x86_64 0:R16B-03.18.el7 erlang-inets.x86_64 0:R16B-03.18.el7

erlang-kernel.x86_64 0:R16B-03.18.el7 erlang-mnesia.x86_64 0:R16B-03.18.el7

erlang-os_mon.x86_64 0:R16B-03.18.el7 erlang-otp_mibs.x86_64 0:R16B-03.18.el7

erlang-public_key.x86_64 0:R16B-03.18.el7 erlang-runtime_tools.x86_64 0:R16B-03.18.el7

erlang-sasl.x86_64 0:R16B-03.18.el7 erlang-sd_notify.x86_64 0:0.1-1.el7

erlang-snmp.x86_64 0:R16B-03.18.el7 erlang-ssl.x86_64 0:R16B-03.18.el7

erlang-stdlib.x86_64 0:R16B-03.18.el7 erlang-syntax_tools.x86_64 0:R16B-03.18.el7

erlang-tools.x86_64 0:R16B-03.18.el7 erlang-xmerl.x86_64 0:R16B-03.18.el7

完毕!

[root@node1 ~]#

  提示:rabbitmq是erlang语言研发,所以安装rabbitmq-server这个包,它会依赖很多erlang包,而这些包都来自epel仓库,所以安装之前一定要先配置好epel源;

  查看rabbitmq-server安装生成了哪些文件

[root@node1 ~]# rpm -ql rabbitmq-server

/etc/logrotate.d/rabbitmq-server

/etc/rabbitmq

/etc/rabbitmq/rabbitmq.config

/usr/lib/ocf/resource.d/rabbitmq/rabbitmq-server

/usr/lib/rabbitmq/bin

/usr/lib/rabbitmq/bin/rabbitmq-defaults

/usr/lib/rabbitmq/bin/rabbitmq-env

/usr/lib/rabbitmq/bin/rabbitmq-plugins

/usr/lib/rabbitmq/bin/rabbitmq-server

/usr/lib/rabbitmq/bin/rabbitmqctl

/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5

/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/ebin

/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/ebin/app_utils.beam

/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/ebin/background_gc.beam

/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/ebin/credit_flow.beam

/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/ebin/delegate.beam

/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/ebin/delegate_sup.beam

……省略部分内容……

/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/sbin

/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/sbin/rabbitmq-defaults

/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/sbin/rabbitmq-env

/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/sbin/rabbitmq-plugins

/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/sbin/rabbitmq-server

/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/sbin/rabbitmqctl

/usr/lib/systemd/system/rabbitmq-server.service

/usr/lib/tmpfiles.d/rabbitmq-server.conf

/usr/sbin/rabbitmq-plugins

/usr/sbin/rabbitmq-server

/usr/sbin/rabbitmqctl

……省略部分内容……

/var/log/rabbitmq

/var/run/rabbitmq

[root@node1 ~]#

  提示:/usr/sbin/rabbitmqctl 这个工具是命令行工具,主要用来管理rabbitmq;/usr/sbin/rabbitmq-plugins用来管理rabbitmq插件的命令行工具;/usr/sbin/rabbitmq-server服务器二进制主程序;/usr/lib/systemd/system/rabbitmq-server.service这个文件是它的基于systemd启动的unit file;/usr/lib/rabbitmq/bin/rabbitmq-defaults这个文件用于定义默认环境变量配置;/var/log/rabbitmq用于存放rabbitmq日志目录;/etc/rabbitmq/rabbitmq.config这个是rabbitmq的主配置文件,主要定义个组件访问权限,资源限制,插件及集群相关配置;rabbitmq的配置方式分3中,第一种是环境变量的方式,该方式主要用来定义网络参数以及配置文件路径相关配置;其次是配置文件的方式,配置文件主要定义服务器各组件间的访问权限,资源限制,插件以及集群相关配置;最后一种是运行时参数,这种方式主要用于定义rabbitmq集群的运行时参数;

  比较常用的环境变量

    RABBITMQ_BASE:用来指定rabbitmq的安装目录,这个目录主要存放rabbitmq数据库和日志相关文件。(一般用于windows,类unix上不常用)

    RABBITMQ_CONFIG_FILE:用于指定配置文件路径;

    RABBITMQ_LOGS:用于单独指定日志文件;

    RABBITMQ_NODE_IP_ADDRESS:用于指定节点监听的ip地址;

    RABBITMQ_NODE_PORT:用于指定节点监听的端口;

    RABBITMQ_NODE_NAME:用于指定节点名称;

    RABBITMQ_PLUGINS_DIR:用于指定插件目录;

  rabbitmq默认配置文件相关变量说明

    auth_mechanisms:用于定义rabbitmq的认证机制;

    default_user:定义默认用户;默认是guest;

    default_pass:定义默认用户的默认密码;默认是guest;

    default_premission:定义默认用户的默认权限;默认是".*" ".*" ".*";

    default_user_tags:定义默认用户的标签,默认是administrator;

    default_vhost:定义默认虚拟主机;默认是“/”;

    disk_free_limit:定义磁盘最少预留空间;默认50M;

    hearbeat:定义检测各组件存活的消息时长(心跳值);默认600秒;

    hipe_compile:用于指定是否使用hipe编译器编译程序;默认是true,表示使用hipe编译器;

    log_levels:用于指定日志级别,这里的日志级别只有四种,分别是none,error,warning,info;

    tcp_listeners:定义监听的地址和端口;默认是本机的所有地址的5672;

    ssl_listeners:定义基于ssl协议通信监听的地址和端口;默认是本机的所有地址的5672;

    vm_memory_high_watermark:定义内存的高水位标记,所谓高水位标记,就是用来指定内存的最少空闲内存空间;

  启动rabbitmq-server

  提示:以默认配置文件启动rabbitmq,它会监听5672和25672,25672是用来集群通信的端口;5672是rabbitmq的管理接口;除了这两个端口,如果开启了rabbitmq-management插件,它还会监听15672;rabbitmq-management这个插件主要提供了web图形化管理界面;

  4、rabbitmqctl使用

  rabbitmqctl帮助信息

[root@node1 ~]# rabbitmqctl -h

Error: could not recognise command

Usage:

rabbitmqctl [-n <node>] [-q] <command> [<command options>]

Options:

-n node

-q

Default node is "rabbit@server", where server is the local host. On a host

named "server.example.com", the node name of the RabbitMQ Erlang node will

usually be rabbit@server (unless RABBITMQ_NODENAME has been set to some

non-default value at broker startup time). The output of hostname -s is usually

the correct suffix to use after the "@" sign. See rabbitmq-server(1) for

details of configuring the RabbitMQ broker.

Quiet output mode is selected with the "-q" flag. Informational messages are

suppressed when quiet mode is in effect.

Commands:

stop [<pid_file>]

stop_app

start_app

wait <pid_file>

reset

force_reset

rotate_logs <suffix>

join_cluster <clusternode> [--ram]

cluster_status

change_cluster_node_type disc | ram

forget_cluster_node [--offline]

update_cluster_nodes clusternode

sync_queue queue

cancel_sync_queue queue

set_cluster_name name

add_user <username> <password>

delete_user <username>

change_password <username> <newpassword>

clear_password <username>

set_user_tags <username> <tag> ...

list_users

add_vhost <vhostpath>

delete_vhost <vhostpath>

list_vhosts [<vhostinfoitem> ...]

set_permissions [-p <vhostpath>] <user> <conf> <write> <read>

clear_permissions [-p <vhostpath>] <username>

list_permissions [-p <vhostpath>]

list_user_permissions <username>

set_parameter [-p <vhostpath>] <component_name> <name> <value>

clear_parameter [-p <vhostpath>] <component_name> <key>

list_parameters [-p <vhostpath>]

set_policy [-p <vhostpath>] [--priority <priority>] [--apply-to <apply-to>]

<name> <pattern> <definition>

clear_policy [-p <vhostpath>] <name>

list_policies [-p <vhostpath>]

list_queues [-p <vhostpath>] [<queueinfoitem> ...]

list_exchanges [-p <vhostpath>] [<exchangeinfoitem> ...]

list_bindings [-p <vhostpath>] [<bindinginfoitem> ...]

list_connections [<connectioninfoitem> ...]

list_channels [<channelinfoitem> ...]

list_consumers [-p <vhostpath>]

status

environment

report

eval <expr>

close_connection <connectionpid> <explanation>

trace_on [-p <vhost>]

trace_off [-p <vhost>]

set_vm_memory_high_watermark <fraction>

<vhostinfoitem> must be a member of the list [name, tracing].

The list_queues, list_exchanges and list_bindings commands accept an optional

virtual host parameter for which to display results. The default value is "/".

<queueinfoitem> must be a member of the list [name, durable, auto_delete,

arguments, policy, pid, owner_pid, exclusive_consumer_pid,

exclusive_consumer_tag, messages_ready, messages_unacknowledged, messages,

consumers, consumer_utilisation, memory, slave_pids, synchronised_slave_pids,

status].

<exchangeinfoitem> must be a member of the list [name, type, durable,

auto_delete, internal, arguments, policy].

<bindinginfoitem> must be a member of the list [source_name, source_kind,

destination_name, destination_kind, routing_key, arguments].

<connectioninfoitem> must be a member of the list [pid, name, port, host,

peer_port, peer_host, ssl, ssl_protocol, ssl_key_exchange, ssl_cipher,

ssl_hash, peer_cert_subject, peer_cert_issuer, peer_cert_validity, state,

channels, protocol, auth_mechanism, user, vhost, timeout, frame_max,

channel_max, client_properties, recv_oct, recv_cnt, send_oct, send_cnt,

send_pend].

<channelinfoitem> must be a member of the list [pid, connection, name, number,

user, vhost, transactional, confirm, consumer_count, messages_unacknowledged,

messages_uncommitted, acks_uncommitted, messages_unconfirmed, prefetch_count,

global_prefetch_count].

[root@node1 ~]#

  提示:从上面的帮助信息可以了解到rabbitmqctl这个工具有很多子命令;主要有对应用到管理相关子命令,对虚拟主机相关管理的,权限,用户,集群,策略等等;

  stop [<pid_file>]:停止rabbitmq-server;

[root@node1 ~]# rabbitmqctl stop

Stopping and halting node rabbit@node1 ...

...done.

[root@node1 ~]# ss -tnl

State Recv-Q Send-Q Local Address:Port Peer Address:Port

LISTEN 0 5 192.168.122.1:53 *:*

LISTEN 0 128 *:22 *:*

LISTEN 0 128 127.0.0.1:631 *:*

LISTEN 0 100 127.0.0.1:25 *:*

LISTEN 0 100 127.0.0.1:64667 *:*

LISTEN 0 128 *:8000 *:*

LISTEN 0 128 *:8001 *:*

LISTEN 0 5 127.0.0.1:8010 *:*

LISTEN 0 128 *:111 *:*

LISTEN 0 128 *:80 *:*

LISTEN 0 128 :::22 :::*

LISTEN 0 128 ::1:631 :::*

LISTEN 0 100 ::1:25 :::*

LISTEN 0 128 :::111 :::*

LISTEN 0 128 :::80 :::*

[root@node1 ~]#

  提示:rabbitmqctl stop 就相当于把rabbitmq服务给杀死,停止服务;

  stop_app:停止rabbitmq-server上的所有应用;

[root@node1 ~]# rabbitmqctl status

Status of node rabbit@node1 ...

[{pid,18223},

{running_applications,[{rabbit,"RabbitMQ","3.3.5"},

{os_mon,"CPO CXC 138 46","2.2.14"},

{mnesia,"MNESIA CXC 138 12","4.11"},

{xmerl,"XML parser","1.3.6"},

{sasl,"SASL CXC 138 11","2.3.4"},

{stdlib,"ERTS CXC 138 10","1.19.4"},

{kernel,"ERTS CXC 138 10","2.16.4"}]},

{os,{unix,linux}},

{erlang_version,"Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:30] [hipe] [kernel-poll:true]\n"},

{memory,[{total,36262168},

{connection_procs,2800},

{queue_procs,5600},

{plugins,0},

{other_proc,13729216},

{mnesia,60144},

{mgmt_db,0},

{msg_index,21880},

{other_ets,756824},

{binary,19048},

{code,16707498},

{atom,602729},

{other_system,4356429}]},

{alarms,[]},

{listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},

{vm_memory_high_watermark,0.4},

{vm_memory_limit,1581588480},

{disk_free_limit,50000000},

{disk_free,39834275840},

{file_descriptors,[{total_limit,924},

{total_used,3},

{sockets_limit,829},

{sockets_used,1}]},

{processes,[{limit,1048576},{used,127}]},

{run_queue,0},

{uptime,367}]

...done.

[root@node1 ~]# rabbitmqctl stop_app

Stopping node rabbit@node1 ...

...done.

[root@node1 ~]# rabbitmqctl status

Status of node rabbit@node1 ...

[{pid,18223},

{running_applications,[{xmerl,"XML parser","1.3.6"},

{sasl,"SASL CXC 138 11","2.3.4"},

{stdlib,"ERTS CXC 138 10","1.19.4"},

{kernel,"ERTS CXC 138 10","2.16.4"}]},

{os,{unix,linux}},

{erlang_version,"Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:30] [hipe] [kernel-poll:true]\n"},

{memory,[{total,35566624},

{connection_procs,0},

{queue_procs,0},

{plugins,0},

{other_proc,13300856},

{mnesia,0},

{mgmt_db,0},

{msg_index,0},

{other_ets,607888},

{binary,12600},

{code,16707498},

{atom,602729},

{other_system,4335053}]},

{alarms,[]},

{listeners,[]},

{processes,[{limit,1048576},{used,46}]},

{run_queue,0},

{uptime,384}]

...done.

[root@node1 ~]# ss -tnl

State Recv-Q Send-Q Local Address:Port Peer Address:Port

LISTEN 0 5 192.168.122.1:53 *:*

LISTEN 0 128 *:22 *:*

LISTEN 0 128 127.0.0.1:631 *:*

LISTEN 0 100 127.0.0.1:25 *:*

LISTEN 0 100 127.0.0.1:64667 *:*

LISTEN 0 128 *:8000 *:*

LISTEN 0 128 *:8001 *:*

LISTEN 0 128 *:25672 *:*

LISTEN 0 5 127.0.0.1:8010 *:*

LISTEN 0 128 *:111 *:*

LISTEN 0 128 *:80 *:*

LISTEN 0 128 *:4369 *:*

LISTEN 0 128 :::22 :::*

LISTEN 0 128 ::1:631 :::*

LISTEN 0 100 ::1:25 :::*

LISTEN 0 128 :::111 :::*

LISTEN 0 128 :::80 :::*

LISTEN 0 128 :::4369 :::*

[root@node1 ~]#

  提示:rabbitmqctl stop_app这个命令只是停止rabbitmq上的应用,而非停止rabbitmq服务;所以监听的端口信息都还在;rabbitmqctl status是查看rabbitmq的状态信息;

  start_app:启动已有应用;

[root@node1 ~]# rabbitmqctl status

Status of node rabbit@node1 ...

[{pid,18223},

{running_applications,[{xmerl,"XML parser","1.3.6"},

{sasl,"SASL CXC 138 11","2.3.4"},

{stdlib,"ERTS CXC 138 10","1.19.4"},

{kernel,"ERTS CXC 138 10","2.16.4"}]},

{os,{unix,linux}},

{erlang_version,"Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:30] [hipe] [kernel-poll:true]\n"},

{memory,[{total,35564488},

{connection_procs,0},

{queue_procs,0},

{plugins,0},

{other_proc,13299600},

{mnesia,0},

{mgmt_db,0},

{msg_index,0},

{other_ets,607888},

{binary,12600},

{code,16707498},

{atom,602729},

{other_system,4334173}]},

{alarms,[]},

{listeners,[]},

{processes,[{limit,1048576},{used,46}]},

{run_queue,0},

{uptime,495}]

...done.

[root@node1 ~]# rabbitmqctl start_app

Starting node rabbit@node1 ...

...done.

[root@node1 ~]# rabbitmqctl status

Status of node rabbit@node1 ...

[{pid,18223},

{running_applications,[{rabbit,"RabbitMQ","3.3.5"},

{os_mon,"CPO CXC 138 46","2.2.14"},

{mnesia,"MNESIA CXC 138 12","4.11"},

{xmerl,"XML parser","1.3.6"},

{sasl,"SASL CXC 138 11","2.3.4"},

{stdlib,"ERTS CXC 138 10","1.19.4"},

{kernel,"ERTS CXC 138 10","2.16.4"}]},

{os,{unix,linux}},

{erlang_version,"Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:30] [hipe] [kernel-poll:true]\n"},

{memory,[{total,36211968},

{connection_procs,2800},

{queue_procs,5600},

{plugins,0},

{other_proc,13678784},

{mnesia,60144},

{mgmt_db,0},

{msg_index,21928},

{other_ets,756792},

{binary,19048},

{code,16707530},

{atom,602729},

{other_system,4356613}]},

{alarms,[]},

{listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},

{vm_memory_high_watermark,0.4},

{vm_memory_limit,1581588480},

{disk_free_limit,50000000},

{disk_free,39833972736},

{file_descriptors,[{total_limit,924},

{total_used,3},

{sockets_limit,829},

{sockets_used,1}]},

{processes,[{limit,1048576},{used,127}]},

{run_queue,0},

{uptime,513}]

...done.

[root@node1 ~]#

  提示:可以看到application中多了mnesia,rabbit,os_mon这3个app的信息;

  reset:重置;

  force_reset:强制重置;

  用户管理相关子命令

    list_users:查看用户列表;

[root@node1 ~]# rabbitmqctl list_users

Listing users ...

guest [administrator]

...done.

[root@node1 ~]#

  提示:默认只有grest用户,这个用户的标签是administrator,表示这是一个管理员;

    add_user <username> <password>:添加用户;

[root@node1 ~]# rabbitmqctl add_user qiuhom test

Creating user "qiuhom" ...

...done.

[root@node1 ~]# rabbitmqctl list_users

Listing users ...

guest [administrator]

qiuhom []

...done.

[root@node1 ~]#

  提示:添加用户必须指定用户名和密码;默认添加到用户都是普通用户,就是没有任何标签的用户;

    delete_user <username>:删除指定用户;

[root@node1 ~]# rabbitmqctl delete_user qiuhom

Deleting user "qiuhom" ...

...done.

[root@node1 ~]# rabbitmqctl list_users

Listing users ...

guest [administrator]

...done.

[root@node1 ~]#

  提示:删除用户只需指定用户名即可;

    change_password <username> <newpassword>:修改指定用户密码;

[root@node1 ~]# rabbitmqctl change_password guest admin

Changing password for user "guest" ...

...done.

[root@node1 ~]#

  提示:以上表示修改guest用户的命名为admin;如果我们开启了web管理界面就可以来测试guest用户的密码,如果使用admin能够登录到管理界面说明密码修改成功了,不能说明没有修改成功,guest用户的默认密码是guest;

  验证:开启rabbitmq-management插件,看看对应guest用户的密码是否更改了?

[root@node1 ~]# rabbitmq-plugins list

[ ] amqp_client 3.3.5

[ ] cowboy 0.5.0-rmq3.3.5-git4b93c2d

[ ] eldap 3.3.5-gite309de4

[ ] mochiweb 2.7.0-rmq3.3.5-git680dba8

[ ] rabbitmq_amqp1_0 3.3.5

[ ] rabbitmq_auth_backend_ldap 3.3.5

[ ] rabbitmq_auth_mechanism_ssl 3.3.5

[ ] rabbitmq_consistent_hash_exchange 3.3.5

[ ] rabbitmq_federation 3.3.5

[ ] rabbitmq_federation_management 3.3.5

[ ] rabbitmq_management 3.3.5

[ ] rabbitmq_management_agent 3.3.5

[ ] rabbitmq_management_visualiser 3.3.5

[ ] rabbitmq_mqtt 3.3.5

[ ] rabbitmq_shovel 3.3.5

[ ] rabbitmq_shovel_management 3.3.5

[ ] rabbitmq_stomp 3.3.5

[ ] rabbitmq_test 3.3.5

[ ] rabbitmq_tracing 3.3.5

[ ] rabbitmq_web_dispatch 3.3.5

[ ] rabbitmq_web_stomp 3.3.5

[ ] rabbitmq_web_stomp_examples 3.3.5

[ ] sockjs 0.3.4-rmq3.3.5-git3132eb9

[ ] webmachine 1.10.3-rmq3.3.5-gite9359c7

[root@node1 ~]# rabbitmq-plugins enable rabbitmq_management

The following plugins have been enabled:

mochiweb

webmachine

rabbitmq_web_dispatch

amqp_client

rabbitmq_management_agent

rabbitmq_management

Plugin configuration has changed. Restart RabbitMQ for changes to take effect.

[root@node1 ~]# rabbitmq-plugins list

[e] amqp_client 3.3.5

[ ] cowboy 0.5.0-rmq3.3.5-git4b93c2d

[ ] eldap 3.3.5-gite309de4

[e] mochiweb 2.7.0-rmq3.3.5-git680dba8

[ ] rabbitmq_amqp1_0 3.3.5

[ ] rabbitmq_auth_backend_ldap 3.3.5

[ ] rabbitmq_auth_mechanism_ssl 3.3.5

[ ] rabbitmq_consistent_hash_exchange 3.3.5

[ ] rabbitmq_federation 3.3.5

[ ] rabbitmq_federation_management 3.3.5

[E] rabbitmq_management 3.3.5

[e] rabbitmq_management_agent 3.3.5

[ ] rabbitmq_management_visualiser 3.3.5

[ ] rabbitmq_mqtt 3.3.5

[ ] rabbitmq_shovel 3.3.5

[ ] rabbitmq_shovel_management 3.3.5

[ ] rabbitmq_stomp 3.3.5

[ ] rabbitmq_test 3.3.5

[ ] rabbitmq_tracing 3.3.5

[e] rabbitmq_web_dispatch 3.3.5

[ ] rabbitmq_web_stomp 3.3.5

[ ] rabbitmq_web_stomp_examples 3.3.5

[ ] sockjs 0.3.4-rmq3.3.5-git3132eb9

[e] webmachine 1.10.3-rmq3.3.5-gite9359c7

[root@node1 ~]#

  提示:启用插件需要用rabbitmq-plugins命令,enable表示启用指定插件,disable表示禁用指定插件,list表示列出插件列表;其中列出插件列表前边中括号中的大写E表示手动开启的插件,小写e表示手动开启插件依赖的插件,自动开启的;

  重启rabbitmq-server服务

  提示:启用了插件,必须要重启服务才能够正常使用插件,从上的信息可以看到我们启用了rabbitmq-mangement插件,重启rabbitmq-server服务后,对应的15672端口就处于监听状态了;

  登录宿主机的15672端口,访问web管理界面

  提示:用guest用户使用admin密码是能够登录到管理界面,说明我们更改密码成功了;其实很多命令行能够管理的,我们都可以基于这个web管理界面进行管理;

    set_user_tags <username> <tag> ...:设置指定用户的标签;

[root@node1 ~]# rabbitmqctl add_user qiuhom test

Creating user "qiuhom" ...

...done.

[root@node1 ~]# rabbitmqctl list_users

Listing users ...

guest [administrator]

qiuhom []

...done.

[root@node1 ~]# rabbitmqctl set_user_tags qiuhom administrator

Setting tags for user "qiuhom" to [administrator] ...

...done.

[root@node1 ~]# rabbitmqctl list_users

Listing users ...

guest [administrator]

qiuhom [administrator]

...done.

[root@node1 ~]# rabbitmqctl set_user_tags qiuhom

Setting tags for user "qiuhom" to [] ...

...done.

[root@node1 ~]# rabbitmqctl list_users

Listing users ...

guest [administrator]

qiuhom []

...done.

[root@node1 ~]#

  提示:如果用户名后面不指定任何标签,相当于把原有的标签信息清空;标签为administrator的用户拥有登录web管理界面的权限;

    clear_password <username>:清空指定用户的密码;

[root@node1 ~]# rabbitmqctl clear_password qiuhom

Clearing password for user "qiuhom" ...

...done.

[root@node1 ~]#

  虚拟主机相关管理子命令

    list_vhosts [<vhostinfoitem> ...]:列出虚拟主机列表;

[root@node1 ~]# rabbitmqctl list_vhosts

Listing vhosts ...

/

...done.

[root@node1 ~]#

  提示:默认只有“/”这个虚拟主机;

    add_vhost <vhostpath>:添加虚拟主机;

[root@node1 ~]# rabbitmqctl add_vhost /qiuhom/test

Creating vhost "/qiuhom/test" ...

...done.

[root@node1 ~]# rabbitmqctl list_vhosts

Listing vhosts ...

/

/qiuhom/test

...done.

[root@node1 ~]#

    delete_vhost <vhostpath>:删除虚拟主机;

[root@node1 ~]# rabbitmqctl delete_vhost /qiuhom/test

Deleting vhost "/qiuhom/test" ...

...done.

[root@node1 ~]# rabbitmqctl list_vhosts

Listing vhosts ...

/

...done.

[root@node1 ~]#

  权限相关管理子命令

    list_permissions [-p <vhostpath>]:列出指定虚拟主机权限,不指定表示查看默认虚拟主机的权限(这个是以虚拟主机查看权限);

[root@node1 ~]# rabbitmqctl list_permissions

Listing permissions in vhost "/" ...

guest .* .* .*

...done.

[root@node1 ~]# rabbitmqctl add_vhost /qiuhom/test

Creating vhost "/qiuhom/test" ...

...done.

[root@node1 ~]# rabbitmqctl list_permissions

Listing permissions in vhost "/" ...

guest .* .* .*

...done.

[root@node1 ~]# rabbitmqctl list_permissions -p /qiuhom/test

Listing permissions in vhost "/qiuhom/test" ...

...done.

[root@node1 ~]#

  提示:默认虚拟主机上“/”,guest用户对“/”这个虚拟主机以下的所有组件有访问权限;其中第一个.*表示配置文件,第二个.*表示写权限,第三个是读权限;

    list_user_permissions <username>:列出指定用户的权限(能够对那些虚拟主机进行哪些操作,这个是以用户名去查看权限)

[root@node1 ~]# rabbitmqctl list_user_permissions guest

Listing permissions for user "guest" ...

/ .* .* .*

...done.

[root@node1 ~]#

  提示:以上表示查看guest这个用户所有虚拟主机上的权限;这里需要注意一点虚拟主机都是以/开始的树状结构,且支持继承,所谓继承就表示一某个虚拟主机开始一下所有子虚拟主机都有相同的权限;以上guest就对所有虚拟主机有访问权限;

    set_permissions [-p <vhostpath>] <user> <conf> <write> <read>:设置权限,不指定虚拟主机表示给默认虚拟主机设定权限;

[root@node1 ~]# rabbitmqctl list_users

Listing users ...

guest [administrator]

qiuhom []

...done.

[root@node1 ~]# rabbitmqctl list_vhosts

Listing vhosts ...

/

/qiuhom/test

...done.

[root@node1 ~]# rabbitmqctl set_permissions qiuhom ".*" ".*" ".*"

Setting permissions for user "qiuhom" in vhost "/" ...

...done.

[root@node1 ~]# rabbitmqctl list_permissions

Listing permissions in vhost "/" ...

guest .* .* .*

qiuhom .* .* .*

...done.

[root@node1 ~]# rabbitmqctl set_permissions -p /qiuhom/test qiuhom ".*" ".*" ".*"

Setting permissions for user "qiuhom" in vhost "/qiuhom/test" ...

...done.

[root@node1 ~]# rabbitmqctl list_permissions

Listing permissions in vhost "/" ...

guest .* .* .*

qiuhom .* .* .*

...done.

[root@node1 ~]#rabbitmqctl list_permissions -p /qiuhom/test

Listing permissions in vhost "/qiuhom/test" ...

qiuhom .* .* .*

...done.

[root@node1 ~]#

    clear_permissions [-p <vhostpath>] <username>:清空指定用户对某虚拟主机的权限,默认不指定虚拟主机表示默认虚拟主机;

[root@node1 ~]# rabbitmqctl list_permissions  -p /qiuhom/test

Listing permissions in vhost "/qiuhom/test" ...

qiuhom .* .* .*

...done.

[root@node1 ~]# rabbitmqctl list_user_permissions qiuhom

Listing permissions for user "qiuhom" ...

/ .* .* .*

/qiuhom/test .* .* .*

...done.

[root@node1 ~]# rabbitmqctl clear_permissions -p / qiuhom

Clearing permissions for user "qiuhom" in vhost "/" ...

...done.

[root@node1 ~]# rabbitmqctl list_user_permissions qiuhom

Listing permissions for user "qiuhom" ...

/qiuhom/test .* .* .*

...done.

[root@node1 ~]# rabbitmqctl list_permissions -p /

Listing permissions in vhost "/" ...

guest .* .* .*

...done.

[root@node1 ~]# rabbitmqctl clear_permissions -p /qiuhom/test qiuhom

Clearing permissions for user "qiuhom" in vhost "/qiuhom/test" ...

...done.

[root@node1 ~]# rabbitmqctl list_permissions -p /qiuhom/test

Listing permissions in vhost "/qiuhom/test" ...

...done.

[root@node1 ~]#

  组件查看类子命令

    list_queues [-p <vhostpath>] [<queueinfoitem> ...]:列出队列;

[root@node1 ~]# rabbitmqctl list_queues

Listing queues ...

...done.

[root@node1 ~]#

    list_exchanges [-p <vhostpath>] [<exchangeinfoitem> ...]:列出交换器;

[root@node1 ~]# rabbitmqctl list_exchanges

Listing exchanges ...

direct

amq.direct direct

amq.fanout fanout

amq.headers headers

amq.match headers

amq.rabbitmq.log topic

amq.rabbitmq.trace topic

amq.topic topic

...done.

[root@node1 ~]#

    list_bindings [-p <vhostpath>] [<bindinginfoitem> ...]:列出绑定器;

[root@node1 ~]# rabbitmqctl list_bindings

Listing bindings ...

...done.

[root@node1 ~]#

    list_connections [<connectioninfoitem> ...]:列出连接列表

[root@node1 ~]# rabbitmqctl list_connections

Listing connections ...

...done.

[root@node1 ~]#

    list_channels [<channelinfoitem> ...]:列出频道

[root@node1 ~]# rabbitmqctl list_channels

Listing channels ...

...done.

[root@node1 ~]#

  提示:上面这些组件我们除了可以在命令行通过子命令的方式查看,其实在web管理界面也给我们提供了一个api访问接口;

  在web界面访问api接口查看虚拟主机

  在web界面查看用户列表

  提示:需要查看某类组件的信息,可以在api后面加上对应组件的名称作为rui即可访问,当然有了这个api接口,程序员就可以调用这个接口从而对rabbitmq进行操作;具体操作文档可访问对应宿主机的15672/api查看示例;

    list_consumers [-p <vhostpath>]:列出消费者

[root@node1 ~]# rabbitmqctl list_consumers

Listing consumers ...

...done.

[root@node1 ~]#

    status:查看rabbitmq的状态信息;

[root@node1 ~]# rabbitmqctl status

Status of node rabbit@node1 ...

[{pid,20202},

{running_applications,

[{rabbitmq_management,"RabbitMQ Management Console","3.3.5"},

{rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.3.5"},

{webmachine,"webmachine","1.10.3-rmq3.3.5-gite9359c7"},

{mochiweb,"MochiMedia Web Server","2.7.0-rmq3.3.5-git680dba8"},

{rabbitmq_management_agent,"RabbitMQ Management Agent","3.3.5"},

{rabbit,"RabbitMQ","3.3.5"},

{os_mon,"CPO CXC 138 46","2.2.14"},

{inets,"INETS CXC 138 49","5.9.8"},

{mnesia,"MNESIA CXC 138 12","4.11"},

{amqp_client,"RabbitMQ AMQP Client","3.3.5"},

{xmerl,"XML parser","1.3.6"},

{sasl,"SASL CXC 138 11","2.3.4"},

{stdlib,"ERTS CXC 138 10","1.19.4"},

{kernel,"ERTS CXC 138 10","2.16.4"}]},

{os,{unix,linux}},

{erlang_version,

"Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:30] [hipe] [kernel-poll:true]\n"},

{memory,

[{total,40816096},

{connection_procs,5600},

{queue_procs,5600},

{plugins,432624},

{other_proc,13494248},

{mnesia,64144},

{mgmt_db,45376},

{msg_index,34528},

{other_ets,1085424},

{binary,119600},

{code,20229052},

{atom,711569},

{other_system,4588331}]},

{alarms,[]},

{listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},

{vm_memory_high_watermark,0.4},

{vm_memory_limit,1581588480},

{disk_free_limit,50000000},

{disk_free,39831085056},

{file_descriptors,

[{total_limit,924},{total_used,3},{sockets_limit,829},{sockets_used,1}]},

{processes,[{limit,1048576},{used,181}]},

{run_queue,0},

{uptime,5271}]

...done.

[root@node1 ~]#

    environment:查看环境变量;

[root@node1 ~]# rabbitmqctl environment

Application environment of node rabbit@node1 ...

[{auth_backends,[rabbit_auth_backend_internal]},

{auth_mechanisms,['PLAIN','AMQPLAIN']},

{backing_queue_module,rabbit_variable_queue},

{channel_max,0},

{channel_operation_timeout,70000},

{cluster_nodes,{[],disc}},

{cluster_partition_handling,ignore},

{collect_statistics,fine},

{collect_statistics_interval,5000},

{default_permissions,[<<".*">>,<<".*">>,<<".*">>]},

{default_user,<<"guest">>},

{default_user_tags,[administrator]},

{default_vhost,<<"/">>},

{delegate_count,16},

{disk_free_limit,50000000},

{enabled_plugins_file,"/etc/rabbitmq/enabled_plugins"},

{error_logger,{file,"/var/log/rabbitmq/rabbit@node1.log"}},

{frame_max,131072},

{halt_on_upgrade_failure,true},

{heartbeat,580},

{hipe_compile,false},

{hipe_modules,[rabbit_reader,rabbit_channel,gen_server2,rabbit_exchange,

rabbit_command_assembler,rabbit_framing_amqp_0_9_1,

rabbit_basic,rabbit_event,lists,queue,priority_queue,

rabbit_router,rabbit_trace,rabbit_misc,rabbit_binary_parser,

rabbit_exchange_type_direct,rabbit_guid,rabbit_net,

rabbit_amqqueue_process,rabbit_variable_queue,

rabbit_binary_generator,rabbit_writer,delegate,gb_sets,lqueue,

sets,orddict,rabbit_amqqueue,rabbit_limiter,gb_trees,

rabbit_queue_index,rabbit_exchange_decorator,gen,dict,ordsets,

file_handle_cache,rabbit_msg_store,array,

rabbit_msg_store_ets_index,rabbit_msg_file,

rabbit_exchange_type_fanout,rabbit_exchange_type_topic,mnesia,

mnesia_lib,rpc,mnesia_tm,qlc,sofs,proplists,credit_flow,pmon,

ssl_connection,tls_connection,ssl_record,tls_record,gen_fsm,

ssl]},

{included_applications,[]},

{log_levels,[{connection,info}]},

{loopback_users,[]},

{msg_store_file_size_limit,16777216},

{msg_store_index_module,rabbit_msg_store_ets_index},

{plugins_dir,"/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/sbin/../plugins"},

{plugins_expand_dir,"/var/lib/rabbitmq/mnesia/rabbit@node1-plugins-expand"},

{queue_index_max_journal_entries,65536},

{reverse_dns_lookups,false},

{sasl_error_logger,{file,"/var/log/rabbitmq/rabbit@node1-sasl.log"}},

{server_properties,[]},

{ssl_apps,[asn1,crypto,public_key,ssl]},

{ssl_cert_login_from,distinguished_name},

{ssl_listeners,[]},

{ssl_options,[]},

{tcp_listen_options,[binary,

{packet,raw},

{reuseaddr,true},

{backlog,128},

{nodelay,true},

{linger,{true,0}},

{exit_on_close,false}]},

{tcp_listeners,[5672]},

{trace_vhosts,[]},

{vm_memory_high_watermark,0.4},

{vm_memory_high_watermark_paging_ratio,0.5}]

...done.

[root@node1 ~]#

    report:生成系统状态报告;

[root@node1 ~]# rabbitmqctl report

Reporting server status on {{2020,8,25},{16,18,8}}

...

Status of node rabbit@node1 ...

[{pid,20202},

{running_applications,

[{rabbitmq_management,"RabbitMQ Management Console","3.3.5"},

{rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.3.5"},

{webmachine,"webmachine","1.10.3-rmq3.3.5-gite9359c7"},

{mochiweb,"MochiMedia Web Server","2.7.0-rmq3.3.5-git680dba8"},

{rabbitmq_management_agent,"RabbitMQ Management Agent","3.3.5"},

{rabbit,"RabbitMQ","3.3.5"},

{os_mon,"CPO CXC 138 46","2.2.14"},

{inets,"INETS CXC 138 49","5.9.8"},

{mnesia,"MNESIA CXC 138 12","4.11"},

{amqp_client,"RabbitMQ AMQP Client","3.3.5"},

{xmerl,"XML parser","1.3.6"},

{sasl,"SASL CXC 138 11","2.3.4"},

{stdlib,"ERTS CXC 138 10","1.19.4"},

{kernel,"ERTS CXC 138 10","2.16.4"}]},

{os,{unix,linux}},

{erlang_version,

"Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:30] [hipe] [kernel-poll:true]\n"},

{memory,

[{total,40510448},

{connection_procs,5600},

{queue_procs,5600},

{plugins,208520},

{other_proc,13407608},

{mnesia,64144},

{mgmt_db,50256},

{msg_index,34528},

{other_ets,1085424},

{binary,119648},

{code,20229052},

{atom,711569},

{other_system,4588499}]},

{alarms,[]},

{listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},

{vm_memory_high_watermark,0.4},

{vm_memory_limit,1581588480},

{disk_free_limit,50000000},

{disk_free,39831064576},

{file_descriptors,

[{total_limit,924},{total_used,3},{sockets_limit,829},{sockets_used,1}]},

{processes,[{limit,1048576},{used,181}]},

{run_queue,0},

{uptime,5347}]

Cluster status of node rabbit@node1 ...

[{nodes,[{disc,[rabbit@node1]}]},

{running_nodes,[rabbit@node1]},

{cluster_name,<<"rabbit@node1">>},

{partitions,[]}]

Application environment of node rabbit@node1 ...

[{auth_backends,[rabbit_auth_backend_internal]},

{auth_mechanisms,['PLAIN','AMQPLAIN']},

{backing_queue_module,rabbit_variable_queue},

{channel_max,0},

{channel_operation_timeout,70000},

{cluster_nodes,{[],disc}},

{cluster_partition_handling,ignore},

{collect_statistics,fine},

{collect_statistics_interval,5000},

{default_permissions,[<<".*">>,<<".*">>,<<".*">>]},

{default_user,<<"guest">>},

{default_user_tags,[administrator]},

{default_vhost,<<"/">>},

{delegate_count,16},

{disk_free_limit,50000000},

{enabled_plugins_file,"/etc/rabbitmq/enabled_plugins"},

{error_logger,{file,"/var/log/rabbitmq/rabbit@node1.log"}},

{frame_max,131072},

{halt_on_upgrade_failure,true},

{heartbeat,580},

{hipe_compile,false},

{hipe_modules,[rabbit_reader,rabbit_channel,gen_server2,rabbit_exchange,

rabbit_command_assembler,rabbit_framing_amqp_0_9_1,

rabbit_basic,rabbit_event,lists,queue,priority_queue,

rabbit_router,rabbit_trace,rabbit_misc,rabbit_binary_parser,

rabbit_exchange_type_direct,rabbit_guid,rabbit_net,

rabbit_amqqueue_process,rabbit_variable_queue,

rabbit_binary_generator,rabbit_writer,delegate,gb_sets,lqueue,

sets,orddict,rabbit_amqqueue,rabbit_limiter,gb_trees,

rabbit_queue_index,rabbit_exchange_decorator,gen,dict,ordsets,

file_handle_cache,rabbit_msg_store,array,

rabbit_msg_store_ets_index,rabbit_msg_file,

rabbit_exchange_type_fanout,rabbit_exchange_type_topic,mnesia,

mnesia_lib,rpc,mnesia_tm,qlc,sofs,proplists,credit_flow,pmon,

ssl_connection,tls_connection,ssl_record,tls_record,gen_fsm,

ssl]},

{included_applications,[]},

{log_levels,[{connection,info}]},

{loopback_users,[]},

{msg_store_file_size_limit,16777216},

{msg_store_index_module,rabbit_msg_store_ets_index},

{plugins_dir,"/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/sbin/../plugins"},

{plugins_expand_dir,"/var/lib/rabbitmq/mnesia/rabbit@node1-plugins-expand"},

{queue_index_max_journal_entries,65536},

{reverse_dns_lookups,false},

{sasl_error_logger,{file,"/var/log/rabbitmq/rabbit@node1-sasl.log"}},

{server_properties,[]},

{ssl_apps,[asn1,crypto,public_key,ssl]},

{ssl_cert_login_from,distinguished_name},

{ssl_listeners,[]},

{ssl_options,[]},

{tcp_listen_options,[binary,

{packet,raw},

{reuseaddr,true},

{backlog,128},

{nodelay,true},

{linger,{true,0}},

{exit_on_close,false}]},

{tcp_listeners,[5672]},

{trace_vhosts,[]},

{vm_memory_high_watermark,0.4},

{vm_memory_high_watermark_paging_ratio,0.5}]

Connections:

Channels:

Queues on /qiuhom/test:

Queues on /:

Exchanges on /qiuhom/test:

name type durable auto_delete internal arguments policy

direct true false false []

amq.direct direct true false false []

amq.fanout fanout true false false []

amq.headers headers true false false []

amq.match headers true false false []

amq.rabbitmq.trace topic true false true []

amq.topic topic true false false []

Exchanges on /:

name type durable auto_delete internal arguments policy

direct true false false []

amq.direct direct true false false []

amq.fanout fanout true false false []

amq.headers headers true false false []

amq.match headers true false false []

amq.rabbitmq.log topic true false true []

amq.rabbitmq.trace topic true false true []

amq.topic topic true false false []

Bindings on /qiuhom/test:

Bindings on /:

Consumers on /qiuhom/test:

Consumers on /:

Permissions on /qiuhom/test:

Permissions on /:

user configure write read

guest .* .* .*

Policies on /qiuhom/test:

Policies on /:

Parameters on /qiuhom/test:

Parameters on /:

...done.

[root@node1 ~]#

  策略相关管理子命令

    list_policies [-p <vhostpath>]:列出指定虚拟主机的策略;默认不指定是列出默认虚拟主机;

    set_policy [-p <vhostpath>] [--priority <priority>] [--apply-to <apply-to>] <name> <pattern> <definition>:对指定虚拟主机设置策略,没有指定虚拟主机表示默认虚拟主机;

    clear_policy [-p <vhostpath>] <name>:清楚指定虚拟主机的策略,没有指定虚拟主机表示对默认虚拟主机操作;

  集群相关子命令

    join_cluster <clusternode> [--ram]:加入指定节点集群;

    cluster_status:查看集群状态

    change_cluster_node_type disc | ram:更改节点存储类型,disc表示磁盘,ram表示内存;一个集群中必须有一个节点为disc类型;

    forget_cluster_node [--offline]:离开集群;

    update_cluster_nodes clusternode:更新集群节点;

    sync_queue queue:同步指定队列;

    cancel_sync_queue queue:取消指定队列同步

    set_cluster_name name:设置集群名称;

  设置参数相关子命令

    list_parameters [-p <vhostpath>]:查看指定虚拟主机运行时参数配置,默认不指定虚拟主机,表示查看默认虚拟主机的参数配置;

    set_parameter [-p <vhostpath>] <component_name> <name> <value>:设置指定参数的配置;不指定虚拟主机表示操作默认虚拟主机;

    clear_parameter [-p <vhostpath>] <component_name> <key>:删除指定配置项;

  其他子命令

    eval <expr>:执行erlang表达式

    close_connection <connectionpid> <explanation>:关闭指定连接;

    trace_on [-p <vhost>]:开启指定虚拟主机的追踪功能;

    trace_off [-p <vhost>]:关闭指定虚拟主机的追踪功能;

    set_vm_memory_high_watermark <fraction>:设置内存高水位标记;

  以上就是rabbitmq的简单介绍和安装配置相关参数的说明,以及rabbitmqctl这个工具的常用子命令的用法;

以上是 消息型web框架之RabbashMQ基础使用 的全部内容, 来源链接: utcz.com/a/50275.html

回到顶部