OpenLooKeng 基于 Presto, 而Presto从编译环境到运行环境都没有考虑支持windows,为了在Win上进行开发调试工作,我们需要进行一些修改。
0x01 环境及依赖
- OS: Windows 7+
- JDK: 1.8 (8u161+)64bit
- Maven: 3.3.9+
- Git for windows
0x02 编译
2.1 Clone Code
因代码配置有
checkstyle-plugin
,代码中不能出现
CRLF
换行,必须为
LF
换行,所以确保git设置
git config --global core.autocrlf
为
input
.
git clone https://gitee.com/openlookeng/hetu-core.git
2.2 编译
- 打开GitBash,使用其MinGW环境作为编译环境。
- 确认当前环境中java工作目录在jdk中:可使用java -verbose 查看目录信息。
- 使用maven 编译
当然我们可以开启多线程、排除不需要的模块比如打安装包的cd hetu-core mvn clean install -DskipTests
来加速编译hetu-server-rpm
mvn -T 8 -pl '!hetu-server-rpm' clean install -DskipTests
0x03 修改代码以在 Windows环境调试运行
使用IDEA打开工程,按如下修改
- file:
修改:presto-main/etc/event-listener.properties
- hetu.event.listener.type=AUDIT + hetu.event.listener.type=LOGGER
- file:
修改:presto-main/src/main/java/io/prestosql/server/PluginDiscovery.java
- if (!file.getPath().endsWith("/target/classes")) + if (!file.getPath().replace('\\','/').endsWith("/target/classes"))
- file:
注释掉:presto-main/src/main/java/io/prestosql/server/PrestoSystemRequirements.java
修改:else { failRequirement("Hetu requires Linux or Mac OS X (found %s)", osName); }
清理相关import- Object maxFileDescriptorCount = mbeanServer.getAttribute(ObjectName.getInstance(OPERATING_SYSTEM_MXBEAN_NAME), "MaxFileDescriptorCount"); + Object maxFileDescriptorCount = 10000;
- file:
注释掉presto-main/pom.xml
的依赖排除io.airlift.resolver
- file:
删除presto-main/etc/config.properties
中hive和oracle插件:plugin.bundles
- ../presto-hive-hadoop2/pom.xml,\ - ../hetu-oracle/pom.xml, \
- dir:
hive及oracle需要在windows上安装相关程序的windows版本才能使用,这里直接删除删除hive及oracle的配置文件presto-main/etc/catalog/
# 在GitBash中 cd presto-main/etc/catalog/ mv hive.properties hive.properties.bak mv oracle.properties oracle.properties.bak
0x04 启动项配置
4.1 IDEA 设置
Crtl+Alt+S 进入设置页面
- Build,Excution,Deployment > Complier > JavaComplier
- 取消勾选 Use ‘–release’ option for corss-compilation
- 设置 project bytecode version为8
4.2 创建运行环境配置
新建Application运行环境
- 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:/Marven
- Working directory:
$MODULE_DIR$
- Use classpath of module:
presto-main
- 注意
是maven仓库.m2文件夹的父目录,且最后两级目录名必须是-Duser.home=D:/Marven
/.m2/repository
- 点击IDEA上的运行,然后在浏览器中输入
http://localhost:8080/
0x05 Hello OpenLooKeng
经过上面的步骤,OpenLooKeng/Presto已经启动好了,这时候就可以尝试其功能了。
5.1 启动CLI客户端,连接OpenLooKen/Presto
OpenLooKen的CLI客户端名称是
hetu-cli
Presto的CLI客户端名称是
presto-cli
连接:
# 进入源码根目录
cd hetu-core
# 运行cli客户端连接OpenLooKeng
java -jar presto-cli/target/hetu-cli-*-executable.jar --server localhost:8080
测试:
# 查看catalogs,会比较慢,耐心等待1分钟,或者在连接时直接指定 --catalog example
lk> SHOW CATALOGS;
Catalog
------------
example
jmx
localfile
memory
mysql
postgresql
sqlserver
system
thrift
tpcds
tpch
(11 rows)
Query 20200926_103900_00007_w3q7w, FINISHED, 1 node
Splits: 19 total, 19 done (100.00%)
0:46 [0 rows, 0B] [0 rows/s, 0B/s]
# 查看example中有哪些SCHEMAS
lk> SHOW SCHEMAS FROM example;
Schema
--------------------
example
information_schema
tpch
(3 rows)
Query 20200926_104259_00010_w3q7w, FINISHED, 1 node
Splits: 19 total, 19 done (100.00%)
0:00 [3 rows, 44B] [57 rows/s, 846B/s]
# USE example CATALOG中的 example SCHEMA
USE example.example;
USE
lk:example>
# 查看当前SCHEMA中有哪些表
lk:example> SHOW TABLES;
Table
---------
numbers
(1 row)
Query 20200926_104741_00014_w3q7w, FINISHED, 1 node
Splits: 19 total, 19 done (100.00%)
0:00 [1 rows, 24B] [25 rows/s, 615B/s]
# 查询numbers表中的数据
lk:example> select * from numbers;
text | value
--------+-------
one | 1
two | 2
three | 3
ten | 10
eleven | 11
twelve | 12
(6 rows)
Query 20200926_104900_00015_w3q7w, FINISHED, 1 node
Splits: 18 total, 18 done (100.00%)
0:01 [6 rows, 0B] [5 rows/s, 0B/s]