window 环境下docker 安装 rocketMQ

最新实践分享:

文档:window docker 搭建 rocketMQ 实践.not…
链接:http://note.youdao.com/noteshare?id=d643c1cf0dda29f7a7335a005d45f590&sub=08899F1677A54C6182EF99A4431623CE

翻车了原文内容仅作参考

RocketMQ 使用docker 安装启动服务,网上资料众多,由于版本更新,很多时候并不会启动成功,特别是在winddows 环境下
笔者耗时两天共6个小时才成功在docker 环境安装了RocketMQ
现在将经验分享,本文章禁止任何形式的转载,所有权利保留。
本文章有效期大概2年,截止到2023年12月。
超过截止日期可能由于版本更新或者其他原因,导致安装示例不成功。

欢迎热爱编程的小伙伴交流
QQ 群:177655321

windows docker环境准备

读者自行学习安装

window 环境下docker 安装 rocketMQ_第1张图片

一搜索RocketMQ 镜像

C:\Users\hamish>docker search rocketmq

笔者选择的是

foxiswho/rocketmq

下载镜像

docker pull foxiswho/rocketmq

没加版本号,默认选择最新版本

C:\Users\hamish>docker pull foxiswho/rocketmq
Using default tag: latest
latest: Pulling from foxiswho/rocketmq
d8d02d457314: Pull complete
eea526233c2d: Pull complete
2ebc148c7ecb: Pull complete
daca8bf38530: Pull complete
2c915389631d: Pull complete
2a55aed7dbfe: Pull complete
dbb7cba127f8: Pull complete
d978a55b78a6: Pull complete
db7a290702b4: Pull complete
93f4f3d6fe95: Pull complete
Digest: sha256:ff402cbdcc1e919b0c63dc9a740afe566309e4f86b2ff7f9c4bc32b980ba1c71
Status: Downloaded newer image for foxiswho/rocketmq:latest
docker.io/foxiswho/rocketmq:latest

二、启动docker 命名空间服务

docker run -d -p 9876:9876 -v d:\data\docker\namesrv\logs:/root/logs -v d:\data\docker\namesrv\store:/root/store --name rmqnamesrv -e "MAX_POSSIBLE_HEAP=100000000" foxiswho/rocketmq sh mqnamesrv

window 环境下可能回报端口占用错误

因为

C:\Users\hamish>netsh interface ipv4 show excludedportrange protocol=tcp

协议 tcp 端口排除范围

开始端口    结束端口
----------    --------
      5357        5357
      9728        9827
      9828        9927
     10034       10133
     10134       10233
     10526       10625
     10626       10725
     11383       11482
     11497       11596
     11597       11696
     11749       11848
     13350       13449
     13450       13549
     50000       50059     *

* - 管理的端口排除。

window可能会限制某些端口的使用
更换端口:

docker run -d -p 19876:9876 -v d:\data\docker\namesrv\logs:/root/logs -v d:\data\docker\namesrv\store:/root/store --name rmqnamesrv -e "MAX_POSSIBLE_HEAP=100000000" foxiswho/rocketmq sh mqnamesrv

三、rocketMQ 服务

注意window 本地文件目录事先手动构建

docker run -d -p 10911:10911 -p 10909:10909 -v  d:\data\docker\rocketmq\broker\logs:/root/logs -v   d:\data\docker\rocketmq\data\broker\store:/root/store -v   d:\data\docker\rocketmq\conf\broker.conf:/opt/rocketmq/conf/broker.conf --name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:19876" -e "MAX_POSSIBLE_HEAP=200000000" rocketmqinc/rocketmq sh mqbroker -c /opt/rocketmq/conf/broker.conf

四、rocketMQ 控制台

docker pull apacherocketmq/rocketmq-console:2.0.0
docker run -d "JAVA_OPTS=-Drocketmq.namesrv.addr=172.17.0.2:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 9082:8080 -t apacherocketmq/rocketmq-console:2.0.0

注意这里的172.17.0.2:9876 来自于之前docker 容器分配的IP地址,这其中的原因不明。希望有高手可以评论

