当前位置:   article > 正文

RocketMQ_org.apache.rocketmq.client.exception.mqclientexcep

org.apache.rocketmq.client.exception.mqclientexception: code: 17 desc: no to

1. 设置网络 主机 时间同步

[root@localhost ~]# vi /etc/sysconfig/network
[root@localhost ~]# vi /etc/hosts
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
[root@localhost ~]# date
Sun Jun 12 14:42:31 UTC 2022
[root@localhost ~]# yum install ntp -y                                                    

Complete!
[root@localhost ~]# vi /etc/ntp.conf
[root@localhost ~]# service ntpd start
Redirecting to /bin/systemctl start ntpd.service
[root@localhost ~]# chkconfig ntpd on
Note: Forwarding request to 'systemctl enable ntpd.service'.
Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.
[root@localhost ~]# date
Sun Jun 12 14:45:16 UTC 2022

2. jdk安装

[root@localhost bin]# cd /soft
[root@localhost soft]# ll
total 198368
-rw-r--r--.  1 root root 170023183 Jun 12 11:39 jdk-8u181-linux-x64.rpm
drwxr-xr-x.  6 root root       103 Feb 22 01:25 rocketmq-4.9.3
-rw-r--r--.  1 root root  26892203 Feb 26 17:10 rocketmq-all-4.9.3-bin-release.zip
[root@localhost soft]# rpm -i jdk-8u181-linux-x64.rpm 
warning: jdk-8u181-linux-x64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Unpacking JAR files...
    tools.jar...
    plugin.jar...
    javaws.jar...
    deploy.jar...
    rt.jar...
    jsse.jar...
    charsets.jar...
    localedata.jar...
[root@localhost soft]# cd /usr/java
[root@localhost java]# ll
total 0
lrwxrwxrwx. 1 root root  16 Jun 12 12:38 default -> /usr/java/latest
drwxr-xr-x. 8 root root 258 Jun 12 12:38 jdk1.8.0_181-amd64
lrwxrwxrwx. 1 root root  28 Jun 12 12:38 latest -> /usr/java/jdk1.8.0_181-amd64
[root@localhost java]# cd default/
[root@localhost default]# ll
total 25976
drwxr-xr-x. 2 root root     4096 Jun 12 12:38 bin
-rw-r--r--. 1 root root     3244 Jul  7  2018 COPYRIGHT
drwxr-xr-x. 3 root root      132 Jun 12 12:38 include
-rw-r--r--. 1 root root  5207314 Jun 27  2018 javafx-src.zip
drwxr-xr-x. 5 root root      185 Jun 12 12:38 jre
drwxr-xr-x. 5 root root      245 Jun 12 12:38 lib
-rw-r--r--. 1 root root       40 Jul  7  2018 LICENSE
drwxr-xr-x. 4 root root       47 Jun 12 12:38 man
-rw-r--r--. 1 root root      159 Jul  7  2018 README.html
-rw-r--r--. 1 root root      424 Jul  7  2018 release
-rw-r--r--. 1 root root 21099920 Jul  7  2018 src.zip
-rw-r--r--. 1 root root   106782 Jun 27  2018 THIRDPARTYLICENSEREADME-JAVAFX.txt
-rw-r--r--. 1 root root   154222 Jul  7  2018 THIRDPARTYLICENSEREADME.txt
[root@localhost default]# vi /etc/profile
[root@localhost default]# echo $PATH
/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/soft/redis5/bin:/root/bin
[root@localhost default]# source /etc/profile
[root@localhost default]# echo $PATH
/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/soft/redis5/bin:/root/bin:/opt/soft/redis5/bin:/usr/java/default/bin
[root@localhost default]# java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
 

3. RocketMQ

3.1 namesrv

