presto_0.280-安装部署
一、官网下载
presto官网:Launch Presto: Local download, JDBC, Docker or on AWS Cloud (prestodb.io)
其他版本:Central Repository: com/facebook/presto (maven.org)
presto-server-0.280.tar.gz
presto-cli-0.280-executable.jar
presto-jdbc-0.280…jar
二、解压安装
#1.将下载好的presto安装包上传到服务器上
#2.解压安装
tar -zxvf /opt/softWare/presto-server-0.280.tar.gz
#3.改名
mv presto-server-0.280.tar.gz presto
三、配置presto
在安装目录下创建一个etc目录,并在该目录下配置以下信息:
节点属性(Node Properties):每个节点的环境配置信息
JVM配置(JVM Config):JVM的命令行选项
配置属性(Config Properties):PrestoServer的配置信息
日志级别(Log Properties):日志级别配置信息
Catalog属性(Catalog Properties):连接器配置信息(数据源)
1.配置节点属性(Node Properties)
vim etc/node.properties
#需要填写一下内容
node.environment=production
node.id=1
node.data-dir=/var/presto/data
各配置参数描述如下:
node.enviroment:集群名称,所有在同一个集群中的Presto节点必须拥有相同的集群名称,这个名字就是控制台右上角展示的enviroment。
node.id:每个Presto节点的唯一标识,每个节点的node.id都必须是唯一的。在Presto进行重启或者升级过程中每个节点的node.id必须保持不变。如果在一个节点上安装多个Presto实例(例如:在同一台机器上安装多个Presto节点),那么每个Presto节点必须拥有唯一的node.id。
node.data-dir:数据存储目录的位置(操作系统上的路径),Presto将会把日期和数据存储在这个目录下。
2.JVM配置(JVM Config)
vim /etc/jvm.config
#需要填写一下内容
-server
-Xmx16G
-XX:+UseG1GC
-XX:G1HeapRegionSize=32M
-XX:+UseGCOverheadLimit
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:+ExitOnOutOfMemoryError
-Djdk.attach.allowAttachSelf=true
3.配置属性(Config Properties)
单节点:
vim etc/config.properties
#需要填写一下内容
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8080
query.max-memory=5GB
query.max-memory-per-node=1GB
discovery-server.enabled=true
discovery.uri=http://example.net:8080 #是指调度节点的IP地址
多节点:
调度节点coordinator
vim etc/config.properties
#需要填写一下内容
coordinator=true
node-scheduler.include-coordinator=false #也可以改成true
http-server.http.port=8080
query.max-memory=50GB
query.max-memory-per-node=1GB
discovery-server.enabled=true
discovery.uri=http://example.net:8080 #是指调度节点的IP地址
工作者节点worker
vim etc/config.properties
#需要填写一下内容
coordinator=false
http-server.http.port=8080
query.max-memory=50GB
query.max-memory-per-node=1GB
discovery.uri=http://example.net:8080 #是指调度节点的IP地址
4.日志级别(Log Properties)
vim etc/log.properties
#需要填写一下内容
com.facebook.presto=INFO
5.Catalog属性(Catalog Properties)
mkdir /etc/catalog
vim etc/catalog/jmx.properties
#需要填写一下内容
connector.name=jmx
四、安装jdk,并配置(非必选)
presto最新版本需要更高的jdk版本,当服务器安装的jdk无法满足presto的需求时,可按如下步骤进行配置。
1.安装jdk
jdk下载地址:https://www.oracle.com/java/technologies/downloads/
#1.将高版本的jdk上传至persto目录下
#2.解压安装
tar -zxvf jdk-11.0.18_linux-x64_bin.tar.gz
#3.改名
mv jdk-11.0.18 jdk11
2.配置
vim presto/bin/launcher
#修改添加如下内容
PATH=/opt/softWare/presto/jdk11/bin/:$PATH
java -version
exec "$(dirname "$0")/launcher.py" "$@"
五、其他节点安装
1.使用scp命令将presto安装到其他节点
scp -r /opt/softWare/presto root@192.168.10.83:/opt/softWare
2.修改配置
修改node.properties
vim etc/node.properties
#修改node.id
node.environment=production
node.id=2
node.data-dir=/var/presto/data
修改config.properties(其他节点一般设置为worker节点)
vim etc/config.properties
#需要填写一下内容
coordinator=false
http-server.http.port=8080
query.max-memory=50GB
query.max-memory-per-node=1GB
discovery.uri=http://example.net:8080 #是指调度节点的IP地址
六、启动测试
后台启动
bin/launcher start
前台启动(可打印出日志)
bin/launcher run
停止
bin/launcher stop
重启
bin/launcher restart
七、presto连接hive
1.在presto/etc/catalog/hive.properties进行配置
vim presto/etc/catalog/hive.properties
#需要填写一下内容
connector.name=hive-hadoop2
hive.metastore.uri=thrift://<hive_metastore_ip>:9083
hive.config.resources=/opt/softWare/presto/etc/catalog/core-site.xml,/opt/softWare/presto/etc/catalog/hdfs-site.xml
备注:
1.hive.metastore.uri在 hive-site.xml 文件中获取
2.从 hdfs 的环境中复制 core-site.xml 和 hdfs-site.xml 文件到 presto 的 etc/catalog目录下。
2.导入presto-cli-0.280-executable.jar
#1.将presto-cli-0.280-executable.jar导入到presto/bin下
#2.修改名称
mv presto-cli-0.280-executable.jar presto-cli
#3.授权
chmod +x presto-cli
3.测试连接
#启动presto 命令行
./presto-cli --server 192.168.10.82:8080 --catalog hive --schema test
# 查询数据库
show schemas from hive;
八、presto连接mysql
1.在presto/etc/catalog/mysql.properties进行配置
vim presto/etc/catalog/mysql.properties
#需要填写一下内容
connector.name=mysql
connection-url=jdbc:mysql://192.168.10.81:3306
connection-user=root
connection-password=root
2.测试连接
./presto-cli --server 192.168.10.82:8080 --catalog mysql --schema test
# 查询数据库
show schemas from mysql;