RocketMQ
Docker容器部署
broker.conf
brokerClusterName=cluster
brokerName=broker-a
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
# 注意,宿主IP是你计算机网卡的IP
brokerIP1=172.21.23.24
docker-compose.yml
version: '3'
services:
namesrv:
image: apache/rocketmq:latest
container_name: rmqnamesrv
ports:
- 9876:9876
networks:
- rocketmq
command: sh mqnamesrv
broker:
image: apache/rocketmq:latest
container_name: rmqbroker
ports:
- 10909:10909
- 10911:10911
- 10912:10912
environment:
- NAMESRV_ADDR=namesrv:9876
depends_on:
- namesrv
networks:
- rocketmq
volumes:
# logs、store目录都需要写权限
- /data/rocketmq/broker/logs:/home/rocketmq/logs
- /data/rocketmq/broker/store:/home/rocketmq/store
# // 根据版本不同动态调整相应目录
- /data/rocketmq/broker/conf/broker.conf:/home/rocketmq/rocketmq-4.9.2/conf/broker.conf
# 注意 -c参数
command: sh mqbroker -c /home/rocketmq/rocketmq-4.9.2/conf/broker.conf
dashboard:
image: apacherocketmq/rocketmq-dashboard:latest
container_name: rmqdashboard
#下方为ulimit配置soft和hard的大小
ulimits:
nofile:
soft: 65536
hard: 65536
ports:
- 8083:8080
environment:
- JAVA_OPTS=-Drocketmq.namesrv.addr=namesrv:9876
depends_on:
- namesrv
networks:
- rocketmq
networks:
rocketmq:
driver: bridge
dashboard相关配置
在对应的 rocketMQ 的启动服务器上面,需要增加端口开放,不然这里就访问不到。我这里是使用的是 iptables ,下面是相关命令
iptables -A INPUT -p tcp --dport 8087 -j ACCEPT
iptables -A INPUT -p tcp --dport 9876 -j ACCEPT
iptables -A INPUT -p tcp --dport 10909 -j ACCEPT
iptables -A INPUT -p tcp --dport 10911 -j ACCEPT
iptables -A INPUT -p tcp --dport 10912 -j ACCEPT
service iptables save #保存配置
service iptables restart #重启服务
service iptables status #查看状态
遇到的问题
问题描述
library initialization failed - unable to allocate file descriptor table - out of memoryAborted (core dumped)
解决方案
在宿主机执行ulimit -n 查看具体数量,如果是1024则需要调大一些
// 查看
ulimit -n
// 设置
ulimit -n 65536
// 刷新
source /etc/profile
在docker-compose配置文件中增加ulimit配置
#下方为ulimit配置soft和hard的大小
ulimits:
nofile:
soft: 65536
hard: 65536
问题描述
closeChannel: close the connection to remote address[] result: true
解决方案
在conf/broker.conf配置文件中增加
brokerIP1=X.X.X.X(公网IP)