{"id":205518,"date":"2020-11-28T10:42:03","date_gmt":"2020-11-28T02:42:03","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=205518"},"modified":"2020-11-16T10:42:47","modified_gmt":"2020-11-16T02:42:47","slug":"kubernetes-rabbitmq","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/kubernetes-rabbitmq.html","title":{"rendered":"\u5982\u4f55\u901a\u8fc7kubernetes-\u90e8\u7f72RabbitMQ"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nRabbitMQ\u662f\u5b9e\u73b0\u4e86\u9ad8\u7ea7\u6d88\u606f\u961f\u5217\u534f\u8bae\uff08AMQP\uff09\u7684\u5f00\u6e90\u6d88\u606f\u4ee3\u7406\u8f6f\u4ef6\uff08\u4ea6\u79f0\u9762\u5411\u6d88\u606f\u7684\u4e2d\u95f4\u4ef6\uff09\u3002RabbitMQ\u670d\u52a1\u5668\u662f\u7528Erlang\u8bed\u8a00\u7f16\u5199\u7684\uff0c\u800c\u96c6\u7fa4\u548c\u6545\u969c\u8f6c\u79fb\u662f\u6784\u5efa\u5728\u5f00\u653e\u7535\u4fe1\u5e73\u53f0\u6846\u67b6\u4e0a\u7684\u3002AMQP\uff1aAdvanced Message Queue\uff0c\u9ad8\u7ea7\u6d88\u606f\u961f\u5217\u534f\u8bae\u3002\u5b83\u662f\u5e94\u7528\u5c42\u534f\u8bae\u7684\u4e00\u4e2a\u5f00\u653e\u6807\u51c6\uff0c\u4e3a\u9762\u5411\u6d88\u606f\u7684\u4e2d\u95f4\u4ef6\u8bbe\u8ba1\uff0c\u57fa\u4e8e\u6b64\u534f\u8bae\u7684\u5ba2\u6237\u7aef\u4e0e\u6d88\u606f\u4e2d\u95f4\u4ef6\u53ef\u4f20\u9012\u6d88\u606f\uff0c\u5e76\u4e0d\u53d7\u4ea7\u54c1\u3001\u5f00\u53d1\u8bed\u8a00\u706f\u6761\u4ef6\u7684\u9650\u5236\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
AMQP\u5177\u6709\u5982\u4e0b\u7684\u7279\u6027<\/strong><\/span><\/div>\n

\u53ef\u9760\u6027(Reliablity)\uff1a\u4f7f\u7528\u4e86\u4e00\u4e9b\u673a\u5236\u6765\u4fdd\u8bc1\u53ef\u9760\u6027\uff0c\u6bd4\u5982\u6301\u4e45\u5316\u3001\u4f20\u8f93\u786e\u8ba4\u3001\u53d1\u5e03\u786e\u8ba4\u3002<\/p>\n

\u7075\u6d3b\u7684\u8def\u7531(Flexible Routing)\uff1a\u5728\u6d88\u606f\u8fdb\u5165\u961f\u5217\u4e4b\u524d\uff0c\u901a\u8fc7Exchange\u6765\u8def\u7531\u6d88\u606f\u3002\u5bf9\u4e8e\u5178\u578b\u7684\u8def\u7531\u529f\u80fd\uff0cRabbit\u5df2\u7ecf\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5185\u7f6e\u7684Exchange\u6765\u5b9e\u73b0\u3002\u9488\u5bf9\u66f4\u590d\u6742\u7684\u8def\u7531\u529f\u80fd\uff0c\u53ef\u4ee5\u5c06\u591a\u4e2aExchange\u7ed1\u5b9a\u5728\u4e00\u8d77\uff0c\u4e5f\u901a\u8fc7\u63d2\u4ef6\u673a\u5236\u5b9e\u73b0\u81ea\u5df1\u7684Exchange\u3002<\/p>\n

\u6d88\u606f\u96c6\u7fa4(Clustering)\uff1a\u591a\u4e2aRabbitMQ\u670d\u52a1\u5668\u53ef\u4ee5\u7ec4\u6210\u4e00\u4e2a\u96c6\u7fa4\uff0c\u5f62\u6210\u4e00\u4e2a\u903b\u8f91Broker\u3002<\/p>\n

\u9ad8\u53ef\u7528(Highly Avaliable Queues)\uff1a\u961f\u5217\u53ef\u4ee5\u5728\u96c6\u7fa4\u4e2d\u7684\u673a\u5668\u4e0a\u8fdb\u884c\u955c\u50cf\uff0c\u4f7f\u5f97\u5728\u90e8\u5206\u8282\u70b9\u51fa\u95ee\u9898\u7684\u60c5\u51b5\u4e0b\u961f\u5217\u4ecd\u7136\u53ef\u7528\u3002<\/p>\n

\u591a\u79cd\u534f\u8bae(Multi-protocol)\uff1a\u652f\u6301\u591a\u79cd\u6d88\u606f\u961f\u5217\u534f\u8bae\uff0c\u5982STOMP\u3001MQTT\u7b49\u3002<\/p>\n

\u591a\u79cd\u8bed\u8a00\u5ba2\u6237\u7aef(Many Clients)\uff1a\u51e0\u4e4e\u652f\u6301\u6240\u6709\u5e38\u7528\u8bed\u8a00\uff0c\u6bd4\u5982Java\u3001.NET\u3001Ruby\u7b49\u3002<\/p>\n

\u7ba1\u7406\u754c\u9762(Management UI)\uff1a\u63d0\u4f9b\u4e86\u6613\u7528\u7684\u7528\u6237\u754c\u9762\uff0c\u4f7f\u5f97\u7528\u6237\u53ef\u4ee5\u76d1\u63a7\u548c\u7ba1\u7406\u6d88\u606fBroker\u7684\u8bb8\u591a\u65b9\u9762\u3002<\/p>\n

\u8ddf\u8e2a\u673a\u5236(Tracing)\uff1a\u5982\u679c\u6d88\u606f\u5f02\u5e38\uff0cRabbitMQ\u63d0\u4f9b\u4e86\u6d88\u606f\u7684\u8ddf\u8e2a\u673a\u5236\uff0c\u4f7f\u7528\u8005\u53ef\u4ee5\u627e\u51fa\u53d1\u751f\u4e86\u4ec0\u4e48\u3002<\/p>\n

\u63d2\u4ef6\u673a\u5236(Plugin System)\uff1a\u63d0\u4f9b\u4e86\u8bb8\u591a\u63d2\u4ef6\uff0c\u6765\u4ece\u591a\u65b9\u9762\u8fdb\u884c\u6269\u5c55\uff0c\u4e5f\u53ef\u4ee5\u7f16\u8f91\u81ea\u5df1\u7684\u63d2\u4ef6\u3002<\/p>\n

RabbitMQ\u4e2d\u7684\u6d88\u606f\u90fd\u53ea\u80fd\u5b58\u50a8\u5728Queue\u4e2d\uff0c\u751f\u4ea7\u8005\uff08\u4e0b\u56fe\u4e2d\u7684P\uff09\u751f\u4ea7\u6d88\u606f\u5e76\u6700\u7ec8\u6295\u9012\u5230Queue\u4e2d\uff0c\u6d88\u8d39\u8005\uff08\u4e0b\u56fe\u4e2d\u7684C\uff09\u53ef\u4ee5\u4eceQueue\u4e2d\u83b7\u53d6\u6d88\u606f\u5e76\u6d88\u8d39\u3002<\/p>\n

\"\"<\/p>\n

RabbitMQ\u90e8\u7f72<\/strong><\/span><\/div>\n

\u4e0b\u9762\u662fRabbitMQ\u90e8\u7f72\u7684\u5b9a\u4e49\u4ee3\u7801\uff0c\u6b64\u4ee3\u7801\u7531\u4e24\u90e8\u5206\u7ec4\u6210\uff0c\u5373RabbitMQ\u90e8\u7f72\u7684\u90e8\u7f72\u4ee5\u53ca\u5176\u4ee3\u7406\u670d\u52a1\u3002\u955c\u50cf\u4f7f\u7528\u7684\u662fbitnami\/rabbitmq:latest\u3002\u901a\u8fc7NodePort\u6a21\u5f0f\u5bf9\u5916\u66b4\u9732\u4e8615672\u548c5672\u7aef\u53e3\uff0c\u5e76\u901a\u8fc7nfs\u6587\u4ef6\u7cfb\u7edf\u5bf9RabbitMQ\u7684\u6570\u636e\u8fdb\u884c\u6301\u4e45\u5316\u3002<\/p>\n

\r\n#-------------\u5b9a\u4e49RabbitMQ\u90e8\u7f72-----------------\r\napiVersion: apps\/v1beta2\r\nkind: Deployment\r\nmetadata:\r\n name: rabbit\r\nspec:\r\n replicas: 1\r\n selector:\r\n   matchLabels:\r\n     app: rabbit\r\n strategy:\r\n   rollingUpdate:\r\n     maxSurge: 25%\r\n     maxUnavailable: 25%\r\n   type: RollingUpdate\r\n template:\r\n   metadata:\r\n     labels:\r\n       app: rabbit\r\n   spec:\r\n     containers:\r\n     - image: bitnami\/rabbitmq:latest\r\n       imagePullPolicy: IfNotPresent\r\n       name: rabbit\r\n       ports:\r\n       - containerPort: 15672\r\n         name: rabbit15672\r\n         protocol: TCP\r\n       - containerPort: 5672 \r\n         name: rabbit5672 \r\n         protocol: TCP\r\n       resources: {}\r\n       volumeMounts:\r\n       - mountPath: \/bitnami\r\n         name: rabbit-persistent-storage\r\n      dnsPolicy: ClusterFirst\r\n      restartPolicy: Always\r\n      schedulerName: default-scheduler\r\n      securityContext: {}\r\n      terminationGracePeriodSeconds: 30\r\n      volumes:\r\n      - name: rabbit-persistent-storage\r\n        nfs:\r\n         path: \/home\/nfs-share\/rabbit\r\n         server: 10.0.33.201\r\n\r\n#-----------------\u5b9a\u4e49rabbit\u7684\u4ee3\u7406\u670d\u52a1--------------\r\napiVersion: v1\r\nkind: Service\r\nmetadata:\r\n name: rabbit-service\r\nspec:\r\n ports:\r\n - name: rabbit15672\r\n   nodePort: 31199\r\n   port: 15672\r\n   protocol: TCP\r\n   targetPort: 15672\r\n - name: rabbit15672 \r\n   nodePort: 305672 \r\n   port: 5672 \r\n   protocol: TCP \r\n   targetPort: 5672\r\n selector:\r\n   app: rabbit\r\n type: NodePort\r\n<\/pre>\n

\u901a\u8fc7kubectl\uff0c\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u5728Kubernetes\u96c6\u7fa4\u4e2d\u90e8\u7f72Oracle\u6570\u636e\u5e93\u3002<\/p>\n

\r\n$ kubectl create -f rabbitmq.yaml --namespace=kube-public\r\n<\/pre>\n

\u5728\u90e8\u7f72\u5b8c\u6210\u540e\uff0c\u901a\u8fc7\u4e0b\u9762\u7684\u547d\u4ee4\u53ef\u4ee5\u67e5\u770bRabbitMQ\u66b4\u9732\u7684\u7aef\u53e3\uff1a<\/p>\n

\r\n$ kubectl get svc --namespace=kube-public\r\n<\/pre>\n
\u90e8\u7f72\u9a8c\u8bc1<\/strong><\/span><\/div>\n

\u5728\u6d4f\u89c8\u5668\u4e2d\u8f93\u5165\uff1ahttp:\/\/10.0.33.203:31199\/\uff0c\u8bbf\u95ee\u90e8\u7f72\u597d\u7684RabbitMQ\u3002\u5728\u767b\u5f55\u9875\u9762\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\uff08\u6b64\u5904\u521d\u59cbuser\/bitnami\uff09\uff0c\u7cfb\u7edf\u5c06\u4f1a\u8fdb\u5165RabbitMQ\u7684\u4e3b\u9875\u3002<\/p>\n

\"\"<\/p>\n

\u8fd0\u884c\u73af\u5883\u914d\u7f6e<\/strong><\/span><\/div>\n

\u5728\u90e8\u7f72\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u4e0b\u9762\u7684\u73af\u5883\u53d8\u91cf\u6765\u6539\u53d8\u5bb9\u5668\u7684\u8fd0\u884c\u65f6\uff1a<\/p>\n

RABBITMQ_USERNAME: \u7528\u6237\u540d\uff0c\u9ed8\u8ba4\u503c\u4e3auser<\/p>\n

RABBITMQ_PASSWORD: \u5bc6\u7801\uff0c\u9ed8\u8ba4\u503c\u4e3abitnami<\/p>\n

RABBITMQ_HASHED_PASSWORD: \u54c8\u5e0c\u5bc6\u7801<\/p>\n

RABBITMQ_VHOST: \u5b89\u88c5\u540e\u542f\u52a8\u521b\u5efa\u7684\u865a\u62df\u4e3b\u673a\uff0c\u9ed8\u8ba4\u503c\u4e3a \/<\/p>\n

RABBITMQ_ERL_COOKIE: Erlang cookie\u7528\u4e8e\u786e\u5b9a\u4e0d\u540c\u7684\u8282\u70b9\u4e4b\u95f4\u662f\u5426\u5141\u8bb8\u884c\u4e92\u76f8\u901a\u4fe1\u3002<\/p>\n

RABBITMQ_NODE_TYPE: \u8282\u70b9\u7c7b\u578b\uff0c\u6709\u9650\u5236: stats, queue-ram or queue-disc\u3002 \u9ed8\u8ba4\u503c\u4e3astats<\/p>\n

RABBITMQ_NODE_NAME: \u8282\u70b9\u540d\u79f0\u548c\u4e3b\u673a\uff0c\u4f8b\u5982: node@hostname\u6216node \u3002\u9ed8\u8ba4\u503c\u4e3arabbit@localhost\u3002<\/p>\n

RABBITMQ_NODE_PORT_NUMBER: \u8282\u70b9\u7aef\u53e3\uff0c\u9ed8\u8ba4\u503c\u4e3a5672<\/p>\n

RABBITMQ_CLUSTER_NODE_NAME: \u96c6\u7fa4\u540d\u79f0\uff0c\u4f8b\u5982\uff1aclusternode@hostname<\/p>\n

RABBITMQ_CLUSTER_PARTITION_HANDLING: \u96c6\u7fa4\u5206\u533a\u6062\u590d\u673a\u5236\uff0c\u9ed8\u8ba4\u503c\u4e3a: ignore<\/p>\n

RABBITMQ_MANAGER_PORT_NUMBER: \u7ba1\u7406\u7aef\u53e3\uff0c\u9ed8\u8ba4\u503c\u4e3a15672<\/p>\n

RABBITMQ_DISK_FREE_LIMIT: Rabbitmq\u5b58\u50a8\u6570\u636e\u7684\u53ef\u7528\u7a7a\u95f4\u9650\u5236\uff0c\u5f53\u4f4e\u4e8e\u8be5\u503c\u7684\u65f6\u5019\uff0c\u5c06\u89e6\u53d1\u6d41\u91cf\u9650\u5236\u3002\u9ed8\u8ba4\u503c\u4e3a {mem_relative, 1.0}<\/p>\n

RABBITMQ_ULIMIT_NOFILES: \u8d44\u6e90\u9650\u5236\uff0c \u6253\u5f00\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u6700\u5927\u6570\u76ee\uff0c\u9ed8\u8ba4\u503c\u4e3a65536<\/p>\n","protected":false},"excerpt":{"rendered":"

\u53ef\u9760\u6027(Reliablity)\uff1a\u4f7f\u7528\u4e86\u4e00\u4e9b\u673a\u5236\u6765\u4fdd\u8bc1\u53ef\u9760\u6027\uff0c\u6bd4\u5982\u6301\u4e45\u5316\u3001\u4f20\u8f93\u786e\u8ba4\u3001\u53d1\u5e03\u786e\u8ba4\u3002 \u7075\u6d3b\u7684\u8def\u7531(Fl […]<\/p>\n","protected":false},"author":1479,"featured_media":82476,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-205518","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/205518","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1479"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=205518"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/205518\/revisions"}],"predecessor-version":[{"id":207329,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/205518\/revisions\/207329"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/82476"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=205518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=205518"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=205518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}