meilongwhpu 2019-12-30
下载RocketMQ源码: http://mirror.bit.edu.cn/apache/rocketmq/4.4.0/rocketmq-all-4.4.0-source-release.zip
执行以下命令:
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
启动nameServer
nohup sh bin/mqnamesrv &
查看日志 tail -f nohup.out (结尾:The Name Server boot success. serializeType=JSON 表示nameServer启动成功)
启动broker(-n 指定 nameServer地址,nameServer服务端口默认为9876, broker服务默认端口为10911)
nohup sh bin/mqbroker -n localhost:9876 &
关闭nameServer,broker服务
sh bin/mqshutdown broker sh bin/mqshutdown namesrv
源码下载 git clone https://github.com/apache/rocketmq-externals cd rocketmq-console 修改配置文件,需要指定nameServer的地址 cd src/main/resources/application.properties 添加配置 rocketmq.config.namesrvAddr=127.0.0.1:9876 编译 mvn clean package -Dmaven.test.skip=true 进入编译后的目录 cd target
启动服务
nohup java -jar -Dserver.port=8088 rocketmq-console-ng-1.0.1.jar &
这里不指定端口,服务默认的端口为8080;
注意事项:
RocketMQ默认分配的内存较大,如果服务器内存不够,需要自己修改JVM参数
1.修改bin/runserver.sh
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
2.修改bin/runbroker.sh
JAVA_OPT="${JAVA_OPT} -server -Xms528m -Xmx528m -Xmn256m"