rocketmq安装使用记录

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




用dd命令创建一个2G的文件(20G=1024*1024*2=20971520)


#dd if=/dev/zero of=/var/swapfile1 bs=1024 count=20971520


将它创建为Linux Swap虚拟交换文件


#mkswap /var/swapfile1


激活并使用/var/swapfile1交换文件


#swapon /var/swapfile1


可以使用free -m查看swap大小,使用swapon -s查看swap状态:


#free -m
...略过


设置系统启动后自动激活虚拟交换文件。


#vi /etc/fstab
/var/swapfile1 swap swap defaults 0 0




#rocketmq-broker jvm参数
JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g"
JAVA_OPT="${JAVA_OPT} -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:SurvivorRatio=8"
JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:/dev/shm/mq_gc_%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy"
JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
JAVA_OPT="${JAVA_OPT} -XX:+AlwaysPreTouch"
JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=1g"
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages -XX:-UseBiasedLocking"

JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib"




rocketmq下载地址:https://github.com/apache/incubator-rocketmq-externals/tree/master/rocketmq-console

下载源码后,找到配置文件application.properties,并按照自己需求进行配置。

例如:

rocketmq.config.namesrvAddr=namesrv服务地址(ip1:port;ip2:port)


在文件根目录执行命令:

mvn clean package -Dmaven.test.skip=true

然后在target目录下找到文件rocketmq-console-ng-1.0.0.jar


启动rocketmq-console,执行命令:

java -jar rocketmq-console-ng-1.0.0.jar


你可能感兴趣的:(java基础)