RocketMQ安装及验证

1.下载

http://mirrors.tuna.tsinghua.edu.cn/apache/rocketmq/4.4.0/rocketmq-all-4.4.0-source-release.zip

2.依赖

系统:Linux、Unix、MAC、(Winodws不兼容)
JDK 1.8
Maven 3.2.X
Git

3.安装

unzip rocketmq-all-4.4.0-source-release.zip
cd rocketmq-all-4.4.0/
mvn -Prelease-all -DskipTests clean install -U
cd distribution/target/apache-rocketmq
最终路径:rocketmq-all-4.4.0/distribution/target/apache-rocketmq

4.启动

1. 启动nameServer (默认端口号9876)
	cd /usr/local/rocketmq-all-4.4.0/distribution/target/apache-rocketmq
	nohup sh bin/mqnamesrv &
3. 启动broker (默认端口号 10911)
	nohup sh bin/mqbroker -n localhost:9876 &
4. 关闭nameServer、broker命令(必须要先关闭broker,再关闭nameServer,broker依赖nameServer,先关闭nameServer会报错)
	sh bin/mqshutdown broker
	sh bin/mqshutdown namesrv

5.验证是否成功

## 设置名称服务地址
export NAMESRV_ADDR=localhost:9876
## 投递消息
sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
SendResult [sendStatus=SEND_OK, msgId= ...
## 消费消息
sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
ConsumeMessageThread_%d Receive New Messages: [MessageExt...

6.问题及解决办法

启动报内存不足错误:
	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.
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000006ec800000, 2147483648, 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 2147483648 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /usr/local/rocketmq-all-4.4.0/distribution/target/apache-rocketmq/hs_err_pid1991.log

解决办法:
1. 修改runserver.sh
vim /usr/local/rocketmq-all-4.4.0/distribution/target/apache-rocketmq/bin/runserver.sh
修改这行代码中的几个数值
JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
2. 修改 runbroker.sh
vim /usr/local/rocketmq-all-4.4.0/distribution/target/apache-rocketmq/bin/runbroker.sh
修改这行代码中的几个数值
JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512 -Xmn256m"

你可能感兴趣的:(消息队列)