KUBERNETES DEPLOYMENT快速部署ROCKETMQ 4.9.2 DLEDGER集群 1-镜像
KUBERNETES DEPLOYMENT快速部署ROCKETMQ 4.9.2 DLEDGER集群 2-NAMESERVER
KUBERNETES DEPLOYMENT快速部署ROCKETMQ 4.9.2 DLEDGER集群 3-BROKER
KUBERNETES DEPLOYMENT快速部署ROCKETMQ 4.9.2 DLEDGER集群 4-DASHBOARD

启动三个独立的broker

ConfigMap broker-01-config

apiVersion: v1
data:
  broker-01.conf: >
    brokerClusterName = RaftCluster

    brokerName=broker-01

    listenPort=30911

    storePathRootDir=/tmp/rmqstore/node00

    storePathCommitLog=/tmp/rmqstore/node00/commitlog

    enableDLegerCommitLog=true

    dLegerGroup=RaftNode00

    dLegerPeers=n1-broker-01.rocketmq.svc.cluster.local:40911;n2-broker-02.rocketmq.svc.cluster.local:40911;n3-broker-03.rocketmq.svc.cluster.local:40911

    ## must be unique

    dLegerSelfId=n1

    sendMessageThreadPoolNums=16
kind: ConfigMap
metadata:
  name: broker-01-config
  namespace: rocketmq

ConfigMap broker-02-config

apiVersion: v1
data:
  broker-02.conf: >
    brokerClusterName = RaftCluster

    brokerName=broker-02

    listenPort=30911

    storePathRootDir=/tmp/rmqstore/node00

    storePathCommitLog=/tmp/rmqstore/node00/commitlog

    enableDLegerCommitLog=true

    dLegerGroup=RaftNode00

    dLegerPeers=n1-broker-01.rocketmq.svc.cluster.local:40911;n2-broker-02.rocketmq.svc.cluster.local:40911;n3-broker-03.rocketmq.svc.cluster.local:40911

    ## must be unique

    dLegerSelfId=n2

    sendMessageThreadPoolNums=16
kind: ConfigMap
metadata:
  name: broker-02-config
  namespace: rocketmq


ConfigMap broker-03-config

apiVersion: v1
data:
  broker-03.conf: >
    brokerClusterName = RaftCluster

    brokerName=broker-03

    listenPort=30911

    storePathRootDir=/tmp/rmqstore/node00

    storePathCommitLog=/tmp/rmqstore/node00/commitlog

    enableDLegerCommitLog=true

    dLegerGroup=RaftNode00

    dLegerPeers=n1-broker-01.rocketmq.svc.cluster.local:40911;n2-broker-02.rocketmq.svc.cluster.local:40911;n3-broker-03.rocketmq.svc.cluster.local:40911

    ## must be unique

    dLegerSelfId=n3

    sendMessageThreadPoolNums=16
kind: ConfigMap
metadata:
  name: broker-03-config
  namespace: rocketmq

三个落盘pvc

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  annotations:
  name: store-broker-01
  namespace: rocketmq
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1000Gi
  storageClassName: nas
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  annotations:
  name: store-broker-02
  namespace: rocketmq
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1000Gi
  storageClassName: nas
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  annotations:
  name: store-broker-02
  namespace: rocketmq
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1000Gi
  storageClassName: nas

Deployment broker-01

生产环境建议把/home/rocketmq/logs也挂pvc

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    mq: broker-01
    mq: broker
  name: broker-01
  namespace: rocketmq
spec:
  replicas: 1
  selector:
    matchLabels:
      mq: broker-01
  template:
    metadata:
      labels:
        mq: broker-01
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchLabels:
                    mq: broker
                topologyKey: kubernetes.io/hostname
              weight: 100
      containers:
        - command:
            - sh
            - mqbroker
            - '-c'
            - /opt/conf/broker-01.conf
          env:
            - name: TZ
              value: Asia/Shanghai
            - name: NAMESRV_ADDR
              value: >-
                nameserver-01.rocketmq.svc.cluster.local:9876;nameserver-02.rocketmq.svc.cluster.local:9876
          image: 'test/rocketmq:4.9.2'
          imagePullPolicy: IfNotPresent
          name: broker-01
          ports:
            - containerPort: 30911
              name: broker
              protocol: TCP
            - containerPort: 30909
              name: test
              protocol: TCP
            - containerPort: 40911
              name: raft
              protocol: TCP
          volumeMounts:
            - mountPath: /opt/conf
              name: broker-01-config
            - mountPath: /home/rocketmq/store
              name: store
      volumes:
        - configMap:
            defaultMode: 420
            name: broker-01-config
          name: broker-01-config
        - name: store
          persistentVolumeClaim:
            claimName: store-broker-01

