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

rabbitmq 学习-5-server管理 rabbitmq 

程序员文章站 2022-07-13 15:46:58
...

RabbitMQ Server Administrator's Guide

http://www.rabbitmq.com/admin-guide.html#installation

 

1, Rabbitmq DB

第一次启动,会检查是否有数据库,没有则创建 一个db,存放在

C:\Documents and Settings\Administrator\Application Data\RabbitMQDB会存储关于uservirtual host,持久化消息等信息

此目录下有两个文件夹:dblog

并会使用到这些资源:

virtual host/

userguest/guest

guest会分配所有的权限到virtual host /

 

2, 命令行管理工具rabbitmqctl

Rabbitmqctlrabbitmq的一个命令行管理工具,它用来对某个机器上(host)的节点(node)进行管理,本机默认的node名称是”rabbit”hostname可以使用hostname –s查看

执行相关命令时,可明确指定一个节点,例如:

rabbitmqctl –n node_name@host_name add_user username password

这个命令将在指定的机器(host_name)的节点(node_name)上创建一个用户

在启动rabbitmq的时命令行中,可以查看到node名称

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

RabbitMQ 1.6.0 (AMQP 8-0)

Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial Technologies LLC., and R

abbit Technologies Ltd.

Licensed under the MPL.  See http://www.rabbitmq.com/

 

node        : rabbit@WWW-65592D80C4A       //这里就是node_name@host_name

log         : C:/Documents and Settings/Administrator/Application Data/RabbitMQ/

log/rabbit.log      //日志目录

sasl log    : C:/Documents and Settings/Administrator/Application Data/RabbitMQ/

log/rabbit-sasl.log  //日志目录

database dir: c:/Documents and Settings/Administrator/Application Data/RabbitMQ/

db/rabbit-mnesia   //db目录

 

starting database              ...done

starting core processes         ...done

starting recovery              ...done

starting persister              ...done

starting guid generator         ...done

starting builtin applications      ...done

starting TCP listeners           ...done

 

broker running

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

3, 查看node状态

rabbitmqctl -q status

输出:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

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

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

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

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

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

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

 {nodes,['rabbit@WWW-65592D80C4A']},

 {running_nodes,['rabbit@WWW-65592D80C4A']}]

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

4, 关闭rabbitmq

rabbitmqctl stop      

直接关闭rabbitmq,关闭rabbitmq节点(elr进程也关掉了),需要通过rabbitmq-server 才能重新启动

 

rabbitmqctl stop_app

关闭rabbitmq应用程序,但是erl进行还在,可以通过rabbitmqctl start_app恢复

 

rabbitmqctl start_app

启动rabbitmq应用程序

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

E:\rabbitmq_server-1.6.0\sbin>rabbitmqctl stop_app

Stopping node 'rabbit@WWW-65592D80C4A' ...

...done.

 

E:\rabbitmq_server-1.6.0\sbin>rabbitmqctl stop

Stopping and halting node 'rabbit@WWW-65592D80C4A' ...

...done.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

5, 查看rabbitmq状态

rabbitmqctl status
rabbitmqctl –q status

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Status of node 'rabbit@WWW-65592D80C4A' ...

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

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

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

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

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

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

 {nodes,['rabbit@WWW-65592D80C4A']},

 {running_nodes,['rabbit@WWW-65592D80C4A']}]

...done.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

6, 重置rabbitmq

rabbitmqctl reset
rabbitmqctl force_reset
使用force_resetreset不同之外在于:它会无条件的重置rabbitmq,不管rabbitmq database state,和rabbitmq已经在集群环境中配置,这个命令应该在迫不得已的情况去使用
 
重置rabbitmq,会有以下影响:
1,从集群节点中删除
2,删除db数据,如user, vhost信息,持久化消息 
 
重置成功后,必须stop rabbitmq,例如使用:rabbitmqctl stop_app
 

7, 修改日志文件后缀名

rabbitmqctl rotate_logs suffix_name
修改日志文件后缀名,执行以后,可以马上看到log目录下创建了指定后缀的日志文件:

rabbit.log.rabbit.log

rabbit-sasl.log.rabbit.log

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

E:\rabbitmq_server-1.6.0\sbin>rabbitmqctl rotate_logs .rabbit.log

Rotating logs to files with suffix ".rabbit.log" ...

...done.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

8, 集群管理

rabbitmqctl cluster clusternode ...

 

9, rabbitmqctl 所有命令:

Usage: rabbitmqctl [-q] [-n <node>] <command> [<arg> ...]

 

Available commands:

 

  stop      - stops the RabbitMQ application and halts the node

  stop_app  - stops the RabbitMQ application, leaving the node running

  start_app - starts the RabbitMQ application on an already-running node

  reset     - resets node to default configuration, deleting all data

  force_reset

  cluster <ClusterNode> ...

  status

  rotate_logs [Suffix]

  close_connection <ConnectionPid> <ExplanationString>

 

  add_user        <UserName> <Password>

  delete_user     <UserName>

  change_password <UserName> <NewPassword>

  list_users

 

  add_vhost    <VHostPath>

  delete_vhost <VHostPath>

  list_vhosts

 

  set_permissions   [-p <VHostPath>] <UserName> <Regexp> <Regexp> <Regexp>

  clear_permissions [-p <VHostPath>] <UserName>

  list_permissions  [-p <VHostPath>]

  list_user_permissions <UserName>

 

  list_queues    [-p <VHostPath>] [<QueueInfoItem> ...]

  list_exchanges [-p <VHostPath>] [<ExchangeInfoItem> ...]

  list_bindings  [-p <VHostPath>]

  list_connections [<ConnectionInfoItem> ...]

  list_channels [<ChannelInfoItem> ...]

  list_consumers [-p <VHostPath>]

 

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

messages are suppressed when quiet mode is in effect.

 

<node> should be the name of the master node of the RabbitMQ

cluster. It defaults to the node named "rabbit" on the local

host. On a host named "server.example.com", the master 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.

 

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, pid, owner_pid, exclusive_consumer_pid,

exclusive_consumer_tag, messages_ready, messages_unacknowledged,

messages_uncommitted, messages, acks_uncommitted, consumers,

transactions, memory]. The default is to display name and (number of)

messages.

 

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

auto_delete, arguments]. The default is to display name and type.

 

The output format for "list_bindings" is a list of rows containing

exchange name, queue name, routing key and arguments, in that order.

 

<ConnectionInfoItem> must be a member of the list [pid, address, port,

peer_address, peer_port, state, channels, user, vhost, timeout,

frame_max, client_properties, recv_oct, recv_cnt, send_oct, send_cnt,

send_pend].  The default is to display user, peer_address, peer_port

and state.

 

<ChannelInfoItem> must be a member of the list [pid, connection,

number, user, vhost, transactional, consumer_count,

messages_unacknowledged, acks_uncommitted, prefetch_count]. The

default is to display pid, user, transactional, consumer_count,

messages_unacknowledged.

 

The output format for "list_consumers" is a list of rows containing,

in order, the queue name, channel process id, consumer tag, and a

boolean indicating whether acknowledgements are expected from the

consumer.

相关标签: rabbitmq