centos7 安装rocketmq(quick start)

Quick Start

This quick start guide is a detailed instruction of setting up RocketMQ messaging system on your local machine to send and receive messages.

Prerequisite

The following softwares are assumed installed:

  1. 64bit OS, Linux/Unix/Mac is recommended;
  2. 64bit JDK 1.8+;   参考文章:http://www.cnblogs.com/weifeng1463/p/8874331.html
  3. Maven 3.2.x   参考文章:http://www.cnblogs.com/weifeng1463/p/8920765.html
  4. Git   参考文章:http://www.cnblogs.com/weifeng1463/p/7417977.html

Download & Build from Release

Click here to download the 4.2.0 source release. Also you could download a binary release from here.

Now execute the following commands to unpack 4.2.0 source release and build the binary artifact.

  > unzip rocketmq-all-4.2.0-source-release.zip
  > cd rocketmq-all-4.2.0/
  > mvn -Prelease-all -DskipTests clean install -U
  > cd distribution/target/apache-rocketmq

测试时本机为虚拟机2G内存 

调整相应配置

[root@compute bin]# vim runserver.sh

JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"

 

[root@compute bin]# vim runbroker.sh

JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn512m"

Start Name Server

  > nohup sh bin/mqnamesrv &
  > tail -f ~/logs/rocketmqlogs/namesrv.log
  The Name Server boot success...

Start Broker

  > nohup sh bin/mqbroker -n localhost:9876 &
  > tail -f ~/logs/rocketmqlogs/broker.log 
  The broker[%s, 172.30.30.233:10911] boot success...

Send & Receive Messages

Before sending/receiving messages, we need to tell clients the location of name servers. RocketMQ provides multiple ways to achieve this. For simplicity, we use environment variable NAMESRV_ADDR

 > 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...

Shutdown Servers

> sh bin/mqshutdown broker
The mqbroker(36695) is running...
Send shutdown request to mqbroker(36695) OK

> sh bin/mqshutdown namesrv
The mqnamesrv(36664) is running...
Send shutdown request to mqnamesrv(36664) OK


参考文章:http://rocketmq.apache.org/docs/quick-start/
posted @ 2018-04-23 21:57  Oops!#  阅读(913)  评论(0编辑  收藏  举报