- 在玩Presto时,最多是mvn clean install -DskipTests
- 在没有通过MAVEN_OPTS设置为较大内存时,甚至还用上了多线程加速
- -DskipTests,表示跳过测试
- -Dmaven.compile.fork=true,表示允许进行多线程编译
- -T表示多线程,2C表示每核2个线程。假设这是一个64核的服务器,则在进行构建时可以使用 2 * 64 = 128个线程
mvn -T 2C clean install -DskipTests -Dmaven.compile.fork=true
- 关于maven的并行构建,可以参考官方文档:Parallel builds in Maven 3
- 但是,自从接触maven依赖,自己还从没将项目deploy到maven远程仓库(私服)过
- 在这里记录下,将Presto 0.240版本部署到maven私服遇到问题和解决办法
-
要想将presto部署到私服,需要设置在settings.xml文件中添加私服的server
-
一般release版本和snapshot版本,有各自的私服server
nexus-releases admin p@ssword nexus-snapshots admin p@ssword -
然后,需要在presto-root模块的pom.xml文件的倒数第二行,添加仓库配置
nexus-releases Local Nexus Repository http://xxx.com/nexus/content/repositories/releases/ nexus-snapshots Local Nexus Repository http://xxx.com/nexus/content/repositories/snapshots
-
为了避免与来自maven中央仓库的Presto官方版本的maven坐标冲突,将presto-root(presto项目的父模块和聚合模块)的version从0.240更新为0.240-deploy-SNAPSHOT
com.facebook.presto presto-root 0.240-deploy-SNAPSHOT pom -
使用如下命令进行部署
mvn clean deploy -DskipTests -Dmaven.compile.fork=true
-
执行过成功报错:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check (checkstyle) on project presto-bm-functions: Failed during checkstyle execution: Unable to find configuration file at location: src/checkstyle/presto-checks.xml: Could not find resource 'src/checkstyle/presto-checks.xml'. -> [Help 1]
-
从报错信息看,在执行checkstyle时,presto-bm-functions模块找不到checkstyle的配置文件presto-checks.xml
-
checkstyle的配置文件,位于presto-root模块的src/checkstyle/presto-checks.xml
-
通过检查presto-bm-functions模块的pom.xml文件发现,该模块指定的父模块presto-root的version还是0.240
com.facebook.presto presto-root 0.240 -
错误的version,怎么可能找到父模块presto-root呢?
-
解决办法: 将所有子模块中定义的presto-root的version都改为0.240-deploy-SNAPSHOT
- 整个部署进到一大半了,结果出错了
Error deploying artifact: Failed to transfer file: http://xxx.xxx.xxx.xxx/nexus/content/repositories/snapshots/com/facebook/0.240-deploy-SNAPSHOT/presto-server-0.240-deploy-SNAPSHOT.tar.gz. Return code is: 413, ReasonPhrase: Request Entity Too Large.
- 通过查阅资料发现,应该是最后生成的安装包presto-server-0.240-deploy-SNAPSHOT.tar.gz过大(800多MB)
- 解决方法一: 更新nginx(或ingress)的配置,使serverdaunt允许接收更大的entity
- Fixing 413 Request Entity Too Large Errors
- When I deploy maven project, I get the error Return code is: 413, ReasonPhrase: Request Entity Too Large #18
- Maven-向 Nexus 私服发布包报错, Return code is: 413, ReasonPhrase: Request Entity Too Large
- 解决方法二: 禁止生成安装包
- 通过查看presto-server模块的pom.xml文件发现,maven-assembly-plugin插件控制其生成tar.gz安装包
- 为了以绝后患,整个Presto项目中,所有使用到maven-assembly-plugin插件的,都将该插件注释掉
- 超级奇怪的事情,一直都使用的settings.xml文件,在部署到私服时突然报错
- 提示到某个仓库的网络不通,无法获取com.sun:tools:pom:1.8
[ERROR] Failed to execute goal com.hubspot.maven.plugins:dependency-scope-maven-plugin:0.8:check (default) on project presto-main: Error resolving descriptor for artifact com.sun:tools:1.8: Failed to read artifact descriptor for com.sun:tools:jar:1.8: Could not transfer artifact com.sun:tools:pom:1.8 from/to nexus-aliyun (http://xxxx/nexus/content/repositories/public/): Transfer failed for http://xxx/nexus/content/repositories/public/com/sun/tools/1.8/tools-1.8.pom: Network is unreachable (connect failed) -> [Help 1]
- 最开始,还以为是自身的网络问题,等到第二天再试试
- 第二天还是同样的问题,于是求助同事
- 负责maven私服的同事说,这个仓库地址是其他领域的仓库地址,这个仓库最近可能出问题了无法使用
- 建议将其他领域的仓库地址去除,只保留我所在领域的仓库地址,说这个地址应该能满足我所有的需求
- 照做后,问题得到解决
自己后来总结了下,错误原因如下:
- 配置的仓库可能存在问题,导致无法访问
- 服务器网络管控,无法访问外部仓库地址
菜鸟的解决办法:
- 找一个使用正常的settings.xml配置,照抄作业(当然,感兴趣的大佬可以自己研究研究)
- presto中,除了有presto-server模块,还有一个presto-server-rpm模块
- 看了presto-server-rpm模块的README.md,大意是:presto-server-rpm模块可以提供RPM包以便使用RPM方式安装Presto
You can build an RPM package for Presto server and install Presto using the RPM. Thus, the installation is easier to manage on RPM-based systems.
- 通过上网查阅资料,发现博客《Linux下rpm软件包rpm命令的安装及卸载》是这样介绍RPM的
RPM 的全称为Redhat Package Manager ,是由Redhat 公司提出的,用于管理Linux 下软件包的软件。
Linux 安装时,除了几个核心模块以外,其余几乎所有的模块均通过RPM 完成安装 - 突然想起来,貌似Linux系统的软件安装包,大多都是以.rpm结尾的,例如JDK的安装除了tar包,还有rpm包
- 这些rpm包可以使用rpm命令进行安装,只是我们可能习惯了使用yum(CentOS 系统)、 apt-get install(Ubuntu系统)
- 之所以不直接使用rpm命令,博客《如何在 CentOS Linux 上安装 RPM 软件包》中说,这是因为rpm命令不会解决依赖问题
-
如果不对presto-server-rpm模块的pom.xml文件做任何改动,deloy时target目录将生成.rpm文件
-
.rpm文件有800多MB,上传到私服时,会因为Request Entity Too Large问题而部署失败
-
所以,需要修改presto-server-rpm模块的pom.xml文件,使其不要生成.rpm文件
-
具体改动如下:
// 打包方式为rpm,将其注释掉 // 注释掉依赖,这是因为之前的presto-server模块并未生成tar.gz包,若不注释掉,编译无法通过 // 注释掉对maven-dependency-plugin插件的配置



