参考
RocketMQ官网地址
ubuntu 安装rocketmq
Linux 安装和部署rocketmq
UBUNTU安装ROCKETMQ 全过程
RocketMQ环境要求
64bit OS,linux/Unix/Max
64bit JDK 1.8+
Maven 3.2.x
Git
1、下载并构建
git clone https://github.com/apache/incubator-rocketmq.git
cd incubator-rocketmq
mvn -Prelease-all -DskipTests clean install -U
2、修改服务器内存
vim target/apache-rocketmq/bin/runbroker.sh
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn256m"
image.png
vim target/apache-rocketmq/bin/runserver.sh
JAVA_OPT="${JAVA_OPT} -server -Xmx256m -Xmx256m -Xmn256m -XX:-MetaspaceSize=256m -XX:MaxMetaspaceSize=300m"
image.png
由于RocketMQ默认配置要求很高,比如内存至少就要4个G,开发调试环境根本吃不消,所以开始启动前需要先修改这些参数。否则的话,会遇到内存分配或者不够的问题。
2.1、在brocket.conf配置文件中加入ip地址
image.pngvim brocket.conf
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
namesrvAddr=xxx.xxx.xx.xxx:9876
brokerIP1=xxx.xxx.xx.xxx
3、rocketmq服务启动
3.1第一种
启动NameServer
nohup sh mqnamesrv &
tail -f ~/logs/rocketmqlogs/namesrv.log
启动Broker
nohup sh bin/mqbroker -n localhost:9876 &
tail -f ~/logs/rocketmqlogs/broker.log
3.2 第二种
nameserver启动命令:
nohup sh bin/mqnamesrv 1>/dev/null 2>&1 &
broker启动命令:
nohup sh bin/mqbroker -n localhost:9876 1>/dev/null 2>&1 &
nohup sh bin/mqbroker -n localhost:9876 -c conf/broker.conf 1>/dev/null 2>&1 &
3.3 查看启动信息
jps (查看启动信息)
4、rocketmq服务关闭
关闭namesrv服务:sh bin/mqshutdown namesrv
关闭broker服务 :sh bin/mqshutdown broker
5、测试消息发送与接收
生产者发送消息:
export NAMESRV_ADDR=127.0.0.1:9876
sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
消费者接受消息:
export NAMESRV_ADDR=127.0.0.1:9876
sh tools.sh org.apache.rocketmq.example.quickstart.Consumer
linux安装rocketMq,测试消息发送和接收
[RocketMQ错]org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to <XXXX> failed
网友评论