RocketMQ是一个纯Java、分布式、队列模型的开源消息中间件,前身是MetaQ,是阿里参考Kafka特点研发的一个队列模型的消息中间件,后开源给apache基金会成为了apache的顶级开源项目,具有高性能、高可靠、高实时、分布式特点。
https://github.com/apache/rocketmq/releases
64bit OS, Linux/Unix/Mac is recommended;(Windows user see guide below) 64bit JDK 1.8+; Maven 3.2.x; Git; 4g+ free disk for Broker server
进入主目录预编译
cd /rocketmq/rocketmq-rocketmq-all-4.9.0 mvn -Prelease-all -DskipTests clean install -U
需要下载的挺多的。
将maven解压打的包挪到常用路径下
cd /rocketmq/rocketmq-rocketmq-all-4.9.0/distribution/target/rocketmq-4.9.0 mv rocketmq-4.9.0/ /usr/local/
-rwxr-xr-x 1 root root 1654 Jun 21 21:49 cachedog.sh -rwxr-xr-x 1 root root 845 Jun 21 21:49 cleancache.sh -rwxr-xr-x 1 root root 1116 Jun 21 21:49 cleancache.v1.sh drwxr-xr-x 2 root root 4096 Jun 21 21:49 dledger -rwxr-xr-x 1 root root 1400 Jun 21 21:49 mqadmin -rwxr-xr-x 1 root root 1029 Jun 21 21:49 mqadmin.cmd -rwxr-xr-x 1 root root 1394 Jun 21 21:49 mqbroker -rwxr-xr-x 1 root root 1084 Jun 21 21:49 mqbroker.cmd -rwxr-xr-x 1 root root 1373 Jun 21 21:49 mqbroker.numanode0 -rwxr-xr-x 1 root root 1373 Jun 21 21:49 mqbroker.numanode1 -rwxr-xr-x 1 root root 1373 Jun 21 21:49 mqbroker.numanode2 -rwxr-xr-x 1 root root 1373 Jun 21 21:49 mqbroker.numanode3 -rwxr-xr-x 1 root root 1396 Jun 21 21:49 mqnamesrv -rwxr-xr-x 1 root root 1088 Jun 21 21:49 mqnamesrv.cmd -rwxr-xr-x 1 root root 1571 Jun 21 21:49 mqshutdown -rwxr-xr-x 1 root root 1398 Jun 21 21:49 mqshutdown.cmd -rwxr-xr-x 1 root root 2222 Jun 21 21:49 os.sh -rwxr-xr-x 1 root root 1148 Jun 21 21:49 play.cmd -rwxr-xr-x 1 root root 1008 Jun 21 21:49 play.sh -rwxr-xr-x 1 root root 772 Jun 21 21:49 README.md -rwxr-xr-x 1 root root 2230 Jun 21 21:49 runbroker.cmd -rwxr-xr-x 1 root root 3734 Jun 21 21:49 runbroker.sh -rwxr-xr-x 1 root root 1840 Jun 21 21:49 runserver.cmd -rwxr-xr-x 1 root root 4048 Jun 21 21:49 runserver.sh -rwxr-xr-x 1 root root 1156 Jun 21 21:49 setcache.sh -rwxr-xr-x 1 root root 1408 Jun 21 21:49 startfsrv.sh -rwxr-xr-x 1 root root 1634 Jun 21 21:49 tools.cmd -rwxr-xr-x 1 root root 1903 Jun 21 21:49 tools.sh
遇到问题:内存不足无法启动,修改runserver.sh配置文件
#JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m" JAVA_OPT="${JAVA_OPT} -server -Xms500m -Xmx500m -Xmn500m -XX:PermSize=128m -XX:MaxPermSize=320m"
启动nameserver
./mqnamesrv
启动mqbroker(同样要求改配置,这个默认的更大)
./mqbroker
./tools.sh org.a[ache.rocketmq.example.quickstart.Producer
遇到异常1:发送失败提示
java.lang.IllegalStateException: org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to null failed
在tools脚本中添加
export NAMESRV_ADDR=localhost:9876
遇到异常2:Broker没有连接到Server
No route info of this topic: TopicTest
重新启动broker,并且指定IP:端口
./mqbroker -n localhost:9876