RocketMQ 安装教程 (Docker)

请把 10.0.2.22 替换成服务器的内网 ip

1. 拉取镜像

docker pull rocketmqinc/rocketmq:4.4.0

4.4.0: Pulling from rocketmqinc/rocketmq
8ba884070f61: Pull complete 
be4e0d7daa16: Pull complete 
a8d5394cdece: Pull complete 
290a723595dc: Pull complete 
3547dbffb2c3: Pull complete 
23f65b12414b: Pull complete 
556e98de2994: Pull complete  
b35007866c79: Pull complete 
dc1dab264d27: Pull complete 
Digest: sha256:7f322ba7798e53981ccae706e9720fc94505e3ad1040179203538b4689bc2b66
Status: Downloaded newer image for rocketmqinc/rocketmq:4.4.0
docker.io/rocketmqinc/rocketmq:4.4.0

2. 配置 namesrv

创建宿主文件夹
mkdir -p /data/app/rocketmq/namesrv/root

使用主机网络启动, namsesrv 监听 9876 端口
docker run -d --restart=on-failure:10 --net=host -v /data/app/rocketmq/namesrv/root:/root --name rocketmq-namesrv -e "MAX_POSSIBLE_HEAP=100000000" rocketmqinc/rocketmq:4.4.0 sh mqnamesrv

3. 配置 broker

创建宿主文件夹 mkdir /data/app/rocketmq/broker/

创建broker 文件
vim /data/app/rocketmq/broker/broker.conf

brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
#换成网络IP
namesrvAddr = 10.0.2.22:9876
#换成网络IP
brokerIP1 = 10.0.2.22
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭 
autoCreateTopicEnable=true
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭 
autoCreateSubscriptionGroup=true

启动 broker

docker run -d --restart=on-failure:10 --net=host -v /data/app/rocketmq/broker:/root -v /data/app/rocketmq/broker/broker.conf:/opt/rocketmq-4.4.0/conf/broker.conf --name rocketmq-broker -e "MAX_POSSIBLE_HEAP=200000000" rocketmqinc/rocketmq:4.4.0 sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker.conf

4.安装 MQ 控制台

4.1 拉取镜像 docker pull apacherocketmq/rocketmq-dashboard:latest

启动

docker run -d --restart=on-failure:10 --name rocketmq-dashboard -e "JAVA_OPTS=-Drocketmq.namesrv.addr=10.0.2.22:9876 -Dserver.port=9877" --net=host -t apacherocketmq/rocketmq-dashboard:latest

5. nginx 配置反向代理

server {
    listen 443 ssl http2;
    server_name rocketmq.jansora.com;

    ssl_protocols    TLSv1 TLSv1.1 TLSv1.2;
    ssl_certificate     /etc/nginx/certs/lets-encrypt-jansora.com/jansora.com.cer;
    ssl_certificate_key /etc/nginx/certs/lets-encrypt-jansora.com/jansora.com.key;

    location / {
      proxy_pass http://10.0.2.22:9877;
      proxy_set_header Host $host;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection upgrade;
      proxy_set_header Accept-Encoding gzip;
    }

}
  1. 打开页面访问

https://rocketmq.jansora.com

评论栏