【Intel Galileo:2】cross compile toolchain (Board Support Package (BSP) Build Guide)
SD Linux に、なんか入れて使うなら、cross-compile しないと駄目だよって書いてあるように読めたので。。
uclib header file query | Intel Communities
以下の場所から、
「Intel〓 Quark SoC X1000 Board Support Package (BSP) Build Guide 」
を手に入れて、環境を作成してみた。
結構、大変だったぁ。。 ・゚・(ノД`)・゚・
作成した環境
Mac OSX にある、VirtualBox に、Debian 7.3 32bit の仮想環境を作成。
その上に、Board Support Package の cross compile toolchain をつくる。
Guest OS は
- CPU 1
- Memory 2G
- Disk 50G
で、動かしている。
以下、Build Guide にそって、やった事と、注意することを書いておく。
やんなかったところは、すっとばす。。
rootで、作業すると駄目なので、root以外のユーザで作業はする事。
Buildのスクリプトで、チェックがはいる。*1
Before you begin
Debian 7.0 で、検証しているので、それ以外の環境だと、Warning がでる。
Downloading software
から、
「Board_Support_Package_Sources_for_Intel_Quark_v0.9.0.7z」
を、ダウンロードした。
sudo aptitude install p7zip
展開する。
p7zip -d Board_Support_Package_Sources_for_Intel_Quark_v0.9.0.7z
以下のファイルが展開される。
Board_Support_Package_Sources_for_Intel_Quark_v0.9.0/Quark_EDKII_v0.9.0.tar.gz Board_Support_Package_Sources_for_Intel_Quark_v0.9.0/clanton_linux_v3.8.7+v0.9.0.tar.gz Board_Support_Package_Sources_for_Intel_Quark_v0.9.0/grub-legacy_5775f32a+v0.9.0.tar.gz Board_Support_Package_Sources_for_Intel_Quark_v0.9.0/meta-clanton_v0.9.0.tar.gz Board_Support_Package_Sources_for_Intel_Quark_v0.9.0/spi-flash-tools_v0.9.0.tar.gz Board_Support_Package_Sources_for_Intel_Quark_v0.9.0/sysimage_v0.9.0.tar.gz
準備。
sudo apt-get install build-essential gcc-multilib vim-common
Creating a file system and building the kernel using Yocto
必要なパッケージのインストール。
sudo aptitude install git sudo aptitude install diffstat sudo aptitude install texinfo sudo aptitude install gawk sudo aptitude install chrpath sudo aptitude install file
meta-clanton_v0.9.0.tar.gz の展開先を、
Board_Support_Package_Sources_for_Intel_Quark_v0.9.0 配下から
~/ へ移動して展開した。*2
cd ~
tar zxvf Board_Support_Package_Sources_for_Intel_Quark_v0.9.0/meta-clanton_v0.9.0.tar.gz
setupする。
cd meta-clanton_v0.9.0
./setup.sh
Building the cross compile toolchain
いよいよ、 toolchain の構築。
すごい時間がかかった。。*3
この source で、作られる環境で既存の環境を壊さない様に
必ず、新しい ターミナルを起動して作業する様に推奨されている。
cd meta-clanton_v0.9.0 source poky/oe-init-build-env yocto_build bitbake image-full -c populate_sdk
終了すると、セットアップの sh ができあがる。
yocto_build/tmp/deploy/sdk/clanton-tiny-uclibc-i686-i586-toolchain-1.4.2.sh
これを実行すると、環境が一式インストールされる。
デフォルトでは、/opt の配下にインストールされた。
ls -l /opt/clanton-tiny/1.4.2/ -rw-r--r-- 1 root root 2124 1月 26 13:01 environment-setup-i586-poky-linux-uclibc -rw-r--r-- 1 root root 14309 1月 26 06:33 site-config-i586-poky-linux-uclibc drwxr-xr-x 4 root root 4096 1月 26 06:30 sysroots -rw-r--r-- 1 root root 129 1月 26 06:33 version-i586-poky-linux-uclibc
cross compile する時には、ターミナルで新しく以下の source を実行して
コンパイルする。
source /opt/clanton-tiny/1.4.2/environment-setup-i586-poky-linux-uclibc
つぎは
一応、やりたい事があるので、作業してみてるけど、まだ、完了してないので
また、いつか。。
【Intel Galileo:1】入れてみる:LINUX IMAGE FOR SD for Intel Galileo
では、インストールして動かしてみる。
7zip
まずは、p7zipを入れてダウンロードした物を展開出来る様にする。
MBA20120331:~ guutara$ brew info p7zip p7zip: stable 9.20.1 http://p7zip.sourceforge.net/ Not installed From: https://github.com/Homebrew/homebrew/commits/master/Library/Formula/p7zip.rb ==> Options --32-bit Build 32-bit only MBA20120331:~ guutara$ brew install p7zip ==> Downloading http://downloads.sourceforge.net/project/p7zip/p7zip/9.20.1/p7zip_9.20.1_src_all.tar.bz2 ######################################################################## 100.0% ==> make all3 CC=clang $(ALLFLAGS) CXX=clang++ $(ALLFLAGS) ==> make DEST_HOME=/usr/local/Cellar/p7zip/9.20.1 DEST_MAN=/usr/local/Cellar/p7zip/9.20.1/share/man install ==> chmod -R +w /usr/local/Cellar/p7zip/9.20.1/share/doc/p7zip /usr/local/Cellar/p7zip/9.20.1: 66 files, 5.4M, built in 3.2 minutes
で、ここからダウンロード。
LINUX_IMAGE_FOR_SD_Intel_Galileo_v0.7.5.7z
MBA20120331:~ guutara$ 7z x ~/LINUX_IMAGE_FOR_SD_Intel_Galileo_v0.7.5.7z 7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 p7zip Version 9.20 (locale=utf8,Utf16=on,HugeFiles=on,4 CPUs) Processing archive: /Users/guutara/LINUX_IMAGE_FOR_SD_Intel_Galileo_v0.7.5.7z Extracting LINUX_IMAGE_FOR_SD_Intel_Galileo_v0.7.5/bzImage Extracting LINUX_IMAGE_FOR_SD_Intel_Galileo_v0.7.5/core-image-minimal-initramfs-clanton.cpio.gz Extracting LINUX_IMAGE_FOR_SD_Intel_Galileo_v0.7.5/boot/grub/grub.conf Extracting LINUX_IMAGE_FOR_SD_Intel_Galileo_v0.7.5/image-full-clanton.ext3 Extracting LINUX_IMAGE_FOR_SD_Intel_Galileo_v0.7.5/boot/grub Extracting LINUX_IMAGE_FOR_SD_Intel_Galileo_v0.7.5/boot Extracting LINUX_IMAGE_FOR_SD_Intel_Galileo_v0.7.5 Everything is Ok Folders: 3 Files: 4 Size: 318129066 Compressed: 38438374
ファイルを全て、コピーして準備完了。
電源とUSBケーブルを外した状態で、SDカードを刺し、電源を繋いで
USBケーブルも繋ぐ。
ネットワークは、MACと直結した。
Network
Networkは、DHCPで取得する様になっている。
とりあえず、直結して弄ってみるために、USB で接続した開発ツールから
ifconfig を動かす スケッチを書き込みます。
Samples of how to run Linux Commands via IDE
を入手すると、いろいろ、サンプルがあるので、それを参考につくった。
void setup() { system("ifconfig eth0 10.0.0.1 netmask 255.255.0.0 up"); //you can now use puTTY or your favourite telnet client //to connect to this IP address } void loop() { // put your main code here, to run repeatedly: system("ifconfig eth0 > /dev/ttyGS0"); sleep(5); }
これを、書き込む。
シリアルモニターで確認。
Networkの疎通を確認。
MBA20120331:~ guutara$ ping 10.0.0.1 PING 10.0.0.1 (10.0.0.1): 56 data bytes 64 bytes from 10.0.0.1: icmp_seq=0 ttl=64 time=4.080 ms 64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=1.222 ms 64 bytes from 10.0.0.1: icmp_seq=2 ttl=64 time=1.147 ms 64 bytes from 10.0.0.1: icmp_seq=3 ttl=64 time=1.254 ms 64 bytes from 10.0.0.1: icmp_seq=4 ttl=64 time=1.161 ms 64 bytes from 10.0.0.1: icmp_seq=5 ttl=64 time=1.164 ms
ssh
sshで繋いでなかを確認してみる。
MBA20120331:~ guutara$ ssh root@10.0.0.1 The authenticity of host '10.0.0.1 (10.0.0.1)' can't be established. RSA key fingerprint is 64:55:b1:7c:99:9e:cf:8c:90:71:75:a2:10:0e:11:bd. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.0.0.1' (RSA) to the list of known hosts. root@clanton:~# ps PID USER VSZ STAT COMMAND 1 root 796 S init [5] 2 root 0 SW [kthreadd] 3 root 0 SW [ksoftirqd/0] 4 root 0 SW [kworker/0:0] 5 root 0 SW< [kworker/0:0H] 6 root 0 SW [kworker/u:0] 7 root 0 SW< [kworker/u:0H] 8 root 0 SW< [cpuset] 9 root 0 SW< [khelper] 10 root 0 SW [kdevtmpfs] 11 root 0 SW< [netns] 12 root 0 SW [kworker/u:1] 119 root 0 SW [bdi-default] 121 root 0 SW< [kblockd] 200 root 0 SW [kworker/0:1] 329 root 0 SW [kswapd0] 384 root 0 SW [fsnotify_mark] 396 root 0 SW< [crypto] 526 root 0 SW< [deferwq] 529 root 0 SW [mmcqd/0] 745 root 0 SW< [kworker/0:1H] 933 root 0 SW< [loop0] 934 root 0 SW [kjournald] 996 root 0 SW [khubd] 1052 root 0 SW [irq/61-0-0020] 1094 root 0 SW [spi0] 1097 root 0 SW [spi1] 1126 root 0 SW< [cfg80211] 1450 messageb 1464 S /usr/bin/dbus-daemon --system 1461 root 3256 S /usr/sbin/sshd 1476 root 1264 S /sbin/syslogd -n -O /var/log/messages 1479 root 1260 S /sbin/klogd -n 1482 root 1264 S /sbin/getty 115200 ttyS1 1483 root 1264 S /sbin/getty 38400 tty1 1484 root 768 S /opt/cln/galileo/galileo_sketch_reset -v 1485 root 1852 S {clloader.sh} /bin/sh /etc/init.d/clloader.sh 1487 root 876 S /opt/cln/galileo/clloader --escape --binary --zmodem --disable-timeouts 1500 root 18292 S /sketch/sketch.elf /dev/pts/0 /dev/ttyS0 1601 root 3316 R {sshd} sshd: root@pts/1 1605 root 1912 S -sh 2288 root 1840 S /bin/sh -c ifconfig eth0 > /dev/ttyGS0 2289 root 1264 S ifconfig eth0 2291 root 1264 R ps
/var/log/messagesの先頭は、以下の感じ。。
Jan 1 00:01:06 clanton syslog.info syslogd started: BusyBox v1.20.2 Jan 1 00:01:06 clanton kern.notice kernel: klogd started: BusyBox v1.20.2 (2013-10-01 00:17:01 IST) Jan 1 00:01:06 clanton kern.info kernel: [ 0.000000] Initializing cgroup subsys cpuset Jan 1 00:01:06 clanton kern.info kernel: [ 0.000000] Initializing cgroup subsys cpu Jan 1 00:01:06 clanton kern.notice kernel: [ 0.000000] Linux version 3.8.7-yocto-standard (clntonsw@irsswdev001) (gcc versio n 4.7.2 (GCC) ) #1 Tue Oct 1 00:09:01 IST 2013
つぎ
Linuxまで、一応は、動いたので、このあと何に使うか、ぼちぼち、試してみようかな。
USBの接続が、うまくいったりいかなかったりするのが、ちょっと、不安。。
【Intel Galileo:0】とりあえず、いじってみる
勢いで、買ってしまったので、ちょっと使ってみる事に。
そもそも、こういう分野は苦手でござる。。
じゃなんで、買ったんかって言うと、ほんとうに、手が滑った系。。
開発ツール (mac osx )
まずは、これを、DownLoad
Software Downloads for Boards and Kits
Intel_Galileo_Arduino_SW_1.5.3_on_MacOSX_v0.7.5.zip
電源をいれてから、USBで、MAC と接続した。
シリアルポートは、以下のところに繋がっていた。
確かめる方法が、よくわからなかったので、ほぼ、勘になってしまった。
ヘルプから、Firmware update を選んで、アップデート。
Example
helpの初心者向けガイドにある
6 | Open the blink example Open the LED blink example sketch: File > Examples > 1.Basics > Blink.
を動かしてみる。
といっても、LED もってないので、動いたのかよくわからんのだが、
一応、ボードのLEDもチカチカしたので、動いたみたい。
次は
SD Linux をいれてみよう。。。
【Facebook Presto:2】Presto Hive Perfomance Test (Hive-CDH4 Plugin)
【Facebook Presto:1】Presto 3Node で、動かす (Hive-CDH4 Plugin) - Guutaraの日記
で作成した、環境にてテストをしてみたので、簡単に記述しておきます。
2014-01-10 に、追記・訂正があります。Prestoが遅かった原因です。
Memory
jvm.config の -Xmx を増加してみました。
結果としては、処理スピードに効果はありませんでした。
config.properties の、task.max-memory も、増減してみましたが
処理スピードに変化はありませんでした。
基本的に、task.max-memory は、Joinの結果の大きさに関係するだけのようです。
以下、jvm.comfigの変更した結果のみ記述しておきます。
[root@data2 ~]# vi /opt/presto-server-0.56/etc/jvm.config [root@data2 ~]# cat /opt/presto-server-0.56/etc/jvm.config -server -Xmx8G -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 [root@data3 ~]# vi /opt/presto-server-0.56/etc/jvm.config [root@data3 ~]# cat /opt/presto-server-0.56/etc/jvm.config -server -Xmx8G -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 [root@data4 ~]# vi /opt/presto-server-0.56/etc/jvm.config [root@data4 ~]# cat /opt/presto-server-0.56/etc/jvm.config -server -Xmx8G -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
再起動します。
[root@data2 ~]# ps aux | grep presto root 16298 0.0 0.0 107516 964 pts/1 S+ 15:35 0:00 grep presto [root@data2 ~]# /opt/presto-server-0.56/bin/launcher start Started as 22474 [root@data2 ~]# ps aux | grep presto root 22474 138 0.8 11010252 140820 ? Ssl 15:35 0:04 java -cp /opt/presto-server-0.56/lib/* -server -Xmx8G -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 -Dlog.output-file=/var/presto/data/var/log/server.log -Dnode.data-dir=/var/presto/data -Dnode.id=ffffffff-ffff-ffff-ffff-ffffffffffff -Dnode.environment=production -Dlog.enable-console=false -Dlog.levels-file=/opt/presto-server-0.56/etc/log.properties -Dconfig=/opt/presto-server-0.56/etc/config.properties com.facebook.presto.server.PrestoServer root 24251 0.0 0.0 107516 964 pts/1 S+ 15:35 0:00 grep presto [root@data2 ~]# free -m total used free shared buffers cached Mem: 15936 13470 2466 0 578 9658 -/+ buffers/cache: 3233 12703 Swap: 16383 146 16237 [root@data3 ~]# ps aux | grep presto root 3547 0.0 0.0 107508 972 pts/0 S+ 15:36 0:00 grep presto [root@data3 ~]# /opt/presto-server-0.56/bin/launcher start Started as 3589 [root@data3 ~]# ps aux | grep presto root 3589 196 1.2 14870856 202196 ? Ssl 15:36 0:09 java -cp /opt/presto-server-0.56/lib/* -server -Xmx8G -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 -Dlog.output-file=/var/presto/data/var/log/server.log -Dnode.data-dir=/var/presto/data -Dnode.id=3fffffff-ffff-ffff-ffff-ffffffffffff -Dnode.environment=production -Dlog.enable-console=false -Dlog.levels-file=/opt/presto-server-0.56/etc/log.properties -Dconfig=/opt/presto-server-0.56/etc/config.properties com.facebook.presto.server.PrestoServer root 3691 0.0 0.0 107508 972 pts/0 S+ 15:37 0:00 grep presto [root@data3 ~]# free -m total used free shared buffers cached Mem: 15936 14870 1066 0 550 8823 -/+ buffers/cache: 5496 10440 Swap: 16383 15 16368 [root@data4 ~]# /opt/presto-server-0.56/bin/launcher start Started as 30846 [root@data4 ~]# ps aux | grep presto root 30846 198 1.5 17656772 250956 ? Ssl 15:37 0:15 java -cp /opt/presto-server-0.56/lib/* -server -Xmx8G -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 -Dlog.output-file=/var/presto/data/var/log/server.log -Dnode.data-dir=/var/presto/data -Dnode.id=4fffffff-ffff-ffff-ffff-ffffffffffff -Dnode.environment=production -Dlog.enable-console=false -Dlog.levels-file=/opt/presto-server-0.56/etc/log.properties -Dconfig=/opt/presto-server-0.56/etc/config.properties com.facebook.presto.server.PrestoServer root 31099 0.0 0.0 107508 988 pts/0 S+ 15:38 0:00 grep presto [root@psdata4 ~]# free -m total used free shared buffers cached Mem: 15936 14475 1461 0 358 11819 -/+ buffers/cache: 2297 13639 Swap: 16383 1 16382 [root@data4 ~]#
実行テストの結果です。
変更前
presto:default> select name,count(1) from oracle_sysstat where name like '%physical%' group by name; . . Splits: 21 total, 15 done (71.43%) 2:42 [9.96M rows, 1GB] [61.6K rows/s, 6.36MB/s]
変更後
presto:default> select name,count(1) from oracle_sysstat where name like '%physical%' group by name; . . Splits: 21 total, 16 done (76.19%) 2:50 [9.97M rows, 1.01GB] [58.6K rows/s, 6.05MB/s]
HIVE より遅い問題。
実行時間が、HIVEよりも遅い問題が発生していました。
原因としては、HIVEの外部テーブルを使用し、外部テーブルがフラットなファイルになっていた為でした。
原因としては、独自のSerDeを使用していた為でした。
外部テーブルからHIVE内に取り込み、バイナリにした結果、高速化しました。
HIVEで実行した場合も、速度の向上はありましたが、Prestoは、劇的に高速化しました。
原因が、外部テーブルか、フラットなせいかは、不明です。ただ、presto のml には、rcファイルにしないと駄目だと言う記述が散見されていました。
prestoのmlには、RCFileにしないと遅いという話がありましたが、今回程度の大きさだと、あまり差はありませんでした。
バイナリのサイズは、以下の感じです。
_hive は、HIVEで、create tableしたものです。
_prestoは。prestoで、create tableしました。
882629318 /user/hive/warehouse/oracle_sysstat_hive 868295034 /user/hive/warehouse/oracle_sysstat_presto
presto 実行結果
以下の処理を流しました。
presto:default> select name,count(1) from oracle_sysstat where name like '%physical%' group by name;
変更前
約3分
Query 20140108_072301_00003_xmb5p, FINISHED, 3 nodes Splits: 21 total, 18 done (85.71%) 2:50 [10M rows, 1.01GB] [58.9K rows/s, 6.08MB/s]
変更後
2秒
Query 20140108_090836_00052_xmb5p, FINISHED, 3 nodes Splits: 19 total, 16 done (84.21%) 0:02 [9.81M rows, 821MB] [4.17M rows/s, 349MB/s]
HIVE 実行結果
実行したものは、同じです。
変更前
45秒
. . . MapReduce Total cumulative CPU time: 3 minutes 11 seconds 180 msec Ended Job = job_201311121157_6392 MapReduce Jobs Launched: Job 0: Map: 5 Reduce: 2 Cumulative CPU: 191.18 sec HDFS Read: 1082379240 HDFS Write: 867 SUCCESS Total MapReduce CPU Time Spent: 3 minutes 11 seconds 180 msec . . Time taken: 45.015 seconds
変更後
19秒
. . . MapReduce Total cumulative CPU time: 50 seconds 260 msec Ended Job = job_201311121157_6431 MapReduce Jobs Launched: Job 0: Map: 4 Reduce: 1 Cumulative CPU: 50.26 sec HDFS Read: 280179952 HDFS Write: 867 SUCCESS Total MapReduce CPU Time Spent: 50 seconds 260 msec . . Time taken: 17.889 seconds
まとめ
これは、どんどん、使ったほうが良いと思います。
実際、どういう理由で、こんだけ速いのか? heapが、いらないのかが不思議で仕方ないです。
今後も、試してみようと思います。
なんか、同じ環境で、spark + shark でやったより、速いんだよなぁ。。
【Facebook Presto:1】Presto 3Node で、動かす (Hive-CDH4 Plugin)
FaceBook のエンジニアが、公開している
Presto | Distributed SQL Query Engine for Big Data
を、試してみる事にします。
1Node は動いたので、3Nodeで構築してみることに。
Install
3Node しかないので、Discovery Service (discovery-server-1.16.tar.gz)
は、使用しません。前回( 2014-01-04 - Guutaraの日記)のNodeを
Discovery としても、使用します。
Presto には、Discovery Service の機能も入っていますので、Nodeが小さいうちは兼用で良いようです。
前回構築した、ディレクトリを再利用して作ります。その方が、楽なので。。
[root@data2 opt]# tar zcvf presto-server-mod-0.56.tar.gz presto-server-0.56
これを、2Nodeにコピーをして、opt配下に展開しておきます。
config
node.properties は、node.id を、一意にかえます。
[root@data3 opt]# vi presto-server-0.56/etc/node.properties [root@data3 opt]# cat presto-server-0.56/etc/node.properties node.environment=production node.id=3fffffff-ffff-ffff-ffff-ffffffffffff node.data-dir=/var/presto/data
[root@data4 opt]# vi presto-server-0.56/etc/node.properties [root@data4 opt]# cat presto-server-0.56/etc/node.properties node.environment=production node.id=4fffffff-ffff-ffff-ffff-ffffffffffff node.data-dir=/var/presto/data
config.properties は、どのノードも同じものになりました。
[root@data3 ~]# vi /opt/presto-server-0.56/etc/config.properties [root@data3 ~]# cat /opt/presto-server-0.56/etc/config.properties coordinator=false 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.uri=http://data2.hadoop.local:9090
[root@data4 opt]# vi presto-server-0.56/etc/config.properties [root@data4 opt]# cat presto-server-0.56/etc/config.properties coordinator=false 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.uri=http://data2.hadoop.local:9090
Test (1Node,2Node,3Node,HIVE)
1〜3Nodeで、同じQueryを流してみました。
ついでに、HIVEも。。。
Nodeを追加すると、Prestoは、ほぼ、リニアに性能は向上しました。
HIVEは、同じNodeで動いているので、Node数などは、一緒の状態。
ただし、Prestoは、512mb しかメモリは割り当てられていないので、大分、不利ですけど。
それでも、2倍の性能はでました。
こんどは、JDBCで、試してみたいけど、
あまり、完成度があがってないようなので、もう少しまとうかなと、思ってます。。
以下、結果です。
Test Results
1Node
(0:35 [659K rows, 61.4MB] [18.9K rows/s, 1.76MB/s])
[root@data2 opt]# ~/presto --server psdata2.hadoop.local:9090 --catalog hive --schema default presto:default> select time from oracle_sysstat limit 5; time ---------------------- 2013-10-31T08:36:28Z 2013-10-31T08:36:28Z 2013-10-31T08:36:28Z 2013-10-31T08:36:28Z 2013-10-31T08:36:28Z (5 rows) Query 20140106_075412_00021_v8qy2, FINISHED, 1 node Splits: 18 total, 2 done (11.11%) 0:35 [659K rows, 61.4MB] [18.9K rows/s, 1.76MB/s] presto:default>
2Node
(0:18 [659K rows, 61.4MB] [37.2K rows/s, 3.46MB/s])
presto:default> select time from oracle_sysstat limit 5; time ---------------------- 2013-10-31T08:52:18Z 2013-10-31T08:52:18Z 2013-10-31T08:52:18Z 2013-10-31T08:52:18Z 2013-10-31T08:52:18Z (5 rows) Query 20140106_075738_00023_v8qy2, FINISHED, 2 nodes Splits: 18 total, 3 done (16.67%) 0:18 [659K rows, 61.4MB] [37.2K rows/s, 3.46MB/s]
3Node
(0:08 [731K rows, 58.8MB] [86.5K rows/s, 6.96MB/s])
presto:default> select time from oracle_sysstat limit 5; time ---------------------- 2013-10-31T13:25:20Z 2013-10-31T13:25:20Z 2013-10-31T13:25:20Z 2013-10-31T13:25:20Z 2013-10-31T13:25:20Z (5 rows) Query 20140106_103939_00052_v8qy2, FINISHED, 3 nodes Splits: 18 total, 6 done (33.33%) 0:08 [731K rows, 58.8MB] [86.5K rows/s, 6.96MB/s]
HIVE
(Time taken: 17.035 seconds)
[root@data2 opt]# hive Logging initialized using configuration in file:/etc/hive/conf-cdh4-ha-hive/hive-log4j.properties Hive history file=/tmp/root/hive_job_log_aa84ad1a-5ef6-4d22-85f5-adc8092f310e_2034885544.txt hive> select time from oracle_sysstat limit 5; Total MapReduce jobs = 1 Launching Job 1 out of 1 Number of reduce tasks is set to 0 since there's no reduce operator Starting Job = job_201311121157_6297, Tracking URL = http://data4.hadoop.local:50030/jobdetails.jsp?jobid=job_201311121157_6297 Kill Command = /usr/lib/hadoop/bin/hadoop job -kill job_201311121157_6297 Hadoop job information for Stage-1: number of mappers: 5; number of reducers: 0 2014-01-06 17:00:07,682 Stage-1 map = 0%, reduce = 0% 2014-01-06 17:00:11,716 Stage-1 map = 80%, reduce = 0%, Cumulative CPU 5.16 sec 2014-01-06 17:00:12,730 Stage-1 map = 100%, reduce = 0%, Cumulative CPU 6.44 sec 2014-01-06 17:00:13,739 Stage-1 map = 100%, reduce = 0%, Cumulative CPU 6.44 sec 2014-01-06 17:00:14,748 Stage-1 map = 100%, reduce = 0%, Cumulative CPU 6.44 sec 2014-01-06 17:00:15,758 Stage-1 map = 100%, reduce = 100%, Cumulative CPU 6.44 sec MapReduce Total cumulative CPU time: 6 seconds 440 msec Ended Job = job_201311121157_6297 MapReduce Jobs Launched: Job 0: Map: 5 Cumulative CPU: 6.44 sec HDFS Read: 38476 HDFS Write: 525 SUCCESS Total MapReduce CPU Time Spent: 6 seconds 440 msec OK 2013-10-31T08:23:48Z 2013-10-31T08:23:48Z 2013-10-31T08:23:48Z 2013-10-31T08:23:48Z 2013-10-31T08:23:48Z Time taken: 17.035 seconds
*1:実は、Spark,Sharkも、動いているんですがね。。
【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]
いい感じですね。。
まとめ
以外と簡単に動かす事ができました。
いろんな、データストアーに対して、単一の方法でクエリーをかける可能性は魅力的。
つぎは、複数ノードにトライしてみようかな。
2013 大晦日
ちょっとした時間ができた。
せっかくだから、なにか書き留めておこう。
はじめとおわりの日記
Mahout で、書き初めて Sparkで、終わってる。
どちらも、それほど使い込んだわけではないのだけど、そういう方向だったんだなぁ、
ってのは、いまさらながらに、気が付いた。
貯蔵庫としての、データベースに一種類の入れ物を使うのではなくて、
用途に合わせた容器と素材とお値段で、賄うのが、ようやく広まりそうな気配。
その上で、うまいとかまずいとかを断定するには、いたってないとおもうけど。
機械学習は、まだまだ、来年以降かなぁと、思って終わっていく大晦日だった。
組織のこと
何年間かかかったけれど、無から作りはじめた組織を、世代交代できたのはよかた。
いまでは、当たり前のように、データベースの技術者やJava APサーバ
の技術者やらが、プロパの基盤の中にいるけれど、そんなもの、なかったからなぁ。w
SIerに騙されない、製品ベンダーから必要な知識を引き出す、とか、
まぁ、少しはましになった程度で降りちゃうけど、じじいが、いつまでやってても
いいことないしね。
おかげで、一人で、組織の面倒を見ない生活ができて、今年の終わりはよい終わり方だった。
老兵は...
世代交代を早めていかないと、色んな事が確実に間に合わない。
自分が組織を世代交代をしたのも、その意思表示なんだけど。
進むのに邪魔な、「文化」「空気」「価値観」とかは、老害から産まれているもの
が多いのも、実感できたし。
それは、僕らと僕らの上の世代が作り上げた、おりのようなものなのかなぁ。*1
人生の半世紀を去年終え、新しい半世紀の新年度の今年は、
確かにそれまでとは色々、違っていくのだと感じた。
エンジニア
なりたかったけど、なれなかったものだったんだよなぁ。
エンジニアという人材を、組織の中で
「愛嬌」があり、
「変」だったり
「異質」だったりもするが
「必要」で「尊敬」もできる
共存可能な生物としての生存権と生息域を作る
のが自分のエンジニアリングになっていく気がする。
コード読んだり書いたり、FreeSoft,OSS,企業の製品を、学んだりする事は、続けるけども
そこから、何かをアウトする事よりも、前述の方が、比較優位性でいうと効果高い。
あんまり、おもしろくはないけどなぁ。。
感謝
今年も、沢山の人やソフトウェアや、ハードウェアに、お世話になりました。
恩返しをするより先に、消えてなくなると思いますが、それまで、よしなに。。
よいおとしをおむかえください。。。
*1:自戒の念というか、おれだいじょうぶか? と、加齢臭なみに自覚が難しいのも目の当たりにして、色々、落ち込む現実もある。。。