PRESTO部署和參數說明(一)
一,概要
在部署和使用presto的過程中,在此記錄一下部署記錄和使用記錄以及需要注意的事項。本人使用的presto版本是0.214,3台redhat虛擬機。使用背景:客戶需要定期查詢大批量的數據,最后選擇了sqoop工具定期導入hive,並且定期刪除定期更新,因為沒有找到是個實時增量導入的工具,批量執行mapreduce任務,然后使用分布式查詢引擎presto查詢數據。
二,安裝部署
在官網下載最新的安裝包和客戶端包:
server安裝包:https://prestodb.io/docs/current/installation/deployment.html
client連接包:https://prestodb.io/docs/current/installation/cli.html
我們有三台測試機器,測試機器的版本類型為:
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 6.7 (Santiago)
Release: 6.7
Codename: Santiago
我們要部署3個worker和一個Coordinator(附帶一個Discovery Server節點)節點,並且這個master節點和一個worker節點部署同一台機器上。
第一步:下載完成之后,解壓壓縮包
tar -zxvf presto-server-0.214.tar.gz
第二步:解壓之后,在目錄presto-server-0.214中創建etc文件夾。進去etc文件夾,建立配置文件,我這里建立配置文件如下

config.properties: presto服務配置
node.properties:每個節點特定配置
jvm.properties:java虛擬機的命令行選項
log.properties:輸出的日志級別
catalog目錄:每個連着者配置
咱們一個一個的講解:
config.properties
如果是Coordinator節點:注意 EXAMPLE.COM是指Coordinator節點的域名或者IP
coordinator=true node-scheduler.include-coordinator=true http-server.http.port=8080 query.max-memory=10GB query.max-memory-per-node=3GB query.max-total-memory-per-node=3GB discovery-server.enabled=true discovery.uri=http://EXAMPLE.COM:8080
如果是worker節點:
coordinator=false http-server.http.port=8080 query.max-memory=10GB query.max-memory-per-node=3GB query.max-total-memory-per-node=3GB discovery.uri=http://EXAMPLE.COM:8080
參數解釋:
coordinator: 是否運行該實例為coordinator(接受client的查詢和管理查詢執行)。
node-scheduler.include-coordinator:coordinator是否也作為work。對於大型集群來說,在coordinator里做worker的工作會影響查詢性能。
http-server.http.port:指定HTTP端口。Presto使用HTTP來與外部和內部進行交流。
query.max-memory: 查詢能用到的最大總內存
query.max-memory-per-node: 查詢能用到的最大單結點內存
discovery-server.enabled: Presto使用Discovery服務去找到集群中的所有結點。每個Presto實例在啟動時都會在Discovery服務里注冊。這樣可以簡化部署, 不需要額外的服務,Presto的coordinator內置一個Discovery服務。也是使用HTTP端口。
discovery.uri: Discovery服務的URI。將example.net:8080替換為coordinator的host和端口。這個URI不能以斜杠結尾,這個錯誤需特別注意,不然會報404錯誤。
另外還有以下屬性:
jmx.rmiregistry.port: 指定JMX RMI的注冊。JMX client可以連接此端口
jmx.rmiserver.port: 指定JXM RMI的服務器。可通過JMX監聽。
node.properties
node.environment=production node.id=node01 node.data-dir=/var/presto/data
解釋:
node.environment: 環境名字,Presto集群中的結點的環境名字都必須是一樣的。
node.id: 唯一標識,每個結點的標識都必須是為一的。就算重啟或升級Presto都必須還保持原來的標識。
node.data-dir: 數據目錄,Presto用它來保存log和其他數據
jvm.properties
-server -Xmx5G -XX:+UseG1GC -XX:G1HeapRegionSize=32M -XX:+UseGCOverheadLimit -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError=kill -9 %p
JVM配置文件etc/jvm.config,包含啟動Java虛擬機時的命令行選項。格式是每一行是一個命令行選項。此文件數據是由shell解析,所以選項中包含空格或特殊字符會被忽略。
log.properties
com.facebook.presto=INFO
備注:日志級別有四種,DEBUG, INFO, WARN and ERROR
catalog目錄
在這里以hive為例子,我在客戶端的配置如下:
connector.name=hive-hadoop2 hive.metastore.uri=thrift://10.18.14.170:9083 hive.config.resources=/etc/alternatives/hadoop-conf/core-site.xml,/etc/alternatives/hadoop-conf/hdfs-site.xml
第三步:啟動presto服務和客戶端命令
啟動presto-server,進入目錄bin目錄執行。
./launcher start
其余選項可供參考:
Usage: launcher [options] command
Commands: run, start, stop, restart, kill, status
Options:
-h, --help show this help message and exit
-v, --verbose Run verbosely
--etc-dir=DIR Defaults to INSTALL_PATH/etc
--launcher-config=FILE
Defaults to INSTALL_PATH/bin/launcher.properties
--node-config=FILE Defaults to ETC_DIR/node.properties
--jvm-config=FILE Defaults to ETC_DIR/jvm.config
--config=FILE Defaults to ETC_DIR/config.properties
--log-levels-file=FILE
Defaults to ETC_DIR/log.properties
--data-dir=DIR Defaults to INSTALL_PATH
--pid-file=FILE Defaults to DATA_DIR/var/run/launcher.pid
--launcher-log-file=FILE
Defaults to DATA_DIR/var/log/launcher.log (only in
daemon mode)
--server-log-file=FILE
Defaults to DATA_DIR/var/log/server.log (only in
daemon mode)
-D NAME=VALUE Set a Java system property
啟動presto-cli客戶端:
把下載的jar包:presto-cli-0.214-executable.jar 重命名為:presto 並且賦予權限
chmod +x presto
執行進去命令以hive為例子:
/presto --server localhost:8080 --catalog hive --schema default

