Presto 引擎

本文主要介绍在 Linkis1.X 中,Presto 引擎的配置、部署和使用。

如果您希望在您的服务器上使用 Presto 引擎,您需要准备 Presto 连接信息,如 Presto 集群的连接地址、用户名和密码等

注意: 编译 Presto 引擎之前需要进行 Linkis 项目全量编译发布的安装部署包中默认不包含此引擎插件, 你可以按此指引部署安装 https://linkis.apache.org/zh-CN/blog/2022/04/15/how-to-download-engineconn-plugin 或者按以下流程,手动编译部署

单独编译 Presto 引擎

  1. ${linkis_code_dir}/linkis-engineconn-plugins/presto/
  2. mvn clean install

将 2.1 步编译出来的引擎包,位于

  1. ${linkis_code_dir}/linkis-engineconn-plugins/jdbc/target/out/presto

上传到服务器的引擎目录下

  1. ${LINKIS_HOME}/lib/linkis-engineplugins

并重启linkis-engineplugin(或则通过引擎接口进行刷新)

  1. cd ${LINKIS_HOME}/sbin
  2. sh linkis-daemon.sh restart cg-engineplugin

检查引擎是否刷新成功:可以查看数据库中的linkis_engine_conn_plugin_bml_resources这张表的last_update_time是否为触发刷新的时间。

  1. #登陆到linkis的数据库
  2. select * from linkis_cg_engine_conn_plugin_bml_resources

Linkis1.X是通过标签来进行的,所以需要在我们数据库中插入数据,插入的方式如下文所示。

  1. -- set variable
  2. SET @PRESTO_LABEL="presto-0.234";
  3. SET @PRESTO_ALL=CONCAT('*-*,',@PRESTO_LABEL);
  4. SET @PRESTO_IDE=CONCAT('*-IDE,',@PRESTO_LABEL);
  5. SET @PRESTO_NAME="presto";
  6. insert into `linkis_cg_manager_label` (`label_key`, `label_value`, `label_feature`, `label_value_size`, `update_time`, `create_time`) VALUES ('combined_userCreator_engineType',@PRESTO_ALL, 'OPTIONAL', 2, now(), now());
  7. insert into `linkis_cg_manager_label` (`label_key`, `label_value`, `label_feature`, `label_value_size`, `update_time`, `create_time`) VALUES ('combined_userCreator_engineType',@PRESTO_IDE, 'OPTIONAL', 2, now(), now());
  8. select @label_id := id from `linkis_cg_manager_label` where `label_value` = @PRESTO_IDE;
  9. insert into `linkis_ps_configuration_category` (`label_id`, `level`) VALUES (@label_id, 2);
  10. INSERT INTO `linkis_ps_configuration_config_key` (`key`, `description`, `name`, `default_value`, `validate_type`, `validate_range`, `engine_conn_type`, `is_hidden`, `is_advanced`, `level`, `treeName`) VALUES ('wds.linkis.presto.url', 'Presto 集群连接', 'presto连接地址', 'http://127.0.0.1:8080', 'None', NULL, @PRESTO_NAME, 0, 0, 1, '数据源配置');
  11. INSERT INTO `linkis_ps_configuration_config_key` (`key`, `description`, `name`, `default_value`, `validate_type`, `validate_range`, `engine_conn_type`, `is_hidden`, `is_advanced`, `level`, `treeName`) VALUES ('wds.linkis.presto.catalog', '查询的 Catalog ', 'presto连接的catalog', 'hive', 'None', NULL, @PRESTO_NAME, 0, 0, 1, '数据源配置');
  12. INSERT INTO `linkis_ps_configuration_config_key` (`key`, `description`, `name`, `default_value`, `validate_type`, `validate_range`, `engine_conn_type`, `is_hidden`, `is_advanced`, `level`, `treeName`) VALUES ('wds.linkis.presto.schema', '查询的 Schema ', '数据库连接schema', '', 'None', NULL, @PRESTO_NAME, 0, 0, 1, '数据源配置');
  13. INSERT INTO `linkis_ps_configuration_config_key` (`key`, `description`, `name`, `default_value`, `validate_type`, `validate_range`, `engine_conn_type`, `is_hidden`, `is_advanced`, `level`, `treeName`) VALUES ('wds.linkis.presto.source', '查询使用的 source ', '数据库连接source', '', 'None', NULL, @PRESTO_NAME, 0, 0, 1, '数据源配置');
  14. -- engine -*
  15. insert into `linkis_ps_configuration_key_engine_relation` (`config_key_id`, `engine_type_label_id`)
  16. (select config.id as `config_key_id`, label.id AS `engine_type_label_id` FROM linkis_ps_configuration_config_key config
  17. INNER JOIN linkis_cg_manager_label label ON config.engine_conn_type = @PRESTO_NAME and label_value = @PRESTO_IDE);
  18. -- engine default configuration
  19. insert into `linkis_ps_configuration_config_value` (`config_key_id`, `config_value`, `config_label_id`)
  20. (select `relation`.`config_key_id` AS `config_key_id`, '' AS `config_value`, `relation`.`engine_type_label_id` AS `config_label_id` FROM linkis_ps_configuration_key_engine_relation relation
  21. INNER JOIN linkis_cg_manager_label label ON relation.engine_type_label_id = label.id AND label.label_value = @PRESTO_IDE);
