Presto 0.157 版本单节点部署教程

因为 Presto 版本的更新速度较快,所以最好按照对应版本的教程进行部署,博主之前看错了版本号,拿0.100版本的教程来部署0.157版本,结果导致部署失败。

一、下载 Presto 0.157 版本

下载地址:

1
https://repo1.maven.org/maven2/com/facebook/presto/presto-server/0.157/presto-server-0.157.tar.gz

二、解压 Presto 压缩包

1
tar -zxvf presto-server-0.157.tar.gz

三、配置 Presto(配置说明可查阅官网)

在 Presto 解压路径下创建 etc 文件夹

1
[root@cdh5 presto-server-0.157]# mkdir etc

在 etc 文件夹下添加 node.properties 配置文件

1
2
3
node.environment=production
node.id=ffffffff-ffff-ffff-ffff-ffffffffffff
node.data-dir=/var/presto/data

在 etc 文件夹下添加 jvm.config 配置文件

1
2
3
4
5
6
7
8
-server
-Xmx16G
-XX:+UseG1GC
-XX:G1HeapRegionSize=32M
-XX:+UseGCOverheadLimit
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:OnOutOfMemoryError=kill -9 %p

在 etc 文件夹下添加 config.properties 配置文件

1
2
3
4
5
6
7
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8080
query.max-memory=50GB
query.max-memory-per-node=1GB
discovery-server.enabled=true
discovery.uri=http://cdh5:8080

注:cdh5 为你的主机名,单节点下 node-scheduler.include-coordinator 属性要设置为 true

在 etc 文件夹下添加 log.properties 配置文件

1
com.facebook.presto=INFO

四、添加数据源(可根据需求添加)

在 etc 路径下创建 catalog 文件夹

1
[root@cdh5 etc]# mkdir catalog

在 catalog 文件下添加 hive 数据源 hive.properties

1
2
connector.name=hive-cdh5
hive.metastore.uri=thrift://cdh5:9083

在 catalog 文件下添加 mysql 数据源 mysql.properties

1
2
3
4
connector.name=mysql
connection-url=jdbc:mysql://cdh5:3306
connection-user=root
connection-password=root

在 catalog 文件下添加 postgresql 数据源 postgresql.properties

1
2
3
4
connector.name=postgresql
connection-url=jdbc:postgresql://192.168.236.1:5432/postgres
connection-user=postgres
connection-password=root

五、启动Presto

Presto 有两种启动方式,一种是后台启动,一种是前台启动。前台启动关闭控制台之后 Presto 就会停止运行。Presto 的启动命令为 launcher,在 Presto 的 bin 目录下。

前台启动并显示日志

1
launcher -v run

后台启动

1
launcher start

查看 Presto 的进程

六、下载并运行 presto-cli-0.157-executable.jar

下载地址:presto-cli-0.157-executable.jar

授予可运行的权限

1
chmod +x presto-cli-0.157-executable.jar

运行该 jar 包并连接到 Presto 服务端,如果 Presto 后台启动,需要等一会,否则 Presto 的服务端还没有初始化完毕导致 Cli 连接不上 Presto Server

1
./presto-cli-0.157-executable.jar --server cdh5:8080

七、执行命令

查询 catalog(我们配置的数据源,如 Hive,Mysql 之类的)

1
presto> show catalogs;

查询 catalog 下的 schema(例如 MySQL 下面的数据库)

1
presto> show schemas in mysql;

跨数据源查询

1
presto> select * from mysql.presto.tb_item as t1,hive.default.htb_item_desc as t2 where t1.id = t2.item_id;