{"id":560,"date":"2018-10-18T19:56:26","date_gmt":"2018-10-18T11:56:26","guid":{"rendered":"http:\/\/prayerlaputa.com\/?p=560"},"modified":"2019-07-18T20:18:46","modified_gmt":"2019-07-18T12:18:46","slug":"rabbitmq%e5%b8%b8%e7%94%a8%e5%91%bd%e4%bb%a4%e6%b1%87%e6%80%bb","status":"publish","type":"post","link":"http:\/\/prayerlaputa.com\/?p=560","title":{"rendered":"RabbitMQ\u5e38\u7528\u547d\u4ee4\u6c47\u603b"},"content":{"rendered":"<p>RabbitMQ\u5e38\u7528\u547d\u4ee4\u6c47\u603b<\/p>\n<p>\u5b89\u88c5\u8fc7\u7a0b\u7565\u3002<\/p>\n<h1>\u6d88\u606f\u961f\u5217\u5e38\u7528\u547d\u4ee4<\/h1>\n<h2>\u542f\u52a8<\/h2>\n<p>\u6ce8\u610f\u6309\u7167\u987a\u5e8f\uff0c\u5fc5\u987b\u5148\u542f\u52a8\u8282\u70b9<\/p>\n<p><code><br \/>\nrabbitmq-server -detached     #\u540e\u53f0\u542f\u52a8\u8282\u70b9<br \/>\nrabbitmqctl start_app         #\u542f\u52a8RabbitMQ\u5e94\u7528\u670d\u52a1, Starts the RabbitMQ application.<br \/>\n<\/code>   <\/p>\n<h2>\u5173\u95edRabbitMQ\u5e94\u7528\u670d\u52a1<\/h2>\n<p><!--more--><\/p>\n<p>Stops the RabbitMQ application, leaving the runtme (Erlang VM) running.<br \/>\n<code><br \/>\nrabbitmqctl stop_app          #\u5173\u95edRabbitMQ\u5e94\u7528\u670d\u52a1<br \/>\n<\/code>   <\/p>\n<h2>\u5173\u95ed\u8282\u70b9<\/h2>\n<p>Shuts down the node, both RabbitMQ and its runtime.<br \/>\n<code><br \/>\nrabbitmqctl shutdown<br \/>\n<\/code>  <\/p>\n<h2>\u5173\u95edErlang\u8282\u70b9<\/h2>\n<p>Stops the Erlang node on which RabbitMQ is running.<br \/>\n<code><br \/>\nrabbitmqctl stop<br \/>\n<\/code><\/p>\n<h2>\u542f\u52a8web\u7ba1\u7406\u63d2\u4ef6<\/h2>\n<p><code><br \/>\nrabbitmq-plugins enable rabbitmq_management #\u542f\u52a8web\u7ba1\u7406\u63d2\u4ef6<br \/>\n<\/code>  <\/p>\n<h2>\u91cd\u7f6e\u8282\u70b9<\/h2>\n<p>Returns a RabbitMQ node to its virgin state.<br \/>\n<code><br \/>\nrabbitmqctl reset<br \/>\n<\/code>   <\/p>\n<h1>\u96c6\u7fa4\u5e38\u7528\u547d\u4ee4<\/h1>\n<h2>\u5c06\u4e00\u4e2a\u8282\u70b9\uff08ram\u65b9\u5f0f\uff0c\u9ed8\u8ba4\u662fdisc\uff09\u52a0\u5165\u96c6\u7fa4<\/h2>\n<p><code><br \/>\nrabbitmqctl join_cluster hare@elena --ram<br \/>\n<\/code>  <\/p>\n<h2>\u67e5\u770b\u96c6\u7fa4\u72b6\u6001<\/h2>\n<p><code><br \/>\nrabbitmqctl cluster_status<br \/>\n<\/code>  <\/p>\n<h2>\u4fee\u6539\u8282\u70b9\u7c7b\u578b<\/h2>\n<p>\u8282\u70b9\u7c7b\u578b\u53ea\u80fd\u662fdisc\u6216\u662fram<br \/>\n<code><br \/>\nrabbitmqctl stop_app<br \/>\nrabbitmqctl change_cluster_node_type ram<br \/>\nrabbitmqtl start_app<br \/>\n<\/code>  <\/p>\n<h2>\u5728\u5f53\u524d\u96c6\u7fa4\u4e2d\u52a0\u5165\u67d0\u8282\u70b9<\/h2>\n<p><code><br \/>\nrabbitmqctl join_cluster {rabbit_node_name} \uff08\u67d0\u4e9b\u4f4e\u7248\u672c\u53ef\u4ee5\u91c7\u7528rabbitmqctl cluster {rabbit_node_name}\uff09<br \/>\n<\/code><\/p>\n<h2>\u5c06\u67d0\u8282\u70b9\u5254\u9664\u51fa\u5f53\u524d\u96c6\u7fa4<\/h2>\n<p><code><br \/>\nrabbitmqctl forget_cluster_node {rabbit_node_name}<br \/>\n<\/code><\/p>\n<h2>\u83b7\u53d6\u670d\u52a1\u5668\u72b6\u6001\u4fe1\u606f<\/h2>\n<p><code><br \/>\nrabbitmqctl status<br \/>\n<\/code><\/p>\n<h2>\u961f\u5217\u4fe1\u606f<\/h2>\n<p><code><br \/>\n rabbitmqctl list_queues [-p vhostpath] [queueinfoitem \u2026]<br \/>\n<\/code><br \/>\nqueueinfoitem\u53ef\u4ee5\u4e3a\uff1a name, durable, auto<em>delete, arguments, messages<\/em>ready, messages_unacknowled, messages, consumers, memory.<\/p>\n<h2>Exchange\u4fe1\u606f<\/h2>\n<p><code><br \/>\n rabbitmqctl list_exchanges [-p vhostpath] [exchangeinfoitem \u2026]<br \/>\n<\/code><br \/>\nexchangeinfoitem\u6709\uff1aname, type, durable, auto_delete, internal, arguments.<\/p>\n<h2>Binding\u4fe1\u606f<\/h2>\n<p><code><br \/>\nrabbitmqctl list_bindings [-p vhostpath] [bindinginfoitem \u2026]<br \/>\n<\/code><br \/>\nbindinginfoitem\u6709\uff1asource<em>name, source<\/em>kind, destination<em>name, destination<\/em>kind, routing_key, arguments.\u7b49<\/p>\n<h2>connection\u4fe1\u606f<\/h2>\n<p><code><br \/>\nrabbitmqctl list_connections [connectioninfoitem \u2026]<br \/>\n<\/code><br \/>\nconnectioninfoitem\u6709\uff1arecv<em>oct\uff0crecv<\/em>cnt\uff0csend<em>oct\uff0csend<\/em>cnt\uff0csend_pend\u7b49\u3002<\/p>\n<h2>channel\u4fe1\u606f<\/h2>\n<p><code><br \/>\nrabbitmqctl list_channels [channelinfoitem \u2026]<br \/>\n<\/code><br \/>\nchannelinfoitem\u6709:consumer<em>count\uff0cmessages<\/em>unacknowledged\uff0cmessages<em>uncommitted\uff0cacks<\/em>uncommitted\uff0cmessages<em>unconfirmed\uff0cprefetch<\/em>count\uff0cclient<em>flow<\/em>blocked<\/p>\n<h2>vhost\u7ba1\u7406<\/h2>\n<p><code><br \/>\n\u6dfb\u52a0vhost: rabbitmqctl add vhost {name}<br \/>\n\u5220\u9664vhost: rabbitmqctl delete vhost {name}<br \/>\n<\/code><\/p>\n<h2>\u955c\u50cf\u961f\u5217\u7684\u8bbe\u7f6e<\/h2>\n<p>\u955c\u50cf\u961f\u5217\u7684\u914d\u7f6e\u901a\u8fc7\u6dfb\u52a0policy\u5b8c\u6210\uff0cpolicy\u6dfb\u52a0\u7684\u547d\u4ee4\u4e3a\uff1a<br \/>\n<code><br \/>\nrabbitmqctl set_policy [-p Vhost] Name Pattern Definition [Priority]<br \/>\n<\/code><br \/>\n-p Vhost: \u53ef\u9009\u53c2\u6570\uff0c\u9488\u5bf9\u6307\u5b9avhost\u4e0b\u7684queue\u8fdb\u884c\u8bbe\u7f6e<br \/>\nName: policy\u7684\u540d\u79f0<br \/>\nPattern: queue\u7684\u5339\u914d\u6a21\u5f0f\uff08\u6b63\u5219\u8868\u8fbe\u5f0f\uff09<br \/>\nDefinition: \u955c\u50cf\u5b9a\u4e49\uff0c\u5305\u62ec\u4e09\u4e2a\u90e8\u5206 ha-mode\uff0cha-params\uff0cha-sync-mode<br \/>\n\u00a0\u00a0\u00a0\u00a0ha-mode: \u6307\u660e\u955c\u50cf\u961f\u5217\u7684\u6a21\u5f0f\uff0c\u6709\u6548\u503c\u4e3a all\/exactly\/nodes<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0all\u8868\u793a\u5728\u96c6\u7fa4\u6240\u6709\u7684\u8282\u70b9\u4e0a\u8fdb\u884c\u955c\u50cf<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0exactly\u8868\u793a\u5728\u6307\u5b9a\u4e2a\u6570\u7684\u8282\u70b9\u4e0a\u8fdb\u884c\u955c\u50cf\uff0c\u8282\u70b9\u7684\u4e2a\u6570\u7531ha-params\u6307\u5b9a<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0nodes\u8868\u793a\u5728\u6307\u5b9a\u7684\u8282\u70b9\u4e0a\u8fdb\u884c\u955c\u50cf\uff0c\u8282\u70b9\u540d\u79f0\u901a\u8fc7ha-params\u6307\u5b9a<br \/>\n\u00a0\u00a0\u00a0\u00a0ha-params: ha-mode\u6a21\u5f0f\u9700\u8981\u7528\u5230\u7684\u53c2\u6570<br \/>\n\u00a0\u00a0\u00a0\u00a0ha-sync-mode: \u955c\u50cf\u961f\u5217\u4e2d\u6d88\u606f\u7684\u540c\u6b65\u65b9\u5f0f\uff0c\u6709\u6548\u503c\u4e3aautomatic\uff0cmanually<br \/>\nPriority: \u53ef\u9009\u53c2\u6570\uff0c policy\u7684\u4f18\u5148\u7ea7<\/p>\n<p>\u4f8b\u5982\uff0c\u5bf9\u961f\u5217\u540d\u79f0\u4ee5hello\u5f00\u5934\u7684\u6240\u6709\u961f\u5217\u8fdb\u884c\u955c\u50cf\uff0c\u5e76\u5728\u96c6\u7fa4\u7684\u4e24\u4e2a\u8282\u70b9\u4e0a\u5b8c\u6210\u955c\u50cf\uff0cpolicy\u7684\u8bbe\u7f6e\u547d\u4ee4\u4e3a\uff1a<br \/>\n<code><br \/>\nrabbitmqctl set_policy hello-ha \u201c^hello\u201d \u2018{\u201cha-mode\u201d:\u201cexactly\u201d,\u201cha-params\u201d:2,\u201cha-sync-mode\u201d:\u201cautomatic\u201d}<br \/>\n<\/code><\/p>\n<h1>\u63d2\u4ef6\u7ba1\u7406<\/h1>\n<h2>\u5f00\u542f\u67d0\u4e2a\u63d2\u4ef6<\/h2>\n<p><code><br \/>\nrabbitmq-plugins enable {\u63d2\u4ef6\u540d}<br \/>\n<\/code><\/p>\n<h2>\u5173\u95ed\u67d0\u4e2a\u63d2\u4ef6<\/h2>\n<p><code><br \/>\nrabbitmq-plugins disable {\u63d2\u4ef6\u540d}<br \/>\n<\/code><\/p>\n<h1>\u7528\u6237\u7ba1\u7406<\/h1>\n<h2>\u6dfb\u52a0\u7528\u6237<\/h2>\n<p><code><br \/>\nrabbitmqctl add_user {username} {password}<br \/>\n<\/code><\/p>\n<h2>\u5220\u9664\u7528\u6237<\/h2>\n<p><code><br \/>\nrabbitmqctl delete_user {username}<br \/>\n<\/code><\/p>\n<h2>\u4fee\u6539\u5bc6\u7801<\/h2>\n<p><code><br \/>\nrabbitmqctl change_password {username} {newpassword}<br \/>\n<\/code><\/p>\n<h2>\u8bbe\u7f6e\u7528\u6237\u89d2\u8272<\/h2>\n<p><code><br \/>\nrabbitmqctl set_user_tags {username} {tag} tag\u53ef\u4ee5\u4e3aadministrator, monitoring, management<br \/>\n<\/code><\/p>\n<h1>\u6743\u9650\u7ba1\u7406<\/h1>\n<h2>\u6743\u9650\u8bbe\u7f6e<\/h2>\n<p><code><br \/>\nrabbitmqctl set_permissions [-p vhostpath] {user} {conf} {write} {read}<br \/>\n<\/code><br \/>\nconf:\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0fmatch\u54ea\u4e9b\u914d\u7f6e\u8d44\u6e90\u80fd\u591f\u88ab\u8be5\u7528\u6237\u8bbf\u95ee\u3002<br \/>\nwrite:\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0fmatch\u54ea\u4e9b\u914d\u7f6e\u8d44\u6e90\u80fd\u591f\u88ab\u8be5\u7528\u6237\u8bfb\u3002<br \/>\nread:\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0fmatch\u54ea\u4e9b\u914d\u7f6e\u8d44\u6e90\u80fd\u591f\u88ab\u8be5\u7528\u6237\u8bbf\u95ee\u3002<\/p>\n<h2>\u67e5\u770b\uff08\u6307\u5b9avhost\uff09\u6240\u6709\u7528\u6237\u7684\u6743\u9650\u4fe1\u606f<\/h2>\n<p><code><br \/>\nrabbitmqctl list_permissions [-p vhostPath]<br \/>\n<\/code><\/p>\n<h2>\u67e5\u770b\u6307\u5b9a\u7528\u6237\u7684\u6743\u9650\u4fe1\u606f<\/h2>\n<p><code><br \/>\nrabbitmqctl list_user_permissions {username}<br \/>\n<\/code><\/p>\n<h2>\u6e05\u9664\u7528\u6237\u7684\u6743\u9650\u4fe1\u606f<\/h2>\n<p><code><br \/>\nrabbitmqctl clear_permissions [-p vhostPath] {username}<br \/>\n<\/code><br \/>\n\u793a\u4f8b\uff1a<br \/>\n<code><br \/>\nrabbitmqctl set_permissions -p \/ root \u201c.*\u201d \u201c.*\u201d \u201c.*\u201d<br \/>\n<\/code><\/p>\n<h1>\u53c2\u8003\u8d44\u6599<\/h1>\n<p><a href=\"https:\/\/www.cnblogs.com\/tx720\/p\/9933269.html\">RabbitMq\u5e38\u7528\u547d\u4ee4<\/a><br \/><a href=\"https:\/\/www.rabbitmq.com\/rabbitmqctl.8.html\">rabbitmqctl(8)<\/a><br \/><a href=\"https:\/\/my.oschina.net\/hncscwc\/blog\/186350?p=1\">rabbitmq\u2014\u2014\u955c\u50cf\u961f\u5217<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>RabbitMQ\u5e38\u7528\u547d\u4ee4\u6c47\u603b \u5b89\u88c5\u8fc7\u7a0b\u7565\u3002 \u6d88\u606f\u961f\u5217\u5e38\u7528\u547d\u4ee4 \u542f\u52a8 \u6ce8\u610f\u6309\u7167\u987a\u5e8f\uff0c\u5fc5\u987b\u5148\u542f\u52a8\u8282\u70b9 rabbit <a href='http:\/\/prayerlaputa.com\/?p=560' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[7,14,15,25],"tags":[62,46],"_links":{"self":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/560"}],"collection":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=560"}],"version-history":[{"count":3,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/560\/revisions"}],"predecessor-version":[{"id":565,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/560\/revisions\/565"}],"wp:attachment":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=560"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}