LoginSignup
2
2

More than 3 years have passed since last update.

Presto 0.227 Install on CentOS

Last updated at Posted at 2020-04-25

はじめに

Prestoは、HiveやMySQL, Object Storage などと連携した、高速なSQLエンジンです。様々なデータソースに対する高速なアクセスを、SQL を使って統一したアクセス方法を提供します。Presto は、Coordinator と Worker という2種類の役割をもったマシンでクラスタ構成を組み、高速なアクセスを提供しています。

今回の手順では、CentOS に Presto をインストールする方法を確認します。

バージョン情報

  • CentOS 7
  • Presto 0.227

CentOS 7 の構築

手元の仮想環境だったり、パブリッククラウドだったり、好きな場所で CentOS 7 を作りましょう。自分は、Oracle Cloud Infrastructure(以下 OCI)で作りました。

Firewalld 停止

OCI 側に仮想ファイアウォールがあるため、CentOS 上の Firewalld を停止

sudo systemctl stop firewalld
sudo systemctl disable firewalld

Open JDK 8 の Install

Presto の動作に必要な Java 8 (記事の手順ではOpen JDK 8) を Install します。好きな JDK 8 で問題ないです。

sudo yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel

依存関係解決例

===========================================================================================================================
Package                                Arch              Version                                 Repository          Size 
===========================================================================================================================
Installing:
 java-1.8.0-openjdk                     x86_64            1:1.8.0.242.b08-0.el7_7                 updates            293 k 
 java-1.8.0-openjdk-devel               x86_64            1:1.8.0.242.b08-0.el7_7                 updates            9.8 M 
Installing for dependencies:
 atk                                    x86_64            2.28.1-1.el7                            base               263 k 
 avahi-libs                             x86_64            0.6.31-19.el7                           base                61 k 
 cairo                                  x86_64            1.15.12-4.el7                           base               741 k 
 copy-jdk-configs                       noarch            3.3-10.el7_5                            base                21 k 
 cups-libs                              x86_64            1:1.6.3-40.el7                          base               358 k 
 dejavu-fonts-common                    noarch            2.33-6.el7                              base                64 k 
 dejavu-sans-fonts                      noarch            2.33-6.el7                              base               1.4 M 
 fontconfig                             x86_64            2.13.0-4.3.el7                          base               254 k 
 fontpackages-filesystem                noarch            1.44-8.el7                              base               9.9 k 
 fribidi                                x86_64            1.0.2-1.el7_7.1                         updates             79 k 
 gdk-pixbuf2                            x86_64            2.36.12-3.el7                           base               570 k 
 giflib                                 x86_64            4.1.6-9.el7                             base                40 k 
 graphite2                              x86_64            1.3.10-1.el7_3                          base               115 k 
 gtk-update-icon-cache                  x86_64            3.22.30-3.el7                           base                28 k 
 gtk2                                   x86_64            2.24.31-1.el7                           base               3.4 M 
 harfbuzz                               x86_64            1.7.5-2.el7                             base               267 k 
 hicolor-icon-theme                     noarch            0.12-7.el7                              base                42 k 
 jasper-libs                            x86_64            1.900.1-33.el7                          base               150 k 
 java-1.8.0-openjdk-headless            x86_64            1:1.8.0.242.b08-0.el7_7                 updates             32 M 
 javapackages-tools                     noarch            3.4.1-11.el7                            base                73 k 
 jbigkit-libs                           x86_64            2.0-11.el7                              base                46 k 
 libICE                                 x86_64            1.0.9-9.el7                             base                66 k 
 libSM                                  x86_64            1.2.2-2.el7                             base                39 k 
 libX11                                 x86_64            1.6.7-2.el7                             base               607 k 
 libX11-common                          noarch            1.6.7-2.el7                             base               164 k 
 libXau                                 x86_64            1.0.8-2.1.el7                           base                29 k 
 libXcomposite                          x86_64            0.4.4-4.1.el7                           base                22 k 
 libXcursor                             x86_64            1.1.15-1.el7                            base                30 k 
 libXdamage                             x86_64            1.1.4-4.1.el7                           base                20 k 
 libXext                                x86_64            1.3.3-3.el7                             base                39 k 
 libXfixes                              x86_64            5.0.3-1.el7                             base                18 k 
 libXft                                 x86_64            2.3.2-2.el7                             base                58 k 
 libXi                                  x86_64            1.7.9-1.el7                             base                40 k 
 libXinerama                            x86_64            1.1.3-2.1.el7                           base                14 k 
 libXrandr                              x86_64            1.5.1-2.el7                             base                27 k 
 libXrender                             x86_64            0.9.10-1.el7                            base                26 k 
 libXtst                                x86_64            1.2.3-1.el7                             base                20 k 
 libXxf86vm                             x86_64            1.1.4-1.el7                             base                18 k 
 libfontenc                             x86_64            1.1.3-3.el7                             base                31 k 
 libglvnd                               x86_64            1:1.0.1-0.8.git5baa1e5.el7              base                89 k 
 libglvnd-egl                           x86_64            1:1.0.1-0.8.git5baa1e5.el7              base                44 k 
 libglvnd-glx                           x86_64            1:1.0.1-0.8.git5baa1e5.el7              base               125 k 
 libjpeg-turbo                          x86_64            1.2.90-8.el7                            base               135 k 
 libthai                                x86_64            0.1.14-9.el7                            base               187 k 
 libtiff                                x86_64            4.0.3-32.el7                            base               171 k 
 libwayland-client                      x86_64            1.15.0-1.el7                            base                33 k 
 libwayland-server                      x86_64            1.15.0-1.el7                            base                39 k 
 libxcb                                 x86_64            1.13-1.el7                              base               214 k 
 libxshmfence                           x86_64            1.2-1.el7                               base               7.2 k 
 libxslt                                x86_64            1.1.28-5.el7                            base               242 k 
 lksctp-tools                           x86_64            1.0.17-2.el7                            base                88 k 
 mesa-libEGL                            x86_64            18.3.4-6.el7_7                          updates            109 k 
 mesa-libGL                             x86_64            18.3.4-6.el7_7                          updates            165 k 
 mesa-libgbm                            x86_64            18.3.4-6.el7_7                          updates             39 k 
 mesa-libglapi                          x86_64            18.3.4-6.el7_7                          updates             45 k 
 pango                                  x86_64            1.42.4-4.el7_7                          updates            280 k 
 pcsc-lite-libs                         x86_64            1.8.8-8.el7                             base                34 k 
 python-javapackages                    noarch            3.4.1-11.el7                            base                31 k 
 python-lxml                            x86_64            3.2.1-4.el7                             base               758 k 
 ttmkfdir                               x86_64            3.0.9-42.el7                            base                48 k 
 tzdata-java                            noarch            2019c-1.el7                             updates            187 k 
 xorg-x11-font-utils                    x86_64            1:7.5-21.el7                            base               104 k 
 xorg-x11-fonts-Type1                   noarch            7.5-9.el7                               base               521 k 

