RocketMQ版本: 4.5.0.RELEASE .
下载页面: download.html

步骤

  • 解压文件

    1. [chen@iZbp11om21c05wzu8e4tx0Z rocket]$ unzip rocketmq-all-4.5.0-bin-release.zip
    2. [chen@iZbp11om21c05wzu8e4tx0Z rocket]$ pwd
    3. /home/chen/rocket
  • 设置ROCKETMQ_HOME ```bash vim ~/.bash_profile

export ROCKETMQ_HOME=/home/chen/rocket/rocketmq-all-4.5.0-bin-release

如果没有设置JAVA_HOME. 还需要设置JAVA_HOME,找到java地址

[chen@iZbp11om21c05wzu8e4tx0Z rocket]$ whereis java java: /usr/bin/java /usr/lib/java /etc/java /usr/share/java /usr/share/man/man1/java.1.gz [chen@iZbp11om21c05wzu8e4tx0Z rocket]$ ll /usr/bin/java lrwxrwxrwx 1 root root 22 12月 18 20:54 /usr/bin/java -> /etc/alternatives/java [chen@iZbp11om21c05wzu8e4tx0Z rocket]$ ll /etc/alternatives/java lrwxrwxrwx 1 root root 73 12月 18 20:54 /etc/alternatives/java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-0.el7_7.x86_64/jre/bin/java [chen@iZbp11om21c05wzu8e4tx0Z rocket]$

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-0.el7_7.x86_64

  1. - 编辑broker.conf文件
  2. > /home/chen/rocket/rocketmq-all-4.5.0-bin-release/conf
  3. - 设置内存,分别启动NameServer & Broker . 高配机器请无视我. 因为是测试,在加上自己机器只是一台1C2G的机器.
  4. > vim runserver.sh
  5. ![image.png](https://cdn.nlark.com/yuque/0/2020/png/191132/1586529879629-00e8352c-0897-4e78-b2b4-1330d74772f8.png#align=left&display=inline&height=395&name=image.png&originHeight=790&originWidth=2878&size=1284605&status=done&style=none&width=1439)
  6. > vim runbroker.sh
  7. ![image.png](https://cdn.nlark.com/yuque/0/2020/png/191132/1586529975395-1ec0bf5e-1b7e-4779-81b5-aec5cf35f1d4.png#align=left&display=inline&height=406&name=image.png&originHeight=812&originWidth=2878&size=1380391&status=done&style=none&width=1439)
  8. - nohup 启动NameServer && Broker
  9. <a name="RAPX5"></a>
  10. ### 命令
  11. <a name="NKuUR"></a>
  12. #### 增加TOPIC
  13. ```bash
  14. [chen@iZbp11om21c05wzu8e4tx0Z bin]$ sh mqadmin updateTopic --help
  15. usage: mqadmin updateTopic -b <arg> | -c <arg> [-h] [-n <arg>] [-o <arg>] [-p <arg>] [-r <arg>] [-s <arg>] -t
  16. <arg> [-u <arg>] [-w <arg>]
  17. -b,--brokerAddr <arg> create topic to which broker
  18. -c,--clusterName <arg> create topic to which cluster
  19. -h,--help Print help
  20. -n,--namesrvAddr <arg> Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876
  21. -o,--order <arg> set topic's order(true|false)
  22. -p,--perm <arg> set topic's permission(2|4|6), intro[2:W 4:R; 6:RW]
  23. -r,--readQueueNums <arg> set read queue nums
  24. -s,--hasUnitSub <arg> has unit sub (true|false)
  25. -t,--topic <arg> topic name
  26. -u,--unit <arg> is unit topic (true|false)
  27. -w,--writeQueueNums <arg> set write queue nums

sh mqadmin updateTopic -b 172.16.254.90:10911 -n 172.16.254.90:9876 -t chenshun-test

查看TOPIC

出现 CODE: 17 DESC: No topic route info in name server for the topic: xxx 错误时可以使用一波

  1. [chen@iZbp11om21c05wzu8e4tx0Z bin]$ sh mqadmin topicRoute -n 172.16.254.90:9876 -t logx
  2. {
  3. "brokerDatas":[
  4. {
  5. "brokerAddrs":{0:"172.16.254.90:10911"
  6. },
  7. "brokerName":"broker-a",
  8. "cluster":"DefaultCluster"
  9. }
  10. ],
  11. "filterServerTable":{},
  12. "queueDatas":[
  13. {
  14. "brokerName":"broker-a",
  15. "perm":6,
  16. "readQueueNums":8,
  17. "topicSynFlag":0,
  18. "writeQueueNums":8
  19. }
  20. ]
  21. }

sh mqadmin topicRoute -n 172.16.254.90:9876 -t chenshun-test