diff --git a/rocketmq-test/client/pom.xml b/rocketmq-test/client/pom.xml new file mode 100644 index 000000000..a0297adee --- /dev/null +++ b/rocketmq-test/client/pom.xml @@ -0,0 +1,18 @@ + + + 4.0.0 + + org.rmq + hello + 0.0.1-SNAPSHOT + + + org.apache.rocketmq + rocketmq-client + 4.7.0 + + + + \ No newline at end of file diff --git a/rocketmq-test/client/src/main/java/demo/ConsumerRunnable.java b/rocketmq-test/client/src/main/java/demo/ConsumerRunnable.java new file mode 100644 index 000000000..56e42c533 --- /dev/null +++ b/rocketmq-test/client/src/main/java/demo/ConsumerRunnable.java @@ -0,0 +1,77 @@ +package org.demo; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; +import org.apache.rocketmq.client.consumer.listener. ConsumeConcurrentlyContext; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; +import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; +import org.apache.rocketmq.common.consumer.ConsumeFromWhere; +import org.apache.rocketmq.common.message.MessageExt; + + + +public class ConsumerRunnable implements Runnable{ + + //private static DefaultMQPushConsumer consumer = null; + + private String url = null; + private String topicName = null; + private String tagName = null; + + public ConsumerRunnable(String url, String topicName, String tagName,int size) { + this.url = url; + this.topicName = topicName; + this.tagName = tagName; + this.size = size; + } + + + private static String createSpecificSizeString(int size){ + byte[] temp = new byte[size]; + Arrays.fill(temp, (byte)0); + String temp_str = new String(temp); + return temp_str; + } + // private static void startConsumer(String topicName) throws Exception { + // System.out.println(topicName + " " + "Start consume"); + // while (true) { + // // Wait for a message + // Message msg = consumer.receive(); + // try { + // System.out.printf(topicName + " " + Thread.currentThread().getName() + " Message from: %s\n", new String(msg.getData())); + // consumer.acknowledge(msg); + // } catch (Exception e) { + // System.err.printf("Unable to consume message: %s", e.getMessage()); + // consumer.negativeAcknowledge(msg); + // } + // } + // } + + @Override + public void run(){ + try { + DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("consumerGroup-"+topicName); + // 设置NameServer的地址 + consumer.setNamesrvAddr(url); + + // 订阅一个或者多个Topic,以及Tag来过滤需要消费的消息 + consumer.subscribe(topicName, tagName); + // 注册回调实现类来处理从broker拉取回来的消息 + consumer.registerMessageListener(new MessageListenerConcurrently() { + @Override + public ConsumeConcurrentlyStatus consumeMessage(List msgs, ConsumeConcurrentlyContext context) { + System.out.printf("%s Receive New Messages: %s %n", Thread.currentThread().getName(), msgs); + // 标记该消息已经被成功消费 + return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; + } + }); + + consumer.start(); + System.out.printf("%s Consumer Started.%n", Thread.currentThread().getName()); + }catch (Exception e){ + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/rocketmq-test/client/src/main/java/demo/ConsumerThreadPool.java b/rocketmq-test/client/src/main/java/demo/ConsumerThreadPool.java new file mode 100644 index 000000000..a7f01afda --- /dev/null +++ b/rocketmq-test/client/src/main/java/demo/ConsumerThreadPool.java @@ -0,0 +1,22 @@ +package org.demo; + + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ConsumerThreadPool { + public static void main(String[] args) { + int consumerThreadCount = 20; + int topicNumber = 20; + + String url = "localhost:9876"; + String topicName = "topic"; + String tagName = "*"; + + ExecutorService pool = Executors.newFixedThreadPool(consumerThreadCount); + for (int topicIndex = 0; topicIndex < topicNumber; topicIndex++) { + pool.submit(new ConsumerRunnable(url, topicName + Integer.toString(topicIndex), tagName)); + } + pool.shutdown(); + } +} \ No newline at end of file diff --git a/rocketmq-test/client/src/main/java/demo/ProducerRunnable.java b/rocketmq-test/client/src/main/java/demo/ProducerRunnable.java new file mode 100644 index 000000000..21a92c12d --- /dev/null +++ b/rocketmq-test/client/src/main/java/demo/ProducerRunnable.java @@ -0,0 +1,61 @@ +package org.demo; + +import org.apache.rocketmq.client.producer.DefaultMQProducer; +import org.apache.rocketmq.common.message.Message; + +import javax.swing.*; + +public class ProducerRunnable implements Runnable{ + + //private static DefaultMQProducer producer; + + private String url = null; + private String topicName = null; + private int sleepTime = 0; + private int size = 0; + + public ProducerRunnable(String url, String topicName, int sleepTime,int size) { + this.url = url; + this.topicName = topicName; + this.sleepTime = sleepTime; + this.size = size; + } + + private static String createSpecificSizeString(int size){ + byte[] temp = new byte[size]; + Arrays.fill(temp, (byte)0); + String temp_str = new String(temp); + return temp_str; + } + + private static void startProducer(String topicName,DefaultMQProducer producer) throws Exception { + System.out.println(topicName + " " + "Start produce"); + while (true) { + Message message = new Message(topicName,"TagTest",createSpecificSizeString(size).getBytes()); + long startTime = System.currentTimeMillis(); + producer.send(message); + long endTime = System.currentTimeMillis(); + System.out.println(topicName + " " + "send message in %d",endTime-startTime); + Thread.sleep(1000); + } + } + + @Override + public void run(){ + try { + //设置生产者组名 + DefaultMQProducer producer = new DefaultMQProducer("producerGroup-"+ topicName); + //指定nameServer的地址, 多个地址用分号分隔 + producer.setNamesrvAddr(url); + + //启动实例 + producer.start(); + + + + startProducer(topicName,producer); + }catch (Exception e){ + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/rocketmq-test/client/src/main/java/demo/ProducerThreadPool.java b/rocketmq-test/client/src/main/java/demo/ProducerThreadPool.java new file mode 100644 index 000000000..a130ab000 --- /dev/null +++ b/rocketmq-test/client/src/main/java/demo/ProducerThreadPool.java @@ -0,0 +1,21 @@ +package org.demo; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ProducerThreadPool { + public static void main(String[] args) { + int producerThreadNumber = 20; + int topicNumber = 20; + + String url = "localhost:9876"; + String topicName = "topic"; + int sleepTime = 1000; + + ExecutorService pool = Executors.newFixedThreadPool(producerThreadNumber); + for (int topicIndex = 0; topicIndex < topicNumber; topicIndex++) { + pool.submit(new ProducerRunnable(url, topicName + Integer.toString(topicIndex), sleepTime)); + } + pool.shutdown(); + } +} \ No newline at end of file diff --git a/rocketmq-test/client/target/classes/org/demo/ConsumerRunnable$1.class b/rocketmq-test/client/target/classes/org/demo/ConsumerRunnable$1.class new file mode 100644 index 000000000..058e42380 Binary files /dev/null and b/rocketmq-test/client/target/classes/org/demo/ConsumerRunnable$1.class differ diff --git a/rocketmq-test/client/target/classes/org/demo/ConsumerRunnable.class b/rocketmq-test/client/target/classes/org/demo/ConsumerRunnable.class new file mode 100644 index 000000000..d9836a2af Binary files /dev/null and b/rocketmq-test/client/target/classes/org/demo/ConsumerRunnable.class differ diff --git a/rocketmq-test/client/target/classes/org/demo/ConsumerThreadPool.class b/rocketmq-test/client/target/classes/org/demo/ConsumerThreadPool.class new file mode 100644 index 000000000..a64348c36 Binary files /dev/null and b/rocketmq-test/client/target/classes/org/demo/ConsumerThreadPool.class differ diff --git a/rocketmq-test/client/target/classes/org/demo/ProducerRunnable.class b/rocketmq-test/client/target/classes/org/demo/ProducerRunnable.class new file mode 100644 index 000000000..8c2b5e272 Binary files /dev/null and b/rocketmq-test/client/target/classes/org/demo/ProducerRunnable.class differ diff --git a/rocketmq-test/client/target/classes/org/demo/ProducerThreadPool.class b/rocketmq-test/client/target/classes/org/demo/ProducerThreadPool.class new file mode 100644 index 000000000..262b0f868 Binary files /dev/null and b/rocketmq-test/client/target/classes/org/demo/ProducerThreadPool.class differ diff --git a/rocketmq-test/client/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/rocketmq-test/client/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 000000000..21f532918 --- /dev/null +++ b/rocketmq-test/client/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,9 @@ +org/demo/ConsumerRunnable$1.class +hello/Hello.class +sample/RocketConsumer$1.class +org/demo/ConsumerRunnable.class +org/demo/ProducerRunnable.class +sample/RocketConsumer.class +sample/RocketProducer.class +org/demo/ConsumerThreadPool.class +org/demo/ProducerThreadPool.class diff --git a/rocketmq-test/client/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/rocketmq-test/client/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 000000000..70607a53f --- /dev/null +++ b/rocketmq-test/client/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,7 @@ +/home/sdn02/rocketmq/Client/src/main/java/demo/ProducerThreadPool.java +/home/sdn02/rocketmq/Client/src/main/java/demo/ConsumerRunnable.java +/home/sdn02/rocketmq/Client/src/main/java/demo/ConsumerThreadPool.java +/home/sdn02/rocketmq/Client/src/main/java/sample/RocketProducer.java +/home/sdn02/rocketmq/Client/src/main/java/hello/Hello.java +/home/sdn02/rocketmq/Client/src/main/java/demo/ProducerRunnable.java +/home/sdn02/rocketmq/Client/src/main/java/sample/RocketConsumer.java diff --git a/rocketmq-test/docker-rocketmq/base/Dockerfile b/rocketmq-test/docker-rocketmq/base/Dockerfile new file mode 100644 index 000000000..46f39e8cf --- /dev/null +++ b/rocketmq-test/docker-rocketmq/base/Dockerfile @@ -0,0 +1,99 @@ +# +# 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. +# + +FROM centos:7 + +RUN yum install -y java-1.8.0-openjdk-devel.x86_64 unzip gettext nmap-ncat openssl, which gnupg, telnet \ + && yum clean all -y + +# FROM openjdk:8-jdk +# RUN apt-get update && apt-get install -y --no-install-recommends \ +# bash libapr1 unzip telnet wget gnupg ca-certificates \ +# && rm -rf /var/lib/apt/lists/* + +ARG user=rocketmq +ARG group=rocketmq +ARG uid=3000 +ARG gid=3000 + +# RocketMQ is run with user `rocketmq`, uid = 3000 +# If you bind mount a volume from the host or a data container, +# ensure you use the same uid +RUN groupadd -g ${gid} ${group} \ + && useradd -u ${uid} -g ${gid} -m -s /bin/bash ${user} + +ARG version=4.7.0 + +# Rocketmq version +ENV ROCKETMQ_VERSION ${version} + +# Rocketmq home +ENV ROCKETMQ_HOME /home/rocketmq/rocketmq-${ROCKETMQ_VERSION} + +WORKDIR ${ROCKETMQ_HOME} + +RUN set -eux; \ + curl https://archive.apache.org/dist/rocketmq/${ROCKETMQ_VERSION}/rocketmq-all-${ROCKETMQ_VERSION}-bin-release.zip -o rocketmq.zip; \ + curl https://archive.apache.org/dist/rocketmq/${ROCKETMQ_VERSION}/rocketmq-all-${ROCKETMQ_VERSION}-bin-release.zip.asc -o rocketmq.zip.asc; \ + #https://www.apache.org/dist/rocketmq/KEYS + #curl https://www.apache.org/dist/rocketmq/KEYS -o KEYS; \ + \ + #gpg --import KEYS; \ + #gpg --batch --verify rocketmq.zip.asc rocketmq.zip ; \ + unzip rocketmq.zip ; \ + mv rocketmq-all*/* . ; \ + rmdir rocketmq-all* ; \ + rm -rf rocketmq.zip rocketmq.zip.asc KEYS + +# add scripts +COPY scripts/ ${ROCKETMQ_HOME}/bin/ + +RUN chown -R ${uid}:${gid} ${ROCKETMQ_HOME} + +# expose namesrv port +EXPOSE 9876 + +# add customized scripts for namesrv +RUN mv -bf ${ROCKETMQ_HOME}/bin/runserver-customize.sh ${ROCKETMQ_HOME}/bin/runserver.sh \ + && chmod a+x ${ROCKETMQ_HOME}/bin/runserver.sh \ + && chmod a+x ${ROCKETMQ_HOME}/bin/mqnamesrv + +# expose broker ports +EXPOSE 10909 10911 10912 + +# add customized scripts for broker +RUN mv -bf ${ROCKETMQ_HOME}/bin/runbroker-customize.sh ${ROCKETMQ_HOME}/bin/runbroker.sh \ + && chmod a+x ${ROCKETMQ_HOME}/bin/runbroker.sh \ + && chmod a+x ${ROCKETMQ_HOME}/bin/mqbroker \ + && ln -s ${ROCKETMQ_HOME}/bin/mqadmin /usr/local/bin/mqadmin \ + && ln -s ${ROCKETMQ_HOME}/bin/runbroker /usr/local/bin/runbroker \ + && ln -s ${ROCKETMQ_HOME}/bin/mqnamesrv /usr/local/bin/mqnamesrv \ + && ln -s ${ROCKETMQ_HOME}/bin/mqbroker /usr/local/bin/mqbroker \ + && ln -s ${ROCKETMQ_HOME}/bin/runbroker.sh /usr/local/bin/runbroker.sh \ + && ln -s ${ROCKETMQ_HOME}/bin/runserver.sh /usr/local/bin/runserver.sh \ + && ln -s ${ROCKETMQ_HOME}/bin/runbroker.sh /usr/local/bin/runbroker-customize.sh \ + && ln -s ${ROCKETMQ_HOME}/bin/runserver.sh /usr/local/bin/runserver-customize.sh + +# export Java options +RUN export JAVA_OPT=" -Duser.home=/opt" + +# Add ${JAVA_HOME}/lib/ext as java.ext.dirs +RUN sed -i 's/${JAVA_HOME}\/jre\/lib\/ext/${JAVA_HOME}\/jre\/lib\/ext:${JAVA_HOME}\/lib\/ext/' ${ROCKETMQ_HOME}/bin/tools.sh + +USER ${user} + +WORKDIR ${ROCKETMQ_HOME}/bin \ No newline at end of file diff --git a/rocketmq-test/docker-rocketmq/base/readme.md b/rocketmq-test/docker-rocketmq/base/readme.md new file mode 100644 index 000000000..a42a2c650 --- /dev/null +++ b/rocketmq-test/docker-rocketmq/base/readme.md @@ -0,0 +1,4 @@ + + + +https://github.com/apache/rocketmq-docker \ No newline at end of file diff --git a/rocketmq-test/docker-rocketmq/base/scripts/runbroker-customize.sh b/rocketmq-test/docker-rocketmq/base/scripts/runbroker-customize.sh new file mode 100644 index 000000000..18b5b5913 --- /dev/null +++ b/rocketmq-test/docker-rocketmq/base/scripts/runbroker-customize.sh @@ -0,0 +1,158 @@ +#!/bin/bash + +# 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. + +#=========================================================================================== +# Java Environment Setting +#=========================================================================================== +error_exit () +{ + echo "ERROR: $1 !!" + exit 1 +} + +find_java_home() +{ + case "`uname`" in + Darwin) + JAVA_HOME=$(/usr/libexec/java_home) + ;; + *) + JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac)))) + ;; + esac +} + +find_java_home + +[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=$HOME/jdk/java +[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/java +[ ! -e "$JAVA_HOME/bin/java" ] && error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)!" + +export JAVA_HOME +export JAVA="$JAVA_HOME/bin/java" +export BASE_DIR=$(dirname $0)/.. +export CLASSPATH=.:${BASE_DIR}/conf:${CLASSPATH} + +#=========================================================================================== +# JVM Configuration +#=========================================================================================== +calculate_heap_sizes() +{ + case "`uname`" in + Linux) + system_memory_in_mb=`free -m| sed -n '2p' | awk '{print $2}'` + system_cpu_cores=`egrep -c 'processor([[:space:]]+):.*' /proc/cpuinfo` + ;; + FreeBSD) + system_memory_in_bytes=`sysctl hw.physmem | awk '{print $2}'` + system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024` + system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'` + ;; + SunOS) + system_memory_in_mb=`prtconf | awk '/Memory size:/ {print $3}'` + system_cpu_cores=`psrinfo | wc -l` + ;; + Darwin) + system_memory_in_bytes=`sysctl hw.memsize | awk '{print $2}'` + system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024` + system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'` + ;; + *) + # assume reasonable defaults for e.g. a modern desktop or + # cheap server + system_memory_in_mb="2048" + system_cpu_cores="2" + ;; + esac + + # some systems like the raspberry pi don't report cores, use at least 1 + if [ "$system_cpu_cores" -lt "1" ] + then + system_cpu_cores="1" + fi + + # set max heap size based on the following + # max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB)) + # calculate 1/2 ram and cap to 1024MB + # calculate 1/4 ram and cap to 8192MB + # pick the max + half_system_memory_in_mb=`expr $system_memory_in_mb / 2` + quarter_system_memory_in_mb=`expr $half_system_memory_in_mb / 2` + if [ "$half_system_memory_in_mb" -gt "1024" ] + then + half_system_memory_in_mb="1024" + fi + if [ "$quarter_system_memory_in_mb" -gt "8192" ] + then + quarter_system_memory_in_mb="8192" + fi + if [ "$half_system_memory_in_mb" -gt "$quarter_system_memory_in_mb" ] + then + max_heap_size_in_mb="$half_system_memory_in_mb" + else + max_heap_size_in_mb="$quarter_system_memory_in_mb" + fi + MAX_HEAP_SIZE="${max_heap_size_in_mb}M" + + # Young gen: min(max_sensible_per_modern_cpu_core * num_cores, 1/4 * heap size) + max_sensible_yg_per_core_in_mb="100" + max_sensible_yg_in_mb=`expr $max_sensible_yg_per_core_in_mb "*" $system_cpu_cores` + + desired_yg_in_mb=`expr $max_heap_size_in_mb / 4` + + if [ "$desired_yg_in_mb" -gt "$max_sensible_yg_in_mb" ] + then + HEAP_NEWSIZE="${max_sensible_yg_in_mb}M" + else + HEAP_NEWSIZE="${desired_yg_in_mb}M" + fi +} + +calculate_heap_sizes + +# Dynamically calculate parameters, for reference. +Xms=$MAX_HEAP_SIZE +Xmx=$MAX_HEAP_SIZE +Xmn=$HEAP_NEWSIZE +MaxDirectMemorySize=$MAX_HEAP_SIZE +# Set for `JAVA_OPT`. +JAVA_OPT="${JAVA_OPT} -server -Xms${Xms} -Xmx${Xmx} -Xmn${Xmn}" +JAVA_OPT="${JAVA_OPT} -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:SurvivorRatio=8" +JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:/dev/shm/mq_gc_%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy" +JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m" +JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow" +JAVA_OPT="${JAVA_OPT} -XX:+AlwaysPreTouch" +JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=${MaxDirectMemorySize}" +JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages -XX:-UseBiasedLocking" +JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib" +#JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n" +JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}" +JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}" +echo "======================================" +echo $JAVA_OPT + +numactl --interleave=all pwd > /dev/null 2>&1 +if [ $? -eq 0 ] +then + if [ -z "$RMQ_NUMA_NODE" ] ; then + numactl --interleave=all $JAVA ${JAVA_OPT} $@ + else + numactl --cpunodebind=$RMQ_NUMA_NODE --membind=$RMQ_NUMA_NODE $JAVA ${JAVA_OPT} $@ + fi +else + $JAVA ${JAVA_OPT} $@ +fi \ No newline at end of file diff --git a/rocketmq-test/docker-rocketmq/base/scripts/runserver-customize.sh b/rocketmq-test/docker-rocketmq/base/scripts/runserver-customize.sh new file mode 100644 index 000000000..b07dc349f --- /dev/null +++ b/rocketmq-test/docker-rocketmq/base/scripts/runserver-customize.sh @@ -0,0 +1,142 @@ +#!/bin/bash + +# 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. + +#=========================================================================================== +# Java Environment Setting +#=========================================================================================== +error_exit () +{ + echo "ERROR: $1 !!" + exit 1 +} + +find_java_home() +{ + case "`uname`" in + Darwin) + JAVA_HOME=$(/usr/libexec/java_home) + ;; + *) + JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac)))) + ;; + esac +} + +find_java_home + +[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=$HOME/jdk/java +[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/java +[ ! -e "$JAVA_HOME/bin/java" ] && error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)!" + +export JAVA_HOME +export JAVA="$JAVA_HOME/bin/java" +export BASE_DIR=$(dirname $0)/.. +export CLASSPATH=.:${BASE_DIR}/conf:${CLASSPATH} + +#=========================================================================================== +# JVM Configuration +#=========================================================================================== +calculate_heap_sizes() +{ + case "`uname`" in + Linux) + system_memory_in_mb=`free -m| sed -n '2p' | awk '{print $2}'` + system_cpu_cores=`egrep -c 'processor([[:space:]]+):.*' /proc/cpuinfo` + ;; + FreeBSD) + system_memory_in_bytes=`sysctl hw.physmem | awk '{print $2}'` + system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024` + system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'` + ;; + SunOS) + system_memory_in_mb=`prtconf | awk '/Memory size:/ {print $3}'` + system_cpu_cores=`psrinfo | wc -l` + ;; + Darwin) + system_memory_in_bytes=`sysctl hw.memsize | awk '{print $2}'` + system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024` + system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'` + ;; + *) + # assume reasonable defaults for e.g. a modern desktop or + # cheap server + system_memory_in_mb="2048" + system_cpu_cores="2" + ;; + esac + + # some systems like the raspberry pi don't report cores, use at least 1 + if [ "$system_cpu_cores" -lt "1" ] + then + system_cpu_cores="1" + fi + + # set max heap size based on the following + # max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB)) + # calculate 1/2 ram and cap to 1024MB + # calculate 1/4 ram and cap to 8192MB + # pick the max + half_system_memory_in_mb=`expr $system_memory_in_mb / 2` + quarter_system_memory_in_mb=`expr $half_system_memory_in_mb / 2` + if [ "$half_system_memory_in_mb" -gt "1024" ] + then + half_system_memory_in_mb="1024" + fi + if [ "$quarter_system_memory_in_mb" -gt "8192" ] + then + quarter_system_memory_in_mb="8192" + fi + if [ "$half_system_memory_in_mb" -gt "$quarter_system_memory_in_mb" ] + then + max_heap_size_in_mb="$half_system_memory_in_mb" + else + max_heap_size_in_mb="$quarter_system_memory_in_mb" + fi + MAX_HEAP_SIZE="${max_heap_size_in_mb}M" + + # Young gen: min(max_sensible_per_modern_cpu_core * num_cores, 1/4 * heap size) + max_sensible_yg_per_core_in_mb="100" + max_sensible_yg_in_mb=`expr $max_sensible_yg_per_core_in_mb "*" $system_cpu_cores` + + desired_yg_in_mb=`expr $max_heap_size_in_mb / 4` + + if [ "$desired_yg_in_mb" -gt "$max_sensible_yg_in_mb" ] + then + HEAP_NEWSIZE="${max_sensible_yg_in_mb}M" + else + HEAP_NEWSIZE="${desired_yg_in_mb}M" + fi +} + +calculate_heap_sizes + +# Dynamically calculate parameters, for reference. +Xms=$MAX_HEAP_SIZE +Xmx=$MAX_HEAP_SIZE +Xmn=$HEAP_NEWSIZE +# Set for `JAVA_OPT`. +JAVA_OPT="${JAVA_OPT} -server -Xms${Xms} -Xmx${Xmx} -Xmn${Xmn}" +JAVA_OPT="${JAVA_OPT} -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -XX:-UseParNewGC" +JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:/dev/shm/rmq_srv_gc.log -XX:+PrintGCDetails" +JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow" +JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages" +JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib" +#JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n" +JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}" +JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}" + +$JAVA ${JAVA_OPT} $@ \ No newline at end of file diff --git a/rocketmq-test/docker-rocketmq/base/scripts/to_bytes.gawk b/rocketmq-test/docker-rocketmq/base/scripts/to_bytes.gawk new file mode 100644 index 000000000..7953981c0 --- /dev/null +++ b/rocketmq-test/docker-rocketmq/base/scripts/to_bytes.gawk @@ -0,0 +1,11 @@ +# Use gawk because gnu awk can't extract regexp groups; gawk has `match` +BEGIN { + suffixes[""]=1 + suffixes["K"]=1024 + suffixes["M"]=1024**2 + suffixes["G"]=1024**3 +} + +match($0, /([0-9.]*)([kKmMgG]?)/, a) { + printf("%d", a[1] * suffixes[toupper(a[2])]) +} \ No newline at end of file diff --git a/rocketmq-test/docker-rocketmq/broker/Dockerfile b/rocketmq-test/docker-rocketmq/broker/Dockerfile new file mode 100644 index 000000000..d46138f4e --- /dev/null +++ b/rocketmq-test/docker-rocketmq/broker/Dockerfile @@ -0,0 +1,30 @@ +# +# 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. +# + +FROM foxiswho/rocketmq:4.7.0 + +EXPOSE 10909 10911 + +#RUN mv ${ROCKETMQ_HOME}/bin/runbroker-customize.sh ${ROCKETMQ_HOME}/bin/runbroker.sh \ +# && chmod +x ${ROCKETMQ_HOME}/bin/runbroker.sh \ +# && chmod +x ${ROCKETMQ_HOME}/bin/mqbroker + +CMD cd ${ROCKETMQ_HOME}/bin \ + && ${ROCKETMQ_HOME}/bin/mqbroker -c /etc/rocketmq/broker.conf + + +# broker 配置文件位于 /etc/rocketmq/broker.conf ,具体请看 broker Dockerfile CMD启动 \ No newline at end of file diff --git a/rocketmq-test/docker-rocketmq/broker/readme.md b/rocketmq-test/docker-rocketmq/broker/readme.md new file mode 100644 index 000000000..a2eb71db6 --- /dev/null +++ b/rocketmq-test/docker-rocketmq/broker/readme.md @@ -0,0 +1,7 @@ +https://github.com/apache/rocketmq-externals/tree/master/rocketmq-docker/4.7.0/rocketmq-broker + + + +# 配置文件位置 + +/etc/rocketmq/broker.conf \ No newline at end of file diff --git a/rocketmq-test/docker-rocketmq/rmq/docker-compose.yml b/rocketmq-test/docker-rocketmq/rmq/docker-compose.yml new file mode 100644 index 000000000..ef5cb7ee5 --- /dev/null +++ b/rocketmq-test/docker-rocketmq/rmq/docker-compose.yml @@ -0,0 +1,102 @@ +version: '3.5' + +services: + rmqnamesrv: + image: foxiswho/rocketmq:4.7.0 +# image: registry.cn-hangzhou.aliyuncs.com/foxiswho/rocketmq:4.7.0 + container_name: rmqnamesrv + ports: + - 9876:9876 + volumes: + - ./rmqs/logs:/opt/logs + - ./rmqs/store:/opt/store + environment: + JAVA_OPT_EXT: "-Duser.home=/opt -Xms512M -Xmx512M -Xmn128m" + command: ["sh","mqnamesrv"] + networks: + rmq: + aliases: + - rmqnamesrv + rmqbroker: + image: foxiswho/rocketmq:4.7.0 +# image: registry.cn-hangzhou.aliyuncs.com/foxiswho/rocketmq:4.7.0 + container_name: rmqbroker + ports: + - 10909:10909 + - 10911:10911 + volumes: + - ./rmq/a/logs:/opt/logs + - ./rmq/a/store:/opt/store + - ./rmq/brokerconf/broker.conf:/etc/rocketmq/broker.conf + environment: + JAVA_OPT_EXT: "-Duser.home=/opt -Xms512M -Xmx512M -Xmn128m" + command: ["sh","mqbroker","-c","/etc/rocketmq/broker.conf","-n","rmqnamesrv:9876","autoCreateTopicEnable=true"] + depends_on: + - rmqnamesrv + networks: + rmq: + aliases: + - rmqbroker + + rmqbroker1: + image: foxiswho/rocketmq:4.7.0 +# image: registry.cn-hangzhou.aliyuncs.com/foxiswho/rocketmq:4.7.0 + container_name: rmqbroker1 + ports: + - 11909:10909 + - 11911:10911 + volumes: + - ./rmq/b/logs:/opt/logs + - ./rmq/b/store:/opt/store + - ./rmq/brokerconf/broker1.conf:/etc/rocketmq/broker.conf + environment: + JAVA_OPT_EXT: "-Duser.home=/opt -Xms512M -Xmx512M -Xmn128m" + command: ["sh","mqbroker","-c","/etc/rocketmq/broker.conf","-n","rmqnamesrv:9876","autoCreateTopicEnable=true"] + depends_on: + - rmqnamesrv + networks: + rmq: + aliases: + - rmqbroker1 + + rmqbroker2: + image: foxiswho/rocketmq:4.7.0 +# image: registry.cn-hangzhou.aliyuncs.com/foxiswho/rocketmq:4.7.0 + container_name: rmqbroker2 + ports: + - 12909:10909 + - 12911:10911 + volumes: + - ./rmq/c/logs:/opt/logs + - ./rmq/c/store:/opt/store + - ./rmq/brokerconf/broker2.conf:/etc/rocketmq/broker.conf + environment: + JAVA_OPT_EXT: "-Duser.home=/opt -Xms512M -Xmx512M -Xmn128m" + command: ["sh","mqbroker","-c","/etc/rocketmq/broker.conf","-n","rmqnamesrv:9876","autoCreateTopicEnable=true"] + depends_on: + - rmqnamesrv + networks: + rmq: + aliases: + - rmqbroker2 + + rmqconsole: + image: styletang/rocketmq-console-ng + container_name: rmqconsole + ports: + - 8180:8080 + environment: + JAVA_OPTS: "-Drocketmq.namesrv.addr=rmqnamesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" + depends_on: + - rmqnamesrv + networks: + rmq: + aliases: + - rmqconsole + + + +networks: + rmq: + name: rmq + driver: bridge \ No newline at end of file diff --git a/rocketmq-test/docker-rocketmq/rmq/readme.md b/rocketmq-test/docker-rocketmq/rmq/readme.md new file mode 100644 index 000000000..f992e9b0b --- /dev/null +++ b/rocketmq-test/docker-rocketmq/rmq/readme.md @@ -0,0 +1,23 @@ + + +docker-compose + + + +进入 本目录下,执行如下命令 +```bash +chmod +x start.sh + +./start.sh +``` + +清除 已创建的 docker +```bash +docker-compose down + +# 删除 产生的 日志及临时文件 +rm -rf ./rmqs/logs/* +rm -rf ./rmqs/store/* +rm -rf ./rmq/logs/* +rm -rf ./rmq/store/* +``` \ No newline at end of file diff --git a/rocketmq-test/docker-rocketmq/rmq/rmq/brokerconf/broker.conf b/rocketmq-test/docker-rocketmq/rmq/rmq/brokerconf/broker.conf new file mode 100644 index 000000000..55c97d5e2 --- /dev/null +++ b/rocketmq-test/docker-rocketmq/rmq/rmq/brokerconf/broker.conf @@ -0,0 +1,97 @@ +# 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. + + +#所属集群名字 +brokerClusterName=DefaultCluster + +#broker名字,注意此处不同的配置文件填写的不一样,如果在broker-a.properties使用:broker-a, +#在broker-b.properties使用:broker-b +brokerName=broker-a + +#0 表示Master,>0 表示Slave +brokerId=0 + +#nameServer地址,分号分割 +#namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876 + +#启动IP,如果 docker 报 com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <192.168.0.120:10909> failed +# 解决方式1 加上一句producer.setVipChannelEnabled(false);,解决方式2 brokerIP1 设置宿主机IP,不要使用docker 内部IP +#brokerIP1=192.168.0.253 + +#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数 +defaultTopicQueueNums=4 + +#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭 !!!这里仔细看是false,false,false +#原因下篇博客见~ 哈哈哈哈 +autoCreateTopicEnable=true + +#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭 +autoCreateSubscriptionGroup=true + +#Broker 对外服务的监听端口 +listenPort=10911 + +#删除文件时间点,默认凌晨4点 +deleteWhen=04 + +#文件保留时间,默认48小时 +fileReservedTime=120 + +#commitLog每个文件的大小默认1G +mapedFileSizeCommitLog=1073741824 + +#ConsumeQueue每个文件默认存30W条,根据业务情况调整 +mapedFileSizeConsumeQueue=300000 + +#destroyMapedFileIntervalForcibly=120000 +#redeleteHangedFileInterval=120000 +#检测物理文件磁盘空间 +diskMaxUsedSpaceRatio=88 +#存储路径 +#storePathRootDir=/home/ztztdata/rocketmq-all-4.1.0-incubating/store +#commitLog 存储路径 +#storePathCommitLog=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/commitlog +#消费队列存储 +#storePathConsumeQueue=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/consumequeue +#消息索引存储路径 +#storePathIndex=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/index +#checkpoint 文件存储路径 +#storeCheckpoint=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/checkpoint +#abort 文件存储路径 +#abortFile=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/abort +#限制的消息大小 +maxMessageSize=65536 + +#flushCommitLogLeastPages=4 +#flushConsumeQueueLeastPages=2 +#flushCommitLogThoroughInterval=10000 +#flushConsumeQueueThoroughInterval=60000 + +#Broker 的角色 +#- ASYNC_MASTER 异步复制Master +#- SYNC_MASTER 同步双写Master +#- SLAVE +brokerRole=ASYNC_MASTER + +#刷盘方式 +#- ASYNC_FLUSH 异步刷盘 +#- SYNC_FLUSH 同步刷盘 +flushDiskType=ASYNC_FLUSH + +#发消息线程池数量 +#sendMessageThreadPoolNums=128 +#拉消息线程池数量 +#pullMessageThreadPoolNums=128 diff --git a/rocketmq-test/docker-rocketmq/rmq/rmq/brokerconf/broker1.conf b/rocketmq-test/docker-rocketmq/rmq/rmq/brokerconf/broker1.conf new file mode 100644 index 000000000..158cb8272 --- /dev/null +++ b/rocketmq-test/docker-rocketmq/rmq/rmq/brokerconf/broker1.conf @@ -0,0 +1,97 @@ +# 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. + + +#所属集群名字 +brokerClusterName=DefaultCluster + +#broker名字,注意此处不同的配置文件填写的不一样,如果在broker-a.properties使用:broker-a, +#在broker-b.properties使用:broker-b +brokerName=broker-b + +#0 表示Master,>0 表示Slave +brokerId=0 + +#nameServer地址,分号分割 +#namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876 + +#启动IP,如果 docker 报 com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <192.168.0.120:10909> failed +# 解决方式1 加上一句producer.setVipChannelEnabled(false);,解决方式2 brokerIP1 设置宿主机IP,不要使用docker 内部IP +#brokerIP1=192.168.0.253 + +#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数 +defaultTopicQueueNums=4 + +#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭 !!!这里仔细看是false,false,false +#原因下篇博客见~ 哈哈哈哈 +autoCreateTopicEnable=true + +#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭 +autoCreateSubscriptionGroup=true + +#Broker 对外服务的监听端口 +listenPort=10911 + +#删除文件时间点,默认凌晨4点 +deleteWhen=04 + +#文件保留时间,默认48小时 +fileReservedTime=120 + +#commitLog每个文件的大小默认1G +mapedFileSizeCommitLog=1073741824 + +#ConsumeQueue每个文件默认存30W条,根据业务情况调整 +mapedFileSizeConsumeQueue=300000 + +#destroyMapedFileIntervalForcibly=120000 +#redeleteHangedFileInterval=120000 +#检测物理文件磁盘空间 +diskMaxUsedSpaceRatio=88 +#存储路径 +#storePathRootDir=/home/ztztdata/rocketmq-all-4.1.0-incubating/store +#commitLog 存储路径 +#storePathCommitLog=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/commitlog +#消费队列存储 +#storePathConsumeQueue=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/consumequeue +#消息索引存储路径 +#storePathIndex=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/index +#checkpoint 文件存储路径 +#storeCheckpoint=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/checkpoint +#abort 文件存储路径 +#abortFile=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/abort +#限制的消息大小 +maxMessageSize=65536 + +#flushCommitLogLeastPages=4 +#flushConsumeQueueLeastPages=2 +#flushCommitLogThoroughInterval=10000 +#flushConsumeQueueThoroughInterval=60000 + +#Broker 的角色 +#- ASYNC_MASTER 异步复制Master +#- SYNC_MASTER 同步双写Master +#- SLAVE +brokerRole=ASYNC_MASTER + +#刷盘方式 +#- ASYNC_FLUSH 异步刷盘 +#- SYNC_FLUSH 同步刷盘 +flushDiskType=ASYNC_FLUSH + +#发消息线程池数量 +#sendMessageThreadPoolNums=128 +#拉消息线程池数量 +#pullMessageThreadPoolNums=128 diff --git a/rocketmq-test/docker-rocketmq/rmq/rmq/brokerconf/broker2.conf b/rocketmq-test/docker-rocketmq/rmq/rmq/brokerconf/broker2.conf new file mode 100644 index 000000000..a80ce5e03 --- /dev/null +++ b/rocketmq-test/docker-rocketmq/rmq/rmq/brokerconf/broker2.conf @@ -0,0 +1,97 @@ +# 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. + + +#所属集群名字 +brokerClusterName=DefaultCluster + +#broker名字,注意此处不同的配置文件填写的不一样,如果在broker-a.properties使用:broker-a, +#在broker-b.properties使用:broker-b +brokerName=broker-c + +#0 表示Master,>0 表示Slave +brokerId=0 + +#nameServer地址,分号分割 +#namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876 + +#启动IP,如果 docker 报 com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <192.168.0.120:10909> failed +# 解决方式1 加上一句producer.setVipChannelEnabled(false);,解决方式2 brokerIP1 设置宿主机IP,不要使用docker 内部IP +#brokerIP1=192.168.0.253 + +#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数 +defaultTopicQueueNums=4 + +#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭 !!!这里仔细看是false,false,false +#原因下篇博客见~ 哈哈哈哈 +autoCreateTopicEnable=true + +#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭 +autoCreateSubscriptionGroup=true + +#Broker 对外服务的监听端口 +listenPort=10911 + +#删除文件时间点,默认凌晨4点 +deleteWhen=04 + +#文件保留时间,默认48小时 +fileReservedTime=120 + +#commitLog每个文件的大小默认1G +mapedFileSizeCommitLog=1073741824 + +#ConsumeQueue每个文件默认存30W条,根据业务情况调整 +mapedFileSizeConsumeQueue=300000 + +#destroyMapedFileIntervalForcibly=120000 +#redeleteHangedFileInterval=120000 +#检测物理文件磁盘空间 +diskMaxUsedSpaceRatio=88 +#存储路径 +#storePathRootDir=/home/ztztdata/rocketmq-all-4.1.0-incubating/store +#commitLog 存储路径 +#storePathCommitLog=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/commitlog +#消费队列存储 +#storePathConsumeQueue=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/consumequeue +#消息索引存储路径 +#storePathIndex=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/index +#checkpoint 文件存储路径 +#storeCheckpoint=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/checkpoint +#abort 文件存储路径 +#abortFile=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/abort +#限制的消息大小 +maxMessageSize=65536 + +#flushCommitLogLeastPages=4 +#flushConsumeQueueLeastPages=2 +#flushCommitLogThoroughInterval=10000 +#flushConsumeQueueThoroughInterval=60000 + +#Broker 的角色 +#- ASYNC_MASTER 异步复制Master +#- SYNC_MASTER 同步双写Master +#- SLAVE +brokerRole=ASYNC_MASTER + +#刷盘方式 +#- ASYNC_FLUSH 异步刷盘 +#- SYNC_FLUSH 同步刷盘 +flushDiskType=ASYNC_FLUSH + +#发消息线程池数量 +#sendMessageThreadPoolNums=128 +#拉消息线程池数量 +#pullMessageThreadPoolNums=128