首页 > 其他分享 >docker-compose 安装activemq、rocketmq

docker-compose 安装activemq、rocketmq

时间:2024-09-16 21:48:41浏览次数:9  
标签:compose ## conf broker1 docker activemq rocketmq

目录结构

创建目录

#activemq目录
mkdir -p /docker/activemq/data
mkdir -p /docker/activemq/conf
#rocket目录
mkdir -p /docker/rocketmq/broker1/conf
mkdir -p /docker/rocketmq/broker1/logs
mkdir -p /docker/rocketmq/broker1/store
mkdir -p /docker/rocketmq/namesrv/logs

 赋予权限

chmod 777 /docker/activemq/data
chmod 777 /docker/activemq/conf
chmod 777 /docker/rocketmq/broker1/conf
chmod 777 /docker/rocketmq/broker1/logs
chmod 777 /docker/rocketmq/broker1/store
chmod 777 /docker/rocketmq/namesrv/logs

activemq.xml 文件内容 schedulerSupport="true" 代码开启延迟队列

<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<!-- START SNIPPET: example -->
<beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

    <!-- Allows us to use system properties as variables in this configuration file -->
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <value>file:${activemq.conf}/credentials.properties</value>
        </property>
    </bean>

    <!--
        The <broker> element is used to configure the ActiveMQ broker.
    -->
    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}" schedulerSupport="true">

        <destinationPolicy>
            <policyMap>
              <policyEntries>
                <policyEntry topic=">" >
                    <!-- The constantPendingMessageLimitStrategy is used to prevent
                         slow topic consumers to block producers and affect other consumers
                         by limiting the number of messages that are retained
                         For more information, see:

                         http://activemq.apache.org/slow-consumer-handling.html

                    -->
                  <pendingMessageLimitStrategy>
                    <constantPendingMessageLimitStrategy limit="1000"/>
                  </pendingMessageLimitStrategy>
                </policyEntry>
              </policyEntries>
            </policyMap>
        </destinationPolicy>


        <!--
            The managementContext is used to configure how ActiveMQ is exposed in
            JMX. By default, ActiveMQ uses the MBean server that is started by
            the JVM. For more information, see:

            http://activemq.apache.org/jmx.html
        -->
        <managementContext>
            <managementContext createConnector="false"/>
        </managementContext>

        <!--
            Configure message persistence for the broker. The default persistence
            mechanism is the KahaDB store (identified by the kahaDB tag).
            For more information, see:

            http://activemq.apache.org/persistence.html
        -->
        <persistenceAdapter>
            <kahaDB directory="${activemq.data}/kahadb"/>
        </persistenceAdapter>


          <!--
            The systemUsage controls the maximum amount of space the broker will
            use before disabling caching and/or slowing down producers. For more information, see:
            http://activemq.apache.org/producer-flow-control.html
          -->
          <systemUsage>
            <systemUsage>
                <memoryUsage>
                    <memoryUsage percentOfJvmHeap="70" />
                </memoryUsage>
                <storeUsage>
                    <storeUsage limit="100 gb"/>
                </storeUsage>
                <tempUsage>
                    <tempUsage limit="50 gb"/>
                </tempUsage>
            </systemUsage>
        </systemUsage>

        <!--
            The transport connectors expose ActiveMQ over a given protocol to
            clients and other brokers. For more information, see:

            http://activemq.apache.org/configuring-transports.html
        -->
        <transportConnectors>
            <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
            <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="amqp" uri="amqp://0.0.0.0:5673?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        </transportConnectors>

        <!-- destroy the spring context on shutdown to stop jetty -->
        <shutdownHooks>
            <bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" />
        </shutdownHooks>

    </broker>

    <!--
        Enable web consoles, REST and Ajax APIs and demos
        The web consoles requires by default login, you can disable this in the jetty.xml file

        Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details
    -->
    <import resource="jetty.xml"/>

</beans>
<!-- END SNIPPET: example -->

jetty-realm.properties 文件内容

## ---------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements.  See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License.  You may obtain a copy of the License at
## 
## http://www.apache.org/licenses/LICENSE-2.0
## 
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------

