1、环境准备 支持操作系统: Linux or Mac OS X Java 8, 64-bit Python 2.4+
支持hadoop集群环境版本: Apache Hadoop 1.x Apache Hadoop 2.x Cloudera CDH 4 Cloudera CDH 5 备注: 这里我们准备三台Ubuntu 14.04 并且搭建CDH5.10集群 2、下载安装包 presto-server-0.191.tar.gz 下载路径:https://repo1.maven.org/maven2/com/facebook/presto/presto-server/0.191/presto-server-0.191.tar.gz 3、将下载的安装包分别解压到3台服务器的/opt目录下,如图:
4、配置presto 在我们解压好的目录下创建一个etc文件夹,etc主要需要配置以下内容 Node Properties: environmental configuration specific to each node(每个节点名称及数据目录,所属集群配置) JVM Config: command line options for the Java Virtual Machine(JVM配置) Config Properties: configuration for the Presto server(presto详细参数配置,端口号、内存分配、主从等) Catalog Properties: configuration for Connectors (data sources)(数据源连接配置) 5、Node Properties配置 在etc下创建文件node.properties etc/node.properties: node.environment=production #集群名称,所有节点都应该统一 node.id=ffffffff-ffff-ffff-ffff-ffffffffffff #节点唯一性标识,ID node.data-dir=/data/presto/data #数据目录,主要存储日志和一些其他的数据 6、JVM配置 在etc下创建文件jvm.config etc/jvm.config: -server -Xmx16G -XX:+UseG1GC -XX:G1HeapRegionSize=32M -XX:+UseGCOverheadLimit -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:+ExitOnOutOfMemoryError 备注:以上参数都是官网参数,实际环境需要调整 7、Config Properties 详细参数配置 在etc下创建文件config.properties,这里的配置要分主从了, 主节点配置,即coordinator配置: coordinator=true #是不是主节点 node-scheduler.include-coordinator=false #主节点是否同时是子节点 http-server.http.port=8080 #http端口号,presto主要用http请求 query.max-memory=50GB #一个query最大内存限定 query.max-memory-per-node=1GB #每个节点提供给一个query的最大内存 discovery-server.enabled=true #类似于hbase的心跳,做节点监控 discovery.uri=http://example.net:8080 #这里填主节点IP 从节点配置,即worker配置: coordinator=false http-server.http.port=8080 query.max-memory=50GB query.max-memory-per-node=1GB discovery.uri=http://example.net:8080 #这里填主节点IP 附:如果主从只有一个节点,配置如下: coordinator=true node-scheduler.include-coordinator=true #即主即从配为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 You may also wish to set the following properties: jmx.rmiregistry.port: Specifies the port for the JMX RMI registry. JMX clients should connect to this port. jmx.rmiserver.port: Specifies the port for the JMX RMI server. Presto exports many metrics that are useful for monitoring via JMX. 8、日志级别 创建文件log.properties 填入内容: com.facebook.presto=INFO 备注:日志级别有四种,DEBUG, INFO, WARN and ERROR 9、连接设置 这里只说一下hive的,其实官网写的很清楚,如果有用到其他的,可以点一下官网连接:https://prestodb.io/docs/current/connector.html hive connector配置如下: (1)创建存放链接配置文件的文件夹,在之前etc目录下创建catalog (2)放入一个jmx的配置文件,jmx.properties,配置内容:connector.name=jmx (通过jmx管理connector) (3)配置一个hive connector的配制文件,hive.properties,内容如下: connector.name=hive-hadoop2 #取个连接名 hive.metastore.uri=thrift://192.168.10.101:9083 #配置metastore连接 hive.config.resources=/etc/hadoop/conf/core-site.xml,/etc/hadoop/conf/hdfs-site.xml #指明hadoop的配置文件,主要是设计hdfs hive.allow-drop-table=true #给删表权限 其他配置如下可参考官网:https://prestodb.io/docs/current/connector/hive.html https://prestodb.io/docs/current/connector/hive-security.html 10、这些都配置好后,就要启动presto,步骤如下: (1)在bin目录下启动服务:bin/launcher start bin/launcher start (2)命令行启动:下载启动jar包:presto-cli-0.191-executable.jar,下载链接为: https://repo1.maven.org/maven2/com/facebook/presto/presto-cli/0.191/presto-cli-0.191-executable.jar
(3)下载下来后改个名字为presto,放在bin目录下,然后给个执行权限:chmod +x presto ,如下图
(4)连接hive,并启动:./presto --server localhost:8080 --catalog hive --schema default (5)如果要关闭presto服务,执行:bin/launcher stop
备注:如上配置像IP地址都要换成自己的集群,最后成功后可查询hive数据,如下图: