Docker 安装 RocketMq(单机)
此种方法安装发消息连接超时,暂未找到原因,这种方法安装的没有问题https://www.cnblogs.com/mangoubiubiu/p/15759671.html
1 参考链接
A 参考:https://blog.csdn.net/fenglibing/article/details/92378090
B 参考:https://zhuanlan.zhihu.com/p/342022297
第二个可靠度更高
2 开始搭建
一、查看当前镜像下的所有版本
curl https://registry.hub.docker.com/v1/repositories/foxiswho/rocketmq/tags\ | tr -d '[\[\]" ]' | tr '}' '\n'\ | awk -F: -v image='foxiswho/rocketmq' '{if(NR!=NF && $3 != ""){printf("%s:%s\n",image,$3)}}'
二、启动
1、拉取镜像
#拉取镜像 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
namesrvAddr=192.168.56.12:9876 brokerClusterName = DefaultCluster brokerName = broker-a brokerId = 0 deleteWhen = 04 fileReservedTime = 48 brokerRole = ASYNC_MASTER flushDiskType = ASYNC_FLUSH brokerIP1 = 192.168.56.12 listenPort=10911
这里一定要先编辑,插入配置,不然直接启动broker 会有问题 ,会报找不到这个配置文件这个错。
4、启动NameServer
#创建nameserver容器 docker create --restart=always -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 --restart=always -d -p 10911:10911 --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、部署RocketMQ的管理工具
拉取镜像
docker pull styletang/rocketmq-console-ng:1.0.0
运行容器
docker run --restart=always -e "JAVA_OPTS=-Drocketmq.namesrv.addr=192.168.56.12:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 8082:8080 -t styletang/rocketmq-console-ng:1.0.0
部署成功 打完收工