# Defines users that can access the web (console, demo, etc.)
# username: password [,rolename ...]
admin: 123456, admin
user: user, user

 broker.conf 文件内容(192.168.0.121需要改成自己服务器的内网ip)

# 所属集群名称,如果节点较多可以配置多个
brokerClusterName = DefaultCluster
#broker名称,master和slave使用相同的名称,表明他们的主从关系
brokerName = broker1
#0表示Master,大于0表示不同的slave
brokerId = 0
#表示几点做消息删除动作,默认是凌晨4点
deleteWhen = 04
#在磁盘上保留消息的时长,单位是小时
fileReservedTime = 48
#有三个值:SYNC_MASTER,ASYNC_MASTER,SLAVE;同步和异步表示Master和Slave之间同步数据的机制;
brokerRole = ASYNC_MASTER
#刷盘策略,取值为:ASYNC_FLUSH,SYNC_FLUSH表示同步刷盘和异步刷盘;SYNC_FLUSH消息写入磁盘后才返回成功状态,ASYNC_FLUSH不需要;
flushDiskType = ASYNC_FLUSH
# 设置broker节点所在服务器的ip地址(**这个非常重要,主从模式下,从节点会根据主节点的brokerIP2来同步数据,如果不配置,主从无法同步,brokerIP1设置为自己外网能访问的ip,服务器双网卡情况下必须配置,比如阿里云这种,主节点需要配置ip1和ip2,从节点只需要配置ip1即可)
# 此ip由使用环境决定 本机使用 127 局域网使用 192 外网使用 外网ip
brokerIP1 = 192.168.0.121
#Broker 对外服务的监听端口,
listenPort = 10911
#是否允许Broker自动创建Topic
autoCreateTopicEnable = true
#是否允许 Broker 自动创建订阅组
autoCreateSubscriptionGroup = true
#linux开启epoll
useEpollNativeSelector = true

进入docker 目录

cd /docker

编写 docker-compose.yml 文件(192.168.0.121需要改成自己服务器的内网ip或者外网ip)

version: '3.8'

services:
  activemq:
    image: apache/activemq-classic:5.18.3
    container_name: activemq
    ports:
      - "8161:8161"   # Web 控制台端口
      - "61616:61616" # JMS 端口
    volumes:
      - /docker/activemq/data:/opt/apache-activemq/data
      - /docker/activemq/conf/activemq.xml:/opt/apache-activemq/conf/activemq.xml
      - /docker/activemq/conf/jetty-realm.properties:/opt/apache-activemq/conf/jetty-realm.properties
    network_mode: "host"

  rmqnamesrv:
    image: apache/rocketmq:5.2.0
    container_name: rmqnamesrv
    ports:
      - "9876:9876"
    environment:
      JAVA_OPT: -server -Xms512m -Xmx512m
    command: sh mqnamesrv
    volumes:
      - /docker/rocketmq/namesrv/logs:/home/rocketmq/logs/rocketmqlogs
    network_mode: "host"

  rmqbroker1:
    image: apache/rocketmq:5.2.0
    container_name: rmqbroker1
    ports:
      - "10911:10911"
      - "10909:10909"
      - "10912:10912"
    environment:
      JAVA_OPT: -server -Xms512M -Xmx512M
      NAMESRV_ADDR: 192.168.0.121:9876
    # --enable-proxy 开启broker与proxy共用模式 生产部署建议将proxy单独部署
    command: sh mqbroker --enable-proxy -c /home/rocketmq/rocketmq-5.2.0/conf/broker.conf
    depends_on:
      - rmqnamesrv
    volumes:
      - /docker/rocketmq/broker1/conf/broker.conf:/home/rocketmq/rocketmq-5.2.0/conf/broker.conf
      - /docker/rocketmq/broker1/logs:/home/rocketmq/logs/rocketmqlogs
      - /docker/rocketmq/broker1/store:/home/rocketmq/store
    privileged: true
    network_mode: "host"

  rmqconsole:
    image: apacherocketmq/rocketmq-dashboard:latest
    container_name: rmqconsole
    ports:
      - "19876:19876"
    environment:
      JAVA_OPTS: -Dserver.port=19876 -Drocketmq.namesrv.addr=192.168.0.121:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false
    depends_on:
      - rmqnamesrv
    network_mode: "host"

