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/

相關文章
相關標籤/搜索