presto分布式环境搭建

 

1.Presto的基本需求java

Linux or Mac OS Xnode

Java 8, 64-bitweb

Python 2.4+spring

Presto支持从如下版本的Hadoop中读取Hive数据:sql

  • Apache Hadoop 1.x
  • Apache Hadoop 2.x
  • Cloudera CDH 4
  • Cloudera CDH 5

支持如下文件类型:Text, SequenceFile, RCFile, ORCapache

此外,须要有远程的Hive元数据。 不支持本地或嵌入模式。 Presto不使用MapReduce,只须要HDFS。bash

2.安装Prestorestful

下载Presto server,https://repo1.maven.org/maven2/com/facebook/presto/presto-server/0.107/,解压。app

Presto须要一个用于存储日志、本地元数据等的数据目录。 建议在安装目录的外面建立一个数据目录。这样方便Presto进行升级。jvm

在安装目录中建立一个etc目录。 在这个etc目录中放入如下配置信息:

  • 节点属性:每一个节点的环境配置信息
  • JVM 配置:JVM的命令行选项
  • 配置属性:Presto server的配置信息
  • Catalog属性:configuration forConnectors(数据源)的配置信息
  • log.properties :配置日志等级

etc目录结构及内容
├── catalog
│   ├── hive.properties
│   └── jmx.properties
├── config.properties
├── jvm.config
├── log.properties
└── node.properties

etc/config.properties  包含 Presto Server 相关的配置,每个 Presto Server 能够做为 coordinator 和 worker 使用。你能够将他们配置在一个节点上,若是资源容许建议分开配置以提升性能。

cat config.properties 

coordinator=true
node-scheduler.include-coordinator=true
datasources=jmx,hive
http-server.http.port=5050
task.max-memory=30GB
discovery-server.enabled=true
discovery.uri=http://ip:5050

 参数说明:

  • coordinator :Presto 实例是否以 coordinator 对外提供服务
  • node-scheduler.include-coordinator :是否容许在 coordinator 上进行调度任务
  • http-server.http.port :HTTP 服务的端口
  • task.max-memory=1GB :每个任务(对应一个节点上的一个查询计划)所能使用的最大内存
  • discovery-server.enabled :是否使用 Discovery service 发现集群中的每个节点。
  • discovery.uri :Discovery server 的 url
cat jvm.config 

-server
-Xmx64G
-XX:+UseConcMarkSweepGC
-XX:+ExplicitGCInvokesConcurrent
-XX:+CMSClassUnloadingEnabled
-XX:+AggressiveOpts
-XX:+HeapDumpOnOutOfMemoryError
-XX:OnOutOfMemoryError=kill -9 %p
-XX:PermSize=150M
-XX:MaxPermSize=150M
-XX:ReservedCodeCacheSize=150M
cat node.properties 
node.environment=production
node.id=ffffffff-ffff-ffff-ffff-ffffffffffff
node.data-dir=/app/Servers/presto/data
cat log.properties 
com.facebook.presto=DEBUG

在catalog目录下建立链接器,我使用的hive

cat hive.properties 
connector.name=hive-hadoop2
hive.metastore.uri=thrift://thrift_ip:9083
hive.config.resources=/app/Servers/hadoop-2.6.0/etc/hadoop/core-site.xml,/app/Servers/hadoop-2.6.0/etc/hadoop/hdfs-site.xml,/app/Servers/hadoop-2.6.0/etc/hadoop/mapred-site.xml

work节点的配置

cat config.properties 
coordinator=false
http-server.http.port=5050
task.max-memory=20GB
discovery.uri=http://10.58.50.249:5050

coordinator设为false

cat node.properties 
node.environment=production
node.id=ffffffff-ffff-ffff-ffff-ffffffffffe1
node.data-dir=/app/Servers/presto/data

不一样节点的node.id保证惟一,其余的配置文件不变便可。

3.启动presto

执行./launcher start,启动日志在node.data-dir=/app/Servers/presto/data下。

4.执行控制台

https://repo1.maven.org/maven2/com/facebook/presto/presto-cli/0.107/,下载

presto-cli-0.107-executable.jar   ,重命名为presto。

执行

./presto --server ip:5050 --catalog hive --schema default
presto:default> show tables;
        Table         
----------------------
 cougar               
 es_user              
 fc_rc_test           
 flume                
 flume1               
 flume_hive           
 glogs1               
 logs                 
 lzo                  
 lzo_test             
 orc_table            
 presto_test          
 price_log_monitor_es 
 t2                   
 test                 
 tmp                  
 tmp1                 
 tmp11                
 tmp4                 
 weblogs              
(20 rows)

Query 20160615_090000_00262_tz9jc, FINISHED, 1 node
Splits: 2 total, 2 done (100.00%)
0:00 [20 rows, 482B] [589 rows/s, 13.9KB/s]

presto:default> select * from orc_table limit 10;
      ts       |   application   |      sequence       |                    filename                    |     ip      |                                                                                                                     
---------------+-----------------+---------------------+------------------------------------------------+-------------+---------------------------------------------------------------------------------------------------------------------
 1461667475066 | item-restful    | 1461667475066125730 | /app/weblogic/item-restful/logs/restful.log    | 10.58.53.39 | **** INFO  2016-04-26 18:44:35,056 [http-nio-3122-exec-44] - Stock4DetailPageController.getExpectedDeliveryTimesFrom
 1461667475086 | item-restful_03 | 1461667475086651851 | /app/weblogic/item-restful_03/logs/restful.log | 10.58.53.39 | **** WARN  2016-04-26 18:44:35,077 [http-nio-3125-exec-229] - SuitsforcurPrdController.doGetInfo(SuitsforcurPrdContr
 1461667475086 | item-restful_03 | 1461667475086657958 | /app/weblogic/item-restful_03/logs/restful.log | 10.58.53.39 | **** ERROR 2016-04-26 18:44:35,079 [http-nio-3125-exec-229] - RestfulStandardResultFilter.doFilter(RestfulStandardRe
 1461667475086 | item-restful_03 | 1461667475086661850 | /app/weblogic/item-restful_03/logs/restful.log | 10.58.53.39 | org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.gome.item.re
 1461667475086 | item-restful_03 | 1461667475086668198 | /app/weblogic/item-restful_03/logs/restful.log | 10.58.53.39 |         at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:948)               
 1461667475086 | item-restful_03 | 1461667475086671503 | /app/weblogic/item-restful_03/logs/restful.log | 10.58.53.39 |         at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)                        
 1461667475086 | item-restful_03 | 1461667475086673650 | /app/weblogic/item-restful_03/logs/restful.log | 10.58.53.39 |         at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)                                             
 1461667475086 | item-restful_03 | 1461667475086675890 | /app/weblogic/item-restful_03/logs/restful.log | 10.58.53.39 |         at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)                      
 1461667475086 | item-restful_03 | 1461667475086676907 | /app/weblogic/item-restful_03/logs/restful.log | 10.58.53.39 |         at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)                                             
 1461667475086 | item-restful_03 | 1461667475086679302 | /app/weblogic/item-restful_03/logs/restful.log | 10.58.53.39 |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)        
(10 rows)

Query 20160615_090109_00265_tz9jc, FINISHED, 3 nodes
Splits: 27 total, 1 done (3.70%)
0:06 [0 rows, 0B] [0 rows/s, 0B/s]

presto:default>

web控制台查看执行的sql

http://ip:5050/

相关文章
相关标签/搜索