安装
官网
下载地址
历史版本下载
https://repo1.maven.org/maven2/com/facebook/presto/presto-cli/0.252/
规划
| 主机 | 规划设置主机名 | 角色 |
|---|---|---|
| 192.168.61.202 | hadoop1 | coordinator、discovery |
| 192.168.61.203 | hadoop2 | worker |
| 192.168.61.204 | hadoop3 | worker |
解压
tar -zxvf presto-server-0.285.1.tar.gz -C ../module/
配置环境变量
sudo vim /etc/profile.d/my_env.sh
#PRESTO_HOME
export HADOOP_HOME=/home/bigdata/module/presto-server-0.285.1
export PATH=$PATH:$HADOOP_HOME/bin
/home/bigdata/shell/xsync.sh /etc/profile.d/my_env.sh
source /etc/profile.d/my_env.sh
配置
在安装目录下创建一个etc目录,并在该目录下配置以下信息:
- 节点属性(Node Properties):每个节点的环境配置信息
- JVM配置(JVM Config):JVM的命令行选项
- 配置属性(Config Properties):PrestoServer的配置信息
- 日志级别(Log Properties):日志级别配置信息
- Catalog属性(Catalog Properties):连接器配置信息(数据源)
node.properties
mkdir /home/bigdata/module/presto-server-0.285.1/etc
mkdir /home/bigdata/module/presto-server-0.285.1/data
vim /home/bigdata/module/presto-server-0.285.1/etc/node.properties
(hadoop1,hadoop2,hadoop3)都要配置就是node.id不一样
#需要填写一下内容
node.environment=production
node.id=1
node.data-dir=/home/bigdata/module/presto-server-0.285.1/data
各配置参数描述如下:
node.enviroment:集群名称,所有在同一个集群中的Presto节点必须拥有相同的集群名称,这个名字就是控制台右上角展示的enviroment。
node.id:每个Presto节点的唯一标识,每个节点的node.id都必须是唯一的。在Presto进行重启或者升级过程中每个节点的node.id必须保持不变。如果在一个节点上安装多个Presto实例(例如:在同一台机器上安装多个Presto节点),那么每个Presto节点必须拥有唯一的node.id。
node.data-dir:数据存储目录的位置(操作系统上的路径),Presto将会把日期和数据存储在这个目录下。
jvm.config
vim /home/bigdata/module/presto-server-0.285.1/etc/jvm.config
#需要填写一下内容
-server
-Xmx20G
-XX:+UseG1GC
-XX:G1HeapRegionSize=32M
-XX:+UseGCOverheadLimit
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:+ExitOnOutOfMemoryError
-DHADOOP_USER_NAME=bigdata
-Djdk.attach.allowAttachSelf=true
config.properties
coordinator节点 (hadoop1)
vim /home/bigdata/module/presto-server-0.285.1/etc/config.properties
#需要填写一下内容
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8881
query.max-memory=70GB
query.max-memory-per-node=8GB
# 单个查询在每个节点上可以使用的最大用户内存+系统内存(user memory: hash join,agg等,system memory:input/output/exchange buffers等)
query.max-total-memory-per-node=9GB
discovery-server.enabled=true
discovery.uri=http://hadoop1:8881 #是指调度节点的IP地址
experimental.reserved-pool-enabled=false
work节点(hadoop2,hadoop3)
vim /home/bigdata/module/presto-server-0.285.1/etc/config.properties
#需要填写一下内容
coordinator=false
http-server.http.port=8881
query.max-memory=70GB
query.max-memory-per-node=8GB
query.max-total-memory-per-node=9GB
discovery.uri=http://hadoop1:8881 #是指调度节点的IP地址
experimental.reserved-pool-enabled=false
log.properties
vim /home/bigdata/module/presto-server-0.285.1/etc/log.properties
#需要填写一下内容
com.facebook.presto=INFO
catalog
mkdir /home/bigdata/module/presto-server-0.285.1/etc/catalog
vim /home/bigdata/module/presto-server-0.285.1/etc/catalog/jmx.properties
#需要填写一下内容
connector.name=jmx
分发到其他节点
./xsync.sh ../module/presto-server-0.285.1/
work节点的配置(与coordinator不同的地方)
修改 node.properties
vim /home/bigdata/module/presto-server-0.285.1/etc/node.properties
(hadoop1,hadoop2,hadoop3)都要配置就是node.id不一样
#需要填写一下内容
node.environment=production
node.id=2
node.data-dir=/home/bigdata/module/presto-server-0.285.1/data
修改 config.properties
vim /home/bigdata/module/presto-server-0.285.1/etc/config.properties
#需要填写一下内容
coordinator=false
http-server.http.port=8881
query.max-memory=50GB
query.max-memory-per-node=1GB
discovery.uri=http://hadoop1:8881 #是指调度节点的IP地址
presto连接hive
修改配置
cp /home/bigdata/module/hadoop-3.2.3/etc/hadoop/core-site.xml /home/bigdata/module/presto-server-0.285.1/etc/catalog
cp /home/bigdata/module/hadoop-3.2.3/etc/hadoop/hdfs-site.xml /home/bigdata/module/presto-server-0.285.1/etc/catalog
vim /home/bigdata/module/presto-server-0.285.1/etc/catalog/hive.properties
connector.name=hive-hadoop2
hive.metastore.uri=thrift://hadoop1:9083
hive.config.resources=/home/bigdata/module/presto-server-0.285.1/etc/catalog/core-site.xml,/home/bigdata/module/
hive.allow-drop-table=true
hive.parquet.use-column-names=true
hive.allow-rename-column=true
hive.allow-rename-table=true
hive.storage-format=ORC
hive.orc.use-column-names=true
分发配置文件
/home/bigdata/shell/xsync.sh /home/bigdata/module/presto-server-0.285.1/etc/catalog
备注:
- 1.hive.metastore.uri在 hive-site.xml 文件中获取
- 2.从 hdfs 的环境中复制 core-site.xml 和 hdfs-site.xml 文件到 presto 的 etc/catalog目录下。
在所有机器执行
/home/bigdata/module/presto-server-0.285.1/bin/launcher run
安装客户端
chmod 744 /home/bigdata/package/presto-cli-0.285.1-executable.jar
#启动presto 命令行
/home/bigdata/package/presto-cli-0.285.1-executable.jar --server hadoop1:8881 --catalog hive --schema test
# 查询数据库
show schemas from hive;
presto连接mysql
vim /home/bigdata/module/presto-server-0.285.1/etc/catalog/mysql.properties
#需要填写一下内容
connector.name=mysql
connection-url=jdbc:mysql://192.168.10.81:3306
connection-user=root
connection-password=root
测试链接
/home/bigdata/package/presto-cli-0.285.1-executable.jar --server hadoop1:8881 --catalog mysql --schema test
# 查询数据库
show schemas from mysql;
启动
前台启动
(可打印出日志)
/home/bigdata/module/presto-server-0.285.1/bin/launcher run
后台启动
/home/bigdata/module/presto-server-0.285.1/bin/launcher start
停止
/home/bigdata/module/presto-server-0.285.1/bin/launcher stop
重启
/home/bigdata/module/presto-server-0.285.1/bin/launcher restart