K8S Helm安装RocketMQ standalone单机版,配置外网地址注册到nameserver中方便本地开发
helm地址
rocketmq 3.0.2 · sir5kong/rocketmq
helm repo add rocketmq https://helm-charts.itboon.top/rocketmq
helm pull rocketmq/rocketmq
tar -xvf rocketmq-3.0.2.tgz
修改配置
修改这个无效
/root/rocketmq/rocketmq/templates/broker/configmap.yaml
文件头有注释 {{/* 3.0 废弃 */}}
修改外网配置namesrvAddr、brokerIP1、listenPort
vi /root/rocketmq/rocketmq/templates/configmap.yaml
data:
broker-base.conf: |
brokerClusterName = {{ .Values.clusterName }}
{{- range $key, $value := .Values.broker.config }}
{{ $key }} = {{ $value }}
{{- end }}
namesrvAddr=你的外网地址加端口:3xxxx
brokerIP1=你的外网地址
listenPort=30911
将10911改成30911,k8s对外端口30000以上
此时如此优秀的RocketMQ也会把你的10909和10912也会改成3打头的 30909(VIP) 30912(HA)
参考:RcoketMQ连接时报错sendDefaultImpl call timeout解决_rcoketmq send call timeout-CSDN博客
配置文件中的配置项:RocketMQ配置解析:手把手教老婆看懂broker.properties-CSDN博客
修改Broker中的端口
vi /root/rocketmq/rocketmq/templates/broker/statefulset.yaml
全换成3打头的
ports:
- containerPort: 30909
name: vip
protocol: TCP
- containerPort: 30911
name: main
protocol: TCP
- containerPort: 30912
name: ha
protocol: TCP
创建broker的service方便外网访问broker
vi broker-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: rocketmq-standalone-broker-master-svc-0
labels:
spec:
type: NodePort
ports:
- name: vip
nodePort: 30909
port: 30909
targetPort: 30909
protocol: TCP
- name: main
nodePort: 30911
port: 30911
targetPort: 30911
protocol: TCP
- name: ha
nodePort: 30912
port: 30912
targetPort: 30912
protocol: TCP
selector:
app.kubernetes.io/name: rocketmq
broker: rocketmq-standalone-broker-master
component: broker
statefulset.kubernetes.io/pod-name: rocketmq-standalone-broker-master-0
kubectl apply -f broker-svc.yaml -n develop
修改/root/rocketmq/rocketmq/templates模板目录中nameservice和dashboard子目录中的service.yaml修改为NodePort并指定端口
spec:
type: NodePort
ports:
nodePort: 3xxxx
安装rocketmq-standalone
helm install rocketmq-standalone /root/rocketmq/rocketmq \
--namespace develop \
--set image.tag="5.1.4" \ #使用新版本
--set image.repository="apache/rocketmq" \ #或者你的私有仓库
--set broker.persistence.storageClass="你的storageClass" --debug
反复检查
kubectl logs -f rocketmq-standalone-broker-master-0 -n develop
kubectl describe pod rocketmq-standalone-broker-master-0 -n develop
观察探针 readinessProbe
kubectl get pods -n develop -owide |grep rocket
kubectl get svc -n develop |grep rocket
rocketmq-standalone-broker-master-svc-0 NodePort 30909:30909/TCP,30911:30911/TCP,30912:30912/TCP
去dashboard中去看看是否正常
出错了卸载
helm uninstall rocketmq-standalone -n develop
创建个springboot工程访问试试
参考:SpringBoot集成RocketMQ(完整demo)_用springboot写一个简单使用rocketmq的demo-CSDN博客
上dashboard中的创建topic mq_test_topic
http://localhost:8080/test?msg=hello文章来源:https://www.toymoban.com/news/detail-773734.html
在本地Git shell窗口里跑100个请求试试
for i in {1..100}; do curl http://localhost:8080/test?msg=hello && echo ""; done文章来源地址https://www.toymoban.com/news/detail-773734.html
去dashboard中去看看
到了这里,关于K8S Helm安装RocketMQ standalone单机版,配置外网地址注册到nameserver中方便本地开发的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!