1、安装jkd1.8
docker pull java:8 或者 docker pull openjdk:8
查看已安装的镜像: docker images
运行jdk命令 docker run -d -it --name java-8 java:8
进入JDK 容器 docker exec -it java-8 /bin/bash
查看java版本,进入java-8容器后输入 :java -version
这里jdk1.8就安装好了
2、安装 Namesrv
2.1拉去镜像
docker pull rocketmqinc/rocketmq:4.4.0
2.2在文件夹下创建mq 命令:mkdir mq
2.3启动命令
docker run -d -p 9876:9876 -v {自己的路径}/data/namesrv/logs:/root/logs -v {自己的路径}/data/namesrv/store:/root/store --name rmqnamesrv -e "MAX_POSSIBLE_HEAP=100000000" rocketmqinc/rocketmq:4.4.0 sh mqnamesrv
我的路径是/mydata/mq
docker run -d -p 9876:9876 -v /mydata/mq/data/namesrv/logs:/root/logs -v /mydata/mq/data/namesrv/store:/root/store --name rmqnamesrv -e "MAX_POSSIBLE_HEAP=100000000" rocketmqinc/rocketmq:4.4.0 sh mqnamesrv
3. 安装 broker
3.1创建 broker.conf 文件
命令:
mkdir conf
cd conf
touch broker.conf
输入命令vi broker.conf , 点击键盘insert键开始插入状态
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
brokerIP1 = 自己服务器地址 (如192.168.118.129)
输入wq! 退出
启动容器
docker run -d -p 10911:10911 -p 10909:10909 -v {自己的路径}/data/broker/logs:/root/logs -v {自己的路径}/rocketmq/data/broker/store:/root/store -v {自己的路径}/conf/broker.conf:/opt/rocketmq-4.4.0/conf/broker.conf --name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" -e "MAX_POSSIBLE_HEAP=200000000" rocketmqinc/rocketmq:4.4.0 sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker.conf
我的地址 /mydata/mq
docker run -d -p 10911:10911 -p 10909:10909 -v /mydata/mq/data/broker/logs:/root/logs -v /mydata/mq/rocketmq/data/broker/store:/root/store -v /mydata/mq/conf/broker.conf:/opt/rocketmq-4.4.0/conf/broker.conf --name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" -e "MAX_POSSIBLE_HEAP=200000000" rocketmqinc/rocketmq:4.4.0 sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker.conf
4. 安装 rocketmq 控制台
拉取镜像
docker pull styletang/rocketmq-console-ng
启动rocketmq 控制台
docker run -e "JAVA_OPTS=-Drocketmq.namesrv.addr=自己的ip:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 8080:8080 -t styletang/rocketmq-console-ng
我的是
docker run -e "JAVA_OPTS=-Drocketmq.namesrv.addr=192.168.118.129:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 8080:8080 -t styletang/rocketmq-console-ng
这样运行成功了
关闭防火墙
这样就完成了