rocketmq在Kubernetes(k8s)中的集群配置,2m-2s-async:多Master多Slave模式,异步复制
目标 rocketmq 集群
2m-2s-async:多Master多Slave模式,异步复制
宿主机IP: 192.168.0.254
fox.风
源码 地址 https://github.com/foxiswho/k8s-nacos-sentinel-rocketmq-zipkin-elasticsearch-redis-mysql
配置目录
mkdir -p /www/k8s/foxdev/rocketmq/logs-1/
mkdir -p /www/k8s/foxdev/rocketmq/store-1/commitlog
mkdir -p /www/k8s/foxdev/rocketmq/logs-1a/
mkdir -p /www/k8s/foxdev/rocketmq/store-1a/commitlog
mkdir -p /www/k8s/foxdev/rocketmq/logs-1as/
mkdir -p /www/k8s/foxdev/rocketmq/store-1as/commitlog
mkdir -p /www/k8s/foxdev/rocketmq/logs-1as2/
mkdir -p /www/k8s/foxdev/rocketmq/store-1as2/commitlogmkdir -p /www/k8s/foxdev/rocketmq/logs-2/
mkdir -p /www/k8s/foxdev/rocketmq/store-2/commitlog
mkdir -p /www/k8s/foxdev/rocketmq/logs-2b/
mkdir -p /www/k8s/foxdev/rocketmq/store-2b/commitlog
mkdir -p /www/k8s/foxdev/rocketmq/logs-2bs/
mkdir -p /www/k8s/foxdev/rocketmq/store-2bs/commitlog
mkdir -p /www/k8s/foxdev/rocketmq/logs-2bs2/
mkdir -p /www/k8s/foxdev/rocketmq/store-2bs2/commitlogchmod -R 777 /www/k8s/foxdev/rocketmq/*
logs
开头目录为 日志目录
store
开头目录为 数据目录
-1
表示 rocketmq nameserver
-1a
表示 rocketmq broker
-1as
表示 rocketmq broker slave
logs-ui
为 rocketmq web ui 管理 日志目录
其他以此类推
相关说明
nodePort
后面表示 外部端口
port
后面表示 内部端口
集群1端口如下
spec:type: NodePortports:- port: 9876targetPort: 9876nodePort: 30876name: rmqser- port: 30911targetPort: 30911nodePort: 30911name: rmqbroker- port: 30921targetPort: 30921nodePort: 30921name: rmqbrokerslave- port: 30931targetPort: 30931nodePort: 30931name: rmqbrokerslave2
集群2端口如下
spec:type: NodePortports:- port: 9876targetPort: 9876nodePort: 30877name: rmqser2- port: 30961targetPort: 30961nodePort: 30961name: rmqbroker2- port: 30971targetPort: 30971nodePort: 30971name: rmqbrokerslave2- port: 30981targetPort: 30981nodePort: 30981name: rmqbrokerslave22
web ui 端口 和 管理员与密码
端口 30879
,管理员账户和密码如下
admin
admin
账户和密码 在 配置文件在 rocketmq/conf/users.properties
文件中修改,
# This file supports hot change, any change will be auto-reloaded without Console restarting.
# Format: a user per line, username=password[,N] #N is optional, 0 (Normal User); 1 (Admin)# Define Admin
admin=admin,1
第一个admin
表示 用户名
第二个admin
表示 密码
1
表示 管理员 角色
集群1配置
broker 配置 broker-a.conf
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.#所属集群名字
brokerClusterName=DefaultCluster#broker名字,注意此处不同的配置文件填写的不一样,如果在broker-a.properties使用:broker-a,
#在broker-b.properties使用:broker-b
brokerName=broker-a#0 表示Master,>0 表示Slave
brokerId=0#nameServer地址,分号分割
#namesrvAddr=rocketmq-0:9876;rocketmq-1:9876
namesrvAddr=rocketmq-0.rocketmq.default.svc.cluster.local:9876;rocketmq2-0.rocketmq2.default.svc.cluster.local:9876#启动IP,如果 docker 报 com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <192.168.0.120:10909> failed
# 解决方式1 加上一句producer.setVipChannelEnabled(false);,解决方式2 brokerIP1 设置宿主机IP,不要使用docker 内部IP
brokerIP1=192.168.0.254#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭 !!!这里仔细看是false,false,false
#原因下篇博客见~ 哈哈哈哈
autoCreateTopicEnable=true#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true#Broker 对外服务的监听端口
listenPort=30911
#haService中使用 默认值为:listenPort + 1
#haListenPort=30912
#主要用于slave同步master listenPort - 2
#fastListenPort=30909#删除文件时间点,默认凌晨4点
deleteWhen=04#文件保留时间,默认48小时
fileReservedTime=120#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/home/rocketmq/store
#commitLog 存储路径
#storePathCommitLog=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/commitlog
#消费队列存储
#storePathConsumeQueue=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/consumequeue
#消息索引存储路径
#storePathIndex=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/index
#checkpoint 文件存储路径
#storeCheckpoint=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/checkpoint
#abort 文件存储路径
#abortFile=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/abort
#限制的消息大小
maxMessageSize=65536#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=ASYNC_MASTER#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH#发消息线程池数量
#sendMessageThreadPoolNums=128
#拉消息线程池数量
#pullMessageThreadPoolNums=128
broker-slave 配置 broker-a-s.conf
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.#所属集群名字
brokerClusterName=DefaultCluster#broker名字,注意此处不同的配置文件填写的不一样,如果在broker-a.properties使用:broker-a,
#在broker-b.properties使用:broker-b
brokerName=broker-a#0 表示Master,>0 表示Slave
brokerId=1#nameServer地址,分号分割
#namesrvAddr=rocketmq-0:9876;rocketmq-1:9876
namesrvAddr=rocketmq-0.rocketmq.default.svc.cluster.local:9876;rocketmq2-0.rocketmq2.default.svc.cluster.local:9876#启动IP,如果 docker 报 com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <192.168.0.120:10909> failed
# 解决方式1 加上一句producer.setVipChannelEnabled(false);,解决方式2 brokerIP1 设置宿主机IP,不要使用docker 内部IP
brokerIP1=192.168.0.254#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=SLAVE#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭 !!!这里仔细看是false,false,false
#原因下篇博客见~ 哈哈哈哈
autoCreateTopicEnable=true#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true#Broker 对外服务的监听端口
listenPort=30921
#haService中使用 默认值为:listenPort + 1
#haListenPort=31912
#主要用于slave同步master listenPort - 2
#fastListenPort=31909#删除文件时间点,默认凌晨4点
deleteWhen=04#文件保留时间,默认48小时
fileReservedTime=120#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/home/rocketmq/store
#commitLog 存储路径
#storePathCommitLog=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/commitlog
#消费队列存储
#storePathConsumeQueue=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/consumequeue
#消息索引存储路径
#storePathIndex=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/index
#checkpoint 文件存储路径
#storeCheckpoint=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/checkpoint
#abort 文件存储路径
#abortFile=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/abort
#限制的消息大小
maxMessageSize=65536#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH#发消息线程池数量
#sendMessageThreadPoolNums=128
#拉消息线程池数量
#pullMessageThreadPoolNums=128
broker-slave 配置 broker-a-s2.conf
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.#所属集群名字
brokerClusterName=DefaultCluster#broker名字,注意此处不同的配置文件填写的不一样,如果在broker-a.properties使用:broker-a,
#在broker-b.properties使用:broker-b
brokerName=broker-a#0 表示Master,>0 表示Slave
brokerId=2#nameServer地址,分号分割
#namesrvAddr=rocketmq-0:9876;rocketmq-1:9876
namesrvAddr=rocketmq-0.rocketmq.default.svc.cluster.local:9876;rocketmq2-0.rocketmq2.default.svc.cluster.local:9876#启动IP,如果 docker 报 com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <192.168.0.120:10909> failed
# 解决方式1 加上一句producer.setVipChannelEnabled(false);,解决方式2 brokerIP1 设置宿主机IP,不要使用docker 内部IP
brokerIP1=192.168.0.254#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=SLAVE#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭 !!!这里仔细看是false,false,false
#原因下篇博客见~ 哈哈哈哈
autoCreateTopicEnable=true#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true#Broker 对外服务的监听端口
listenPort=30931
#haService中使用 默认值为:listenPort + 1
#haListenPort=31912
#主要用于slave同步master listenPort - 2
#fastListenPort=31909#删除文件时间点,默认凌晨4点
deleteWhen=04#文件保留时间,默认48小时
fileReservedTime=120#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/home/rocketmq/store
#commitLog 存储路径
#storePathCommitLog=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/commitlog
#消费队列存储
#storePathConsumeQueue=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/consumequeue
#消息索引存储路径
#storePathIndex=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/index
#checkpoint 文件存储路径
#storeCheckpoint=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/checkpoint
#abort 文件存储路径
#abortFile=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/abort
#限制的消息大小
maxMessageSize=65536#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH#发消息线程池数量
#sendMessageThreadPoolNums=128
#拉消息线程池数量
#pullMessageThreadPoolNums=128
k8s pod
rocketmq1-pod.yml
apiVersion: apps/v1
kind: StatefulSet
metadata:name: rocketmqlabels:app: rocketmqspec:serviceName: rocketmqreplicas: 1selector:matchLabels:app: rocketmqtemplate:metadata:labels:app: rocketmqspec:containers:- name: rocketmqimage: foxiswho/rocketmq:4.8.0imagePullPolicy: IfNotPresentresources:limits:cpu: 450mmemory: 2000Mirequests:cpu: 400mmemory: 2000Mienv:- name: TZvalue: Asia/Shanghai- name: JAVA_OPTvalue: -Duser.home=/home/rocketmq- name: JAVA_OPT_EXTvalue: -Xmn256mcommand: ["sh","-c","mqnamesrv"]ports:- containerPort: 9876volumeMounts:- name: vol-logsmountPath: /home/rocketmq/logs- name: vol-storemountPath: /home/rocketmq/store- name: rmqbrokerimage: foxiswho/rocketmq:4.8.0imagePullPolicy: IfNotPresentresources:limits:cpu: 440mmemory: 2000Mirequests:cpu: 400mmemory: 2000Mienv:- name: TZvalue: Asia/Shanghai- name: JAVA_OPT_EXTvalue: -Duser.home=/home/rocketmq -Xms1024M -Xmx1024M -Xmn256mcommand: [ "sh","-c","mqbroker -c /etc/rocketmq/broker-a.conf" ]ports:- containerPort: 30909- containerPort: 30911- containerPort: 30912volumeMounts:- name: vol-logs-amountPath: /home/rocketmq/logs- name: vol-store-amountPath: /home/rocketmq/store- name: vol-confmountPath: /etc/rocketmq/- name: rmqbroker-slaveimage: foxiswho/rocketmq:4.8.0imagePullPolicy: IfNotPresentresources:limits:cpu: 450mmemory: 2000Mirequests:cpu: 400mmemory: 2000Mienv:- name: TZvalue: Asia/Shanghai- name: JAVA_OPT_EXTvalue: -Duser.home=/home/rocketmq -Xms1024M -Xmx1024M -Xmn256mcommand: [ "sh","-c","mqbroker -c /etc/rocketmq/broker-a-s.conf" ]ports:- containerPort: 30919- containerPort: 30921- containerPort: 30922volumeMounts:- name: vol-logs-asmountPath: /home/rocketmq/logs- name: vol-store-asmountPath: /home/rocketmq/store- name: vol-confmountPath: /etc/rocketmq/- name: rmqbroker-slave2image: foxiswho/rocketmq:4.8.0imagePullPolicy: IfNotPresentresources:limits:cpu: 450mmemory: 2000Mirequests:cpu: 400mmemory: 2000Mienv:- name: TZvalue: Asia/Shanghai- name: JAVA_OPT_EXTvalue: -Duser.home=/home/rocketmq -Xms1024M -Xmx1024M -Xmn256mcommand: [ "sh","-c","mqbroker -c /etc/rocketmq/broker-a-s2.conf" ]ports:- containerPort: 30929- containerPort: 30931- containerPort: 30932volumeMounts:- name: vol-logs-as2mountPath: /home/rocketmq/logs- name: vol-store-as2mountPath: /home/rocketmq/store- name: vol-confmountPath: /etc/rocketmq/volumes:- name: vol-logshostPath:path: /www/k8s/foxdev/rocketmq/logs-1type: Directory- name: vol-storehostPath:path: /www/k8s/foxdev/rocketmq/store-1type: Directory- name: vol-confhostPath:path: /www/k8s/foxdev/rocketmq/conftype: Directory- name: vol-logs-ahostPath:path: /www/k8s/foxdev/rocketmq/logs-1atype: Directory- name: vol-store-ahostPath:path: /www/k8s/foxdev/rocketmq/store-1atype: Directory- name: vol-logs-ashostPath:path: /www/k8s/foxdev/rocketmq/logs-1astype: Directory- name: vol-store-ashostPath:path: /www/k8s/foxdev/rocketmq/store-1astype: Directory- name: vol-logs-as2hostPath:path: /www/k8s/foxdev/rocketmq/logs-1as2type: Directory- name: vol-store-as2hostPath:path: /www/k8s/foxdev/rocketmq/store-1as2type: Directory
k8s service
rocketmq1-service.yml
apiVersion: v1
kind: Service
metadata:name: rocketmqlabels:app: rocketmq
spec:type: NodePortports:- port: 9876targetPort: 9876nodePort: 30876name: rmqser- port: 30911targetPort: 30911nodePort: 30911name: rmqbroker- port: 30921targetPort: 30921nodePort: 30921name: rmqbrokerslave- port: 30931targetPort: 30931nodePort: 30931name: rmqbrokerslave2selector:app: rocketmq
集群2配置
broker 配置 broker-b.conf
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.#所属集群名字
brokerClusterName=DefaultCluster#broker名字,注意此处不同的配置文件填写的不一样,如果在broker-a.properties使用:broker-a,
#在broker-b.properties使用:broker-b
brokerName=broker-b#0 表示Master,>0 表示Slave
brokerId=0#nameServer地址,分号分割
#namesrvAddr=rocketmq-0:9876;rocketmq-1:9876
namesrvAddr=rocketmq-0.rocketmq.default.svc.cluster.local:9876;rocketmq2-0.rocketmq2.default.svc.cluster.local:9876#启动IP,如果 docker 报 com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <192.168.0.120:10909> failed
# 解决方式1 加上一句producer.setVipChannelEnabled(false);,解决方式2 brokerIP1 设置宿主机IP,不要使用docker 内部IP
brokerIP1=192.168.0.254#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭 !!!这里仔细看是false,false,false
#原因下篇博客见~ 哈哈哈哈
autoCreateTopicEnable=true#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true#Broker 对外服务的监听端口
listenPort=30961
#haService中使用 默认值为:listenPort + 1
#haListenPort=30912
#主要用于slave同步master listenPort - 2
#fastListenPort=30909#删除文件时间点,默认凌晨4点
deleteWhen=04#文件保留时间,默认48小时
fileReservedTime=120#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/home/rocketmq/store
#commitLog 存储路径
#storePathCommitLog=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/commitlog
#消费队列存储
#storePathConsumeQueue=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/consumequeue
#消息索引存储路径
#storePathIndex=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/index
#checkpoint 文件存储路径
#storeCheckpoint=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/checkpoint
#abort 文件存储路径
#abortFile=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/abort
#限制的消息大小
maxMessageSize=65536#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=ASYNC_MASTER#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH#发消息线程池数量
#sendMessageThreadPoolNums=128
#拉消息线程池数量
#pullMessageThreadPoolNums=128
broker-slave 配置 broker-b-s.conf
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.#所属集群名字
brokerClusterName=DefaultCluster#broker名字,注意此处不同的配置文件填写的不一样,如果在broker-a.properties使用:broker-a,
#在broker-b.properties使用:broker-b
brokerName=broker-b#0 表示Master,>0 表示Slave
brokerId=1#nameServer地址,分号分割
#namesrvAddr=rocketmq-0:9876;rocketmq-1:9876
namesrvAddr=rocketmq-0.rocketmq.default.svc.cluster.local:9876;rocketmq2-0.rocketmq2.default.svc.cluster.local:9876#启动IP,如果 docker 报 com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <192.168.0.120:10909> failed
# 解决方式1 加上一句producer.setVipChannelEnabled(false);,解决方式2 brokerIP1 设置宿主机IP,不要使用docker 内部IP
brokerIP1=192.168.0.254#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=SLAVE#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭 !!!这里仔细看是false,false,false
#原因下篇博客见~ 哈哈哈哈
autoCreateTopicEnable=true#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true#Broker 对外服务的监听端口
listenPort=30971
#haService中使用 默认值为:listenPort + 1
#haListenPort=30912
#主要用于slave同步master listenPort - 2
#fastListenPort=30909#删除文件时间点,默认凌晨4点
deleteWhen=04#文件保留时间,默认48小时
fileReservedTime=120#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/home/rocketmq/store
#commitLog 存储路径
#storePathCommitLog=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/commitlog
#消费队列存储
#storePathConsumeQueue=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/consumequeue
#消息索引存储路径
#storePathIndex=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/index
#checkpoint 文件存储路径
#storeCheckpoint=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/checkpoint
#abort 文件存储路径
#abortFile=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/abort
#限制的消息大小
maxMessageSize=65536#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH#发消息线程池数量
#sendMessageThreadPoolNums=128
#拉消息线程池数量
#pullMessageThreadPoolNums=128
broker-slave 配置 broker-b-s2.conf
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.#所属集群名字
brokerClusterName=DefaultCluster#broker名字,注意此处不同的配置文件填写的不一样,如果在broker-a.properties使用:broker-a,
#在broker-b.properties使用:broker-b
brokerName=broker-b#0 表示Master,>0 表示Slave
brokerId=2#nameServer地址,分号分割
#namesrvAddr=rocketmq-0:9876;rocketmq-1:9876
namesrvAddr=rocketmq-0.rocketmq.default.svc.cluster.local:9876;rocketmq2-0.rocketmq2.default.svc.cluster.local:9876#启动IP,如果 docker 报 com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <192.168.0.120:10909> failed
# 解决方式1 加上一句producer.setVipChannelEnabled(false);,解决方式2 brokerIP1 设置宿主机IP,不要使用docker 内部IP
brokerIP1=192.168.0.254#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=SLAVE#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭 !!!这里仔细看是false,false,false
#原因下篇博客见~ 哈哈哈哈
autoCreateTopicEnable=true#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true#Broker 对外服务的监听端口
listenPort=30981
#haService中使用 默认值为:listenPort + 1
#haListenPort=30912
#主要用于slave同步master listenPort - 2
#fastListenPort=30909#删除文件时间点,默认凌晨4点
deleteWhen=04#文件保留时间,默认48小时
fileReservedTime=120#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/home/rocketmq/store
#commitLog 存储路径
#storePathCommitLog=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/commitlog
#消费队列存储
#storePathConsumeQueue=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/consumequeue
#消息索引存储路径
#storePathIndex=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/index
#checkpoint 文件存储路径
#storeCheckpoint=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/checkpoint
#abort 文件存储路径
#abortFile=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/abort
#限制的消息大小
maxMessageSize=65536#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH#发消息线程池数量
#sendMessageThreadPoolNums=128
#拉消息线程池数量
#pullMessageThreadPoolNums=128
k8s pod
rocketmq2-pod.yml
apiVersion: apps/v1
kind: StatefulSet
metadata:name: rocketmq2labels:app: rocketmq2spec:serviceName: rocketmq2replicas: 1selector:matchLabels:app: rocketmq2template:metadata:labels:app: rocketmq2spec:containers:- name: rocketmqimage: foxiswho/rocketmq:4.8.0imagePullPolicy: IfNotPresentresources:limits:cpu: 450mmemory: 2000Mirequests:cpu: 400mmemory: 2000Mienv:- name: TZvalue: Asia/Shanghai- name: JAVA_OPTvalue: -Duser.home=/home/rocketmq- name: JAVA_OPT_EXTvalue: -Xmn256mcommand: ["sh","-c","mqnamesrv"]ports:- containerPort: 9876volumeMounts:- name: vol-logsmountPath: /home/rocketmq/logs- name: vol-storemountPath: /home/rocketmq/store- name: rmqbrokerimage: foxiswho/rocketmq:4.8.0imagePullPolicy: IfNotPresentresources:limits:cpu: 440mmemory: 2000Mirequests:cpu: 400mmemory: 2000Mienv:- name: TZvalue: Asia/Shanghai- name: JAVA_OPT_EXTvalue: -Duser.home=/home/rocketmq -Xms1024M -Xmx1024M -Xmn256mcommand: [ "sh","-c","mqbroker -c /etc/rocketmq/broker-b.conf" ]ports:- containerPort: 30959- containerPort: 30961- containerPort: 30962volumeMounts:- name: vol-logs-amountPath: /home/rocketmq/logs- name: vol-store-amountPath: /home/rocketmq/store- name: vol-confmountPath: /etc/rocketmq/- name: rmqbroker-slaveimage: foxiswho/rocketmq:4.8.0imagePullPolicy: IfNotPresentresources:limits:cpu: 450mmemory: 2000Mirequests:cpu: 400mmemory: 2000Mienv:- name: TZvalue: Asia/Shanghai- name: JAVA_OPT_EXTvalue: -Duser.home=/home/rocketmq -Xms1024M -Xmx1024M -Xmn256mcommand: [ "sh","-c","mqbroker -c /etc/rocketmq/broker-b-s.conf" ]ports:- containerPort: 30969- containerPort: 30971- containerPort: 30972volumeMounts:- name: vol-logs-asmountPath: /home/rocketmq/logs- name: vol-store-asmountPath: /home/rocketmq/store- name: vol-confmountPath: /etc/rocketmq/- name: rmqbroker-slave2image: foxiswho/rocketmq:4.8.0imagePullPolicy: IfNotPresentresources:limits:cpu: 450mmemory: 2000Mirequests:cpu: 400mmemory: 2000Mienv:- name: TZvalue: Asia/Shanghai- name: JAVA_OPT_EXTvalue: -Duser.home=/home/rocketmq -Xms1024M -Xmx1024M -Xmn256mcommand: [ "sh","-c","mqbroker -c /etc/rocketmq/broker-b-s2.conf" ]ports:- containerPort: 30979- containerPort: 30981- containerPort: 30982volumeMounts:- name: vol-logs-as2mountPath: /home/rocketmq/logs- name: vol-store-as2mountPath: /home/rocketmq/store- name: vol-confmountPath: /etc/rocketmq/volumes:- name: vol-logshostPath:path: /www/k8s/foxdev/rocketmq/logs-2type: Directory- name: vol-storehostPath:path: /www/k8s/foxdev/rocketmq/store-2type: Directory- name: vol-confhostPath:path: /www/k8s/foxdev/rocketmq/conftype: Directory- name: vol-logs-ahostPath:path: /www/k8s/foxdev/rocketmq/logs-2btype: Directory- name: vol-store-ahostPath:path: /www/k8s/foxdev/rocketmq/store-2btype: Directory- name: vol-logs-ashostPath:path: /www/k8s/foxdev/rocketmq/logs-2bstype: Directory- name: vol-store-ashostPath:path: /www/k8s/foxdev/rocketmq/store-2bstype: Directory- name: vol-logs-as2hostPath:path: /www/k8s/foxdev/rocketmq/logs-2bs2type: Directory- name: vol-store-as2hostPath:path: /www/k8s/foxdev/rocketmq/store-2bs2type: Directory
k8s service
rocketmq2-service.yml
apiVersion: v1
kind: Service
metadata:name: rocketmq2labels:app: rocketmq2
spec:type: NodePortports:- port: 9876targetPort: 9876nodePort: 30877name: rmqser2- port: 30961targetPort: 30961nodePort: 30961name: rmqbroker2- port: 30971targetPort: 30971nodePort: 30971name: rmqbrokerslave2- port: 30981targetPort: 30981nodePort: 30981name: rmqbrokerslave22selector:app: rocketmq2
UI
pod
ui-rc.yml
apiVersion: apps/v1
kind: StatefulSet
metadata:name: rmquilabels:app: rmquispec:serviceName: rmquireplicas: 1selector:matchLabels:app: rmquitemplate:metadata:labels:app: rmquispec:containers:- name: rmquiimage: pongsky/rocketmq-console-ngimagePullPolicy: IfNotPresentresources:limits:cpu: 450mmemory: 1024Mirequests:cpu: 400mmemory: 768Mienv:- name: TZvalue: Asia/Shanghai- name: JAVA_OPTSvalue: -Drocketmq.config.namesrvAddr=rocketmq:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false -Duser.home=/root -Drocketmq.config.dataPath=/tmp/rocketmq-console/data -Xms768m -Xmx768mports:- containerPort: 8080volumeMounts:- name: vol-logsmountPath: /root/logs- name: vol-confmountPath: /tmp/rocketmq-console/data/users.propertiesvolumes:- name: vol-logshostPath:path: /www/k8s/foxdev/rocketmq/logs-uitype: Directory- name: vol-confhostPath:path: /www/k8s/foxdev/rocketmq/conf/users.propertiestype: File
service
ui-service.yml
apiVersion: v1
kind: Service
metadata:name: rmquilabels:app: rmqui
spec:type: NodePortports:- port: 8080targetPort: 8080nodePort: 30879selector:app: rmqui
创建执行
kubectl create -f ui-rc.yml
kubectl create -f ui-service.ymlkubectl create -f rocketmq1-pod.yml
kubectl create -f rocketmq1-service.ymlkubectl create -f rocketmq2-pod.yml
kubectl create -f rocketmq2-service.yml
至此创建完成
rocketmq在Kubernetes(k8s)中的集群配置,2m-2s-async:多Master多Slave模式,异步复制相关推荐
- Kubernetes(k8s)之在集群环境部署Prometheus(普罗米修斯监控)和集群的ui管理工具Grafana
Prometheus Prometheus 演示环境 部署Prometheus和Grafana 测试 Prometheus Prometheus是一个开源系统监控和警报工具包. 现在是一个独立的开源项 ...
- redis哨兵集群配置
Redis集群配置(docker环境) 一.redis集群架构图 一主两从三哨兵集群,当master节点宕机时,通过哨兵(sentinel)重新推选出新的master节点,保证集群的可用性. 二.se ...
- K8s——kubernetes集群中ceph集群使用【下】
kubernetes集群中ceph集群使用 一:CephFS 创建和使用 CephFS 允许用户挂载一个兼容posix的共享目录到多个主机,该存储和NFS共享存储以及CIFS共享目录相似 1.file ...
- K8s——kubernetes集群中ceph集群使用【上】
kubernetes集群中ceph集群使用 块设备创建和使用 Ceph 能够为 pod 提供裸的块设备卷,定义在Ceph数据冗余级别的一个池中 1.storageclass 配置 storagecla ...
- 【Linux云计算架构:第四阶段-Linux虚拟化-私有云-docker】第12章—— 搭建 Kubernetes 的 web 管理界面和基于 k8s 搭建+redis 集群案例
13.1 部署 Kubernetes Dashboard web 界面 13.1.1 创建 dashboard-deployment.yaml deployment 配置文件 13.1.2 创建 da ...
- kubernetes入门到精通(二):k8s部署Tomcat集群,基于NTFS协议的文件集群共享,Service提供负载均衡,端口转发工具Rinetd配置外部访问
首先,配置 Docker 镜像加速服务 登录阿里云账号,进入控制台 -> 容器镜像服务 (不需要有阿里云的服务器,只要注册账号即可) 在两台 node 节点上配置好阿里云的镜像加速. 重启一下 ...
- 企业实战-Kubernetes(十四)k8s高可用集群
k8s高可用集群 1 使用pacemaker搭建k8s的高可用(haproxy的高可用) 安装并配置haproxy 安装并配置pacemaker 2 k8s集群部署 master准备 三个结点关闭交换 ...
- Kubernetes学习-K8S安装篇-集群安装网段划分
Kubernetes学习-K8S安装篇-集群安装网段划分 1. 集群安装网段划分 2. 网段IP常用设置 3. 集群安装网段划分注意事项 1. 集群安装网段划分 集群安装时会涉及到三个网段: 宿主机网 ...
- 容器编排技术 -- Kubernetes从零开始搭建自定义集群
容器编排技术 -- Kubernetes从零开始搭建自定义集群 1 设计和准备 1.1 学习 1.2 Cloud Provider 1.3 节点 1.4 网络 1.4.1 网络连接 1.4.2 网络策 ...
- 使用Kubeadm搭建Kubernetes(1.12.2)集群
Kubeadm是Kubernetes官方提供的用于快速安装Kubernetes集群的工具,伴随Kubernetes每个版本的发布都会同步更新,在2018年将进入GA状态,说明离生产环境中使用的距离越来 ...
最新文章
- TL-WDN3321 Ubuntu 下安装
- Pytorch中的向前计算(autograd)、梯度计算以及实现线性回归操作
- CPU 核数与线程数有什么关系?
- numpy 的array 用于矩阵运算 与 python的列表表示矩阵的区别
- w7计算机屏幕保护设置方法,W7屏保怎么设置
- 多线程:AQS的一些心得
- 微信跳一跳python全部代码_微信跳一跳python代码
- LIBCLNTSH.SO: WRONG ELF CLASS: ELFCLASS32错误一例
- 大数据之-Hadoop完全分布式_集群文件存储路径说明_完全分布式集群测试---大数据之hadoop工作笔记0038
- QQ 新增“语音进度条”;滴滴顺风车负责人道歉;华为研发费将超 1000 亿美元 | 极客头条...
- 铝电解电容总结[转]
- 纯净版VS2015安装教程(适合初次安装或者重装系统后)
- 【学术报告】几经沉浮,人工智能(AI)前路何方?
- 一位acm过来人的心得
- kalibr源码解析之fov模型重投影误差计算
- 《Cocos Creator游戏实战》打砖块主要功能与逻辑实现
- VMware(6):如何配置虚拟机与宿主机的端口映射
- Siri 语音识别 Speech
- 在线 Beosin EOS-IDE 免费版本同时支持智能合约在线编辑、编译、运行调试、部署
- 天猫api接口,天猫详情api接口,天猫优惠券信息api接口,天猫到手价api接口,天猫商品详情接口,可用于行业数据分析,价格监控,竞品分析,品牌维权接口代码对接