Transaction Summary
=========================================================================================================================

Presto Install

以下にインストール方法が公開されています。特定のバージョンをインストールしたい場合は、URLのバージョン数値を変更すればよいと思います。tar.gz ファイルのダウンロードURLを確認します。

1587815404636.png

Cent OS にダウンロードします。

mkdir ~/presto
cd ~/presto
wget https://repo1.maven.org/maven2/com/facebook/presto/presto-server/0.227/presto-server-0.227.tar.gz

解凍

tar xfvz presto-server-0.227.tar.gz

以下のファイルが作成されます

[opc@presto presto-server-0.227]$ ls -la ~/presto/presto-server-0.227
total 208
drwxrwxr-x.  5 opc opc     74 Apr 25 12:11 .
drwxrwxr-x.  3 opc opc     67 Apr 25 12:11 ..
-rw-r--r--.  1 opc opc 191539 Oct 17  2019 NOTICE
-rw-r--r--.  1 opc opc    126 Oct 17  2019 README.txt
drwxr-xr-x.  3 opc opc     84 Oct 17  2019 bin
drwxrwxr-x.  2 opc opc   8192 Apr 25 12:11 lib
drwxrwxr-x. 30 opc opc   4096 Apr 25 12:11 plugin

設定用のetcディレクトリ作成

mkdir ~/presto/presto-server-0.227/etc
mkdir ~/presto/presto-server-0.227/etc/catalog

log を格納するためのディレクトリを作成

mkdir ~/prestolog/

etcディレクトリの下に4種類の設定ファイルを作成します

  • Node Properties : Node単体の設定
  • JVM Config : Java Virtual Machine の設定
  • Config Properties : Presto Server の設定
  • Log Properties : ログ出力動作の設定
  • Catalog Properties : Connector の設定

