官方网站:http://rocketmq.apache.org
GitHub 下载:https://github.com/apache/rocketmq
下载完成后,上传到 linux 系统中,我这边是上传到 /home/rocketmq/ 下
unzip rocketmq-master.zip
这一步我以前写过博客,说过,下面贴上链接
Linux下jdk,maven,tomacat和mysql的安装 : https://blog.csdn.net/qq_40230026/article/details/108352990?spm=1001.2014.3001.5501
进入进入rocketmq主目录编译项目,编译过程中需要几分钟,耐心等待
mvn -Prelease-all -DskipTests clean install -U
编译成功:
来到编译好的文件夹下,在 /rocketmq-master/distribution/target/ 下,能看到编译好的包
cd distribution/target/rocketmq-4.7.1
我一般喜欢在 /usr/local/ 去运行,因此把它移动出来
mv rocketmq-4.7.1 /usr/local/
里面默认的参数都很大,如果你的虚拟机分配的内存很小,会报错
进入到rocketmq 的 bin 目录中,先查看 runserver.sh
cd rocketmq-4.7.1/
ls
cd bin/
ls
vi runserver.sh
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=100m"
vi runbroker.sh
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m"
bin
目录下执行
./mqnamesrv
bin
目录下执行
./mqbroker
tool.sh
脚本执行测试程序在bin
目录下执行
./tools.sh org.apache.rocketmq.example.quickstart.Producer
但我在执行时,报错了,内存分配不足:
于是修改 tools.sh 的jvm 参数,同上修改参数
vi tools.sh
修改成下面的参数:
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=64m"
重新尝试命令
./tools.sh org.apache.rocketmq.example.quickstart.Producer
报错 connect to null failed
原因:不知道nameserver
在哪儿
打开tools
脚本
vi tools.sh
添加下面的语句
export NAMESRV_ADDR=localhost:9876
保存后再次执行命令
./tools.sh org.apache.rocketmq.example.quickstart.Producer
还是报错
原因是:与刚才启动的broker 有关了找不到 nameServer,需要去nameServer 注册,重启 broker
./mqbroker -n localhost:9876
./tools.sh org.apache.rocketmq.example.quickstart.Producer
**原因:**网络不好或maven仓库服务器出错
重试即可,或者欢迎镜像仓库
./tools.sh org.apache.rocketmq.example.quickstart.Producer
22:49:02.470 [main] DEBUG i.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
java.lang.IllegalStateException: org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to
null failed
**原因:**不知道nameserver
在哪儿
在tools
脚本中添加
export NAMESRV_ADDR=localhost:9876
**原因:**jvm启动初始化内存分配大于物理内存
[root@node-113b bin]# ./mqbroker -n localhost:9876
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:
# /usr/local/rocketmq/bin/hs_err_pid1997.log
修改启动脚本中的jvm参数
runbroker.sh
broker
runserver.sh
nameserver
默认数值给的都很大,改小即可
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=100m"
JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn128m"
[root@node-113b bin]# ./mqbroker -n localhost:9876
22:30:42.307 [main] ERROR RocketmqCommon - Failed to obtain the host name
java.net.UnknownHostException: node-113b: node-113b: No address associated with hostname
at java.net.InetAddress.getLocalHost(InetAddress.java:1505) ~[na:1.8.0_181]
at org.apache.rocketmq.common.BrokerConfig.localHostName(BrokerConfig.java:189) [rocketmq-common-4.6
.1.jar:4.6.1] at org.apache.rocketmq.common.BrokerConfig.(BrokerConfig.java:38) [rocketmq-common-4.6.1.jar:4
.6.1] at org.apache.rocketmq.broker.BrokerStartup.createBrokerController(BrokerStartup.java:110) [rocketmq
-broker-4.6.1.jar:4.6.1] at org.apache.rocketmq.broker.BrokerStartup.main(BrokerStartup.java:58) [rocketmq-broker-4.6.1.jar:4
.6.1]Caused by: java.net.UnknownHostException: node-113b: No address associated with hostname
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) ~[na:1.8.0_181]
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928) ~[na:1.8.0_181]
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323) ~[na:1.8.0_181]
at java.net.InetAddress.getLocalHost(InetAddress.java:1500) ~[na:1.8.0_181]
... 4 common frames omitted
The broker[DEFAULT_BROKER, 192.168.150.213:10911] boot success. serializeType=JSON and name server is localh
ost:9876
**原因:**无法解析当前的主机名
hosts里添加映射即可
ip地址 node-113b
进入到 修改/conf/broker.conf
namesrvAddr=服务器外网IP:9876
brokerIP1=服务器外网IP
修改完成后重启 broker, ./mqbroker -n localhost:9876 -c ../conf/broker.conf
gitHub 地址:https://github.com/apache/rocketmq-externals
观察是否有 rocketmq -console ,有的话下载,因为我最近登录,发现找不到了
这里提供一个链接(需要一点积分):https://download.csdn.net/download/qq_40230026/12797346?spm=1001.2014.3001.5503
下载下来,上传到 linux 服务器
unzip rocketmq-externals-master.zip
cd rocketmq-console
ls
mvn clean package -Dmaven.test.skip=true
编译成功后,进入 target 文件夹,能看到一个 springboot jar 包 ,可以将 jar 包移动到 /usr/local/ 下(个人习惯)
cd target/
mv rocketmq-console-ng-1.0.1.jar /usr/local/
java -jar rocketmq-console-ng-1.0.1.jar --rocketmq.config.namesrvAddr=127.0.0.1:9876