{"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":"
\u5bfc\u8bfb<\/td>\n | RabbitMQ\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 |