rabbitmqctl 用于管理RabbitMQ代理的命令行

更多命令参考:http://www.rabbitmq.com/rabbitmqctl.8.html

一、命令格式

rabbitmqctl [ -q ] [ -l ] [ -n node ] [ -t timeout ] 命令 [ command_options ]

二、常用命令

rabbitmqctl force_reset  //Forcefully returns a RabbitMQ node to its virgin state.
rabbitmqctl reset        //Returns a RabbitMQ node to its virgin state.
rabbitmqctl shutdown     //Shuts down the Erlang process on which RabbitMQ is running. The command is blocking and will return after the Erlang process exits. If RabbitMQ fails to stop, it will return a non-zero exit code.
rabbitmqctl start_app    //Starts the RabbitMQ application.
rabbitmqctl stop_app     //Stops the RabbitMQ application, leaving the Erlang node running.

三、集群管理

  • 命令:join_cluster clusternode [–ram]

    rabbitmqctl join_cluster hare@elena --ram       //this command instructs the RabbitMQ node to join the cluster that “hare@elena” is part of, as a ram node:
    rabbitmqctl cluster_status          //this command displays the nodes in the cluster:
    rabbitmqctl change_cluster_node_type disc        //this command will turn a RAM node into a disc node:The type must be one of the following:disc ram
    rabbitmqctl -n hare@mcnulty forget_cluster_node rabbit@stringer       //this command will remove the node “rabbit@stringer” from the node “hare@mcnulty”:
    rabbitmqctl rename_cluster_node rabbit@misshelpful rabbit@cordelia    //this command will rename the node “rabbit@misshelpful” to the node “rabbit@cordelia”
    rabbitmqctl force_boot    // this will force the node not to wait for other nodes next time it is started:
    purge_queue [-p vhost] queue  //removes all messages in it
    rabbitmqctl set_cluster_name london    //this sets the cluster name to “london”:
    

四、用户管理

rabbitmqctl add_user tonyg changeit   // this command instructs the RabbitMQ broker to create a (non-administrative) user named “tonyg” with (initial) password “changeit”:
rabbitmqctl delete_user tonyg   //this command instructs the RabbitMQ broker to delete the user named “tonyg”:
rabbitmqctl change_password tonyg newpass  //this command instructs the RabbitMQ broker to change the password for the user named “tonyg” to “newpass”:
rabbitmqctl clear_password tonyg  //this command instructs the RabbitMQ broker to clear the password for the user named “tonyg”:
rabbitmqctl authenticate_user tonyg verifyit // this command instructs the RabbitMQ broker to authenticate the user named “tonyg” with password “verifyit”:
rabbitmqctl set_user_tags tonyg administrator  //this command instructs the RabbitMQ broker to ensure the user named “tonyg” is an administrator:
rabbitmqctl set_user_tags tonyg  //This command instructs the RabbitMQ broker to remove any tags from the user named “tonyg”:
rabbitmqctl list_users   //this command instructs the RabbitMQ broker to list all users:

五、访问控制

rabbitmqctl add_vhost test //his command instructs the RabbitMQ broker to create a new virtual host called “test”:
rabbitmqctl delete_vhost test   //this command instructs the RabbitMQ broker to delete the virtual host called “test”:
rabbitmqctl list_vhosts name tracing  //this command instructs the RabbitMQ broker to list all virtual hosts:
rabbitmqctl set_permissions -p /myvhost tonyg “^tonyg-.*” “.*” “.*”   //this command instructs the RabbitMQ broker to grant the user named “tonyg” access to the virtual host called “/myvhost”, with configure permissions on all resources whose names starts with “tonyg-”, and write and read permissions on all resources:
rabbitmqctl clear_permissions -p /myvhost tonyg  //this command instructs the RabbitMQ broker to deny the user named “tonyg” access to the virtual host called “/myvhost”:
rabbitmqctl list_permissions -p /myvhost  // this command instructs the RabbitMQ broker to list all the users which have been granted access to the virtual host called “/myvhost”, and the permissions they have for operations on resources in that virtual host. Note that an empty string means no permissions granted:
rabbitmqctl list_user_permissions tonyg   //this command instructs the RabbitMQ broker to list all the virtual hosts to which the user named “tonyg” has been granted access, and the permissions the user has for operations on resources in these virtual hosts:
rabbitmqctl set_topic_permissions -p /myvhost tonyg amq.topic “^tonyg-.*” “^tonyg-.*”  //this command instructs the RabbitMQ broker to let the user named “tonyg” publish and consume messages going through the “amp.topic” exchange of the “/myvhost” virtual host with a routing key starting with “tonyg-”:
//Topic permissions support variable expansion for the following variables: username, vhost, and client_id. Note that client_id is expanded only when using MQTT. The previous example could be made more generic by using “^{username}-.*”:
rabbitmqctl set_topic_permissions -p /myvhost tonyg amq.topic “^{username}-.*” “^{username}-.*”

rabbitmqctl clear_topic_permissions -p /myvhost tonyg amq.topic  //this command instructs the RabbitMQ broker to remove topic permissions for user named “tonyg” for the topic exchange “amq.topic” in the virtual host called “/myvhost”:

rabbitmqctl list_topic_permissions -p /myvhost   //this command instructs the RabbitMQ broker to list all the users which have been granted topic permissions in the virtual host called “/myvhost:”

rabbitmqctl list_topic_user_permissions tonyg   // this command instructs the RabbitMQ broker to list all the virtual hosts to which the user named “tonyg” has been granted access, and the topic permissions the user has in these virtual hosts:

六、参数管理

Parameter Management  【第三方插件比较多】

七、政策管理

对queue的全局设置用的上这个“政策“,
队列的镜像也是用这个命令。

八、服务器状态

《1》 list_queues [-p vhost] [queueinfoitem …]

    rabbitmqctl list_queues name durable exclusive

《2》 list_exchanges [-p vhost] [exchangeinfoitem …]

《3》 list_bindings [-p vhost] [bindinginfoitem …]

《4》 list_connections [connectioninfoitem …]

《5》 list_channels [channelinfoitem …]

    connections =》 channels   建立connections是长连接 ,channels是挂在connection之上的。。

《6》 status

《7》 environment

《8》 Miscellaneous 【混合一些命令】

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值