[root@localhost default]# cd /soft
[root@localhost soft]# ll
total 198368
-rw-r--r--.  1 root root 170023183 Jun 12 11:39 jdk-8u181-linux-x64.rpm
drwxr-xr-x.  6 root root       103 Feb 22 01:25 rocketmq-4.9.3
-rw-r--r--.  1 root root   3722978 Feb 26 17:10 rocketmq-all-4.9.3-source-release.zip
[root@localhost soft]# cd rocketmq-4.9.3/
[root@localhost rocketmq-4.9.3]# ll
total 40
drwxr-xr-x. 2 root root   126 Feb 22 01:25 benchmark
drwxr-xr-x. 3 root root  4096 Jun 12 12:37 bin
drwxr-xr-x. 7 root root   201 Feb 22 00:25 conf
drwxr-xr-x. 2 root root  4096 Feb 22 01:25 lib
-rw-r--r--. 1 root root 17327 Feb 22 00:25 LICENSE
-rw-r--r--. 1 root root  1338 Feb 22 00:25 NOTICE
-rw-r--r--. 1 root root  6069 Feb 22 00:25 README.md
[root@localhost rocketmq-4.9.3]# cd bin
[root@localhost bin]# ll
total 116
-rwxr-xr-x. 1 root root 1654 Feb 22 00:25 cachedog.sh
-rwxr-xr-x. 1 root root  845 Feb 22 00:25 cleancache.sh
-rwxr-xr-x. 1 root root 1116 Feb 22 00:25 cleancache.v1.sh
drwxr-xr-x. 2 root root   25 Feb 22 00:25 dledger
-rwxr-xr-x. 1 root root 2523 Feb 22 00:25 export.sh
-rwxr-xr-x. 1 root root 1400 Feb 22 00:25 mqadmin
-rwxr-xr-x. 1 root root 1029 Feb 22 00:25 mqadmin.cmd
-rwxr-xr-x. 1 root root 1394 Feb 22 00:25 mqbroker
-rwxr-xr-x. 1 root root 1084 Feb 22 00:25 mqbroker.cmd
-rwxr-xr-x. 1 root root 1373 Feb 22 00:25 mqbroker.numanode0
-rwxr-xr-x. 1 root root 1373 Feb 22 00:25 mqbroker.numanode1
-rwxr-xr-x. 1 root root 1373 Feb 22 00:25 mqbroker.numanode2
-rwxr-xr-x. 1 root root 1373 Feb 22 00:25 mqbroker.numanode3
-rwxr-xr-x. 1 root root 1396 Feb 22 00:25 mqnamesrv
-rwxr-xr-x. 1 root root 1088 Feb 22 00:25 mqnamesrv.cmd
-rwxr-xr-x. 1 root root 1571 Feb 22 00:25 mqshutdown
-rwxr-xr-x. 1 root root 1398 Feb 22 00:25 mqshutdown.cmd
-rwxr-xr-x. 1 root root 2222 Feb 22 00:25 os.sh
-rwxr-xr-x. 1 root root 1148 Feb 22 00:25 play.cmd
-rwxr-xr-x. 1 root root 1008 Feb 22 00:25 play.sh
-rwxr-xr-x. 1 root root  772 Feb 22 00:25 README.md
-rwxr-xr-x. 1 root root 2159 Feb 22 00:25 runbroker.cmd
-rwxr-xr-x. 1 root root 4528 Feb 22 00:25 runbroker.sh
-rwxr-xr-x. 1 root root 1799 Feb 22 00:25 runserver.cmd
-rwxr-xr-x. 1 root root 4093 Feb 22 00:25 runserver.sh
-rwxr-xr-x. 1 root root 1156 Feb 22 00:25 setcache.sh
-rwxr-xr-x. 1 root root 1408 Feb 22 00:25 startfsrv.sh
-rwxr-xr-x. 1 root root 1543 Feb 22 00:25 tools.cmd
-rwxr-xr-x. 1 root root 1820 Feb 22 00:25 tools.sh
[root@localhost bin]# ./mqnamesrv
Java HotSpot(TM) 64-Bit Server VM warning: Using the DefNew young collector with the CMS collector is deprecated and will likely be removed in a future release
Java HotSpot(TM) 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
The Name Server boot success. serializeType=JSON
 

3.2 broker

