rocketmq安装
1、安装maven3.2.x版本(其它版本可能不兼容报错),并配置环境变量
解压:tar -zxvf apache-maven-3.6.0-bin.tar.gz
重命名:mv apache-maven-3.6.0 maven
vim /etc/profile
export MAVEN_HOME=/usr/local/apache-maven-3.2.5
export PATH=$MAVEN_HOME/bin:$PATH
source /etc/profile
2、安装本地jdk1.8,并配置JAVA_HOME
export MAVEN_HOME=/usr/local/apache-maven-3.2.5
export JAVA_HOME=/usr/local/lib/jdk1.8.0_291
export PATH=$MAVEN_HOME/bin:$PATH:$JAVA_HOME/bin
3、解压rocketmq安装包
unzip rocketmq-all-4.4.0-source-release.zip
cd rocketmq-all-4.4.0/
编译打包成jar包
mvn -Prelease-all -DskipTests clean install -U
最终路径 rocketmq-all-4.4.0/distribution/target/apache-rocketmq
4、启动rocketmq的nameServer(利用nohup守护进程启动,nameserver服务默认端口为9876)
nohup sh bin/mqnamesrv &
如果报错:'Cannot allocate memory'表示本地linux环境的内存不够,修改:
bin/mqnamesrv.sh修改JAVA_OPT适合本机内存大小
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn125m"
5、启动rocketmq的broker(利用nohup守护进程启动,broker默认端口10911)
nohup sh bin/mqbroker -n localhost:9876 &
如果报错:'Cannot allocate memory'表示本地linux环境的内存不够,修改:
bin/runbroker.sh修改JAVA_OPT适合本机内存大小
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn125m"
6、关闭broker和nameServer
注:要先关闭broker再关闭nameServer,因为broker依赖于nameServer,
如果先关闭nameServer导broker找不到nameServer
sh bin/mqshutdown broker
sh bin/mqshutdown namesrv
7、测试rocketmq的生产和消费消息:
#设置名称服务地址
export NAMESRV_ADDR=localhost:9876
#投递消息
sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
#消费消息
sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
安装rocketmq可视化工具
安装rocketmq可视化工具:
1、下载 https://github.com/apache/rocketmq-externals
2、如本地:
cd /opt/rocketmq-externals/rocketmq-console
编译打包
mvn clean package -Dmaven.test.skip=true
在/opt/rocketmq-externals/rocketmq-console/target/目录生成jar包:rocketmq-console-ng-1.0.0.jar
3、启动可视化工具:
nohup java -jar rocketmq-console-ng-1.0.0.jar &
4、启动可能报错未连接broker
(1)修改配置文件:/opt/rocketmq-externals/rocketmq-console/pom.xml
解决 <rocketmq.version>4.4.0-SNAPSHOT</rocketmq.version>
改为 <rocketmq.version>4.4.0</rocketmq.version>
(2)修改配置文件:/opt/rocketmq-externals/rocketmq-console/src/main/resources/application.properties
修改:server.port=8181 {默认为8080有可能被占用}
修改:rocketmq.config.namesrvAddr=192.168.0.112:9876 {默认为空,修改为安装nameServer的IP}
(3)修改执行可能无法打开可视化页面,此时检查linux的防火墙,需要关闭
systemctl stop firewalld.service {CentOS关闭防火墙}
注:修改配置文件后需要重新mvn编译打包成jar包,然后再启动。
5、访问:
http:{安装IP}:{server.port}
其它错误:
https://blog.csdn.net/qq_14853889/article/details/81053145
https://blog.csdn.net/wangmx1993328/article/details/81588217#%E5%BC%82%E5%B8%B8%E8%AF%B4%E6%98%8E
https://www.jianshu.com/p/bfd6d849f156
https://blog.csdn.net/wangmx1993328/article/details/81588217
网友评论