Node Properties ファイルを作成します。

  • node.environment : 全ての Presto クラスターで任意の同じ名前を指定します
  • node.id : クラスター内で一意の ID を指定します
  • node.data-dir : log などのデータを格納するディレクトリを指定します
cat <<'EOF' > ~/presto/presto-server-0.227/etc/node.properties
node.environment=production
node.id=00000000-0000-0000-0000-000000000000
node.data-dir=/home/opc/prestolog
EOF

JVM 用ファイルを作成します。

cat <<'EOF' > ~/presto/presto-server-0.227/etc/jvm.config
-Xmx16G
-XX:+UseG1GC
-XX:G1HeapRegionSize=32M
-XX:+UseGCOverheadLimit
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:+ExitOnOutOfMemoryError
EOF

Config Properties ファイルを作成します。Presto クラスターの中で2種類の役割があります。Presto は coordinator と worker と2種類の役割があって、このファイルでどちらの役割で動くか or 両方の役割で動くか指定します。大規模なクラスターで動かす場合は、仮想マシンレベルで役割を分けたほうが良いです。今回はクイックスタート的に始めるため、1個の仮想マシン内で、coordinator と worker を両方動かします。

cat <<'EOF' > ~/presto/presto-server-0.227/etc/config.properties
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8080
query.max-memory=5GB
query.max-memory-per-node=1GB
query.max-total-memory-per-node=2GB
discovery-server.enabled=true
discovery.uri=http://10.0.0.4:8080
EOF

log の出力レベルを指定します。DEBUG,INFO,WARN,ERROR が指定できます。

cat <<'EOF' > ~/presto/presto-server-0.227/etc/log.properties
com.facebook.presto=INFO
EOF

動作確認のために、Connector は2種類の設定をします。

  • Black Hole : 何も処理をしないコネクター。今回の手順では動作確認のために使用。Black Hole コネクターを宛先にしても、/dev/null のように何もデータを書き込まない動作
  • TCPH : TPC-H ベンチマークで定義されているスキーマを提供。サンプルデータとして利用

cat <<'EOF' > ~/presto/presto-server-0.227/etc/catalog/blackhole.properties
connector.name=blackhole
EOF
cat <<'EOF' > ~/presto/presto-server-0.227/etc/catalog/tpch.properties
connector.name=tpch
EOF

Presto を Linux Shell としてのフォアグラウンドで起動

cd ~/presto/presto-server-0.227
bin/launcher run

実行例

色々文字が流れますが、末尾に SERVER STARTED と表示されれば正常です。

[opc@presto presto-server-0.227]$ bin/launcher run
WARNING: Current OS file descriptor limit is 4096. Presto recommends at least 8192
2020-04-25T12:56:15.994Z        INFO    main    io.airlift.log.Logging  Logging to stderr
2020-04-25T12:56:15.997Z        INFO    main    Bootstrap       Loading configuration
2020-04-25T12:56:16.160Z        INFO    main    Bootstrap       Initializing logging
2020-04-25T12:56:16.922Z        INFO    main    Bootstrap       PROPERTY                           
省略
2020-04-25T12:56:23.194Z        INFO    main    com.facebook.presto.security.AccessControlManager  -- Loading system access control --
2020-04-25T12:56:23.195Z        INFO    main    com.facebook.presto.security.AccessControlManager  -- Loaded system access control allow-all --
2020-04-25T12:56:23.235Z        INFO    main    com.facebook.presto.server.PrestoServer ======== SERVER STARTED ========

フォアグラウンドで正常起動が確認できたので、バックグラウンドで起動します

cd ~/presto/presto-server-0.227
bin/launcher start

実行例
PID 3964 で起動していることが分かります

[opc@presto presto-server-0.227]$ bin/launcher start
Started as 3964

Presto CLI Install

次の URL に、Presto CLI の jar ファイルが公開されています。

1587820806291.png

アドレスをコピーして、Presto の仮想マシンでダウンロードします

wget https://repo1.maven.org/maven2/com/facebook/presto/presto-cli/0.227/presto-cli-0.227-executable.jar

名前を変更して実行権限を付与します

mv presto-cli-0.227-executable.jar ~/presto/presto-server-0.227/bin/presto
chmod +x ~/presto/presto-server-0.227/bin/presto

動作確認

Presto CLI を使って、Black Hole カタログに接続します

~/presto/presto-server-0.227/bin/presto --server localhost:8080 --catalog hive

実行例

[opc@presto presto-server-0.227]$ ~/presto/presto-server-0.227/bin/presto --server localhost:8080 --catalog hive
presto> 

