title: 安装配置.md
toc: true
date: 2021-12-22 09:25:00


安装配置

RocketMQ install

Require

  1. 64bit OS, Linux/Unix/Mac is recommended;
  2. (Windows user see guide below)64bit JDK 1.8+;
  3. Maven 3.2.x;
  4. Git;
  5. 4g+ free disk for Broker server

1、Download

采用编译完好的二进制文件

登录RocketMQ官网,选择download a binary release here,从指定位置下载编译好的二进制Rocketmq

2、配置环境

2.1 Maven

安装Maven

sudo apt-get install maven

更换国内源

cp /usr/share/maven/conf/settings.xml /usr/share/maven/conf/settings.xml.backup
gedit /usr/share/maven/conf/settings.xml

备份后,替换内容如下

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

    <pluginGroups>
    </pluginGroups>

    <proxies>
    </proxies>

    <servers>
    </servers>

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

    <profiles>
        <profile>
            <id>aliyun</id>
            <!-- repositories and pluginRepositories here-->
            <repositories>
                <repository>
                    <id>nexus-aliyun</id>
                    <name>Nexus aliyun</name>
                    <url>http://maven.aliyun.com/nexus/content/groups/public</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>aliyun</activeProfile>
    </activeProfiles>
</settings>

2.2 替换文件

使用解压后的内容替换RocketMQ/bin文件

bin.zip

2.3 下载操作脚本

RocketMQ.zip

3 启动测试

3.1 修改脚本内容

修改启动脚本StartRocketMQ,sh 中路径,如果未安装可视化客户端需要注释后三行内容。5000表示RocketMQ所使用的端口号,可以根据需要进行修改。

StartRocketMQ.sh

#!/bin/bash
#修改为安装路径
cd /home/lightning/Aplications/RocketMQ
#修改为启动脚本所在路径
nohup sh bin/mqnamesrv -c /home/lightning/桌面/RocketMQ/mqnamesrv.properties > /dev/null
2> /dev/null &
nohup sh bin/mqbroker -n localhost:5000 > /dev/null 2> /dev/null &
#export NAMESRV_ADDR=localhost:5000
#cd Tools
#nohup java -jar rocketmq-console-ng-2.0.0.jar --server.port=5002 > /usr/local/bin/RocketMQ/Tools/console.log.txt &

ShutdownRocketMQ.sh

#!/bin/bash

#修改路径为安装目录
cd /home/lightning/Aplications/RocketMQ
bin/mqshutdown broker
bin/mqshutdown namesrv

3.2 测试服务是否运行正常

修改完成后在脚本目录下打开命令行

./StartRocketMQ.sh
sudo netstat -ap | grep 5000

若返回端口为5000当前的服务,说明运行正常