RocketMQ版本: 4.5.0.RELEASE .
下载页面: download.html
步骤
解压文件
[chen@iZbp11om21c05wzu8e4tx0Z rocket]$ unzip rocketmq-all-4.5.0-bin-release.zip
[chen@iZbp11om21c05wzu8e4tx0Z rocket]$ pwd
/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
- 编辑broker.conf文件
> /home/chen/rocket/rocketmq-all-4.5.0-bin-release/conf
- 设置内存,分别启动NameServer & Broker . 高配机器请无视我. 因为是测试,在加上自己机器只是一台1C2G的机器.
> vim runserver.sh
![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)
> vim runbroker.sh
![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)
- nohup 启动NameServer && Broker
<a name="RAPX5"></a>
### 命令
<a name="NKuUR"></a>
#### 增加TOPIC
```bash
[chen@iZbp11om21c05wzu8e4tx0Z bin]$ sh mqadmin updateTopic --help
usage: mqadmin updateTopic -b <arg> | -c <arg> [-h] [-n <arg>] [-o <arg>] [-p <arg>] [-r <arg>] [-s <arg>] -t
<arg> [-u <arg>] [-w <arg>]
-b,--brokerAddr <arg> create topic to which broker
-c,--clusterName <arg> create topic to which cluster
-h,--help Print help
-n,--namesrvAddr <arg> Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876
-o,--order <arg> set topic's order(true|false)
-p,--perm <arg> set topic's permission(2|4|6), intro[2:W 4:R; 6:RW]
-r,--readQueueNums <arg> set read queue nums
-s,--hasUnitSub <arg> has unit sub (true|false)
-t,--topic <arg> topic name
-u,--unit <arg> is unit topic (true|false)
-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 错误时可以使用一波
[chen@iZbp11om21c05wzu8e4tx0Z bin]$ sh mqadmin topicRoute -n 172.16.254.90:9876 -t logx
{
"brokerDatas":[
{
"brokerAddrs":{0:"172.16.254.90:10911"
},
"brokerName":"broker-a",
"cluster":"DefaultCluster"
}
],
"filterServerTable":{},
"queueDatas":[
{
"brokerName":"broker-a",
"perm":6,
"readQueueNums":8,
"topicSynFlag":0,
"writeQueueNums":8
}
]
}
sh mqadmin topicRoute -n 172.16.254.90:9876 -t chenshun-test