TPCH コネクターで、用意されているスキーマを確認します

SHOW SCHEMAS FROM tpch;

実行例

presto> SHOW SCHEMAS FROM tpch;
       Schema
--------------------
 information_schema 
 sf1
 sf100
 sf1000
 sf10000
 sf100000
 sf300
 sf3000
 sf30000
 tiny
(10 rows)

Query 20200425_133005_00000_76c2i, FINISHED, 1 node
Splits: 19 total, 19 done (100.00%)
0:02 [10 rows, 119B] [5 rows/s, 65B/s]

presto> 

TCPH のデータをSELECTで表示します。

SELECT * from tpch.tiny.nation;

実行例

presto> SELECT * from tpch.tiny.nation;
 nationkey |      name      | regionkey |                                                      comment
-----------+----------------+-----------+--------------------------------------------------------------------------------------------------------------------
         0 | ALGERIA        |         0 |  haggle. carefully final deposits detect slyly agai
         1 | ARGENTINA      |         1 | al foxes promise slyly according to the regular accounts. bold requests alon
         2 | BRAZIL         |         1 | y alongside of the pending deposits. carefully special packages are about the ironic forges. slyly special
         3 | CANADA         |         1 | eas hang ironic, silent packages. slyly regular packages are furiously over the tithes. fluffily bold
         4 | EGYPT          |         4 | y above the carefully unusual theodolites. final dugouts are quickly across the furiously regular d
         5 | ETHIOPIA       |         0 | ven packages wake quickly. regu
         6 | FRANCE         |         3 | refully final requests. regular, ironi
         7 | GERMANY        |         3 | l platelets. regular accounts x-ray: unusual, regular acco
         8 | INDIA          |         2 | ss excuses cajole slyly across the packages. deposits print aroun
         9 | INDONESIA      |         2 |  slyly express asymptotes. regular deposits haggle slyly. carefully ironic hockey players sleep blithely. carefull
        10 | IRAN           |         4 | efully alongside of the slyly final dependencies.
        11 | IRAQ           |         4 | nic deposits boost atop the quickly final requests? quickly regula
        12 | JAPAN          |         2 | ously. final, express gifts cajole a
        13 | JORDAN         |         4 | ic deposits are blithely about the carefully regular pa
        14 | KENYA          |         0 |  pending excuses haggle furiously deposits. pending, express pinto beans wake fluffily past t
        15 | MOROCCO        |         0 | rns. blithely bold courts among the closely regular packages use furiously bold platelets?
        16 | MOZAMBIQUE     |         0 | s. ironic, unusual asymptotes wake blithely r
        17 | PERU           |         1 | platelets. blithely pending dependencies use fluffily across the even pinto beans. carefully silent accoun
        18 | CHINA          |         2 | c dependencies. furiously express notornis sleep slyly regular accounts. ideas sleep. depos
        19 | ROMANIA        |         3 | ular asymptotes are about the furious multipliers. express dependencies nag above the ironically ironic account
        20 | SAUDI ARABIA   |         4 | ts. silent requests haggle. closely express packages sleep across the blithely
        21 | VIETNAM        |         2 | hely enticingly express accounts. even, final
        22 | RUSSIA         |         3 |  requests against the platelets use never according to the quickly regular pint
        23 | UNITED KINGDOM |         3 | eans boost carefully special requests. accounts are. carefull
        24 | UNITED STATES  |         1 | y final packages. slow foxes cajole quickly. quickly silent platelets breach ironic accounts. unusual pinto be
(25 rows)

Query 20200425_134204_00004_76c2i, FINISHED, 1 node
Splits: 20 total, 20 done (100.00%)
0:00 [25 rows, 0B] [137 rows/s, 0B/s]

presto>

Black Hole へ、TPCH のデータをコピーします。が、Black Hole なので何もテーブルを作りません。

CREATE TABLE blackhole.default.nation AS
SELECT * from tpch.tiny.nation;

実行例

presto> CREATE TABLE blackhole.default.nation AS SELECT * from tpch.tiny.nation;
CREATE TABLE: 25 rows

Query 20200425_134107_00002_76c2i, FINISHED, 1 node
Splits: 38 total, 38 done (100.00%)
0:03 [25 rows, 0B] [9 rows/s, 0B/s]

参考URL

Official Site
https://prestodb.io/

Document
https://prestodb.io/docs/current/

過去VersionのDocument
https://prestodb.io/docs/0.227/index.html

2
2
2

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
2
2