【Facebook Presto:0】Presto 1Node で、動かす (Hive-CDH4 Plugin)
酒飲むのにも、飽きたので。。
FaceBook のエンジニアが、公開している
Presto | Distributed SQL Query Engine for Big Data
を、試してみる事にします。
まずは、1Node で、構築してみることに。
Install
以下を参考にします。
2. Installation — Presto 0.131 Documentation
Presto DownLoad
curl -L -O http://central.maven.org/maven2/com/facebook/presto/presto-server/0.56/presto-server-0.56.tar.gz
で、ダウンロードします。
そのあと、opt配下に、展開しました。
[root@ ~]# curl -L -O http://central.maven.org/maven2/com/facebook/presto/presto-server/0.56/presto-server-0.56.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 85.7M 100 85.7M 0 0 4065k 0 0:00:21 0:00:21 --:--:-- 9745k [root@ ~]# cd /opt/ [root@ opt]# tar zxf ~/presto-server-0.56.tar.gz [root@ opt]# ls hive-0.9.0-shark-0.8.0-bin presto-server-0.56 scala-2.9.3 shark-0.8.0 spark
Config
Prestoのコンフィグを設定します。基本的に、展開した directory の配下に、etcを作りその配下に配置していきます。
また、Prestoは、Data Access に Connector を使用します。Connectorの設定は、etc/catalogの配下に配置します。
以下の設定は、1Nodeで動かす際の設定値です。
Connector は、HIVE-CDH4を使用しています。
[root@ ]# cd /opt/presto-server-0.56/ [root@ presto-server-0.56]# mkdir etc [root@ presto-server-0.56]# mkdir etc/catalog [root@ presto-server-0.56]# ls NOTICE README.txt bin etc lib plugin
etc/node.properties
[root@ presto-server-0.56]# vi etc/node.properties [root@ presto-server-0.56]# cat etc/node.properties node.environment=production node.id=ffffffff-ffff-ffff-ffff-ffffffffffff node.data-dir=/var/presto/data [root@ presto-server-0.56]# mkdir -p /var/presto/data
etc/jvm.config
[root@ presto-server-0.56]# vi etc/jvm.config [root@ presto-server-0.56]# cat etc/jvm.config -server -Xmx512M -XX:+UseConcMarkSweepGC -XX:+ExplicitGCInvokesConcurrent -XX:+CMSClassUnloadingEnabled -XX:+AggressiveOpts -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError=kill -9 %p -XX:PermSize=150M -XX:MaxPermSize=150M -XX:ReservedCodeCacheSize=150M -Xbootclasspath/p:/opt/presto-server-0.56/lib/floatingdecimal-0.1.jar
etc/config.properties
[root@ presto-server-0.56]# vi etc/config.properties [root@ presto-server-0.56]# cat etc/config.properties coordinator=true datasources=jmx,hive http-server.http.port=9090 presto-metastore.db.type=h2 presto-metastore.db.filename=var/db/MetaStore task.max-memory=256GB discovery-server.enabled=true discovery.uri=http://localhost:9090
etc/log.properties
[root@ presto-server-0.56]# vi etc/log.properties [root@ presto-server-0.56]# cat etc/log.properties com.facebook.presto=DEBUG
etc/catalog/jmx.properties
[root@ presto-server-0.56]# vi etc/catalog/jmx.properties [root@ presto-server-0.56]# cat etc/catalog/jmx.properties connector.name=jmx
etc/catalog/hive.properties
[root@ presto-server-0.56]# vi etc/catalog/hive.properties [root@ presto-server-0.56]# cat etc/catalog/hive.properties connector.name=hive-cdh4 hive.metastore.uri=thrift://data3.hadoop.local:9083 hive.config.resources=/etc/hadoop/conf/core-site.xml,/etc/hadoop/conf/hdfs-site.xml
HIVE MetaException
HIVEのテーブルを使用するときに、
MetaException(message:org.apache.hadoop.hive.serde2.SerDeException SerDe xxxxxx does not exist)
が発生する事があります。
この場合、必要な jar を、HIVEのlibからもってくるか、ln -s で、connectorの中に配置します。
今回は、以下の感じになります。
[root@ ~]# ln -s /usr/lib/hive/lib/xxxxxx.jar plugin/hive-cdh4/
Run in the foreground
まずは、確認のため、foregroundで起動します。
bin/launcher run で、起動すると foreground です。
基本的な設定が間違っていなければ起動するはずです。*4
Command Line Tool
Presto を操作するための Command Line が用意されているので、DownLoad して使います。
curl -L -o presto http://central.maven.org/maven2/com/facebook/presto/presto-cli/0.56/presto-cli-0.56-executable.jar
で、DownLoadします。
そのあと、実行できるようにしておきます。
[root@ ~]# curl -L -o presto http://central.maven.org/maven2/com/facebook/presto/presto-cli/0.56/presto-cli-0.56-executable.jar % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 12.0M 100 12.0M 0 0 1875k 0 0:00:06 0:00:06 --:--:-- 8352k [root@ ~]# chmod 0744 presto [root@ ~]# ls -l presto -rwxr--r-- 1 root root 12683954 1月 3 14:17 2014 presto
Try (schema sys)
まず、sys の schema で確認してみます。
server は、Localhost, Connector(catalog)は、hive、schema をsysで指定します。
[root@ ~]# ./presto --server localhost:9090 --catalog hive --schema sys presto:sys> show tables; Table --------- alias catalog node query task (5 rows) Query 20140103_052416_00009_rajut, FINISHED, 1 node Splits: 2 total, 2 done (100.00%) 0:00 [5 rows, 90B] [35 rows/s, 647B/s]
presto:sys> select * from query; node_id | query_id | state | user | que --------------------------------------+-----------------------------+----------+------+----------------------------------------- ffffffff-ffff-ffff-ffff-ffffffffffff | 20140103_052412_00008_rajut | FINISHED | root | SELECT table_name FROM information_schem ffffffff-ffff-ffff-ffff-ffffffffffff | 20140103_052451_00010_rajut | RUNNING | root | select * from query . . . Query 20140103_052451_00010_rajut, FINISHED, 1 node Splits: 2 total, 2 done (100.00%) 3:36 [22 rows, 3.78KB] [0 rows/s, 17B/s]
ちゃんと、動いているようです。
Try (schema default)
すでに Hadoop HIVE で、作成していたテーブルを使用します。
schema をdefaultで指定します。
[root@ ~]# /opt/presto-server-0.56/bin/launcher start Started as 19014 [root@ ~]# ./presto --server localhost:9090 --catalog hive --schema default presto:default> show tables; Table --------------------------------------- oracle_sysstat . . . Query 20140104_070906_00002_ekdea, FINISHED, 1 node Splits: 2 total, 2 done (100.00%) 0:00 [8 rows, 347B] [41 rows/s, 1.75KB/s] presto:default> DESCRIBE oracle_sysstat; Column | Type | Null | Partition Key ----------+---------+------+--------------- time | varchar | true | false tag | varchar | true | false datetime | varchar | true | false name | varchar | true | false value | double | true | false (5 rows) Query 20140104_070915_00003_ekdea, FINISHED, 1 node Splits: 2 total, 1 done (50.00%) 0:01 [0 rows, 0B] [0 rows/s, 0B/s] presto:default> select time from oracle_sysstat limit 10; time ---------------------- 2013-10-31T13:24:50Z 2013-10-31T13:24:50Z 2013-10-31T13:24:50Z 2013-10-31T13:24:50Z 2013-10-31T13:24:50Z 2013-10-31T13:24:50Z 2013-10-31T13:24:50Z 2013-10-31T13:24:50Z 2013-10-31T13:24:50Z 2013-10-31T13:24:50Z (10 rows) Query 20140104_071917_00005_ekdea, FINISHED, 1 node Splits: 18 total, 1 done (5.56%) 0:35 [557K rows, 57.5MB] [15.8K rows/s, 1.63MB/s]
いい感じですね。。
まとめ
以外と簡単に動かす事ができました。
いろんな、データストアーに対して、単一の方法でクエリーをかける可能性は魅力的。
つぎは、複数ノードにトライしてみようかな。