---
apiVersion: v1
kind: Service
metadata:
  labels:
    mq: broker-01
    mq: broker
  name: broker-01
  namespace: rocketmq
spec:
  ports:
    - name: broker
      port: 3911
      protocol: TCP
      targetPort: 30911
    - name: test
      port: 30909
      protocol: TCP
      targetPort: 30909
    - name: raft
      port: 40911
      protocol: TCP
      targetPort: 40911
  selector:
    mq: broker-01
  type: ClusterIP

Deployment broker-02

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    mq: broker-02
    mq: broker
  name: broker-02
  namespace: rocketmq
spec:
  replicas: 1
  selector:
    matchLabels:
      mq: broker-02
  template:
    metadata:
      labels:
        mq: broker-02
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchLabels:
                    mq: broker
                topologyKey: kubernetes.io/hostname
              weight: 100
      containers:
        - command:
            - sh
            - mqbroker
            - '-c'
            - /opt/conf/broker-02.conf
          env:
            - name: TZ
              value: Asia/Shanghai
            - name: NAMESRV_ADDR
              value: >-
                nameserver-01.rocketmq.svc.cluster.local:9876;nameserver-02.rocketmq.svc.cluster.local:9876
          image: 'test/rocketmq:4.9.2'
          imagePullPolicy: IfNotPresent
          name: broker-01
          ports:
            - containerPort: 30911
              name: broker
              protocol: TCP
            - containerPort: 30909
              name: test
              protocol: TCP
            - containerPort: 40911
              name: raft
              protocol: TCP
          volumeMounts:
            - mountPath: /opt/conf
              name: broker-01-config
            - mountPath: /home/rocketmq/store
              name: store
      volumes:
        - configMap:
            defaultMode: 420
            name: broker-02-config
          name: broker-02-config
        - name: store
          persistentVolumeClaim:
            claimName: store-broker-02

---
apiVersion: v1
kind: Service
metadata:
  labels:
    mq: broker-02
    mq: broker
  name: broker-02
  namespace: rocketmq
spec:
  ports:
    - name: broker
      port: 3911
      protocol: TCP
      targetPort: 30911
    - name: test
      port: 30909
      protocol: TCP
      targetPort: 30909
    - name: raft
      port: 40911
      protocol: TCP
      targetPort: 40911
  selector:
    mq: broker-02
  type: ClusterIP

Deployment broker-03

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    mq: broker-03
    mq: broker
  name: broker-03
  namespace: rocketmq
spec:
  replicas: 1
  selector:
    matchLabels:
      mq: broker-03
  template:
    metadata:
      labels:
        mq: broker-03
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchLabels:
                    mq: broker
                topologyKey: kubernetes.io/hostname
              weight: 100
      containers:
        - command:
            - sh
            - mqbroker
            - '-c'
            - /opt/conf/broker-03.conf
          env:
            - name: TZ
              value: Asia/Shanghai
            - name: NAMESRV_ADDR
              value: >-
                nameserver-01.rocketmq.svc.cluster.local:9876;nameserver-02.rocketmq.svc.cluster.local:9876
          image: 'test/rocketmq:4.9.2'
          imagePullPolicy: IfNotPresent
          name: broker-03
          ports:
            - containerPort: 30911
              name: broker
              protocol: TCP
            - containerPort: 30909
              name: test
              protocol: TCP
            - containerPort: 40911
              name: raft
              protocol: TCP
          volumeMounts:
            - mountPath: /opt/conf
              name: broker-01-config
            - mountPath: /home/rocketmq/store
              name: store
      volumes:
        - configMap:
            defaultMode: 420
            name: broker-03-config
          name: broker-03-config
        - name: store
          persistentVolumeClaim:
            claimName: store-broker-03

---
apiVersion: v1
kind: Service
metadata:
  labels:
    mq: broker-03
    mq: broker
  name: broker-03
  namespace: rocketmq
spec:
  ports:
    - name: broker
      port: 3911
      protocol: TCP
      targetPort: 30911
    - name: test
      port: 30909
      protocol: TCP
      targetPort: 30909
    - name: raft
      port: 40911
      protocol: TCP
      targetPort: 40911
  selector:
    mq: broker-03
  type: ClusterIP

发表评论

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

Captcha Code