Presto Engine

This article mainly introduces the installation, usage and configuration of the Presto engine plugin in Linkis .

If you want to use the Presto engine on your Linkis service, you need to install the Presto service and make sure the service is available.

  1. # prepare presto-cli
  2. wget https://repo1.maven.org/maven2/com/facebook/presto/presto-cli/0.234/presto-cli-0.234-executable.jar
  3. mv presto-cli-0.234-executable.jar presto-cli
  4. chmod + x presto-cli
  5. # execute task
  6. ./presto-cli --server localhost:8082 --execute 'show tables from system.jdbc'
  7. # Get the following output to indicate that the service is available
  8. "attributes"
  9. "catalogs"
  10. "columns"
  11. "procedure_columns"
  12. "procedures"
  13. "pseudo_columns"
  14. "schemas"
  15. "super_tables"
  16. "super_types"
  17. "table_types"
  18. "tables"
  19. "types"
  20. "udts"

Method 1: Download the engine plug-in package directly

Linkis Engine Plugin Download

Method 2: Compile the engine plug-in separately (maven environment is required)

  1. # compile
  2. cd ${linkis_code_dir}/linkis-engineconn-plugins/presto/
  3. mvn clean install
  4. # The compiled engine plug-in package is located in the following directory
  5. ${linkis_code_dir}/linkis-engineconn-plugins/presto/target/out/

EngineConnPlugin Engine Plugin Installation

Upload the engine package in 2.1 to the engine directory of the server

  1. ${LINKIS_HOME}/lib/linkis-engineconn-plugins

The directory structure after uploading is as follows

  1. linkis-engineconn-plugins/
  2. ├── soon
  3. ├── dist
  4. └── 0.234
  5. ├── conf
  6. └── lib
  7. └── plugin
  8. └── 0.234

Refresh the engine by restarting the linkis-cg-linkismanager service

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

You can check whether the last_update_time of the linkis_engine_conn_plugin_bml_resources table in the database is the time to trigger the refresh.

  1. #Login to the `linkis` database
  2. select * from linkis_cg_engine_conn_plugin_bml_resources;
  1. sh ./bin/linkis-cli -engineType presto-0.234 \
  2. -codeType psql -code 'show tables;' \
  3. -submitUser hadoop -proxyUser hadoop

If the management console, task interface, and configuration file are not configured (see 4.2 for the configuration method), they can be configured through the -runtimeMap attribute in the Linkis-cli client

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

More Linkis-Cli command parameter reference: Linkis-Cli usage

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, ‘数据源配置’); 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, ‘数据源配置’); 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, ‘数据源配置’); 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, ‘数据源配置’);

ConfigurationDefaultDescriptionRequired
wds.linkis.presto.urlhttp://127.0.0.1:8080Presto Cluster Connectiontrue
wds.linkis.presto.usernamedefaultPresto cluster usernamefalse
wds.linkis.presto.passwordnonePresto cluster passwordfalse
wds.linkis.presto.catalogsystemQuery Catalogtrue
wds.linkis.presto.schemaNoneSchema to querytrue
wds.linkis.presto.sourceglobalsource used for queryfalse
presto.session.query_max_total_memory8GBquery uses maximum memoryfalse
wds.linkis.presto.http.connectTimeout60Presto client connect timeout (unit: second)false
wds.linkis.presto.http.readTimeout60Presto client read timeout (unit: seconds)false
wds.linkis.engineconn.concurrent.limit100The maximum number of concurrent Presto enginesfalse

If the default parameters are not satisfied, there are the following ways to configure some basic parameters

Presto Engine - 图1

Note: After modifying the configuration under the IDE tag, you need to specify -creator IDE to take effect (other tags are similar), such as:

  1. sh ./bin/linkis-cli -creator IDE \
  2. -engineType presto-0.234 -codeType tsql \
  3. -code 'show tables;' \
  4. -submitUser hadoop -proxyUser hadoop

Submit the task interface, configure it through the parameter params.configuration.runtime

  1. Example of http request parameters
  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. }

Configure by modifying the linkis-engineconn.properties file in the directory install path/lib/linkis-engineconn-plugins/presto/dist/0.234/conf/, as shown below:

Presto Engine - 图2

Linkis is managed through the engine tag, and the data table information involved is shown below.

  1. linkis_ps_configuration_config_key: key and default values ​​of configuration parameters inserted into the engine
  2. linkis_cg_manager_label: Insert engine label such as: presto-0.234
  3. linkis_ps_configuration_category: The directory association relationship of the insertion engine
  4. linkis_ps_configuration_config_value: Insert the configuration that the engine needs to display
  5. linkis_ps_configuration_key_engine_relation: The relationship between the configuration item and the engine

The initial data related to the engine in the table is as follows

  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. -- engine label
  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_ALL, 'OPTIONAL', 2, now(), now());
  8. 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());
  9. select @label_id := id from `linkis_cg_manager_label` where `label_value` = @PRESTO_IDE;
  10. insert into `linkis_ps_configuration_category` (`label_id`, `level`) VALUES (@label_id, 2);
  11. -- configuration key
  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.url', 'Presto cluster connection', 'presto connection address', 'http://127.0.0.1:8080', 'None', NULL, @PRESTO_NAME, 0, 0, 1 , 'data source conf');
  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.catalog', 'Query's Catalog', 'presto-connected catalog', 'hive', 'None', NULL, @PRESTO_NAME, 0, 0, 1, 'Datasource configuration') ;
  14. 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', 'Query Schema', 'Database connection schema', '', 'None', NULL, @PRESTO_NAME, 0, 0, 1, 'data source conf');
  15. 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 for query', 'database connection source', '', 'None', NULL, @PRESTO_NAME, 0, 0, 1, 'data source conf');
  16. -- key engine relation
  17. insert into `linkis_ps_configuration_key_engine_relation` (`config_key_id`, `engine_type_label_id`)
  18. (select config.id as `config_key_id`, label.id AS `engine_type_label_id` FROM linkis_ps_configuration_config_key config
  19. INNER JOIN linkis_cg_manager_label label ON config.engine_conn_type = @PRESTO_NAME and label_value = @PRESTO_ALL);
  20. -- engine default configuration
  21. insert into `linkis_ps_configuration_config_value` (`config_key_id`, `config_value`, `config_label_id`)
  22. (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
  23. INNER JOIN linkis_cg_manager_label label ON relation.engine_type_label_id = label.id AND label.label_value = @PRESTO_ALL);