命令行与管控台-基础操作
启动应用
[root@Jiavg /]# rabbitmqctl start_app
Starting node rabbit@Jiavg …
节点状态
[root@Jiavg /]# rabbitmqctl status
Status of node rabbit@Jiavg ...
[{pid,24387},
{running_applications,
[{rabbitmq_management,"RabbitMQ Management Console","3.6.6"},
{rabbitmq_management_agent,"RabbitMQ Management Agent","3.6.6"},
{rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.6.6"},
{rabbit,"RabbitMQ","3.6.6"},
{os_mon,"CPO CXC 138 46","2.4.1"},
{amqp_client,"RabbitMQ AMQP Client","3.6.6"},
{rabbit_common,[],"3.6.6"},
{webmachine,"webmachine","1.10.3"},
{mochiweb,"MochiMedia Web Server","2.13.1"},
{mnesia,"MNESIA CXC 138 12","4.14"},
{inets,"INETS CXC 138 49","6.3.2"},
{ssl,"Erlang/OTP SSL application","8.0.1"},
{public_key,"Public key infrastructure","1.2"},
{xmerl,"XML parser","1.3.11"},
{crypto,"CRYPTO","3.7"},
{compiler,"ERTS CXC 138 10","7.0.1"},
{asn1,"The Erlang ASN1 compiler version 4.0.3","4.0.3"},
{ranch,"Socket acceptor pool for TCP protocols.","1.2.1"},
{syntax_tools,"Syntax tools","2.0"},
{sasl,"SASL CXC 138 11","3.0"},
{stdlib,"ERTS CXC 138 10","3.0.1"},
{kernel,"ERTS CXC 138 10","5.0.1"}]},
{os,{unix,linux}},
{erlang_version,
"Erlang/OTP 19 [erts-8.0.3] [source] [64-bit] [smp:2:2] [async-threads:64] [hipe] [kernel-poll:true]\n"},
{memory,
[{total,55645528},
{connection_readers,0},
{connection_writers,0},
{connection_channels,0},
{connection_other,2832},
{queue_procs,2832},
{queue_slave_procs,0},
{plugins,770696},
{other_proc,18182848},
{mnesia,67616},
{mgmt_db,661496},
{msg_index,44080},
{other_ets,1430128},
{binary,29576},
{code,24640713},
{atom,1000625},
{other_system,8812086}]},
{alarms,[]},
{listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
{vm_memory_high_watermark,0.4},
{vm_memory_limit,767174246},
{disk_free_limit,50000000},
{disk_free,20552192000},
{file_descriptors,
[{total_limit,924},{total_used,2},{sockets_limit,829},{sockets_used,0}]},
{processes,[{limit,1048576},{used,228}]},
{run_queue,0},
{uptime,80},
{kernel,{net_ticktime,60}}]
关闭应用
[root@Jiavg /]# rabbitmqctl stop_app
Stopping node rabbit@Jiavg …
注意:
如果在关闭RabbitMQ管控台(即使用rabbitmqctl stop_app命令)后,重新启动管控台,可能会出现如下情况:
[root@Jiavg /]# rabbitmqctl start_app Starting node rabbit@Jiavg ... Error: unable to connect to node rabbit@Jiavg: nodedown DIAGNOSTICS =========== attempted to contact: [rabbit@Jiavg] rabbit@Jiavg: * connected to epmd (port 4369) on Jiavg * epmd reports: node 'rabbit' not running at all no other nodes on Jiavg * suggestion: start the node current node details: - node name: 'rabbitmq-cli-99@Jiavg' - home dir: /var/lib/rabbitmq - cookie hash: aTORW4S5X/Uol6/P8PSLqw== 解决方案: 1.kill掉RabbitMQ所有进程 2.重启RabbitMQ服务 [root@Jiavg /]# rabbitmq-server start RabbitMQ 3.6.6. Copyright (C) 2007-2016 Pivotal Software, Inc. ## ## Licensed under the MPL. See http://www.rabbitmq.com/ ## ## ########## Logs: /var/log/rabbitmq/rabbit@Jiavg.log ###### ## /var/log/rabbitmq/rabbit@Jiavg-sasl.log ########## Starting broker... completed with 6 plugins. 3.重新运行rabbitmqctl start_app命令
使用lsof命令查看RabbitMQ状态
lsof(list open files)是一个列出当前系统打开文件的工具。在linux环境下,任何事物都以文件的形式存在,通过文件不仅仅可以访问常规数据,还可以访问网络连接和硬件。所以如传输控制协议 (TCP) 和用户数据报协议 (UDP) 套接字等,系统在后台都为该应用程序分配了一个文件描述符,无论这个文件的本质如何,该文件描述符为应用程序与基础操作系统之间的交互提供了通用接口。因为应用程序打开文件的描述符列表提供了大量关于这个应用程序本身的信息,因此通过lsof工具能够查看这个列表对系统监测以及排错将是很有帮助的。
[root@Jiavg /]# lsof -i:5672
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
beam.smp 24387 rabbitmq 53u IPv6 139726 0t0 TCP *:amqp (LISTEN)
添加用户
rabbitmqctl add_user username password
[root@Jiavg /]# rabbitmqctl add_user jiavg jiavg
Creating user “jiavg” …
列出所有用户
rabbitmqctl list_users
[root@Jiavg /]# rabbitmqctl list_users
Listing users …
jiavg []
guest [administrator]
修改密码
rabbitmqctl change_password username newpassword
[root@Jiavg /]# rabbitmqctl change_password jiavg jiavg123
Changing password for user “jiavg” ..
删除用户
rabbitmqctl delete_user username
[root@Jiavg /]# rabbitmqctl delete_user jiavg
Deleting user “jiavg” …
创建虚拟主机
*rabbitmqctl add_vhost *vhostpath **
[root@Jiavg /]# rabbitmqctl add_vhost /test
Creating vhost “/test” …
列出所有虚拟主机
rabbitmqctl list_vhosts
[root@Jiavg /]# rabbitmqctl list_vhosts
Listing vhosts …
/test
/
设置用户权限
rabbitmqctl set_permissions -p vhostpath username “.“ “.*” “.*”*
[root@Jiavg /]# rabbitmqctl set_permissions -p /test jiavg “.*” “.*” “.*”
Setting permissions for user “jiavg” in vhost “/test” …
列出虚拟主机上所有权限
rabbitmqctl list_permissions -p vhostpath
[root@Jiavg /]# rabbitmqctl list_permissions -p /test
Listing permissions in vhost “/test” …
jiavg .* .* .*
清除用户权限
rabbitmqctl clear_permissions -p vhostpath username
[root@Jiavg /]# rabbitmqctl clear_permissions -p /test jiavg
Clearing permissions for user “jiavg” in vhost “/test” …
查看所有交换机信息
rabbitmqctl list_exchanges
[root@Jiavg /]# rabbitmqctl list_exchanges
Listing exchanges …
direct
amq.fanout fanout
amq.headers headers
amq.rabbitmq.log topic
amq.direct direct
amq.match headers
amq.rabbitmq.trace topic
amq.topic topic
查看所有队列信息
rabbitmqctl list_queues
[root@Jiavg /]# rabbitmqctl list_queues
Listing queues …
注:此时没有队列
清除队列里的消息
rabbitmqctl -p vhostpath purge_queue blue
命令行与管控台-高级操作
移除所有数据,要在rabbitmqctl stop_app之后使用
rabbitmqctl reset
组成集群命令
rabbitmqctl join_cluster
查看集群状态
rabbitmqctl cluster_status
修改集群节点的储存形式
rabbitmqctl change_cluster_node_type disc|ram
忘记节点(摘除节点)
rabbitmqctl forget_cluster_node [–offline]
修改节点名称
rabbitmqctl rename_cluster_node oldnode1 newnode1 [oldnode2] [newnode2…]
管控台-Overview项预览