求一份在kubernetes环境里面部署rockermq的文档?

部署RocketMQ在Kubernetes环境中需要以下步骤:

求一份在kubernetes环境里面部署rockermq的文档?
(图片来源网络,侵删)

1、创建命名空间

2、创建持久化存储

3、部署NameServer

4、部署Broker

以下是详细的操作步骤:

1. 创建命名空间

apiVersion: v1
kind: Namespace
metadata:
  name: rocketmq

将以上内容保存为namespace.yaml,然后运行kubectl apply f namespace.yaml

2. 创建持久化存储

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: rocketmqpvc
  namespace: rocketmq
spec:
  accessModes:
    ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  storageClassName: manual

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: rocketmqnamesrvpvc
  namespace: rocketmq
spec:
  accessModes:
    ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  storageClassName: manual

将以上内容保存为pvc.yaml,然后运行kubectl apply f pvc.yaml

3. 部署NameServer

apiVersion: apps/v1
kind: Deployment
metadata:
  name: rocketmqnamesrv
  namespace: rocketmq
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rocketmqnamesrv
  template:
    metadata:
      labels:
        app: rocketmqnamesrv
    spec:
      containers:
      name: rocketmqnamesrv
        image: apacherocketmq/rocketmq:4.7.1
        command: ["sh", "mqnamesrv"]
        env:
        name: ROCKETMQ_NAMESRV_ADDR
          value: "localhost:9876"
        ports:
        containerPort: 9876
        volumeMounts:
        name: rocketmqnamesrvdata
          mountPath: /opt/rocketmq4.7.1/store/commitlog
          subPath: commitlog
        name: rocketmqnamesrvdata
          mountPath: /opt/rocketmq4.7.1/store/consumequeue
          subPath: consumequeue
      volumes:
      name: rocketmqnamesrvdata
        persistentVolumeClaim:
          claimName: rocketmqnamesrvpvc

将以上内容保存为namesrv.yaml,然后运行kubectl apply f namesrv.yaml

4. 部署Broker

apiVersion: apps/v1
kind: Deployment
metadata:
  name: rocketmqbroker
  namespace: rocketmq
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rocketmqbroker
  template:
    metadata:
      labels:
        app: rocketmqbroker
    spec:
      containers:
      name: rocketmqbroker
        image: apacherocketmq/rocketmq:4.7.1
        command: ["sh", "mqbroker", "n", "localhost:9876", "c", "/opt/rocketmq4.7.1/conf/2mnoslave/brokera.properties"]
        env:
        name: ROCKETMQ_BROKER_NAMESRV_ADDR
          value: "localhost:9876"
        ports:
        containerPort: 10911
        containerPort: 10909
        volumeMounts:
        name: rocketmqbrokerdata
          mountPath: /opt/rocketmq4.7.1/store/commitlog
          subPath: commitlog
        name: rocketmqbrokerdata
          mountPath: /opt/rocketmq4.7.1/store/consumequeue
          subPath: consumequeue
      volumes:
      name: rocketmqbrokerdata
        persistentVolumeClaim:
          claimName: rocketmqpvc

将以上内容保存为broker.yaml,然后运行kubectl apply f broker.yaml

至此,RocketMQ已经在Kubernetes环境中部署完成。

原创文章,作者:未希,如若转载,请注明出处:https://www.kdun.com/ask/533902.html

本网站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本网站。如有问题,请联系客服处理。

(0)
未希新媒体运营
上一篇 2024-04-29 01:06
下一篇 2024-04-29 01:08

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

产品购买 QQ咨询 微信咨询 SEO优化
分享本页
返回顶部
云产品限时秒杀。精选云产品高防服务器,20M大带宽限量抢购 >>点击进入