k8s部署中间件-rocketmq

1,345次阅读
没有评论

共计 3867 个字符,预计需要花费 10 分钟才能阅读完成。

k8s部署中间件-rocketmq

单namesrv/broker模式

nameserver部署文件

[root@k8s-master rocketmq]# cat >mqnamesrv.yaml<-'EOF'
apiVersion: v1
kind: Service
metadata:
  name: mqnamesrv
spec:
  ports:
  - port: 9876
    protocol: TCP
    targetPort: 9876
  selector:
    app: mqnamesrv
  type: NodePort
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mqnamesrv
spec:
  serviceName: mqnamesrv
  replicas: 1
  selector:
    matchLabels:
      app: mqnamesrv
  template:
    metadata:
      labels:
        app: mqnamesrv
    spec:
      containers:
      - name: mqnamesrv
        image: apache/rocketmq:latest
        command: ["sh","mqnamesrv"]
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9876
          protocol: TCP
EOF

broker部署文件

[root@k8s-master rocketmq]# cat >mqbroker.yaml<<'EOF'
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mqbroker
spec:
  serviceName: mqbroker
  replicas: 1
  selector:
    matchLabels:
      app: mqbroker
  template:
    metadata:
      labels:
        app: mqbroker
    spec:
      containers:
      - name: mqbroker
        image: apache/rocketmq:latest
        command: ["sh","mqbroker", "-n","mqnamesrv:9876"]
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 10911
        volumeMounts:
        - mountPath: /home/rocketmq/store
          subPath: store
          name: rocketmq-broker-storage
        - mountPath: /home/rocketmq/logs
          subPath: logs
          name: rocketmq-broker-storage
  volumeClaimTemplates:
  - metadata:
      name: rocketmq-broker-storage
    spec:
      accessModes:
      - ReadWriteMany
      storageClassName: "nfs-storage"
      resources:
        requests:
          storage: 2Gi
EOF

web ui部署文件

[root@k8s-master rocketmq]# cat >mqui.yaml<<-'EOF'
---
apiVersion: v1
kind: Service
metadata:
  #  namespace: default
  name: mqui
  labels:
    app: mqui
spec:
  type: NodePort
  ports:
    - port: 8080
      targetPort: 8080
  selector:
    app: mqui
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mqui
  labels:
    app: mqui
#  namespace: default
spec:
  serviceName: mqui
  replicas: 1
  selector:
    matchLabels:
      app: mqui
  template:
    metadata:
      labels:
        app: mqui
    spec:
      containers:
        - name: mqui
          image: styletang/rocketmq-console-ng
          imagePullPolicy: Always
          resources:
            limits:
              cpu: 450m
              memory: 1768Mi
            requests:
              cpu: 100m
              memory: 768Mi
          env:
            - name: TZ
              value: Asia/Shanghai
            - name: JAVA_OPTS
              value: -Drocketmq.namesrv.addr=mqnamesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false -Duser.home=/root  -Xms768m -Xmx768m
          ports:
            - containerPort: 8080
EOF

测试验证

# 查看集群状态
[root@k8s-master rocketmq]# kubectl exec -it mqbroker-0 -- /bin/bash
[rocketmq@mqbroker-0 bin]$ sh mqadmin clusterList -n mqnamesrv:9876
#Cluster Name     #Broker Name            #BID  #Addr                  #Version                #InTPS(LOAD)       #OutTPS(LOAD) #PCWait(ms) #Hour #SPACE
DefaultCluster    mqbroker-0.mqbroker.default.svc.cluster.local  0     10.100.235.220:10911   V4_9_4                   0.00(0,0ms)         0.00(0,0ms)          0 462063.30 0.1800

# 查看broker状态
[rocketmq@mqbroker-0 bin]$ sh mqadmin brokerStatus -n mqnamesrv:9876 -b mqbroker-0:10911
EndTransactionQueueSize         : 0
EndTransactionThreadPoolQueueCapacity: 100000
bootTimestamp                   : 1663427840396
brokerVersion                   : 401
brokerVersionDesc               : V4_9_4
commitLogDirCapacity            : Total : 47.8 GiB, Free : 39.6 GiB.
commitLogDiskRatio              : 0.18
commitLogDiskRatio_/home/rocketmq/store/commitlog: 0.18
commitLogMaxOffset              : 0
commitLogMinOffset              : -1
consumeQueueDiskRatio           : 0.18
dispatchBehindBytes             : 0
dispatchMaxBuffer               : 0
earliestMessageTimeStamp        : -1
getFoundTps                     : 0.0 0.0
getMessageEntireTimeMax         : 0
getMissTps                      : 0.0 0.03331223558413005
getTotalTps                     : 0.0 0.03331223558413005 0.0
getTransferedTps                : 0.0 0.0
msgGetTotalTodayMorning         : 0
msgGetTotalTodayNow             : 0
msgGetTotalYesterdayMorning     : 0
msgPutTotalTodayMorning         : 0
msgPutTotalTodayNow             : 0
msgPutTotalYesterdayMorning     : 0
pageCacheLockTimeMills          : 0
pullThreadPoolQueueCapacity     : 100000
pullThreadPoolQueueHeadWaitTimeMills: 0
pullThreadPoolQueueSize         : 0
putLatency99                    : 0.00
putLatency999                   : 0.00
putMessageAverageSize           : 0.0
putMessageDistributeTime        : [<=0ms]:0 [0~10ms]:0 [10~50ms]:0 [50~100ms]:0 [100~200ms]:0 [200~500ms]:0 [500ms~1s]:0 [1~2s]:0 [2~3s]:0 [3~4s]:0 [4~5s]:0 [5~10s]:0 [10s~]:0
putMessageEntireTimeMax         : 0
putMessageFailedTimes           : 0
putMessageSizeTotal             : 0
putMessageTimesTotal            : 1
putTps                          : 0.0 0.0
queryThreadPoolQueueCapacity    : 20000
queryThreadPoolQueueHeadWaitTimeMills: 0
queryThreadPoolQueueSize        : 0
remainHowManyDataToFlush        : 0 B
remainTransientStoreBufferNumbs : 2147483647
runtime                         : [ 0 days, 0 hours, 3 minutes, 22 seconds ]
sendThreadPoolQueueCapacity     : 10000
sendThreadPoolQueueHeadWaitTimeMills: 0
sendThreadPoolQueueSize         : 0
startAcceptSendRequestTimeStamp : 0

双主模式

双主双从+同步模式

双主双从+异步模式

正文完
 1
xadocker
版权声明:本站原创文章,由 xadocker 2020-10-03发表,共计3867字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)