确定命名空间内部IP地址方法:
进入命名空间的命令窗口:

sh-4.2$ cat /etc/host
cat: /etc/host: No such file or directory
sh-4.2$ cat /etc/hosts
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.3      6dc38bb3a4f4
sh-4.2$

1.可能会出现报错信息

关键字:connect to failed

原因是控制台镜像版本选择的问题,优秀镜像版本比较老,配置参数有变动


Caused by: org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to <null> failed
        at org.apache.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:357)
        at org.apache.rocketmq.client.impl.MQClientAPIImpl.getBrokerClusterInfo(MQClientAPIImpl.java:1147)
        at org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl.examineBrokerClusterInfo(DefaultMQAdminExtImpl.java:269)
        at org.apache.rocketmq.tools.admin.DefaultMQAdminExt.examineBrokerClusterInfo(DefaultMQAdminExt.java:212)
        at org.apache.rocketmq.console.service.client.MQAdminExtImpl.examineBrokerClusterInfo(MQAdminExtImpl.java:175)
        at sun.reflect.GeneratedMethodAccessor102.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
        at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
        at org.apache.rocketmq.console.aspect.admin.MQAdminAspect.aroundMQAdminMethod(MQAdminAspect.java:63)
        at sun.reflect.GeneratedMethodAccessor101.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629)
        at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618)
        at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
        at com.sun.proxy.$Proxy71.examineBrokerClusterInfo(Unknown Source)
        at org.apache.rocketmq.console.service.impl.ConsumerServiceImpl.queryGroupList(ConsumerServiceImpl.java:71)
        ... 87 common frames omitted

2.可能会出现报错信息

关键字: connect to [localhost:19876] failed

管理界面配置 链接参数:

Caused by: org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to [localhost:19876] failed
        at org.apache.rocketmq.remoting.netty.NettyRemotingClient.getAndCreateNameserverChannel(NettyRemotingClient.java:445)
        at org.apache.rocketmq.remoting.netty.NettyRemotingClient.getAndCreateChannel(NettyRemotingClient.java:400)
        at org.apache.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:369)
        at org.apache.rocketmq.client.impl.MQClientAPIImpl.getBrokerClusterInfo(MQClientAPIImpl.java:1331)
        at org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl.examineBrokerClusterInfo(DefaultMQAdminExtImpl.java:306)
        at org.apache.rocketmq.tools.admin.DefaultMQAdminExt.examineBrokerClusterInfo(DefaultMQAdminExt.java:251)
        at org.apache.rocketmq.console.service.client.MQAdminExtImpl.examineBrokerClusterInfo(MQAdminExtImpl.java:204)
        at org.apache.rocketmq.console.service.client.MQAdminExtImpl$$FastClassBySpringCGLIB$$f6279829.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747)
        at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)
        at org.apache.rocketmq.console.aspect.admin.MQAdminAspect.aroundMQAdminMethod(MQAdminAspect.java:63)
        at sun.reflect.GeneratedMethodAccessor52.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
        at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
        at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747)

[2021-10-30 13:45:53.362]  INFO closeChannel: close the connection to remote address[172.17.0.3:9876] result: true

[2021-10-30 13:45:53.363]  INFO op=look_clusterInfo {}

[2021-10-30 13:45:54.422]  INFO closeChannel: close the connection to remote address[172.17.0.3:9876] result: true

[2021-10-30 13:45:54.423]  INFO op=look_clusterInfo {}

[2021-10-30 13:45:57.694]  INFO closeChannel: close the connection to remote address[172.17.0.3:9876] result: true

[2021-10-30 13:45:57.695]  INFO op=look_clusterInfo {}

[2021-10-30 13:46:00.011]  INFO closeChannel: close the connection to remote address[172.17.0.3:9876] result: true

[2021-10-30 13:46:30.009]  INFO closeChannel: close the connection to remote address[172.17.0.3:9876] result: true

参考资料:
1.https://github.com/apache/rocketmq-dashboard

2.https://zhuanlan.zhihu.com/p/281337002

你可能感兴趣的:(docker,docker,运维,linux)