docker-compose部署rocketmq
docker-compose安装:
1.从github上下载docker-compose二进制文件安装
Ubuntu下载docker-compose文件
sudo curl -L https://github.com/docker/compose/releases/download/1.27.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
CentOs下载docker-compose文件
curl -L https://github.com/docker/compose/releases/download/1.27.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
2.添加可执行权限
chmod +x /usr/local/bin/docker-compose
2.测试安装结果
docker-compose --version
3.手动下载
官网选择版本 https://github.com/docker/compose/releases 选择相应版本,下载docker-compose-Linux-x86_64到本地或者服务器中 更名为docker-compose,并移动到 /usr/local/bin 目录下
1,新建挂载目录:
mkdir -p /my/config/rocketmq/
mkdir -p /my/rocketmq/broker-logs/
mkdir -p /my/rocketmq/broker-store/
mkdir -p /my/rocketmq/logs/
mkdir -p /my/rocketmq/logs/
2,pull相关的镜像:
docker pull foxiswho/rocketmq:server-4.5.2
docker pull foxiswho/rocketmq:broker-4.5.2
docker pull styletang/rocketmq-console-ng
3,编写broker.conf:
cd /my/config/rocketmq/
vim broker.conf
内容为:
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
autoCreateTopicEnable = true
# 如果是本地程序调用云主机 mq,这个需要设置成 云主机 IP
brokerIP1=<主机IP>
namesrvAddr=<主机IP>:9876
4,编写docker-compose.yaml:
cd /my/rocketmq
vim docker-compose.yaml
内容为:
version: '3.5' services: rmqnamesrv: image: foxiswho/rocketmq:server-4.5.2 container_name: rmqnamesrv ports: - :9876 volumes: - /my/rocketmq/logs:/opt/logs - /my/rocketmq/store:/opt/store networks: rmq: aliases: - rmqnamesrv
rmqbroker:
image: foxiswho/rocketmq:broker-4.5.2
container_name: rmqbroker
ports:
- 10909:10909
- 10911:10911
volumes:
- /my/rocketmq/broker-logs:/root/logs/rocketmqlogs
- /my/rocketmq/broker-store:/opt/store
- /my/config/rocketmq/broker.conf:/etc/rocketmq/broker.conf
environment:
NAMESRV_ADDR: "rmqnamesrv:9876"
JAVA_OPTS: " -Duser.home=/opt"
JAVA_OPT_EXT: "-server -Xms128m -Xmx128m -Xmn128m"
command: mqbroker -c /etc/rocketmq/broker.conf
depends_on:
- rmqnamesrv
networks:
rmq:
aliases:
- rmqbrokerrmqconsole:
image: styletang/rocketmq-console-ng
container_name: rmqconsole
ports:
- 8087:8080
environment:
JAVA_OPTS: "-Drocketmq.namesrv.addr=rmqnamesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false"
depends_on:
- rmqnamesrv
networks:
rmq:
aliases:
- rmqconsole
networks:
rmq:
name: rmq
driver: bridge
4,在/my/rocketmq下运行:
docker-compose up
#关闭
docker-compose down
检查docker容器:
docker ps