当我们在进行openLooKeng的项目任务时,很多情况需要在openLooKeng下进行开发调试,但只有windows 电脑的我们该怎么做?本期,小助手将介绍在Windows下搭建openLooKeng开发环境的方法,希望对朋友们有帮助。如果您有任何想要交流的,欢迎在社区内提Issue;也欢迎加小助手微信,进入专属技术交流群。
欢迎访问官网 openlookeng.io
搭建openLooKeng开发环境
(win运行presto)
首先要确认拥有代码的git clone权限,最好是clone的代码,否则,后期会出现配置上的问题
(一)环境依赖
-
JDK: 1.8 (8u161+)64bit
-
Maven: 3.3.9
如果是直接从
github
上下载的源码压缩包,则需要做如下配置:1. 进入源码根目录 2. 修改根目录的pom.xml 在<build>的<pluginManagement>元素中,添加如下配置: <plugin> <groupId>pl.project13.maven</groupId> <artifactId>git-commit-id-plugin</artifactId> <configuration> <skip>true</skip> </configuration> </plugin> 复制代码
不添加会有如下错误:
Failed to execute goal pl.project13.maven:git-commit-id-plugin:3.0.1:revision (default) on project hetu-common: .git directory is not found! Please specify a valid [dotGitDirectory] in your pom.xml 复制代码
如果是从
github
上clone
的代码,则不需要做上述配置。 -
更换代码仓:
在maven的setting中,修改:
<mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> 复制代码
镜像仓库。
<localRepository>D:\document\Maven\repository</localRepository>
复制代码
这是我的本地的仓库地址
(二)编译
2.1编译前准备
-
presto-main/etc/event-listener.properties
- hetu.event.listener.type=AUDIT + hetu.event.listener.type=LOGGER 复制代码
-
presto-main/src/main/java/io/prestosql/server/PluginDiscovery.java
- if (!file.getPath().endsWith("/target/classes")) + if (!file.getPath().replace('\\','/').endsWith("/target/classes")) 复制代码
win系统下路径字符的变化
-
presto-main/src/main/java/io/prestosql/server/PrestoSystemRequirements.java
注释:
else {
failRequirement("Hetu requires Linux or Mac OS X (found %s)", osName);
}
复制代码
其实注释修改都是可以的:
修改:
// 注释掉对操作系统的限制,更改为:warnRequirement
// failRequirement("Presto requires Linux or Mac OS X (found %s)", osName);
warnRequirement("Presto requires Linux or Mac OS X (found %s)", osName);
复制代码
注释和修改任选一种
- presto-main/src/main/java/io/prestosql/server/PrestoSystemRequirements.java
修改:
- Object maxFileDescriptorCount = mbeanServer.getAttribute(ObjectName.getInstance(OPERATING_SYSTEM_MXBEAN_NAME), "MaxFileDescriptorCount");
+ Object maxFileDescriptorCount = 10000;
复制代码
- presto-main/pom.xml
注释掉io.airlift.resolver
的依赖中的exclusions
<dependency>
<groupId>io.airlift.resolver</groupId>
<artifactId>resolver</artifactId>
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <artifactId>netty</artifactId>-->
<!-- <groupId>io.netty</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>async-http-client</artifactId>-->
<!-- <groupId>com.ning</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>maven-compat</artifactId>-->
<!-- <groupId>org.apache.maven</groupId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
</dependency>
复制代码
注释掉一下依赖项:
(如果不注释后期会有错),可以参考附录学习
<!-- <dependency>-->
<!-- <groupId>org.apache.maven</groupId>-->
<!-- <artifactId>maven-compat</artifactId>-->
<!-- <version>3.5.0</version>-->
<!-- <scope>runtime</scope>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <artifactId>maven-core</artifactId>-->
<!-- <groupId>org.apache.maven</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>maven-model</artifactId>-->
<!-- <groupId>org.apache.maven</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>maven-repository-metadata</artifactId>-->
<!-- <groupId>org.apache.maven</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>plexus-classworlds</artifactId>-->
<!-- <groupId>org.codehaus.plexus</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>jsr250-api</artifactId>-->
<!-- <groupId>javax.annotation</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>maven-resolver-provider</artifactId>-->
<!-- <groupId>org.apache.maven</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>org.eclipse.sisu.plexus</artifactId>-->
<!-- <groupId>org.eclipse.sisu</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>maven-resolver-api</artifactId>-->
<!-- <groupId>org.apache.maven.resolver</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>maven-resolver-impl</artifactId>-->
<!-- <groupId>org.apache.maven.resolver</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>maven-resolver-spi</artifactId>-->
<!-- <groupId>org.apache.maven.resolver</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>maven-resolver-util</artifactId>-->
<!-- <groupId>org.apache.maven.resolver</groupId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
复制代码
若不注释,会报错:
org.codehaus.plexus.component.repository.exception.ComponentLifecycleException: Error constructing component role: 'org.apache.maven.repository.RepositorySystem', implementation: 'org.apache.maven.repository.legacy.LegacyRepositorySystem', role hint: 'default'
复制代码
- presto-main/etc/config.properties
删除plugin.bundles
中hive和oracle插件:
(在win中运行hive和oracal需要别的插件,暂且用不到,先屏蔽掉。后期有时间解决这个问题)。
- ../presto-hive-hadoop2/pom.xml,\
- ../hetu-oracle/pom.xml, \
复制代码
-
presto-main/etc/catalog/
hive及oracle需要在windows上安装相关程序的windows版本才能使用,这里直接删除删除hive及oracle的配置文件
# 在GitBash中 cd presto-main/etc/catalog/ mv hive.properties hive.properties.bak mv oracle.properties oracle.properties.bak 复制代码
2.2 编译构建
mvn clean package -DskipTests
复制代码
这里提供另外一种编译构建的方法,如果遇到如下问题:
问题: 打包时候出现check错误还有其他检查错误。并且mvn clean install -DskipTests 并不能跳过check,需要在hetu-core的pom的properties里面增加
<air.check.skip-extended>true</air.check.skip-extended>
复制代码
然后再执行:
mvn clean install -Dcheckstyle.skip=true -DskipTests
复制代码
编译结果:
(三)运行
3.1 运行前准备
1)打开idea
2)Crtl+Alt+S 进入设置页面(file-settings)
-
Build,Excution,Deployment > Complier > JavaComplier
-
取消勾选 Use ‘–release’ option for corss-compilation
-
设置 project bytecode version为8
- 运行参数设置
run->edit confurations
Main class :
-ea -XX:+UseG1GC -XX:G1HeapRegionSize=32M -XX:+UseGCOverheadLimit -XX:+ExplicitGCInvokesConcurrent -Xmx2G -Dconfig=etc/config.properties -Dlog.levels-file=etc/log.properties -Duser.home=D:\document\Maven
Working directory: $MODULE_DIR$
Use classpath of module: presto-main
注意-Duser.home=D:/Marven是maven仓库.m2文件夹的父目录,且最后两级目录名必须是/.m2/repositor
复制代码
-Duser.home=D:\document\Maven
未添加这一项的,会出现如下错误:
Caused by: org.apache.maven.project.ProjectBuildingException: 1 problem was encountered while building the effective model for io.hetu.core:presto-resource-group-managers:1.2.0-SNAPSHOT
[FATAL] Non-resolvable parent POM for io.hetu.core:presto-root:1.2.0-SNAPSHOT: Could not transfer artifact io.airlift:airbase:pom:97 from/to central (http://repo.maven.apache.org/maven2): connection timed out to http://repo.maven.apache.org/maven2/io/airlift/airbase/97/airbase-97.pom and 'parent.relativePath' points at wrong local POM @ io.hetu.core:presto-root:1.2.0-SNAPSHOT, D:\document\hetu-core\pom.xml, line 6, column 13
for project io.hetu.core:presto-resource-group-managers:1.2.0-SNAPSHOT at D:\document\hetu-core\presto-main\..\presto-resource-group-managers\pom.xml
复制代码
4)presto-main\etc\config.properties
添加:
hetu.queryeditor-ui.allow-insecure-over-http=true
复制代码
添加原因是:不添加会报http不安全的错误:
3.2 运行结果
点击IDEA上的运行,然后在浏览器中输入http://localhost:8080/
(四)进入openLooKeng
# 进入源码根目录
cd hetu-core
# 运行cli客户端连接OpenLooKeng
java -jar presto-cli/target/hetu-cli-*-executable.jar --server localhost:8080
SHOW CATALOGS;
SHOW SCHEMAS FROM jmx;
use jmx.current;
show tables;
复制代码
图形化界面查询正常:
其余问题解决方法:
问题1:
Failed to execute goal org.skife.maven:really-executable-jar-maven-plugin:1.0.5:really-executable-jar (default) on project presto-benchmark-driver: FAILURE!
复制代码
直接注掉所有的依赖引用。涉及到的模块比较多,因此就不一一截图了。搜下,引用到的都注掉。
问题2:
(imports) UnusedImports: 无用导入 - javax.management.MBeanServer 。
复制代码
进入指定的类,将这个import删除
问题3:
遇到一些类无法加载的,重新reload一下maven
问题4:
Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce (default) on project hetu-state-store: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.
[WARNING] Rule 2: org.apache.maven.plugins.enforcer.BanDuplicatePomDependencyVersions failed with message:
Found 1 duplicate dependency declaration in this project:
- dependencies.dependency[com.hazelcast:hazelcast:jar] ( 2 times )
复制代码
重复定义的配置 duplicate dependency,找到直接删除。
问题5:
1)org.codehaus.plexus.component.repository.exception.ComponentLifecycleException: Error constructing component role: 'org.apache.maven.repository.RepositorySystem', implementation: 'org.apache.maven.repository.legacy.LegacyRepositorySystem', role hint: 'default'
2)Error loading pom......
复制代码
通过定位:
line356 pomFile ..\presto-resource-group-managers\pom.xml
PlexusContainer container = container();
复制代码
无法加载一些jar包:
修改方法:
presto-main/pom.xml
注释掉一下文件:
<!-- <dependency>-->
<!-- <groupId>org.apache.maven</groupId>-->
<!-- <artifactId>maven-compat</artifactId>-->
<!-- <version>3.5.0</version>-->
<!-- <scope>runtime</scope>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <artifactId>maven-core</artifactId>-->
<!-- <groupId>org.apache.maven</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>maven-model</artifactId>-->
<!-- <groupId>org.apache.maven</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>maven-repository-metadata</artifactId>-->
<!-- <groupId>org.apache.maven</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>plexus-classworlds</artifactId>-->
<!-- <groupId>org.codehaus.plexus</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>jsr250-api</artifactId>-->
<!-- <groupId>javax.annotation</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>maven-resolver-provider</artifactId>-->
<!-- <groupId>org.apache.maven</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>org.eclipse.sisu.plexus</artifactId>-->
<!-- <groupId>org.eclipse.sisu</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>maven-resolver-api</artifactId>-->
<!-- <groupId>org.apache.maven.resolver</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>maven-resolver-impl</artifactId>-->
<!-- <groupId>org.apache.maven.resolver</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>maven-resolver-spi</artifactId>-->
<!-- <groupId>org.apache.maven.resolver</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>maven-resolver-util</artifactId>-->
<!-- <groupId>org.apache.maven.resolver</groupId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
复制代码
参考资料:
本文转载请联系openLooKeng