broker服务启动失败
centos7 rocketmq5.1.4
启动broker脚本时报错:
bash
[root@cs opt]# sh /opt/rocketmq-all-5.1.4-bin-release/bin/mqbroker -c /opt/rocketmq-all-5.1.4-bin-release/conf/broker.conf
Invalid maximum direct memory size: -XX:MaxDirectMemorySize=15g
The specified size exceeds the maximum representable size.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
1
2
3
4
5
2
3
4
5
这是由于runbroker.sh
脚本的参数配置有问题:
bash
# 执行命令
cd /opt
vim /opt/rocketmq-all-5.1.4-bin-release/bin/runbroker.sh
# 具体修改位置
choose_gc_log_directory
# JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g" # 修改前
JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g" # 修改后
choose_gc_options
JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
JAVA_OPT="${JAVA_OPT} -XX:+AlwaysPreTouch"
# JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=15g" # 应该是这里的15g太大了,你根据你的服务器内存大小忘小了调整
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages -XX:-UseBiasedLocking"
#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}"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
调整后的:
bash
# 执行命令
cd /opt
vim /opt/rocketmq-all-5.1.4-bin-release/bin/runbroker.sh
# 具体修改位置
choose_gc_log_directory
# JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g" # 修改前
JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g" # 修改后
choose_gc_options
JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
JAVA_OPT="${JAVA_OPT} -XX:+AlwaysPreTouch"
# JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=15g" # 修改前
JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=512m" # 修改后
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages -XX:-UseBiasedLocking"
#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}"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
org.apache.rocketmq.client.exception.MQClientException: No route info of this topic: TopicTest See https://rocketmq.apache.org/docs/bestPractice/06FAQ for further details.
centos7 rocketmq5.1.4
我在broker的配置文件中,配置了下面两个参数:
bash
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
# 就下面这俩参数,重点是autoCreateTopicEnable参数
autoCreateTopicEnable=true
namesrvAddr=1ocalhost:9876
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
然后我开始启动broker服务,然后报错:
bash
[root@cs opt]# nohup sh /opt/rocketmq-all-5.1.4-bin-release/bin/mqbroker -c /opt/rocketmq-all-5.1.4-bin-release/conf/broker.conf &
...省略...
org.apache.rocketmq.client.exception.MQClientException: No route info of this topic: TopicTest
See https://rocketmq.apache.org/docs/bestPractice/06FAQ for further details.
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendDefaultImpl(DefaultMQProducerImpl.java:842)
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1526)
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1468)
at org.apache.rocketmq.client.producer.DefaultMQProducer.sendDirect(DefaultMQProducer.java:681)
at org.apache.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:393)
at org.apache.rocketmq.example.quickstart.Producer.main(Producer.java:78)
org.apache.rocketmq.client.exception.MQClientException: No route info of this topic: TopicTest
See https://rocketmq.apache.org/docs/bestPractice/06FAQ for further details.
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendDefaultImpl(DefaultMQProducerImpl.java:842)
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1526)
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1468)
at org.apache.rocketmq.client.producer.DefaultMQProducer.sendDirect(DefaultMQProducer.java:681)
at org.apache.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:393)
at org.apache.rocketmq.example.quickstart.Producer.main(Producer.java:78)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
说是无法自动创建topic,但我们在配置文件中明明指定了autoCreateTopicEnable=true
,就很神奇。
解决办法是,在启动命令中添加上autoCreateTopicEnable=true
参数,就好了。
bash
# 先把原先的broker服务停掉
nohup sh /opt/rocketmq-all-5.1.4-bin-release/bin/mqbroker -c /opt/rocketmq-all-5.1.4-bin-release/conf/broker.conf -n localhost:9876 autoCreateTopicEnable=true &
1
2
3
4
2
3
4
但明明配置文件中声明了,可以通过这个命令查看sh /opt/rocketmq-all-5.1.4-bin-release/bin/mqbroker -m
,但就是却不好使,我也不知道为啥。