配置默认值说明是否必须
wds.linkis.presto.urlhttp://127.0.0.1:8080Presto 集群连接true
wds.linkis.presto.usernamedefaultPresto 集群用户名false
wds.linkis.presto.passwordPresto 集群密码false
wds.linkis.presto.catalogsystem查询的 Catalogtrue
wds.linkis.presto.schema查询的 Schematrue
wds.linkis.presto.sourceglobal查询使用的 sourcefalse
presto.session.query_max_total_memory8GB查询使用最大的内存false
wds.linkis.presto.http.connectTimeout60Presto 客户端的 connect timeout(单位:秒)false
wds.linkis.presto.http.readTimeout60Presto 客户端的 read timeout(单位:秒)false
wds.linkis.engineconn.concurrent.limit100Presto 引擎最大并发数false

如果默认参数不满足时,有三种方式可以进行一些基础参数配置。

Presto 引擎 - 图1

提交任务接口,通过参数params.configuration.runtime进行配置

  1. http 请求参数示例
  2. {
  3. "executionContent": {"code": "show teblas;", "runType": "psql"},
  4. "params": {
  5. "variable": {},
  6. "configuration": {
  7. "runtime": {
  8. "wds.linkis.presto.url":"http://127.0.0.1:9090",
  9. "wds.linkis.presto.catalog ":"hive",
  10. "wds.linkis.presto.schema ":"default",
  11. "wds.linkis.presto.source ":""
  12. }
  13. }
  14. },
  15. "source": {"scriptPath": "file:///mnt/bdp/hadoop/1.sql"},
  16. "labels": {
  17. "engineType": "presto-0.234",
  18. "userCreator": "hadoop-IDE"
  19. }
  20. }

通过修改目录 install path/lib/linkis-engineconn-plugins/presto/dist/v0.234/conf/ 中的linkis-engineconn.properties 文件进行配置,如下图:

Presto 引擎 - 图2

通过linkis-cli的方式提交任务,需要指定对应的EngineConn和CodeType标签类型,presto的使用如下:

  • 注意 engineType presto-0.234 引擎版本设置是有前缀的 如 presto 版本为0.234 则设置为 presto-0.234
  1. sh ./bin/linkis-cli -engineType presto-0.234 -codeType psql -code 'show tables;' -submitUser hadoop -proxyUser hadoop

如果管理台,任务接口,配置文件,均未配置时可在 cli 客户端中通过-runtimeMap属性进行配置

  1. sh ./bin/linkis-cli -engineType presto-0.234 -codeType tsql -code 'show tables;' -runtimeMap wds.linkis.presto.url=http://127.0.0.1:50070 -runtimeMap wds.linkis.presto.catalog=hive -runtimeMap wds.linkis.presto.schema=default -runtimeMap wds.linkis.presto.catalog=hive -submitUser hadoop -proxyUser hadoop

具体使用可以参考: Linkis CLI Manual.

工作空间模块右键选择新建一个类型为psql的脚本

Presto 引擎 - 图3