部署rocketmq(含docker部署rocket)

部署rocketmq(含docker部署rocketmq)

文章目录


一、用官网下载的zip部署

1.部署前准备

2.启动rocketmq

  • 首先解压,通过命令unzip
unzip rocketmq-all-4.4.0-source-release.zip
  • 打包
mvn -Prelease-all -DskipTests clean install -U
cd rocketmq-all-4.4.0
  • 启动 NameServer
# 启动NameServer
 nohup sh bin/mqnamesrv &
# 查看日志,确认是否成功
 tail -f ~/logs/rocketmqlogs/namesrv.log
 
 #出现下面信息成功
 The Name Server boot success...
  • 追加 conf/broker.conf 里面的配置
brokerIP1=x.x.x.x
# 是否允许 Broker 自动创建 Topic,建议线下开启,线上关闭 !!!这里仔细看是 false,false,false
autoCreateTopicEnable=true
namesrvAddr=x.x.x.x:9876
  • 启动Broker 并指定刚才编辑好的broker.conf
nohup sh bin/mqbroker -n localhost:9876 -c conf/broker.conf &
# 查看日志,确认是否成功
tail -f ~/logs/rocketmqlogs/broker.log 
  • 关闭服务
# 关闭 broker
> sh bin/mqshutdown broker
The mqbroker(36695) is running...
Send shutdown request to mqbroker(36695) OK

# 关闭 namesrv
> sh bin/mqshutdown namesrv
The mqnamesrv(36664) is running...
Send shutdown request to mqnamesrv(36664) OK

3.启动rocketmq-console

  • 编辑rocketmq-console的application.properties
rocketmq.config.namesrvAddr=x.x.x.x:9876
  • 编译rocketmq-console
# 注意:不要直接使用mvn package,会提示很多错误,在rocketmq-console的目录下执行
mvn clean package -Dmaven.test.skip=true
  • 启动rocketmq-console

此时target下就有一个rocketmq-console-ng-1.0.1.jar的jar放到服务器运行即可。

nohup java -jar rocketmq-console-ng-1.0.1.jar >> console.log & 

二、使用docker部署

1.下载对应的镜像

# mq
docker pull rocketmqinc/rocketmq
# mq控制台
docker pull styletang/rocketmq-console-ng

2. 编辑docker的yml文件

相当于启动三个应用,写成docker-compose更方便些配置如下:

version: '2'
services:
  namesrv:
    image: rocketmqinc/rocketmq
    container_name: rmqnamesrv
    ports:
      - 9876:9876
    volumes:
      - D:/soft/docker-file/rocketmq/data/logs:/home/rocketmq/logs
      - D:/soft/docker-file/rocketmq/data/store:/home/rocketmq/store
    command: sh mqnamesrv
  broker:
    image: rocketmqinc/rocketmq
    container_name: rmqbroker
    ports:
      - 10909:10909
      - 10911:10911
      - 10912:10912
    volumes:
      - D:/soft/docker-file/rocketmq/data/logs:/home/rocketmq/logs
      - D:/soft/docker-file/rocketmq/data/store:/home/rocketmq/store
      - D:/soft/docker-file/rocketmq/data/conf/broker.conf:/etc/rocketmq/broker.conf
    #command: sh mqbroker -n namesrv:9876
    command: sh mqbroker -n  namesrv:9876 -c /etc/rocketmq/broker.conf
    depends_on:
      -  namesrv
    environment:
      - JAVA_HOME=/usr/lib/jvm/jre
  console:
    image: styletang/rocketmq-console-ng
    container_name: rocketmq-console-ng
    ports:
      - 8080:8080
    depends_on:
      - namesrv
    environment:
      - JAVA_OPTS= -Dlogging.level.root=info   -Drocketmq.namesrv.addr=x.x.x.x:9876 
      - Dcom.rocketmq.sendMessageWithVIPChannel=false

3.启动服务

docker-compose up -d

可能遇到的问题

无法正常启动rocketmq服务时,尝试下面命令可看到详细错误信息
sh bin/mqnamesrv
sh bin/mqbroker -n localhost:9876

上一篇:EMQ broker window10 关闭匿名,开启登录认证


下一篇:zookeeper