其他分享
首页 > 其他分享> > RocketMQ单机安装

RocketMQ单机安装

作者:互联网

[root@localhost ~]# mqbroker -n IP:9876 &    ##改成本机IP地址

  

1.环境准备   系统环境     1、操作系统:64位CentOS Linux release 7.2.1511 (Core)     2、jdk版本:     
export JAVA_HOME=/usr/java/jdk1.8.0_221
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

  

  2. 解压安装
[root@localhost data]# cd /soft
解压
[root@localhost soft]# unzip rocketmq-all-4.3.2-bin-release.zip
移动
[root@localhost soft]# mv rocketmq-all-4.3.2-bin-release /usr/local/rocketmq

  

  3.设置rocketmq的环境变量
编辑profile文件
[root@localhost rocket]# vi /etc/profile
将下面的配置添加到文件最底部
export PATH=$PATH:/usr/local/rocketmq/bin
export NAMESRV_ADDR=IP:9876                   ##手动更改为本地地址
保存,并退出。
更新profile文件
[root@localhost rocket]# source /etc/profile
说明:export NAMESRV_ADDR=localhost:9876是NAMESRV_ADDR环境变量

  

4.启动Name Server
[root@localhost rocket]# mqnamesrv &

  

  5.启动Broker [root@localhost ~]# mqbroker -n IP:9876 & ##改成本机IP地址 会遇到如下问题:
[1] 3361
[root@localhost ~]# Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000005c0000000, 8589934592, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 8589934592 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /root/hs_err_pid3368.log

  

原因是:bin/ 下的服务启动脚本 runserver.sh 、runbroker.sh 中对于内存的限制 解决办法:
[root@localhost ~]# cd /usr/local/rocketmq/bin/
[root@localhost bin]# vi runserver.sh

  

  将JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m" 改成如下: JAVA_OPT="${JAVA_OPT} -server -Xms128m -Xmx128m -Xmn128m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m"   再次启动
[root@localhost bin]# mqbroker -n IP:9876 & ##改成本机IP地址

  

会提示:
[root@localhost bin]# The broker[localhost.localdomain, 192.168.1.210:10911] boot success. serializeType=JSON and name server is localhost:9876
表示启动成功

  

  6.关闭防火墙
[root@localhost bin]# systemctl stop firewalld.service
[root@localhost bin]# systemctl disable firewalld.service               //关闭开机启动

  

  7. 关闭Name Server和Broker
[root@localhost bin]# mqshutdown broker
[root@localhost bin]# mqshutdown namesrv

  

8. 安装可视化管理界面   下载 https://github.com/apache/rocketmq-externals/tree/master/rocketmq-console   编译
mvn clean package -Dmaven.test.skip=true

  

  运行
nohup java -jar \
    -Drocketmq.config.namesrvAddr=IP:9876 \        ## 修改为本机IP地址
    -Drocketmq.config.isVIPChannel=false \
    rocketmq-console-ng-1.0.0.jar &

  

  访问 http://IP:8080/ ## 修改为本地IP    

 

 

标签:bin,JAVA,单机,安装,rocketmq,RocketMQ,9876,root,localhost
来源: https://www.cnblogs.com/NGU-PX/p/14132492.html