Docker安装RocketMQ
1.0 背景
由于自己的电脑vnp不能连公司的vpn,所以在家运行项目不方便,打算给自己的linux安装RocketMQ。
2.0 拉取镜像
docker pull rocketmqinc/rocketmq:latest
2.1 创建目录
/usr/local/docker/rocketmq/data/namesrv/logs
/usr/local/docker/rocketmq/data/namesrv/store
2.2 安装namesrv
docker run -d -p 9876:9876 -v /usr/local/docker/rocketmq/data/namesrv/logs:/root/logs -v /usr/local/docker/rocketmq/data/namesrv/store:/root/store --name rmqnamesrv -e "MAX_POSSIBLE_HEAP=100000000" rocketmqinc/rocketmq:latest sh mqnamesrv
2.3 安装broker
-
1.首先需要创建broker.conf配置文件
-
/usr/local/docker/rocketmq/conf/broker.conf
-
2.其中填入如下内容,注意最后一项ip改成你的linux的ip
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
brokerIP1 = XX.XX.XX.XX
-
3.用broker.conf配置启动容器
docker run -d -p 10911:10911 -p 10909:10909 -v /usr/local/docker/rocketmq/data/broker/logs:/root/logs -v /usr/local/docker/rocketmq/data/broker/store:/root/store -v /usr/local/docker/rocketmq/conf/broker.conf:/opt/rocketmq-latest/conf/broker.conf --name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" -e "MAX_POSSIBLE_HEAP=200000000" rocketmqinc/rocketmq:latest sh mqbroker -c /opt/rocketmq-latest/conf/broker.conf
2.4 安装 rocketmq 控制台
-
1.拉取rocketmq控制台的镜像
-
docker pull pangliang/rocketmq-console-ng
-
2.后台启动rocketmq的控制台镜像,映射到18080端口
docker run -d -e "JAVA_OPTS=-Drocketmq.namesrv.addr=192.168.8.128:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 18080:8080 -t pangliang/rocketmq-console-ng
2.5 查看
docker ps -a
检验成果
打开浏览器访问ip:18080 注意访问你linux的ip和上面rocketmq控制台映射的18080端口