1)服务器启动与关闭
启动:
rabbitmq-server –detached service rabbitmq-server start
systemctl start rabbitmq-server.service
关闭:
rabbitmqctl stop service rabbitmq-server
systemctl stop rabbitmq-server.service
ps: 若单机有多个实例,则在rabbitmqctlh后加–n 指定名称
2)插件管理
开启某个插件:rabbitmq-plugins enable xxx 关闭某个插件:rabbitmq-plugins disable xxx 例如: rabbitmq-plugins enable rabbitmq_management
ps:重启服务器后生效。
3)virtual_host管理
新建virtual_host: rabbitmqctl add_vhost xxx
撤销virtual_host:rabbitmqctl delete_vhost xxx
4)用户管理
新建用户:rabbitmqctl add_user xxx password
删除用户: rabbitmqctl delete_user xxx
改密码: rabbimqctlchange_password {username} {newpassword}
设置用户角色:rabbitmqctlset_user_tags {username} {tag ...}
Tag可以为 administrator,monitoring, management
5)权限管理
权限设置:set_permissions [-p vhostpath] {user} {conf} {write} {read} Vhostpath:Vhost路径 user:用户名 Conf:一个正则表达式match哪些配置资源能够被该用户访问 Write:一个正则表达式match哪些配置资源能够被该用户读 Read:一个正则表达式match哪些配置资源能够被该用户访问
6)获取服务器状态信息
服务器状态:rabbitmqctl status 队列信息:rabbitmqctl list_queues[-p vhostpath] [queueinfoitem ...] Queueinfoitem可以为:name,durable,auto_delete,arguments,messages_ready,messages_unacknowledged,messages,consumers,memory Exchange信息:rabbitmqctllist_exchanges[-p vhostpath] [exchangeinfoitem ...] Exchangeinfoitem有:name,type,durable,auto_delete,internal,arguments. Binding信息:rabbitmqctllist_bindings[-p vhostpath] [bindinginfoitem ...] Bindinginfoitem有:source_name,source_kind,destination_name,destination_kind,routing_key,arguments Connection信息:rabbitmqctllist_connections [connectioninfoitem ...] Connectioninfoitem有:recv_oct,recv_cnt,send_oct,send_cnt,send_pend等。 Channel信息:rabbitmqctl list_channels[channelinfoitem ...] Channelinfoitem有consumer_count,messages_unacknowledged,messages_uncommitted,acks_uncommitted,messages_unconfirmed,prefetch_count,client_flow_blocked
7)Node的类型修改
先关闭
rabbitmqctl stop_app
修改类型
rabbitmqctl change_cluster_node_type disc
rabbitmqctl change_cluster_node_type ram
最后启动
rabbitmqctl start_app
8)退出集群
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app
9)移除节点
rabbitmqctl stop_app rabbitmqctl forget_cluster_node rabbit@rabbit1 ps:rabbit@rabbit1为集群中存在的一个节点