客戶端其他命令供參考:
NAME
presto - Presto interactive console
SYNOPSIS
presto [--access-token <access token>] [--catalog <catalog>]
[--client-info <client-info>]
[--client-request-timeout <client request timeout>]
[--client-tags <client tags>] [--debug] [--execute <execute>]
[(-f <file> | --file <file>)] [(-h | --help)]
[--http-proxy <http-proxy>] [--ignore-errors]
[--keystore-password <keystore password>]
[--keystore-path <keystore path>]
[--krb5-config-path <krb5 config path>]
[--krb5-credential-cache-path <krb5 credential cache path>]
[--krb5-disable-remote-service-hostname-canonicalization]
[--krb5-keytab-path <krb5 keytab path>]
[--krb5-principal <krb5 principal>]
[--krb5-remote-service-name <krb5 remote service name>]
[--log-levels-file <log levels file>] [--output-format <output-format>]
[--password] [--resource-estimate <resource-estimate>...]
[--schema <schema>] [--server <server>] [--session <session>...]
[--socks-proxy <socks-proxy>] [--source <source>]
[--truststore-password <truststore password>]
[--truststore-path <truststore path>] [--user <user>] [--version]
OPTIONS
--access-token <access token>
Access token
--catalog <catalog>
Default catalog
--client-info <client-info>
Extra information about client making query
--client-request-timeout <client request timeout>
Client request timeout (default: 2m)
--client-tags <client tags>
Client tags
--debug
Enable debug information
--execute <execute>
Execute specified statements and exit
-f <file>, --file <file>
Execute statements from file and exit
-h, --help
Display help information
--http-proxy <http-proxy>
HTTP proxy to use for server connections
--ignore-errors
Continue processing in batch mode when an error occurs (default is
to exit immediately)
--keystore-password <keystore password>
Keystore password
--keystore-path <keystore path>
Keystore path
--krb5-config-path <krb5 config path>
Kerberos config file path (default: /etc/krb5.conf)
--krb5-credential-cache-path <krb5 credential cache path>
Kerberos credential cache path
--krb5-disable-remote-service-hostname-canonicalization
Disable service hostname canonicalization using the DNS reverse
lookup
--krb5-keytab-path <krb5 keytab path>
Kerberos key table path (default: /etc/krb5.keytab)
--krb5-principal <krb5 principal>
Kerberos principal to be used
--krb5-remote-service-name <krb5 remote service name>
Remote peer's kerberos service name
--log-levels-file <log levels file>
Configure log levels for debugging using this file
--output-format <output-format>
Output format for batch mode [ALIGNED, VERTICAL, CSV, TSV,
CSV_HEADER, TSV_HEADER, NULL] (default: CSV)
--password
Prompt for password
--resource-estimate <resource-estimate>
Resource estimate (property can be used multiple times; format is
key=value)
--schema <schema>
Default schema
--server <server>
Presto server location (default: localhost:8080)
--session <session>
Session property (property can be used multiple times; format is
key=value; use 'SHOW SESSION' to see available properties)
--socks-proxy <socks-proxy>
SOCKS proxy to use for server connections
--source <source>
Name of source making query
--truststore-password <truststore password>
Truststore password
--truststore-path <truststore path>
Truststore path
--user <user>
Username
--version
Display version information and exit
查看web界面 http://EXAMPLE.COM:8080/ui/,舉例說明:至此部署成功