执行命令,构建并启动容器(第一次构建的时候要等待一会)

docker-compose up -d

 浏览器输入下面地址,查看是否启动成功

http://192.168.0.121:8161/

http://192.168.0.121:19876/

标签:compose,##,conf,broker1,docker,activemq,rocketmq
From: https://blog.csdn.net/weixin_39925159/article/details/142089056

相关文章

  • ubuntu安装docker
    设置Docker的存储库AddDocker'sofficialGPGkey:sudoapt-getupdatesudoapt-getinstallca-certificatescurlsudoinstall-m0755-d/etc/apt/keyringssudocurl-fsSLhttps://download.docker.com/linux/ubuntu/gpg-o/etc/apt/keyrings/docker.ascsudoch......
  • 堪称最优秀的 Docker 可视化管理工具 ——Portainer
    随着Docker内实例越来越多,就得涉及到监控以及统计的需求:有多少个容器?运行的有几个?有哪些容器CPU使用率低?...Portainer是一款轻量级的应用,它提供了图形化界面,用于方便地管理Docker环境,包括单机环境和集群环境。‍启动与登录官网:portainer.io安装文档:https://docs.porta......
  • 初识Docker容器
    初识Docker容器1.什么是DockerDocker是一个开源的容器化平台,用于自动化部署和管理应用程序。它通过将应用程序及其所有依赖打包成一个轻量级、可移植的容器来解决传统虚拟化中的性能开销问题。Docker容器可以在任何支持Docker的环境中运行,无论是本地开发环境、测试服务器......
  • HTTP Status 404 – Not Found Docker Tomcat Image
    这没有错误,由于Docker社区提出的安全问题,它被设计为具有这样的行为。您可以在DockerHub中的Tomcat镜像官方文档中找到有关安全性的信息。根据社区请求,Webapps文档夹将移动到webapps.dist文档夹,这意味着webapps文档夹为空,并且浏览器上没有要提供的文档。这时,您会看......
  • 一步到位:通过 Docker Compose 部署 EFK 进行 Docker 日志采集
    一、EFK简介Elasticsearch:一个开源的分布式搜索和分析引擎,用于存储和查询日志数据。它是EFK的核心组件,负责高效地存储和检索日志信息。Filebeat:一个轻量级的日志采集器,主要用于将日志文件数据发送到Logstash或Elasticsearch。Filebeat设计用于高效地转发和处理日志......
  • 关于 Docker
    这是个不怎么大众的技术,因为很多时候,你事实上是没有把东西打包带走的需求的。但是,据说很多人来杭州第一个项目,研究这个事情怎么搞。well,我适应适应。 第一,概念。image镜像docker中的静态元素;container是image实例。所以原则上,一个image声称多个container,暂时理解为......
  • Docker 网络基本概念
    在之前讲Redis集群搭建的时候,我们用过一个选项--nethost​,现在就来讲讲该选项,以及Docker的网络。dockerrun-d--nameredis-node-1--nethost--privileged=true-v/data/redis/share/redis-node-1:/dataredis:6.0.8--cluster-enabledyes--appendonlyyes--port6......
  • Docker-compose:管理多个容器
    170.Docker-compose容器编排Docker-Compose是Docker公司推出的一个开源工具软件,可以管理多个Docker容器组成一个应用。用户需要定义一个YAML格式的配置文件docker-compose.yml,写好多个容器之间的调用关系。然后,只要一个命令,就能同时启动/关闭这些容器(或者说能实现对Dock......
  • docker安装prometheus+Granfan并监控容器
    docker安装普罗米修斯+Granfan并监控容器一、基本概念​1、之间的关系​prometheus与grafana之间是相辅相成的关系。作为完美的分布式监控系统的Prometheus,就想布加迪威龙一样示例和动力强劲。在猛的车也少不了仪表盘来观察。于是优雅的可视化平台Grafana出现......
  • Docker 网络和存储
    Docker的网络和存储功能是其重要的组成部分,它们分别处理容器之间的通信和数据持久化。下面我们逐一介绍Docker的网络和存储。Docker网络Docker提供了一套灵活且强大的网络选项,用于处理容器间、容器与主机及容器与外部网络的连接需求。网络类型**Bridge网络(桥接网络)**:......