docker安装rocketmq和console

# 安装docker服务
# 1.更新yum服务
yum update
# 2.安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的
yum install -y yum-utils device-mapper-persistent-data lvm2
# 3.配置使用阿里云镜像服务
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 4.查看docker版本
yum list docker-ce --showduplicates | sort -r
# 5.安装docker
yum install docker-ce-18.03.1.ce
# 6.启动docker
systemctl start docker
# 7.开机启动
systemctl enable docker
# 8.验证
docker version
# 1.获取rockermq镜像
docker pull foxiswho/rocketmq:server-4.3.2 
docker pull foxiswho/rocketmq:broker-4.3.2
# 2.创建数据挂载目录
mkdir -p /usr/dockerrocketmq/rmqserver01/logs
mkdir -p /usr/dockerrocketmq/rmqserver01/store
mkdir -p /usr/dockerrocketmq/rmqbroker01/logs
mkdir -p /usr/dockerrocketmq/rmqbroker01/store
mkdir -p /usr/dockerrocketmq/rmqbroker01/conf
# 3.新建配置文件
vi /usr/dockerrocketmq/rmqbroker01/conf/broker.conf

broker.conf

namesrvAddr=172.25.x.x:9876 #阿里云内网IP
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
brokerIP1 = 172.25.x.x #阿里云内网IP
listenPort=10911
# 4.创建并启动mqserver
docker create -p 9876:9876 --name rmqserver01 -e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m" -e "JAVA_OPTS=-Duser.home=/opt" -v /usr/dockerrocketmq/rmqserver01/logs:/opt/logs -v /usr/dockerrocketmq/rmqserver01/store:/opt/store foxiswho/rocketmq:server-4.3.2

docker start rmqserver01

# 5.启动broker
docker run -it -d --net host --name rmqbroker01 -e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m" -e "JAVA_OPTS=-Duser.home=/opt" -v /usr/dockerrocketmq/rmqbroker01/conf/broker.conf:/etc/rocketmq/broker.conf -v /usr/dockerrocketmq/rmqbroker01/logs:/opt/logs -v /usr/dockerrocketmq/rmqbroker01/store:/opt/store --privileged=true foxiswho/rocketmq:broker-4.3.2
# 6.拉取mq-console镜像
docker pull styletang/rocketmq-console-ng:1.0.0

# 7.启动console
docker run --name rmqconsole -e "JAVA_OPTS=-Drocketmq.namesrv.addr=172.25.x.x:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 8082:8080 -t styletang/rocketmq-console-ng:1.0.0

遇到的问题:

[2021-10-06 09:19:36.030] ERROR Unexpected error occurred in scheduled task.
java.lang.RuntimeException: org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to <外网ip:10911> failed
        at com.google.common.base.Throwables.propagate(Throwables.java:160)
        at org.apache.rocketmq.console.task.DashboardCollectTask.collectTopic(DashboardCollectTask.java:156)
        at org.apache.rocketmq.console.task.DashboardCollectTask$$FastClassBySpringCGLIB$$c818b8cd.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:721)
        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)

解决办法:

编辑broker.conf,brokerIP1指定为内网IP,而不是公网IP,重启docker即可。

上一篇:如何启动RocketMQ(Mac系统)


下一篇:$POJ2942\ Knights\ of\ the\ Round\ Table$ 图论