[root@localhost ~]# jps
2502 Jps
2430 NamesrvStartup
[root@localhost ~]# netstat -natp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      680/redis-server 12 
tcp        0      0 127.0.0.1:6380          0.0.0.0:*               LISTEN      683/redis-server 12 
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      398/rpcbind         
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      672/sshd            
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      889/master          
tcp        0      0 192.168.56.200:22       192.168.56.1:54513      ESTABLISHED 924/sshd: vagrant [ 
tcp        0     52 192.168.56.200:22       192.168.56.1:65247      ESTABLISHED 1254/sshd: vagrant  
tcp6       0      0 :::111                  :::*                    LISTEN      398/rpcbind         
tcp6       0      0 :::9876                 :::*                    LISTEN      2430/java           
tcp6       0      0 :::22                   :::*                    LISTEN      672/sshd            
tcp6       0      0 ::1:25                  :::*                    LISTEN      889/master          
[root@localhost ~]# cd /soft/rocketmq-4.9.3/
[root@localhost rocketmq-4.9.3]# ll
total 40
drwxr-xr-x. 2 root root   126 Feb 22 01:25 benchmark
drwxr-xr-x. 3 root root  4096 Jun 12 12:37 bin
drwxr-xr-x. 7 root root   201 Feb 22 00:25 conf
drwxr-xr-x. 2 root root  4096 Feb 22 01:25 lib
-rw-r--r--. 1 root root 17327 Feb 22 00:25 LICENSE
-rw-r--r--. 1 root root  1338 Feb 22 00:25 NOTICE
-rw-r--r--. 1 root root  6069 Feb 22 00:25 README.md
[root@localhost rocketmq-4.9.3]# cd bin
[root@localhost bin]# ./mqbroker -n localhost:9876 --> 注册到本机namesrv
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000005c0000000, 8589934592, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 8589934592 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /soft/rocketmq-4.9.3/bin/hs_err_pid2773.log
[root@localhost bin]# cat mqbroker
#!/bin/sh

# 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.

if [ -z "$ROCKETMQ_HOME" ] ; then
  ## resolve links - $0 may be a link to maven's home
  PRG="$0"

  # need this for relative symlinks
  while [ -h "$PRG" ] ; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '.*-> .$'`
    if expr "$link" : '/.*' > /dev/null; then
      PRG="$link"
    else
      PRG="`dirname "$PRG"`/$link"
    fi
  done

  saveddir=`pwd`

  ROCKETMQ_HOME=`dirname "$PRG"`/..

  # make it fully qualified
  ROCKETMQ_HOME=`cd "$ROCKETMQ_HOME" && pwd`

  cd "$saveddir"
fi

export ROCKETMQ_HOME

sh ${ROCKETMQ_HOME}/bin/runbroker.sh org.apache.rocketmq.broker.BrokerStartup $@
[root@localhost bin]# vi runbroker.sh  --> 本地测试调整最大内存为1g
[root@localhost bin]# ./mqbroker -n localhost:9876
The broker[localhost.localdomain, 10.0.2.15:10911] boot success. serializeType=JSON and name server is localhost:9876
 

3.3 观察

[root@localhost ~]# jps
3095 Jps
2430 NamesrvStartup
2895 BrokerStartup
[root@localhost ~]# netstat -natp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      680/redis-server 12 
tcp        0      0 127.0.0.1:6380          0.0.0.0:*               LISTEN      683/redis-server 12 
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      398/rpcbind         
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      672/sshd            
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      889/master          
tcp        0      0 192.168.56.200:22       192.168.56.1:54513      ESTABLISHED 924/sshd: vagrant [ 
tcp        0     52 192.168.56.200:22       192.168.56.1:56264      ESTABLISHED 3019/sshd: vagrant  
tcp        0      0 192.168.56.200:22       192.168.56.1:65247      ESTABLISHED 1254/sshd: vagrant  
tcp6       0      0 :::111                  :::*                    LISTEN      398/rpcbind         
tcp6       0      0 :::9876                 :::*                    LISTEN      2430/java           
tcp6       0      0 :::22                   :::*                    LISTEN      672/sshd            
tcp6       0      0 ::1:25                  :::*                    LISTEN      889/master          
tcp6       0      0 :::10909                :::*                    LISTEN      2895/java           
tcp6       0      0 :::10911                :::*                    LISTEN      2895/java           
tcp6       0      0 :::10912                :::*                    LISTEN      2895/java           
tcp6       0      0 127.0.0.1:33422         127.0.0.1:9876          ESTABLISHED 2895/java           
tcp6       0      0 127.0.0.1:9876          127.0.0.1:33422         ESTABLISHED 2430/java         

4 . 192.168.56.201 同理

[root@localhost bin]# ./mqnamesrv
Java HotSpot(TM) 64-Bit Server VM warning: Using the DefNew young collector with the CMS collector is deprecated and will likely be removed in a future release
Java HotSpot(TM) 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
The Name Server boot success. serializeType=JSON
 

[root@localhost ~]# cd /soft/rocketmq-4.9.3/bin
[root@localhost bin]# ./mqbroker -n 192.168.56.200:6379
The broker[localhost.localdomain, 10.0.2.15:10911] boot success. serializeType=JSON and name server is 192.168.56.200:6379
 

5. commitlog store

[root@localhost soft]# cd ~
[root@localhost ~]# ll
total 20
-rw-------. 1 root root 5570 Apr 30  2020 anaconda-ks.cfg
drwxr-xr-x. 3 root root   26 Jun 12 12:54 logs
-rw-------. 1 root root 5300 Apr 30  2020 original-ks.cfg
drwxr-xr-x. 5 root root  100 Jun 12 13:02 store
-rwxr-xr-x. 1 root root   73 Jun 11 04:15 test.sh
[root@localhost ~]# cd logs
[root@localhost logs]# ll
total 4
drwxr-xr-x. 2 root root 4096 Jun 12 13:02 rocketmqlogs
[root@localhost logs]# cd ~
[root@localhost ~]# cd store
[root@localhost store]# ll
total 8
-rw-r--r--. 1 root root    0 Jun 12 13:02 abort
-rw-r--r--. 1 root root 4096 Jun 12 13:43 checkpoint
drwxr-xr-x. 2 root root    6 Jun 12 13:02 commitlog
drwxr-xr-x. 2 root root  193 Jun 12 13:43 config
drwxr-xr-x. 2 root root    6 Jun 12 13:02 consumequeue
-rw-r--r--. 1 root root    4 Jun 12 13:02 lock
[root@localhost store]# cd commitlog
[root@localhost commitlog]# ll
total 0
[root@localhost commitlog]# cd .
[root@localhost commitlog]# cd ..
[root@localhost store]# cd consumequeue/
[root@localhost consumequeue]# ll
total 0


6. 代码

Simple Message Example - Apache RocketMQ

  1. @Test
  2. public void admin() throws MQClientException, RemotingException, InterruptedException {
  3. DefaultMQAdminExt admin = new DefaultMQAdminExt();
  4. admin.setNamesrvAddr("192.168.56.200:9876");
  5. admin.start();
  6. TopicList topicList = admin.fetchAllTopicList();
  7. Set<String> sets = topicList.getTopicList();
  8. sets.forEach(s -> System.out.println(s));
  9. System.out.println("topic route | info");
  10. TopicRouteData wula = admin.examineTopicRouteInfo("wula");
  11. System.out.println(wula);
  12. }
  1. SCHEDULE_TOPIC_XXXX
  2. RMQ_SYS_TRANS_HALF_TOPIC
  3. DefaultCluster_REPLY_TOPIC
  4. BenchmarkTest
  5. OFFSET_MOVED_EVENT
  6. TBW102
  7. localhost.localdomain
  8. SELF_TEST_TOPIC
  9. DefaultCluster
  10. topic route | info
  11. org.apache.rocketmq.client.exception.MQClientException: CODE: 17 DESC: No topic route info in name server for the topic: wula
  12. See http://rocketmq.apache.org/docs/faq/ for further details.
  13. at org.apache.rocketmq.client.impl.MQClientAPIImpl.getTopicRouteInfoFromNameServer(MQClientAPIImpl.java:1387)
  14. at org.apache.rocketmq.client.impl.MQClientAPIImpl.getTopicRouteInfoFromNameServer(MQClientAPIImpl.java:1357)
  15. at org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl.examineTopicRouteInfo(DefaultMQAdminExtImpl.java:333)
  16. at org.apache.rocketmq.tools.admin.DefaultMQAdminExt.examineTopicRouteInfo(DefaultMQAdminExt.java:264)
  17. at rocketmq.SimpleRocketMQ.admin(SimpleRocketMQ.java:121)
  18. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  19. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  20. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  21. at java.lang.reflect.Method.invoke(Method.java:498)
  22. at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
  23. at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  24. at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
  25. at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  26. at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
  27. at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
  28. at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
  29. at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
  30. at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
  31. at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
  32. at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
  33. at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
  34. at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
  35. at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
  36. at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
  37. at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
  38. at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:221)
  39. at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

上述结果:首次运行admin

  1. @Test
  2. public void consumerPull() throws MQClientException, IOException {
  3. DefaultLitePullConsumer consumer = new DefaultLitePullConsumer("ooxx");
  4. consumer.setNamesrvAddr("192.168.56.200:9876");
  5. consumer.start();
  6. Collection<MessageQueue> mqs = consumer.fetchMessageQueues("wula");
  7. System.out.println("queues:");
  8. mqs.forEach(messageQueue -> System.out.println(messageQueue));
  9. System.out.println("poll...");
  10. // consumer.assign(mqs);
  11. Collection<MessageQueue> queue = new ArrayList<>();
  12. queue.add(new MessageQueue("wula", "node01", 0));
  13. consumer.assign(queue);
  14. List<MessageExt> poll = consumer.poll();
  15. poll.forEach(messageExt -> System.out.println(messageExt));
  16. System.in.read();
  17. }
  18. @Test
  19. public void consumerPush() throws Exception {
  20. DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("consumer_ox");
  21. consumer.setNamesrvAddr("192.168.56.200:9876");
  22. consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
  23. consumer.subscribe("wula", "*");
  24. consumer.registerMessageListener(new MessageListenerConcurrently() {
  25. @Override
  26. public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> list, ConsumeConcurrentlyContext consumeConcurrentlyContext) {
  27. list.forEach(messageExt -> {
  28. byte[] body = messageExt.getBody();
  29. String message = new String(body);
  30. System.out.println(message);
  31. });
  32. return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
  33. }
  34. });
  35. consumer.start();
  36. // 自测 加个 无线循环或阻塞
  37. }

7. 集群

7.1 路径规划

常识理论:防火墙关闭,主机名,hosts设置

注意:主机名不要包含下划线 _  但是 - 是可以的

node01~04

4个配置文件

自动去ns上注册

store、logs文件路径的规划

[root@node01 ~]# mkdir -p /var/rocketmq/{logs,store/{commitlog,consumequeue,index}}
[root@node01 ~]# cd /var/rocketmq/
[root@node01 rocketmq]# ll
total 0
drwxr-xr-x. 2 root root  6 Jun 14 14:05 logs
drwxr-xr-x. 5 root root 56 Jun 14 14:05 store
[root@node01 rocketmq]# cd store
[root@node01 store]# ll
total 0
drwxr-xr-x. 2 root root 6 Jun 14 14:05 commitlog
drwxr-xr-x. 2 root root 6 Jun 14 14:05 consumequeue
drwxr-xr-x. 2 root root 6 Jun 14 14:05 index
[root@node01 store]# cd
[root@node01 ~]# cd /soft/rocketmq-4.9.3/conf
[root@node01 conf]# ll
total 32
drwxr-xr-x. 2 root root   118 Feb 22 00:25 2m-2s-async
drwxr-xr-x. 2 root root   118 Feb 22 00:25 2m-2s-sync
drwxr-xr-x. 2 root root    91 Feb 22 00:25 2m-noslave
drwxr-xr-x. 2 root root    27 Feb 22 00:25 acl
-rw-r--r--. 1 root root   949 Feb 22 00:25 broker.conf
drwxr-xr-x. 2 root root    72 Feb 22 00:25 dledger
-rw-r--r--. 1 root root 15362 Feb 22 00:25 logback_broker.xml
-rw-r--r--. 1 root root  3836 Feb 22 00:25 logback_namesrv.xml
-rw-r--r--. 1 root root  3761 Feb 22 00:25 logback_tools.xml
-rw-r--r--. 1 root root   834 Feb 22 00:25 tools.yml
[root@node01 conf]#  cp -r 2m-2s-sync/ 22ms-sync-bak
[root@node01 conf]# ll
total 32
drwxr-xr-x. 2 root root   118 Jun 14 14:28 22ms-sync-bak
drwxr-xr-x. 2 root root   118 Feb 22 00:25 2m-2s-async
drwxr-xr-x. 2 root root   118 Feb 22 00:25 2m-2s-sync
drwxr-xr-x. 2 root root    91 Feb 22 00:25 2m-noslave
drwxr-xr-x. 2 root root    27 Feb 22 00:25 acl
-rw-r--r--. 1 root root   949 Feb 22 00:25 broker.conf
drwxr-xr-x. 2 root root    72 Feb 22 00:25 dledger
-rw-r--r--. 1 root root 15362 Feb 22 00:25 logback_broker.xml
-rw-r--r--. 1 root root  3836 Feb 22 00:25 logback_namesrv.xml
-rw-r--r--. 1 root root  3761 Feb 22 00:25 logback_tools.xml
-rw-r--r--. 1 root root   834 Feb 22 00:25 tools.yml
[root@node01 conf]# cd 22ms-sync-bak/
[root@node01 22ms-sync-bak]# ll
total 16
-rw-r--r--. 1 root root 928 Jun 14 14:28 broker-a.properties
-rw-r--r--. 1 root root 922 Jun 14 14:28 broker-a-s.properties
-rw-r--r--. 1 root root 928 Jun 14 14:28 broker-b.properties
-rw-r--r--. 1 root root 922 Jun 14 14:28 broker-b-s.properties
 

  1. brokerClusterName=DefaultCluster
  2. #这个要主从一致
  3. brokerName=broker-a
  4. #master是0,slave是>0
  5. brokerId=0
  6. deleteWhen=04
  7. fileReservedTime=48
  8. # SYNC_MASTER,ASYNC_MASTER, SLAVE
  9. brokerRole=SYNC_MASTER
  10. # 降低机器的磁盘的IO瓶颈
  11. flushDiskType=ASYNC_FLUSH
  12. namesrvAddr=192.168.56.200:9876;192.168.56.201:9876;192.168.56.202:9876;
  13. storePathRootDir=/var/rocketmq/store
  14. storePathCommitLog=/var/rocketmq/store/commitlog
  15. storePathIndex=/var/rocketmq/store/index
  16. storePathConsumeQueue=/var/rocketmq/store/consumequeue

[root@node01 22ms-sync-bak]# vi broker-a.properties 
[root@node01 22ms-sync-bak]# vi broker-a-s.properties 
[root@node01 22ms-sync-bak]# vi broker-b.properties 
[root@node01 22ms-sync-bak]# vi broker-b-s.properties 
[root@node01 22ms-sync-bak]# pwd
/soft/rocketmq-4.9.3/conf/22ms-sync-bak
[root@node01 22ms-sync-bak]# cd /soft/rocketmq-4.9.3/conf
[root@node01 conf]# grep user.home ./*
grep: ./22ms-sync-bak: Is a directory
grep: ./2m-2s-async: Is a directory
grep: ./2m-2s-sync: Is a directory
grep: ./2m-noslave: Is a directory
grep: ./acl: Is a directory
grep: ./dledger: Is a directory
./logback_broker.xml:        <file>${user.home}/logs/rocketmqlogs/${brokerLogDir}/broker_default.log</file>
./logback_broker.xml:            <fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/${brokerLogDir}/broker_default.%i.log.gz</fileNamePattern>
./logback_broker.xml:        <file>${user.home}/logs/rocketmqlogs/${brokerLogDir}/broker.log</file>
./logback_broker.xml:            <fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/${brokerLogDir}/broker.%i.log.gz</fileNamePattern>
./logback_broker.xml:        <file>${user.home}/logs/rocketmqlogs/${brokerLogDir}/protection.log</file>
./logback_broker.xml:            <fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/${brokerLogDir}/protection.%i.log.gz</fileNamePattern>
./logback_broker.xml:        <file>${user.home}/logs/rocketmqlogs/${brokerLogDir}/watermark.log</file>
./logback_broker.xml:            <fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/${brokerLogDir}/watermark.%i.log.gz</fileNamePattern>
./logback_broker.xml:        <file>${user.home}/logs/rocketmqlogs/${brokerLogDir}/store.log</file>
./logback_broker.xml:            <fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/${brokerLogDir}/store.%i.log.gz</fileNamePattern>
./logback_broker.xml:        <file>${user.home}/logs/rocketmqlogs/${brokerLogDir}/remoting.log</file>
./logback_broker.xml:            <fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/${brokerLogDir}/remoting.%i.log.gz</fileNamePattern>
./logback_broker.xml:        <file>${user.home}/logs/rocketmqlogs/${brokerLogDir}/storeerror.log</file>
./logback_broker.xml:            <fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/${brokerLogDir}/storeerror.%i.log.gz</fileNamePattern>
./logback_broker.xml:        <file>${user.home}/logs/rocketmqlogs/${brokerLogDir}/transaction.log</file>
./logback_broker.xml:            <fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/${brokerLogDir}/transaction.%i.log.gz</fileNamePattern>
./logback_broker.xml:        <file>${user.home}/logs/rocketmqlogs/${brokerLogDir}/lock.log</file>
./logback_broker.xml:            <fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/${brokerLogDir}/lock.%i.log.gz</fileNamePattern>
./logback_broker.xml:        <file>${user.home}/logs/rocketmqlogs/${brokerLogDir}/filter.log</file>
./logback_broker.xml:            <fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/${brokerLogDir}/filter.%i.log.gz</fileNamePattern>
./logback_broker.xml:        <file>${user.home}/logs/rocketmqlogs/${brokerLogDir}/stats.log</file>
./logback_broker.xml:            <fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/${brokerLogDir}/stats.%i.log.gz</fileNamePattern>
./logback_broker.xml:        <file>${user.home}/logs/rocketmqlogs/${brokerLogDir}/commercial.log</file>
./logback_broker.xml:            <fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/${brokerLogDir}/commercial.%i.log.gz</fileNamePattern>
./logback_namesrv.xml:        <file>${user.home}/logs/rocketmqlogs/namesrv_default.log</file>
./logback_namesrv.xml:            <fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/namesrv_default.%i.log.gz</fileNamePattern>
./logback_namesrv.xml:        <file>${user.home}/logs/rocketmqlogs/namesrv.log</file>
./logback_namesrv.xml:            <fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/namesrv.%i.log.gz</fileNamePattern>
./logback_tools.xml:        <file>${user.home}/logs/rocketmqlogs/tools_default.log</file>
./logback_tools.xml:            <fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/tools_default.%i.log.gz</fileNamePattern>
./logback_tools.xml:        <file>${user.home}/logs/rocketmqlogs/tools.log</file>
./logback_tools.xml:            <fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/tools.%i.log.gz</fileNamePattern>
[root@node01 conf]# sed -i 's#${user.home}#/var/rocketmq#g' *.xml
[root@node01 conf]# grep user.home ./*
grep: ./22ms-sync-bak: Is a directory
grep: ./2m-2s-async: Is a directory
grep: ./2m-2s-sync: Is a directory
grep: ./2m-noslave: Is a directory
grep: ./acl: Is a directory
grep: ./dledger: Is a directory
[root@node01 conf]# cd /soft/rocketmq-4.9.3/bin
 

  1. nameserver:
  2. node01~node03
  3. broker
  4. node01~node02 broker-a 0,1 master slave
  5. node01:
  6. mqbroker -c /soft/rocketmq-4.9.3/conf/22ms-sync-bak/broker-a.properties
  7. node02:
  8. mqbroker -c /soft/rocketmq-4.9.3/conf/22ms-sync-bak/broker-a-s.properties
  9. node03~node04 broker-b 0,1 master slave
  10. node03:
  11. mqbroker -c /soft/rocketmq-4.9.3/conf/22ms-sync-bak/broker-b.properties
  12. node04:
  13. mqbroker -c /soft/rocketmq-4.9.3/conf/22ms-sync-bak/broker-b-s.properties

7.2 区别

brokerRole=SYNC_MASTER | ASYNC_MASTER

message.setWaitStoreMsgOK(true);

SYNC_MASTER: producer send 到 master后,master同步给slave,然后给producer返回ok

ASYNC_MASTER: producer send 到 master后,master异步给slave,并给producer返回ok

message.setWaitStoreMsgOK(false);

集群也是该sync,或者async的同步形式,只不过ok不需要等了

8.  分布式事务

不只解决自己生产消息的事务能力     --->   一批操作

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/256974
推荐阅读
相关标签
  

闽ICP备14008679号