LoginSignup
16
16

More than 5 years have passed since last update.

Greenplum Database(オープンソース版)使ってみた

Last updated at Posted at 2015-10-28

早速使ってみました。

インストール時にいろいろ詰まったので、そのメモです。
簡単なクエリを投げるところまで書きました。

環境

CentOS 6.5

ソースコードの入手

githubから入手します。

$ git clone https://github.com/greenplum-db/gpdb

コンパイル

configureスクリプト

$ cd gpdb
$ ./configure --prefix=/opt/gp
:
:
checking for curl >= 7.20.0... can't find curl >=7.20.0
configure: error Library requirements (curl) not met.
$

curlが古いと怒られたので、http://curl.haxx.se/download.html から新しいバージョンを入手。
解凍してcurlのインストール

$ tar zxf curl-7.45.0.tar.bz2
$ cd curl-7.45.0
$ ./configure
$ make
# make install
$ curl --version
curl 7.45.0 (x86_64-pc-linux-gnu) libcurl/7.45.0 OpenSSL/1.0.1e zlib/1.2.3 libidn/1.18
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: IDN IPv6 Largefile NTLM NTLM_WB SSL libz UnixSockets

再度、configureを実行

$ ./configure --prefix=/opt/gp

完了!

make && make install

次はmake。

$ make -j 3
:
All of Greenplum Database successfully made. Ready to install.
$

makeはすんなり完了。
次はインストール。

$ make install
:
./gpMgmt/bin/pythonSrc/ext/ && /bin/tar xzf lockfile-0.9.1.tar.gz
tar (child): lockfile-0.9.1.tar.gz: open 不能: そのようなファイルやディレクトリはありません
tar (child): Error is not recoverable: exiting now
/bin/tar: Child returned status 2
/bin/tar: Error is not recoverable: exiting now
make[2]: *** [lockfile] エラー 2
make[2]: ディレクトリ `/opt/source/gpdb/gpMgmt/bin' から出ます
make[1]: *** [install] エラー 2
make[1]: ディレクトリ `/opt/source//gpdb/gpMgmt' から出ます
make: *** [install] エラー 2

./gpMgmt/bin/pythonSrc/ext/にlockfile-0.9.1.tar.gzがなくてエラーとなっている。
実はlockfile-0.9.1.tar.gzを準備した後も、他のpythonライブラリがなくて次々にmake installが失敗した。
make installが成功するまでに自分で準備したファイルは以下の通り。

  • lockfile-0.9.1.tar.gz
  • pychecker-0.8.18.tar.gz
  • pycrypto-2.0.1.tar.gz
  • unittest2-0.5.1.targz
  • PSI-0.3b2.tar.gz
  • paramiko-1.7.6.tar.gz

ただし、paramiko-1.7.6.tar.gz→paramiko-1.7.6-9.tar.gz、PSI-0.3b.tar.gz→PSI-0.3b_gp.tar.gzにパッケージ名(解凍後のディレクトリも含む)を変更する必要があった。
もっとスマートにできる方法あると思うので、知っている方がいたら教えて下さい。

これらのパッケージを/gpMgmt/bin/pythonSrc/extに移動して再度実行。

$ make install
:
Greenplum Database installation complete.
$

無事完了。

データベースを構築

今回は、http://gpdb.docs.pivotal.io/gs/43/pdf/GPDB43xGettingStarted.pdf を参考に単一サーバに3台(マスタサーバ1台、セグメントサーバ2台)

$ /opt/gp
$ mkdir /opt/{gpmaster, gpdata1, gpdata2}
$ source greenplum_path.sh
$ cp docs/cli_help/gpconfigs/*_singlenode .
$ chmod +w *_singlenode
$ vi gpinitsystem_singlenode
ARRAY_NAME="GPDB SINGLENODE" 
MACHINE_LIST_FILE=./hostlist_singlenode
SEG_PREFIX=gpsne
PORT_BASE=40000 
declare -a DATA_DIRECTORY=(/opt/gpdata1 /opt/gpdata2)
MASTER_HOSTNAME=127.0.0.1
MASTER_DIRECTORY=/opt/gpmaster
MASTER_PORT=5432
$ vi hostlist_singlenode
127.0.0.1
$ gpssh-exkeys -h 127.0.0.1
$ gpinitsystem -c gpinisytem_singlenode
:
Continue with Greenplum creation Yy/Nn> y
:
[INFO]:-Database successfully started.
:
$

完了

ちょっと使ってみる

テーブルを作成して、100万件のデータを投入。
(5432ポートでマスタサーバがListenしています)

$ psql -d postgres
psql (8.2.15)
Type "help" for help.
=# create table hoge (col1 int, col2 text) distributed by (col1);
=# insert into hoge select generate_series(1, 1000000);

次はcount(*)の実行計画を見てみる。

                                                                         QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------
 Aggregate  (cost=13623.53..13623.54 rows=1 width=8)
   Rows out:  1 rows with 491 ms to end, start offset by 0.512 ms.
   ->  Gather Motion 2:1  (slice1; segments: 2)  (cost=13623.48..13623.52 rows=1 width=8)
         Rows out:  2 rows at destination with 429 ms to first row, 491 ms to end, start offset by 0.514 ms.
         ->  Aggregate  (cost=13623.48..13623.49 rows=1 width=8)
               Rows out:  Avg 1.0 rows x 2 workers.  Max 1 rows (seg0) with 490 ms to end, start offset by 1.248 ms.
               ->  Seq Scan on hoge  (cost=0.00..11119.18 rows=500859 width=0)
                     Rows out:  Avg 500000.0 rows x 2 workers.  Max 500001 rows (seg0) with 0.056 ms to first row, 382 ms to end, start offset by 1.248 ms.
 Slice statistics:
   (slice0)    Executor memory: 159K bytes.
   (slice1)    Executor memory: 163K bytes avg x 2 workers, 163K bytes max (seg0).
 Statement statistics:
   Memory used: 128000K bytes
 Total runtime: 492.106 ms
(14 rows)

Time: 517.075 ms

PostgreSQLと出力が違うのでちゃんとは読めないけど、1つのテーブルを2つのworkerで分散して集計しているっぽい。

メモ終わり。

16
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
16