原创

Java编译安装RocketMQ

1.安装

0.介绍

  1. quan全网最全编译安装文章
  2. 包含编译过程中所有报错解决
  3. 你要是编译不成功你可以来打我
  4. 纯采坑原创!

1.源码地址

https://github.com/apache/rocketmq

2.源码编译

1.环境准备

  1. jdk8
  2. maven3.x

2.编译参数VM Options

由于编译内存超大加上以及源码带有测试用例编译不过需要加以下参数到 idea ->Maven->Runner即可

-Dmaven.test.skip=true  -DskipTests=true -server -Xms328m -Xmx1024m -XX:PermSize=128m -XX:MaxNewSize=556m -XX:MaxPermSize=1024m

3.修改源码rocketmq-distribution模块下的pom.xml

解决报错!! maven-assembly-plugin:3.0.0:single failed: group id '1603212982' is too big ( > 2097151 )

"修改maven-assembly-plugin插件"
加上配置
<configuration>
    <descriptors>
        <descriptor>src/assembly/distribution.xml</descriptor>
    </descriptors>
    <tarLongFileMode>posix</tarLongFileMode>
    <outputDirectory>${project.build.directory}</outputDirectory>
    <appendAssemblyId>false</appendAssemblyId>
</configuration><plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <executions>
        <execution>
            <id>release-all</id>
            <goals>
                <goal>single</goal>
            </goals>
            <phase>package</phase>
            <configuration>
                <descriptors>
                    <descriptor>release.xml</descriptor>
                </descriptors>
                <appendAssemblyId>false</appendAssemblyId>
            </configuration>
        </execution>
    </executions>
</plugin>

"修改为"

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <executions>
        <execution>
            <id>release-all</id>
            <goals>
                <goal>single</goal>
            </goals>
            <phase>package</phase>
            <configuration>
                <descriptors>
                    <descriptor>release.xml</descriptor>
                </descriptors>
                <appendAssemblyId>false</appendAssemblyId>
            </configuration>
        </execution>
    </executions>
    <configuration>
        <descriptors>
            <descriptor>src/assembly/distribution.xml</descriptor>
        </descriptors>
        <tarLongFileMode>posix</tarLongFileMode>
        <outputDirectory>${project.build.directory}</outputDirectory>
        <appendAssemblyId>false</appendAssemblyId>
    </configuration>
</plugin>

总共有2处都需要修改 不然会报错

Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:3.0.0:single (release-all) on project rocketmq-distribution: Execution release-all of goal rg.apache.maven.plugins:maven-assembly-plugin:3.0.0:single failed: group id '1603212982' is too big ( > 2097151 ).

3.编译安装(编译package -P release-all)

INFO] Deleting /Users/lishihao/Desktop/github/rocketmq/test/target
[INFO] 
[INFO] -------------< org.apache.rocketmq:rocketmq-distribution >--------------
[INFO] Building rocketmq-distribution 4.5.2 4.5.2                       [17/17]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ rocketmq-distribution ---
[INFO] Deleting /Users/lishihao/Desktop/github/rocketmq/distribution/target
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Apache RocketMQ 4.5.2 4.5.2 ........................ SUCCESS [  1.123 s]
[INFO] rocketmq-logging 4.5.2 ............................. SUCCESS [  0.026 s]
[INFO] rocketmq-remoting 4.5.2 ............................ SUCCESS [  0.035 s]
[INFO] rocketmq-common 4.5.2 .............................. SUCCESS [  0.071 s]
[INFO] rocketmq-client 4.5.2 .............................. SUCCESS [  0.055 s]
[INFO] rocketmq-store 4.5.2 ............................... SUCCESS [  0.035 s]
[INFO] rocketmq-srvutil 4.5.2 ............................. SUCCESS [  0.015 s]
[INFO] rocketmq-filter 4.5.2 .............................. SUCCESS [  0.046 s]
[INFO] rocketmq-acl 4.5.2 ................................. SUCCESS [  0.020 s]
[INFO] rocketmq-broker 4.5.2 .............................. SUCCESS [  0.054 s]
[INFO] rocketmq-tools 4.5.2 ............................... SUCCESS [  0.048 s]
[INFO] rocketmq-namesrv 4.5.2 ............................. SUCCESS [  0.017 s]
[INFO] rocketmq-logappender 4.5.2 ......................... SUCCESS [  0.018 s]
[INFO] rocketmq-openmessaging 4.5.2 ....................... SUCCESS [  0.019 s]
[INFO] rocketmq-example 4.5.2 ............................. SUCCESS [  0.037 s]
[INFO] rocketmq-test 4.5.2 ................................ SUCCESS [  0.048 s]
[INFO] rocketmq-distribution 4.5.2 4.5.2 .................. SUCCESS [  0.037 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.103 s
[INFO] Finished at: 2019-08-15T17:50:33+08:00
[INFO] ------------------------------------------------------------------------

恭喜安装成功

1.配置环境变量ROCKETMQ_HOME

解决报错!! 错误: 找不到或无法加载主类 org.apache.rocketmq.namesrv.NamesrvStartup

export ROCKETMQ_HOME="/Users/lishihao/Desktop/github/rocketmq/distribution/target/rocketmq-4.5.2/rocketmq-4.5.2/"
export PATH=$PATH:$ROCKETMQ_HOME

2.启动nameserver

ZBMAC-C02WD12BH:bin lishihao$ sh mqnamesrv
Java HotSpot(TM) 64-Bit Server VM warning: Using the DefNew young collector with the CMS collector is deprecated and will likely be removed in a future release
Java HotSpot(TM) 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
The Name Server boot success. serializeType=JSON

3.启动Borker

ZBMAC-C02WD12BH:bin lishihao$ sh mqbroker -n localhost:9876
The broker[ZBMAC-C02WD12BH.local, 10.0.75.158:10911] boot success. serializeType=JSON and name server is localhost:9876

4.编译安装成功之后的文件

这就完整的完成了编译安装启动

如果对你有用欢迎评论或者点个赞

正文到此结束
本文目录