文章目录
Presto 0.240 源码 GitHub prestodb/presto 0.240 或 CSDN下载
所需环境:
1. 修改presto-maven-plugin
Presto使用presto-maven-plugin编译。在Window下编译失败原因是编译过程中类找不到,而且文件路径错了。
这里Presto使用的presto-maven-plugin的版本为0.3,从 GitHub prestodb/presto-maven-plugin 0.3 下载源码。
修改ServiceDescriptorGenerator
String className = classPath.substring(0, classPath.length() - 6).replace('/', '.');
为
String className = classPath.substring(0, classPath.length() - 6).replace(File.separatorChar, '.');
因为类名是通过把类路径的文件分隔符替换成.
来生成,Windows的分隔符是\
,所以把'/'
替换成File.separatorChar
。
再将presto-maven-plugin,mvn clean install -DskipTests
到本地仓库中。
也可以直接从 CSDN 资源下载 已修改好的presto-maven-plugin源码。
2. 修改根目录pom.xml
是否安装Python
可能和Python环境有关。文档由sphinx生成,未安装就注释。
<module>presto-docs</module>
是否创建GIT仓库
有,就不用管。
没有,需要在的元素中,添加配置
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
再注释
<Build-Time>${git.build.time}</Build-Time>
<Git-Commit-Id>${git.commit.id}</Git-Commit-Id>
<Implementation-Version>${project.version}-${git.commit.id.abbrev}</Implementation-Version>
3. 配置类unix环境
Presto编译过程中会用到Linux中的命令,Git Bash带有一些类Unix的命令。
设置Windows的环境变量Path,加上:%GIT_HOME%\usr\bin
,其中GIT_HOME是Git的安装路径,一般默认安装路径为:C:\Program Files\Git
。
如果使用了Intellij Idea,配置好环境变量之后,需要重启Intellij Idea才能生效。
3. 编译项目
mvn clean install -DskipTests
4. 修改presto-main\etc下配置
修改presto-main\etc\config.properties
# http端口
http-server.http.port=18080
# 这里在Coordinator中启用了Discovery的嵌入式版本,所以它应该是Coordinator的URI
discovery.uri=http://localhost:18080
# 插件文件夹
plugin.dir=../presto-server/target/presto-server-0.240/presto-server-0.240/plugin
#plugin.bundles=\
# ../presto-blackhole/pom.xml,\
# ../presto-memory/pom.xml,\
# ../presto-jmx/pom.xml,\
# ../presto-raptor/pom.xml,\
# ../presto-hive-hadoop2/pom.xml,\
# ../presto-example-http/pom.xml,\
# ../presto-kafka/pom.xml, \
# ../presto-tpch/pom.xml, \
# ../presto-local-file/pom.xml, \
# ../presto-mysql/pom.xml,\
# ../presto-sqlserver/pom.xml, \
# ../presto-postgresql/pom.xml, \
# ../presto-tpcds/pom.xml, \
# ../presto-i18n-functions/pom.xml,\
# ../presto-function-namespace-managers/pom.xml,\
# ../presto-druid/pom.xml
修改presto-main\etc\catalog\hive.properties
将hive.properties重命名为hive.properties.bak。启动后默认会加载catalog目录下所有的连接器,本地无hadoop、hive等环境,就会报错导致启动失败。
5. 修改PrestoSystemRequirements.java
修改presto-main\src\main\java\com\facebook\presto\server\PrestoSystemRequirements.java
private static OptionalLong getMaxFileDescriptorCount()
{
try {
// MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
// Object maxFileDescriptorCount = mbeanServer.getAttribute(ObjectName.getInstance(OPERATING_SYSTEM_MXBEAN_NAME), "MaxFileDescriptorCount");
// 修改为固定大小的文件描述符数量
Object maxFileDescriptorCount = 10000;
return OptionalLong.of(((Number) maxFileDescriptorCount).longValue());
}
catch (Exception e) {
return OptionalLong.empty();
}
}
private static void verifyOsArchitecture()
{
String osName = StandardSystemProperty.OS_NAME.value();
String osArch = StandardSystemProperty.OS_ARCH.value();
if ("Linux".equals(osName)) {
if (!"amd64".equals(osArch) && !"ppc64le".equals(osArch)) {
failRequirement("Presto requires amd64 or ppc64le on Linux (found %s)", osArch);
}
if ("ppc64le".equals(osArch)) {
warnRequirement("Support for the POWER architecture is experimental");
}
}
else if ("Mac OS X".equals(osName)) {
if (!"x86_64".equals(osArch)) {
failRequirement("Presto requires x86_64 on Mac OS X (found %s)", osArch);
}
}
else {
// failRequirement("Presto requires Linux or Mac OS X (found %s)", osName);
// 修改为警告
warnRequirement("Presto requires Linux or Mac OS X (found %s)", osName);
}
}
6. 添加启动类
Main class:com.facebook.presto.server.PrestoServer
VM options:-ea -XX:+UseG1GC -XX:G1HeapRegionSize=32M -XX:+UseGCOverheadLimit -XX:+ExplicitGCInvokesConcurrent -Xmx2G -Dconfig=etc/config.properties -Dlog.levels-file=etc/log.properties -Djdk.attach.allowAttachSelf=true
Working directory:$MODULE_DIR$
Use classpath of module: presto-main
参考:
GitHub prestodb/presto
Presto在Windows环境下编译错误
Linux和Windows环境下编译presto
Windows环境下使用Intellij Idea运行和调试Presto