美文网首页
CentOS7安装RocketMQ

CentOS7安装RocketMQ

作者: JBryan | 来源:发表于2020-04-17 21:52 被阅读0次

1、安装maven

maven下载地址:http://archive.apache.org/dist/maven/maven-3/3.6.0/binaries/
下载apache-maven-3.6.0-bin.tar.gz到本地,然后上传到云服务器/usr/local路径下
解压:

tar -zxvf apache-maven-3.6.0-bin.tar.gz

重命名:

mv apache-maven-3.6.0 maven

打开profile文件

vim /etc/profile

在文件的最下方添加:

export PATH=/usr/local/maven/bin:$PATH

立刻生效:

source /etc/profile

查看maven版本,检查是否安装成功:

[root@iZbp1fk51wcf50rx5ngu9qZ rocketmq-all-4.4.0]#  mvn -version
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T02:41:47+08:00)
Maven home: /usr/local/maven
Java version: 1.8.0_231, vendor: Oracle Corporation, runtime: /usr/local/java/jdk1.8.0_231/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-514.26.2.el7.x86_64", arch: "amd64", family: "unix"

修改maven的镜像仓库

[root@localhost maven]# cd conf
[root@localhost conf]# vi settings.xml

<mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->

       <mirror>
          <id>alimaven</id>
          <name>aliyun maven</name>
          <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
          <mirrorOf>central</mirrorOf>
        </mirror>

  </mirrors>

2、安装RocketMQ

进入/usr/local文件夹

cd /usr/local/

下载地址RocketMQ:http://rocketmq.apache.org/docs/quick-start/
下载rocketmq-all-4.4.0-source-release.zip以后,上传至/usr/local/路径下。
安装unzip工具

yum install unzip

解压

unzip rocketmq-all-4.4.0-source-release.zip

进入安装目录

cd rocketmq-all-4.4.0/

使用maven编译安装

mvn -Prelease-all -DskipTests clean install -U

这个过程比较久,可以先找点其他事情干等他跑完。

进入apache-rocketmq文件夹

cd distribution/target/apache-rocketmq

启动NameServer

[root@iZbp1fk51wcf50rx5ngu9qZ apache-rocketmq]# sh bin/mqnamesrv
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:
# /usr/local/rocketmq-all-4.4.0/distribution/target/apache-rocketmq/hs_err_pid26882.log

RocketMQ的NameServer默认内存是4G,我这里内存不够,需要修改一下默认内存。
打开配置文件

vim bin/runserver.sh

修改JAVA_OPT

JAVA_OPT="${JAVA_OPT} -server -Xms128m -Xmx128m -Xmn128m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m"

启动NameServer:

//守护进程启动
nohup sh bin/mqnamesrv &

同样,启动Broker也会内存不足
进入配置文件

vi bin/runbroker.sh

修改配置文件

JAVA_OPT="${JAVA_OPT} -server -Xms128m -Xmx128m -Xmn128m"

启动Broker:

//守护进程启动
nohup sh bin/mqbroker -n localhost:9876 &

3、安装RocketMQ管控台

源码链接: https://pan.baidu.com/s/1BTiD69E9H1-84-THzITcaA 提取码: wid2
进入/usr/local文件夹

cd /usr/local

上传管控台项目,然后解压

unzip rocketmq-externals-master.zip

进入管控台,然后进入rocketmq-console目录

cd rocketmq-externals-master
cd rocketmq-console

打开application.properties

cd src/main/resources
vi application.properties

修改下面这一行

rocketmq.config.namesrvAddr=127.0.0.1:9876

退出到rocketmq-console目录

[root@iZbp1fk51wcf50rx5ngu9qZ rocketmq-console]#

进行编译

mvn clean package -Dmaven.test.skip=true

进入target目录,启动java -jar rocketmq-console-ng-1.0.0.jar

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

守护进程方式启动

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

相关文章

网友评论

      本文标题:CentOS7安装RocketMQ

      本文链接:https://www.haomeiwen.com/subject/esjuvhtx.html