Windows环境下使用Intellij Idea运行和调试Presto
1、要先编译构建:
参考:https://bbs.huaweicloud.com/blogs/182111
2、修改presto-main:
修改Presto plugin的路径:
presto-main\etc\config.properties:
# 注释掉原来的plugin.bundles
#plugin.bundles=\
# ../presto-resource-group-managers/pom.xml,\
# ../presto-blackhole/pom.xml,\
# ../presto-memory/pom.xml,\
# ../presto-jmx/pom.xml,\
# ../presto-raptor-legacy/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-thrift/pom.xml, \
# ../presto-tpcds/pom.xml
# 修改为下面这样:
plugin.dir=../presto-server/target/presto-server-316/plugin
修改文件描述符数量:
presto-main\src\main\java\io\prestosql\server\PrestoSystemRequirements.java:
// 注释掉下面这几个import,
// 主要是为了避免Presto的Check code style插件检查代码不符合规范而编译不通过:
// import javax.management.MBeanServer;
// import javax.management.ObjectName;
// import static java.lang.management.ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME;
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();
}
}
// 注释掉对操作系统的限制,更改为:warnRequirement
// failRequirement("Presto requires Linux or Mac OS X (found %s)", osName);
warnRequirement("Presto requires Linux or Mac OS X (found %s)", osName);
3、presto-main\etc\catalog目录:
将该目录下的hive.properties重命名为hive.properties.bak。
因为presto运行hive connector需要依赖hadoop的nativelib本地库,在Windows下需要依赖hadoop.dll、snappy.dll、zstd.dll等dll库,暂时没找到合适的dll来解决这个问题,所以先不用hive connector了,不然运行会报错,而剩余的connector还是可以正常加载使用的。
因此对于涉及到hive connector的源码改动,暂时可以在Windows上写好代码之后,再放到Linux环境中调试。
4、配置启动程序入口:
在Intellij Idea中,点击Run -> Edit Configurations -> +Application,添加1个Application,名称为:presto-server,该Application参考官方配置如下:https://github.com/prestosql/presto
Presto comes with sample configuration that should work out-of-the-box for development. Use the following options to create a run configuration:
Main Class: io.prestosql.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
Working directory: $MODULE_DIR$
Use classpath of module: presto-main
然后就可以Run或者Debug了。
5、使用Presto客户端连接:
在Intellij Idea的Terminal窗口中,执行以下命令连接Presto Server:
java -jar presto-cli/target/presto-cli-316-executable.jar --server localhost:8080
- 点赞
- 收藏
- 关注作者
评论(0)