环境搭建
1 源码下载
wget http://mirror.bit.edu.cn/apache/rocketmq/4.2.0/rocketmq-all-4.2.0-bin-release.zip
unzip rocketmq-all-4.2.0-bin-release.zip
2 启动namesrv
cd /Users/rocketmq/bin
nohup sh mqnamesrv
&
结果出错:
cat nohup.out
OpenJDK 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
java.net.BindException: Address already in use
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:127)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:501)
at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1218)
at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:506)
at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:491)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:965)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:210)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:353)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:408)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:455)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
at java.lang.Thread.run(Thread.java:852)
ERROR: Please set the JAVA_HOME variable in your environment, We need java(x64)! !!
ERROR: Please set the JAVA_HOME variable in your environment, We need java(x64)! !!
ERROR: Please set the JAVA_HOME variable in your environment, We need java(x64)! !!
ERROR: Please set the JAVA_HOME variable in your environment, We need java(x64)! !!
和
文件,将 [ ! -e "$JAVA_HOME/bin/java" ]
&
&
JAVA_HOME=/user/java 改为 [ ! -e "$JAVA_HOME/bin/java" ]
&
&
JAVA_HOME=/opt/taobao/java
再执行命令,显示
The Name Server boot success. serializeType=JSON
说明namesrv成功了
3 启动broker
nohup sh mqbroker -n 11.162.141.67:9876
&
看nohup.out报错
/Users/rocketmq/bin/runbroker.sh: line 62: 204749 Killed $JAVA ${JAVA_OPT} $@
说明脚本执行有问题,比较脚本runbroker.sh和runserver.sh,发现这两个文件的配置有不一样
#===========================================================================================
JVM Configuration
#===========================================================================================
JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
JAVA_OPT="${JAVA_OPT} -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -XX:-UseParNewGC"
JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:/dev/shm/rmq_srv_gc.log -XX:+PrintGCDetails"
JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages"
JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib"
#JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
但是runserver.sh脚本能执行成功,
于是将runserver.sh的配置替换runbroker.sh
,再执行命令,成功了。
netstat -ano | grep "11.162.141.67:9876" tcp 0 0 11.162.141.67:50772 11.162.141.67:9876 ESTABLISHED off (0.00/0/0) tcp 0 0 11.162.141.67:9876 11.162.141.67:50772 ESTABLISHED off (0.00/0/0) 目前都是在一台机器上,既作为namesrv又作为broker。