{"id":5443,"date":"2014-01-03T17:48:07","date_gmt":"2014-01-03T09:48:07","guid":{"rendered":"https:\/\/kyle.ai\/blog\/?p=5443"},"modified":"2014-01-03T17:48:07","modified_gmt":"2014-01-03T09:48:07","slug":"%e5%ae%89%e8%a3%85rabbitmq%e4%bd%9ccelery%e7%9a%84broker","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/5443.html","title":{"rendered":"\u5b89\u88c5RabbitMQ\u4f5cCelery\u7684broker"},"content":{"rendered":"<p>\u4e0a\u4e00\u7bc7\u8bb2\u4e86\u7528redis\u4f5cCelery\u7684broker\uff0c\u4f1a\u5bfc\u81f4\u6267\u884c\u957f\u5ef6\u8fdf\u7684ETA\u5b9a\u65f6\u4efb\u52a1\u65f6\uff0c\u8d85\u8fc7visibility_timeout\u8bbe\u7f6e\u540e\u4efb\u52a1\u88ab\u91cd\u590d\u6267\u884c\u7684bug\u3002\u7531\u4e8e\u6ca1\u6709\u6bd4\u8f83\u597d\u7684\u89e3\u51b3\u529e\u6cd5\uff0c\u53ea\u597d\u6362\u7528RabbitMQ\u3002<\/p>\n<p>\u5728Ubuntu\u4e0a\u5b89\u88c5RabbitMQ\u975e\u5e38\u7b80\u5355\uff0c\u76f4\u63a5\u4ece\u6e90\u5b89\u88c5\u5c31\u597d\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo apt-get install rabbitmq-server\r\n<\/pre>\n<p>\u4e3a\u4e86\u80fd\u5728celery\u4e2d\u7528rabbitmq\uff0c\u9700\u8981\u8bbe\u7f6e\u7528\u6237\u5bc6\u7801\u548cvirtual host\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo rabbitmqctl add_user myuser mypassword\r\nsudo rabbitmqctl add_vhost myvhost\r\nsudo rabbitmqctl set_permissions -p myvhost myuser &quot;.*&quot; &quot;.*&quot; &quot;.*&quot;\r\n<\/pre>\n<p>\u4e0a\u9762\u8bbe\u7f6e\u4e86\u7528\u6237\u540d\uff1amyuser\uff0c\u5bc6\u7801\uff1amypassword\uff0cvirtual_host\uff1amyvhost<br \/>\n\u4e8e\u662f\uff0c\u6309\u7167celery\u7684broker url\u89c4\u5219\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ntransport:\/\/userid:password@hostname:port\/virtual_host\r\n\u8bbe\u7f6eceleryconfig.py\u4e2d\u5199\uff1a\r\nBROKER_URL = 'amqp:\/\/myuser:mypassword@localhost:5672\/myvhost'\r\n<\/pre>\n<p>\u6700\u540e\u91cd\u542frabbitmq server\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo service rabbitmq-server\r\n<\/pre>\n<p>\u5b89\u88c5rabbitmq\u7ba1\u7406\u5de5\u5177\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo rabbitmq-plugins enable rabbitmq_management\r\nsudo service rabbitmq-server restart\r\n<\/pre>\n<p>\u8fd9\u65f6\u5019\uff0c\u6253\u5f00 http:\/\/server-name:55672\/ \u5c31\u53ef\u4ee5\u8fdb\u5165\u7ba1\u7406\u754c\u9762\u4e86\u3002\u901a\u8fc7 http:\/\/server-name:55672\/cli \u4e0b\u8f7drabbitmqadmin\u547d\u4ee4\u884c\u5de5\u5177\u3002<\/p>\n<p>rabbitmq\u4f1a\u542f\u52a8 beam.smp \u8fdb\u7a0b\uff0c\u5360\u7528\u4e24\u4e09\u4e2a\u7aef\u53e3\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ntcp        0      0 0.0.0.0:56908           0.0.0.0:*               LISTEN      21072\/beam.smp\r\ntcp        0      0 0.0.0.0:15672           0.0.0.0:*               LISTEN      21072\/beam.smp\r\ntcp        0      0 0.0.0.0:55672           0.0.0.0:*               LISTEN      21072\/beam.smp\r\ntcp6       0      0 :::5672                 :::*                    LISTEN      21072\/beam.smp\r\n<\/pre>\n<p>\u53e6\u5916\u8fd8\u6709 erlang \u8fdb\u7a0b\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nrabbitmq  6228     1  0 Jan02 ?        00:00:00 \/usr\/lib\/erlang\/erts-5.9.1\/bin\/epmd -daemon\r\n<\/pre>\n<p>\u7ecf\u6d4b\u8bd5\uff0c\u4f4d\u4e8e rabbitmq\u4e2d\u7684\u5b9a\u65f6\u4efb\u52a1\uff0c\u5728\u91cd\u542f rabbitmq\u540e\u4f9d\u7136\u5b58\u5728\u3002<\/p>\n<p>\u4e0d\u8fc7\uff0c\u91cd\u542frabbitmq\u540e\uff0ccelery\u5df2\u7ecf\u5931\u53bbbroker\u8fde\u63a5\uff0c\u6240\u6709celery\u8fdb\u7a0b\u90fd\u6ca1\u6709\u4e86\uff0csupervisor\u7684\u72b6\u6001\u4e3a not running\uff0c\u9700\u8981\u624b\u52a8\u518d\u91cd\u542f\u4e00\u4e0bcelery\u624d\u884c\u3002<\/p>\n<p>rabbitmq\u7684\u547d\u4ee4\u884c\u7ba1\u7406 \u5de5\u5177\u6587\u6863\uff0chttps:\/\/www.rabbitmq.com\/man\/rabbitmqctl.1.man.html<\/p>\n<p>rabbitmq\u652f\u6301\u5206\u6b65\u5f0f\u90e8\u7f72\uff0c\u9ad8\u53ef\u7528\uff1ahttp:\/\/www.rabbitmq.com\/clustering.html\uff0c http:\/\/symphony.b3log.org\/article\/1380179992896<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u4e00\u7bc7\u8bb2\u4e86\u7528redis\u4f5cCelery\u7684broker\uff0c\u4f1a\u5bfc\u81f4\u6267\u884c\u957f\u5ef6\u8fdf\u7684ETA\u5b9a\u65f6\u4efb\u52a1\u65f6\uff0c\u8d85\u8fc7visibilit [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-5443","post","type-post","status-publish","format-standard","hentry","category-diary"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/5443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=5443"}],"version-history":[{"count":2,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/5443\/revisions"}],"predecessor-version":[{"id":5445,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/5443\/revisions\/5445"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=5443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=5443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=5443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}