docke安装rocketmq

#拉取官方的docker地址
git clone https://github.com/apache/rocketmq-docker.git
#构建镜像
cd image-build
sh build-image.sh 4.7.1 centos

版本对应可以查看官方进行匹配

#安装maven

http://maven.apache.org/download.cgi

#上传文件,解压
tar -zxvf apache-maven-3.6.3-bin.tar.gz
#编辑环境变量
vi /etc/profile
#在文件最后追加以下内容

export MAVEN_HOME=/usr/local/apache-maven-3.6.3
export PATH=$MAVEN_HOME/bin:$PATH
#环境变量生效
source /etc/profile
#查看版本
mvn -v 
#增加国内打包源
vim /usr/local/apache-maven-3.6.3/conf/settings.xml

#在里追加以下内容
 
      alimaven 
      aliyun maven   
      http://maven.aliyun.com/nexus/content/groups/public/ 
      central 
 

// 构建dashboard的镜像。
git clone https://github.com/apache/rocketmq-dashboard
cd rocketmq-dashboard
#注释目录下的插件pom.xml中的frontend-maven-plugin和maven-antrun-plugin再进行打包
#注意,如果单节点docker部署,则需要进到rocketmq-dashboard项目目录进行修改src/main/resources/application.yml文件的ip,因为默认是127.0.0.1会指向docker本身ip,导致找不到reckermq服务从而报错

mvn clean package -Dmaven.test.skip=true docker:build #打包程序并做成docker镜像
#如果报找不到java8的错误则需要进行以下命令
sudo yum install java-1.8.0-openjdk
sudo alternatives --config java
#选择需要的Java,一般是*后面的数字,一般为1
#查看镜像是否都构建完成
docker images

RockerMQ 单机部署

#创建rocketmq的数据和日志路径
mkdir -p /root/rocketmq/data/namesrv/logs
chmod 777  /root/rocketmq/data/namesrv/logs
mkdir -p /root/rocketmq/data/namesrv/store
chmod 777  /root/rocketmq/data/namesrv/store

#创建broker的数据和日志路径
mkdir -p /root/rocketmq/data/broker/logs
mkdir -p /root/rocketmq/data/broker/store
mkdir -p /root/rocketmq/etc/broker
chmod 777 /root/rocketmq/data/broker/logs
chmod 777 /root/rocketmq/data/broker/store
chmod 777 /root/rocketmq/etc/broker
#Broker配置文件创建
vi /root/rocketmq/etc/broker/broker.conf

#输入以下内容

brokerClusterName = mxsm-docker
brokerName = mxsm-docker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
# Docker环境需要设置成宿主机IP
#brokerIP1 = {docker宿主机IP}
brokerIP1 = 192.168.2.226
#安装docker-compose命令(有则不进行安装)
curl -SL https://github.com/docker/compose/releases/download/v2.7.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose

#赋予权限
chmod +x /usr/local/bin/docker-compose

#编辑文件
chmod 777  /root/rocketmq/etc/broker/broker.conf
cd  /usr/local/bin/
vi docker-compose.yml
#输入以下内容,我这里的 docker-compose为2

version: '2'
services:
  #Service for nameserver
  namesrv:
    image: apacherocketmq/rocketmq:4.7.1
    container_name: rocketmq-namesrv
    ports:
      - 9876:9876
    environment:
      - JAVA_OPT_EXT=-server -Xms256m -Xmx256m -Xmn256m
    volumes:
      - /root/rocketmq/data/namesrv/logs:/root/logs
    command: sh mqnamesrv
 
  #Service for broker
  broker:
    image: apacherocketmq/rocketmq:4.7.1
    container_name: rocketmq-broker
    links:
      - namesrv
    depends_on:
      - namesrv
    ports:
      - 10909:10909
      - 10911:10911
      - 10912:10912
    environment:
      - NAMESRV_ADDR=namesrv:9876
      - JAVA_OPT_EXT=-server -Xms512m -Xmx512m -Xmn256m
    volumes:
      - /root/rocketmq/data/broker/logs:/home/rocketmq/logs
      - /root/rocketmq/data/broker/store:/home/rocketmq/store
      - /root/rocketmq/etc/broker/broker.conf:/home/rocketmq/conf/broker.conf
    command: sh mqbroker -c /home/rocketmq/conf/broker.conf
 
  #Service for rocketmq-dashboard
  dashboard:
    image: apache/rocketmq-dashboard:1.0.0-centos
    container_name: rocketmq-dashboard
    ports:
      - 8080:8080
    links:
      - namesrv
    depends_on:
      - namesrv
    environment:
      - NAMESRV_ADDR=namesrv:9876

docker-compose -f ./docker-compose.yml up
// A code block
var foo = 'bar';
// A code block
var foo = 'bar';
// A code block
var foo = 'bar';

你可能感兴趣的:(rocketmq)