HBaseをインストールするには

「7つのデータベース 7つの世界」第4章の学習のために、Hbaseをインストールします。スタンドアローンモードです。

7つのデータベース 7つの世界

  • PotgreSQL
  • Riak
  • HBase
  • MongoDB
  • CouchDB
  • Neo4j
  • Redis
Apache HBase – Apache HBase™ Home

Mac OS X

HBase 1.3.5

Mac OS X 10.15.4
Hbase 1.3.5

書籍のバージョンは 0.90.3

Hbaseの最新は 2.2.4

homebrewでインストールできます。

$ brew install hbaseCode language: Bash (bash)

場所を確認します。

$ which hbase
/usr/local/bin/hbaseCode language: Bash (bash)

バージョンは、1.3.5でした。

$ hbase version
HBase 1.3.5
Source code repository git://apurtell-ltm4.internal.salesforce.com/Users/apurtell/tmp/hbase-build-1 revision=b59afe7b1dc650ff3a86034477b563734e8799a9
Compiled by apurtell on Wed Jun  5 15:57:14 PDT 2019
From source with checksum b3373527ed7fbf3566b68c12230298aeCode language: Bash (bash)

インストールされた場所は、/usr/local/Cellar/hbase/1.3.5 です。hbase-site.xml は、/usr/local/Cellar/hbase/1.3.5/libexec/conf/hbase-site.xml にありました。

p91 HBaseの設定で「hbase-site.xmlでhbase.rootdirやhbase.zookeeper.property.dataDirを設定しよう」とあります。homebrewでインストールした hbase-site.xml は、すでに設定済みなので、このままで問題ありません。

<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>file:///usr/local/var/hbase</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.clientPort</name>
    <value>2181</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/usr/local/var/zookeeper</value>
  </property>
  <property>
    <name>hbase.zookeeper.dns.interface</name>
    <value>lo0</value>
  </property>
  <property>
    <name>hbase.regionserver.dns.interface</name>
    <value>lo0</value>
  </property>
  <property>
    <name>hbase.master.dns.interface</name>
    <value>lo0</value>
  </property>

</configuration>Code language: HTML, XML (xml)

HBaseを起動します。

$ start-hbase.sh
starting master, logging to /usr/local/var/log/hbase/hbase-aoki.makoto-master-MacBookPro-2016.local.outCode language: Bash (bash)

ログファイルの場所が表示されているわね

RESTサーバを起動します。

$ hbase rest start &
2020-04-29 11:46:34,137 INFO  [main] util.VersionInfo: HBase 1.3.5
(省略)
2020-04-29 11:46:35,108 INFO  [main] http.HttpServer: Jetty bound to port 8085
2020-04-29 11:46:35,108 INFO  [main] mortbay.log: jetty-6.1.26
2020-04-29 11:46:35,409 INFO  [main] mortbay.log: Started SelectChannelConnector@0.0.0.0:8085
2020-04-29 11:46:35,409 INFO  [main] mortbay.log: jetty-6.1.26
2020-04-29 11:46:35,410 INFO  [main] mortbay.log: Started SelectChannelConnector@0.0.0.0:8080
Code language: Bash (bash)

起動ログの最後の4行に、0.0.0.0:8085、0.0.0.0:8080 があります。ブラウザで、localhost:8085にアクセスすると、RESETサーバのコンソール画面が表示されました。localhost:8080にアクセスすると、エラーではないものの、白い画面でした。

hbaseシェルに入ります。

$ hbase shell
2020-04-29 15:09:25,676 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.3.5, rb59afe7b1dc650ff3a86034477b563734e8799a9, Wed Jun  5 15:57:14 PDT 2019

hbase(main):001:0> Code language: Bash (bash)

versionを確認します。

hbase(main):001:0> version
1.3.5, rb59afe7b1dc650ff3a86034477b563734e8799a9, Wed Jun  5 15:57:14 PDT 2019
Code language: Bash (bash)

statusコマンドを実行します。

hbase(main):002:0> status
1 active master, 0 backup masters, 1 servers, 0 dead, 2.0000 average loadCode language: Bash (bash)

exit または quit で、hbaseシェルから出ます。

hbase(main):003:0> exit

$Code language: Bash (bash)

RESTサーバを終了します。

$ jobs
[1]+  Running                 hbase rest start &

$ kill %1
2020-04-29 11:47:43,263 INFO  [Shutdown] mortbay.log: Shutdown hook executing
2020-04-29 11:47:43,263 INFO  [Shutdown] mortbay.log: Stopped SelectChannelConnector@0.0.0.0:8080
2020-04-29 11:47:43,270 INFO  [Shutdown] mortbay.log: Shutdown hook complete
Code language: Bash (bash)

HBaseを終了します。

$ stop-hbase.sh
stopping hbase...................
Code language: Bash (bash)

Thrift

3日目に使います。

$ brew install thrift

$ which thrift
/usr/local/bin/thrift

$ thrift -version
Thrift version 0.13.0Code language: Bash (bash)

Ubuntu 18.04

aptでインストールできないの?

残念ながらaptやもsnapでインストールできるパッケージはありませんでした。

学習用なので、/usr/lib/hbase ではなく、ホーム下の学習用ディレクトリにインストールします。具体的には、次の場所とディレクトリ構造です。1day.txtは1日めの学習メモです。

HBase 2.2.4

2.2.4では、p98 JRubyのコードが動きませんでした。

1.6.0、1.3.6は動いたわよ

$ cd ~/projects/personals/study_7db/hbase

$ tree -L 1
.
├── 1day.txt
├── hbase -> hbase-2.2.4
├── hbase-2.2.4
├── hbase-2.2.4-bin.tar.gz
├── env.sh
└── varCode language: Bash (bash)
Apache Download Mirrors
Home page of The Apache Software Foundation

ダウンロードのミラーサイト一覧からたどって、stable releaseの2.2.4をダウンロードします。

$ VER=2.2.4
$ wget https://ftp.riken.jp/net/apache/hbase/$VER/hbase-$VER-bin.tar.gzCode language: Bash (bash)

解凍します。hbase-2.2.4/ に展開されます。

$ tar xzf hbase-2.2.4-bin.tar.gzCode language: Bash (bash)

シンボリックリンクを作ります。

$ ln -s hbase-2.2.4 hbaseCode language: Bash (bash)

環境変数を設定するシェルスクリプトを作ります。

$ echo "export HBASE_HOME=$(pwd)/hbase"      >  env.sh
$ echo 'export PATH="$HBASE_HOME/bin:$PATH"' >> env.sh

$ cat env.sh
export HBASE_HOME=/home/aoki/projects/personals/study_7db/hbase/hbase
export PATH="$HBASE_HOME/bin:$PATH"
Code language: Bash (bash)

env.shを適用します。ターミナルを開くたびに、env.shを適用してください。

$ source env.shCode language: Bash (bash)

hbaseの場所とバージョンを確認します。

$ which hbase
/home/aoki/projects/personals/study_7db/hbase/hbase/bin/hbase

$ hbase version
HBase 2.2.4
Source code repository git://hao-OptiPlex-7050/home/hao/open_source/hbase revision=67779d1a325a4f78a468af3339e73bf075888bac
Compiled by hao on 2020年 03月 11日 星期三 12:57:39 CST
From source with checksum 19ada8ab3844a5aa8ccaacdd5f2893ca
Code language: Bash (bash)

HBaseのデータディレクトリ var/ を作成します。

$ mkdir varCode language: Bash (bash)

p91「HBaseの設定」で説明している、hbase-site.xmlの編集です。さきほど作成したvarディレクトリを指定します。「/var/hbase」や「/var/zookeeper」はmkdirの必要はなく、自動で作成されます。

「/home/aoki/projects/personals/study_7db/hbase」の部分を、みなさんの学習用ディレクトリの場所に合わせて、編集してください。

<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>file:///home/aoki/projects/personals/study_7db/hbase/var/hbase</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/home/aoki/projects/personals/study_7db/hbase/var/zookeeper</value>
  </property>

</configuration>
Code language: HTML, XML (xml)

HBaseを起動します。

$ start-hbase.sh
running master, logging to /home/aoki/projects/personals/study_7db/hbase/hbase/logs/hbase-aoki-master-tsukumo-2016.outCode language: Bash (bash)

ログファイルの場所が表示されているわね

RESTサーバを起動します。

$ hbase rest start &
2020-04-29 14:56:13,600 INFO  [main] RESTServer: ***** STARTING service 'RESTServer' *****
2020-04-29 14:56:13,601 INFO  [main] util.VersionInfo: HBase 2.2.4
(省略)
2020-04-29 14:56:14,892 INFO  [main] server.AbstractConnector: Started ServerConnector@d2de489{HTTP/1.1,[http/1.1]}{0.0.0.0:8085}
2020-04-29 14:56:14,893 INFO  [main] server.Server: Started @2094ms
2020-04-29 14:56:14,893 INFO  [main] server.Server: jetty-9.3.27.v20190418, build timestamp: 2019-04-19T03:11:38+09:00, git hash: d3e249f86955d04bc646bb620905b7c1bc596a8d
2020-04-29 14:56:14,899 WARN  [main] security.SecurityHandler: ServletContext@o.e.j.s.ServletContextHandler@6d4e5011{/,null,STARTING} has uncovered http methods for path: /*
2020-04-29 14:56:14,900 INFO  [main] http.SecurityHeadersFilter: Added security headers filter
2020-04-29 14:56:15,273 INFO  [main] handler.ContextHandler: Started o.e.j.s.ServletContextHandler@6d4e5011{/,null,AVAILABLE}
2020-04-29 14:56:15,283 INFO  [main] server.AbstractConnector: Started ServerConnector@1613674b{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2020-04-29 14:56:15,283 INFO  [main] server.Server: Started @2484ms

Code language: Bash (bash)

起動ログの最後の7行に、0.0.0.0:8085、0.0.0.0:8080 があります。ブラウザで、localhost:8085にアクセスすると、RESETサーバのコンソール画面が表示されました。localhost:8080にアクセスすると、エラーではないものの、白い画面でした。

hbaseシェルに入ります。

$ hbase shell
2020-04-29 15:16:17,098 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell
Version 2.2.4, r67779d1a325a4f78a468af3339e73bf075888bac, 2020年 03月 11日 星期三 12:57:39 CST
Took 0.0030 seconds                                                                                                                                                               
hbase(main):001:0> 
Code language: Bash (bash)

versionを確認します。

hbase(main):001:0> version
2.2.4, r67779d1a325a4f78a468af3339e73bf075888bac, 2020年 03月 11日 星期三 12:57:39 CST
Took 0.0003 seconds 
Code language: Bash (bash)

statusコマンドを実行します。

hbase(main):002:0> status
1 active master, 0 backup masters, 1 servers, 0 dead, 2.0000 average load
Took 0.3739 seconds  Code language: Bash (bash)

exit または quit で、hbaseシェルから出ます。

hbase(main):003:0> exit

$Code language: Bash (bash)

RESTサーバを終了します。

$ jobs
[1]+  実行中               hbase rest start &

$ kill %1
2020-04-29 14:58:26,614 INFO  [Thread-11] server.AbstractConnector: Stopped ServerConnector@1613674b{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2020-04-29 14:58:26,617 INFO  [Thread-11] handler.ContextHandler: Stopped o.e.j.s.ServletContextHandler@6d4e5011{/,null,UNAVAILABLE}
2020-04-29 14:58:26,618 INFO  [main] RESTServer: ***** STOPPING service 'RESTServer' *****
Code language: Bash (bash)

HBaseを終了します。

$ stop-hbase.sh
stopping hbase...................
Code language: Bash (bash)

HBase 1.6.0

1.6.0で、p98 JRubyのコードが動きました。

$ cd ~/projects/personals/study_7db/hbase

$ tree -L 1
.
├── 1day.txt
├── hbase -> hbase-1.6.0
├── hbase-1.6.0
├── hbase-1.6.0-bin.tar.gz
├── env.sh
└── varCode language: Bash (bash)
Apache Download Mirrors
Home page of The Apache Software Foundation

ダウンロードのミラーサイト一覧からたどって、1.6.0をダウンロードします。

$ VER=1.6.0
$ wget https://ftp.riken.jp/net/apache/hbase/$VER/hbase-$VER-bin.tar.gzCode language: Bash (bash)

解凍します。hbase-1.6.0/ に展開されます。

$ tar xzf hbase-1.6.0-bin.tar.gzCode language: Bash (bash)

シンボリックリンクを作ります。

$ ln -s hbase-1.6.0 hbaseCode language: Bash (bash)

環境変数を設定するシェルスクリプトを作ります。

$ echo "export HBASE_HOME=$(pwd)/hbase"      >  env.sh
$ echo 'export PATH="$HBASE_HOME/bin:$PATH"' >> env.sh

$ cat env.sh
export HBASE_HOME=/home/aoki/projects/personals/study_7db/hbase/hbase
export PATH="$HBASE_HOME/bin:$PATH"
Code language: Bash (bash)

env.shを適用します。ターミナルを開くたびに、env.shを適用してください。

$ source env.shCode language: Bash (bash)

hbaseの場所とバージョンを確認します。

$ which hbase
/home/aoki/projects/personals/study_7db/hbase/hbase/bin/hbase

$ hbase version
HBase 1.6.0
Source code repository git://apurtell-ltm.internal.salesforce.com/Users/apurtell/src/hbase revision=5ec5a5b115ee36fb28903667c008218abd21b3f5
Compiled by apurtell on Fri Feb 14 12:00:03 PST 2020
From source with checksum 09d63c428823b5595e6f717a21e61326
Code language: Bash (bash)

HBaseのデータディレクトリ var/ を作成します。2.2.4を試した後だったら、var/hbaseとvar/zookeeperを削除するか、別のディレクトリ(var-1.6.0など)にしてください。

$ mkdir varCode language: Bash (bash)

p91「HBaseの設定」で説明している、hbase-site.xmlの編集です。さきほど作成したvarディレクトリを指定します。「/var/hbase」や「/var/zookeeper」はmkdirの必要はなく、自動で作成されます。

「/home/aoki/projects/personals/study_7db/hbase」の部分を、みなさんの学習用ディレクトリの場所に合わせて、編集してください。

<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>file:///home/aoki/projects/personals/study_7db/hbase/var/hbase</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/home/aoki/projects/personals/study_7db/hbase/var/zookeeper</value>
  </property>

</configuration>
Code language: HTML, XML (xml)

HBaseを起動します。

$ start-hbase.sh
running master, logging to /home/aoki/projects/personals/study_7db/hbase/hbase/logs/hbase-aoki-master-tsukumo-2016.out
OpenJDK 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0Code language: Bash (bash)

ログファイルの場所が表示されているわね

RESTサーバを起動します。

$ hbase rest start &
2020-05-01 00:16:08,049 INFO  [main] util.VersionInfo: HBase 1.6.0
(省略)
2020-05-01 00:16:09,095 INFO  [main] http.HttpServer: Jetty bound to port 8085
2020-05-01 00:16:09,095 INFO  [main] mortbay.log: jetty-6.1.26
2020-05-01 00:16:09,287 INFO  [main] mortbay.log: Started SelectChannelConnector@0.0.0.0:8085
2020-05-01 00:16:09,287 INFO  [main] mortbay.log: jetty-6.1.26
2020-05-01 00:16:09,288 INFO  [main] mortbay.log: Started SelectChannelConnector@0.0.0.0:8080Code language: Bash (bash)

起動ログの最後の7行に、0.0.0.0:8085、0.0.0.0:8080 があります。ブラウザで、localhost:8085にアクセスすると、RESETサーバのコンソール画面が表示されました。localhost:8080にアクセスすると、エラーではないものの、白い画面でした。

hbaseシェルに入ります。

$ hbase shell
2020-05-01 00:18:26,125 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
Version 1.6.0, r5ec5a5b115ee36fb28903667c008218abd21b3f5, Fri Feb 14 12:00:03 PST 2020

hbase(main):001:0> Code language: Bash (bash)

versionを確認します。

hbase(main):001:0> version
1.6.0, r5ec5a5b115ee36fb28903667c008218abd21b3f5, Fri Feb 14 12:00:03 PST 2020Code language: Bash (bash)

statusコマンドを実行します。

hbase(main):002:0> status
1 active master, 0 backup masters, 1 servers, 0 dead, 2.0000 average loadCode language: Bash (bash)

exit または quit で、hbaseシェルから出ます。

hbase(main):003:0> exit

$Code language: Bash (bash)

RESTサーバを終了します。

$ jobs
[1]+  実行中               hbase rest start &

$ kill %1
2020-05-01 00:19:14,836 INFO  [Shutdown] mortbay.log: Shutdown hook executing
2020-05-01 00:19:14,836 INFO  [Shutdown] mortbay.log: Stopped SelectChannelConnector@0.0.0.0:8080
2020-05-01 00:19:14,938 INFO  [Shutdown] mortbay.log: Shutdown hook completeCode language: Bash (bash)

HBaseを終了します。

$ stop-hbase.sh
stopping hbase...................
Code language: Bash (bash)

HBase 1.3.6

1.3.6で、p98 JRubyのコードが動きました。

$ cd ~/projects/personals/study_7db/hbase

$ tree -L 1
.
├── 1day.txt
├── hbase -> hbase-1.3.6
├── hbase-1.3.6
├── hbase-1.3.6-bin.tar.gz
├── env.sh
└── varCode language: Bash (bash)
Apache Download Mirrors
Home page of The Apache Software Foundation

ダウンロードのミラーサイト一覧からたどって、hbase-1.3.6をダウンロードします。

$ VER=1.3.6
$ wget https://ftp.riken.jp/net/apache/hbase/hbase-$VER/hbase-$VER-bin.tar.gzCode language: Bash (bash)

解凍します。hbase-1.3.6/ に展開されます。

$ tar xzf hbase-1.3.6-bin.tar.gzCode language: Bash (bash)

シンボリックリンクを作ります。

$ ln -s hbase-1.3.6 hbaseCode language: Bash (bash)

環境変数を設定するシェルスクリプトを作ります。

$ echo "export HBASE_HOME=$(pwd)/hbase"      >  env.sh
$ echo 'export PATH="$HBASE_HOME/bin:$PATH"' >> env.sh

$ cat env.sh
export HBASE_HOME=/home/aoki/projects/personals/study_7db/hbase/hbase
export PATH="$HBASE_HOME/bin:$PATH"
Code language: Bash (bash)

env.shを適用します。ターミナルを開くたびに、env.shを適用してください。

$ source env.shCode language: Bash (bash)

hbaseの場所とバージョンを確認します。

$ which hbase
/home/aoki/projects/personals/study_7db/hbase/hbase/bin/hbase

$ hbase version
HBase 1.3.6
Source code repository git://Sakthis-MacBook-Pro-2.local/Users/sakthi/dev/hbase revision=806dc3625c96fe2cfc03048f3c54a0b38bc9e984
Compiled by sakthi on Tue Oct 15 01:55:41 PDT 2019
From source with checksum d587feefff2057a2e5001da5db4a6fac
Code language: Bash (bash)

HBaseのデータディレクトリ var/ を作成します。2.2.4を試した後だったら、var/hbaseとvar/zookeeperを削除するか、別のディレクトリ(var-1.3.6など)にしてください

$ mkdir varCode language: Bash (bash)

p91「HBaseの設定」で説明している、hbase-site.xmlの編集です。さきほど作成したvarディレクトリを指定します。「/var/hbase」や「/var/zookeeper」はmkdirの必要はなく、自動で作成されます。

「/home/aoki/projects/personals/study_7db/hbase」の部分を、みなさんの学習用ディレクトリの場所に合わせて、編集してください。

<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>file:///home/aoki/projects/personals/study_7db/hbase/var/hbase</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/home/aoki/projects/personals/study_7db/hbase/var/zookeeper</value>
  </property>

</configuration>
Code language: HTML, XML (xml)

HBaseを起動します。

$ start-hbase.sh
starting master, logging to /home/aoki/projects/personals/study_7db/hbase/hbase/logs/hbase-aoki-master-tsukumo-2016.out
OpenJDK 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
Code language: Bash (bash)

ログファイルの場所が表示されているわね

RESTサーバを起動します。

$ hbase rest start &
2020-05-01 00:02:59,416 INFO  [main] util.VersionInfo: HBase 1.3.6
(省略)
2020-05-01 00:03:00,374 INFO  [main] http.HttpServer: Jetty bound to port 8085
2020-05-01 00:03:00,375 INFO  [main] mortbay.log: jetty-6.1.26
2020-05-01 00:03:00,580 INFO  [main] mortbay.log: Started SelectChannelConnector@0.0.0.0:8085
2020-05-01 00:03:00,580 INFO  [main] mortbay.log: jetty-6.1.26
2020-05-01 00:03:00,581 INFO  [main] mortbay.log: Started SelectChannelConnector@0.0.0.0:8080

Code language: Bash (bash)

起動ログの最後の7行に、0.0.0.0:8085、0.0.0.0:8080 があります。ブラウザで、localhost:8085にアクセスすると、RESETサーバのコンソール画面が表示されました。localhost:8080にアクセスすると、エラーではないものの、白い画面でした。

hbaseシェルに入ります。

$ hbase shell
2020-05-01 00:09:22,629 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.3.6, r806dc3625c96fe2cfc03048f3c54a0b38bc9e984, Tue Oct 15 01:55:41 PDT 2019                                                                                                                                                        
hbase(main):001:0> 
Code language: Bash (bash)

versionを確認します。

hbase(main):001:0> version
1.3.6, r806dc3625c96fe2cfc03048f3c54a0b38bc9e984, Tue Oct 15 01:55:41 PDT 2019Code language: Bash (bash)

statusコマンドを実行します。

hbase(main):002:0> status
1 active master, 0 backup masters, 1 servers, 0 dead, 2.0000 average loadCode language: Bash (bash)

exit または quit で、hbaseシェルから出ます。

hbase(main):003:0> exit

$Code language: Bash (bash)

RESTサーバを終了します。

$ jobs
[1]+  実行中               hbase rest start &

$ kill %1
2020-05-01 00:10:27,703 INFO  [Shutdown] mortbay.log: Shutdown hook executing
2020-05-01 00:10:27,704 INFO  [Shutdown] mortbay.log: Stopped SelectChannelConnector@0.0.0.0:8080
2020-05-01 00:10:27,807 INFO  [Shutdown] mortbay.log: Shutdown hook completeCode language: Bash (bash)

HBaseを終了します。

$ stop-hbase.sh
stopping hbase...................
Code language: Bash (bash)

Thrift

aptもsnapもありませんでした。tar.gzをダウンロードします。

Apache Thrift - Download
$ wget http://ftp.kddilabs.jp/infosystems/apache/thrift/0.13.0/thrift-0.13.0.tar.gz

$ tar xzf thrift-0.13.0.tar.gzCode language: Bash (bash)

依存パッケージをインストールします。必要に応じて、ruby-devやpython-devもインストールしてください。筆者は rbenv で ruby 2.7.1 の環境です。

$ sudo apt install automake libtool flex bison g++ libevent-dev zlib1g-dev pkg-config libboost-dev

$ sudo apt install ruby-dev
$ sudo apt install python-devCode language: Bash (bash)

オプションなしで ./configureして makeしたら、javaのgradleのversionが〜というエラーでmakeできなかったので、ruby以外は全てnoにして ./configure しました。

$ cd thrift-0.13.0

$ ./configure --with-java=no --with-cpp=no --with-c_glib=no --with-php=no --with-python=no --with-py3=no --with-nodejs=no

$ make
(省略)
Bundler could not find compatible versions for gem "bundler":
  In Gemfile:
    bundler (~> 1.11)

  Current Bundler version:
    bundler (2.1.4)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?

Could not find gem 'bundler (~> 1.11)' in any of the relevant sources:
  the local ruby installation
(省略)
Code language: Bash (bash)

rbenv下のbundlerは2.1.4なので、thrift-0.13.0/lib/rb/thrift.gemspec を編集しました。

編集前
  s.add_development_dependency 'bundler',            '~> 1.11'

編集後
  s.add_development_dependency 'bundler',            '~> 2.1'Code language: Ruby (ruby)

再度、make して、sudo make install しました。

$ make
(省略)

$ sudo make install
(省略)

Failures:

  1) Thrift::ThinHTTPServer::RackApplication 404 response receives a non-POST
     Failure/Error: expect(last_response.status).to be 404
     
       expected #<Integer:809> => 404
            got #<Integer:1001> => 500
     
       Compared using equal?, which compares object identity,
       but expected and actual are not the same object. Use
       `expect(actual).to eq(expected)` if you don't care about
       object identity in this example.
     # ./spec/thin_http_server_spec.rb:102:in `block (3 levels) in <top (required)>'

  2) Thrift::ThinHTTPServer::RackApplication 404 response receives a header other than application/x-thrift
     Failure/Error: expect(last_response.status).to be 404
     
       expected #<Integer:809> => 404
            got #<Integer:1001> => 500
     
       Compared using equal?, which compares object identity,
       but expected and actual are not the same object. Use
       `expect(actual).to eq(expected)` if you don't care about
       object identity in this example.
     # ./spec/thin_http_server_spec.rb:108:in `block (3 levels) in <top (required)>'

  3) Thrift::ThinHTTPServer::RackApplication 200 response status code 200
     Failure/Error: expect(last_response.ok?).to be_truthy
     
       expected: truthy value
            got: false
     # ./spec/thin_http_server_spec.rb:135:in `block (3 levels) in <top (required)>'

Finished in 4.92 seconds (files took 0.281 seconds to load)
445 examples, 3 failures, 1 pending

Failed examples:

rspec ./spec/thin_http_server_spec.rb:99 # Thrift::ThinHTTPServer::RackApplication 404 response receives a non-POST
rspec ./spec/thin_http_server_spec.rb:105 # Thrift::ThinHTTPServer::RackApplication 404 response receives a header other than application/x-thrift
rspec ./spec/thin_http_server_spec.rb:132 # Thrift::ThinHTTPServer::RackApplication 200 response status code 200
(省略)Code language: Bash (bash)

エラー表示されましたが、which thriftすると、インストールできたようです。

$ which thrift
/usr/local/bin/thrift

$ thrift -version
Thrift version 0.13.0

最後に gem install thrift します。

$ gem install thrift
Fetching thrift-0.11.0.0.gem
Building native extensions. This could take a while...
Successfully installed thrift-0.11.0.0
Parsing documentation for thrift-0.11.0.0
Installing ri documentation for thrift-0.11.0.0
Done installing documentation for thrift after 1 seconds
1 gem installed

$ ruby -e "require 'thrift'"
Code language: JavaScript (javascript)

インストールだけで1日がかりだね

その他

p104 圧縮とブルームフィルタ

importする直前のwikiテーブルです。1日目と2日目に分かれて書かれていたのでまとめました。

create 'wiki', 'text'
alter 'wiki', { NAME => 'text', VERSIONS => org.apache.hadoop.hbase.HConstants::ALL_VERSIONS }
alter 'wiki', { NAME => 'revision', VERSIONS => org.apache.hadoop.hbase.HConstants::ALL_VERSIONS }
alter 'wiki', { NAME => 'text', COMPRESSION => 'GZ', BLOOMFILTER => 'ROW' }Code language: PHP (php)

p105 エンゲージ

Wikipediaのxml.bz2は16GBもあるよ!

10日もかかるの?
代わりのファイルはないの?

Wikipediaの、https://dumps.wikimedia.org/enwiki/latest/enwiki-latest-pages-articles.xml.bz2 は16GBもあります。curlしたら「残り10d」と表示されたので、中止しました。

Wiktionaryの、https://dumps.wikimedia.org/enwiktionary/latest/enwiktionary-latest-pages-articles.xml.bz2 は726Mです。これも「残り16h 30m」と表示されたので、中止しました。

Wikimedia Downloads

そこで、Wikiの分割ファイルの最初のファイル 177MBをダウンロードしました。約1時間でした。importしたところ、約2万件でした。残念ながら、リージョンは1つのままでした。

$ dump_url="https://dumps.wikimedia.org/enwiki/20200420/enwiki-20200420-pages-articles-multistream27.xml-p63663462p63719877.bz2"

$ wget $dump_url

$ bzcat $(basename $dump_url) | hbase shell import_from_wikipedia.rb
2020-05-02 00:27:24,796 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
500 records inserted (Alfonso Aráu)
1000 records inserted (Australian Democrats)
(省略)
19000 records inserted (Single-sideband modulation)
19500 records inserted (Trial de novo)Code language: PHP (php)

p107 リージョンの調査

var/hbase/data/default/wiki/の下に、bfbc58b40e86875a8657bc45f8329854 が1つあります。これがリージョンです。

$ du -h var/hbase/
4.0K	var/hbase/.tmp/data/default
4.0K	var/hbase/.tmp/data/hbase
12K	var/hbase/.tmp/data
16K	var/hbase/.tmp
47M	var/hbase/WALs/tsukumo-2016,33451,1588339102729
47M	var/hbase/WALs
28K	var/hbase/MasterProcWALs
4.0K	var/hbase/oldWALs
4.0K	var/hbase/data/default/wiki/.tmp
4.0K	var/hbase/data/default/wiki/bfbc58b40e86875a8657bc45f8329854/text
4.0K	var/hbase/data/default/wiki/bfbc58b40e86875a8657bc45f8329854/revision
4.0K	var/hbase/data/default/wiki/bfbc58b40e86875a8657bc45f8329854/recovered.edits
20K	var/hbase/data/default/wiki/bfbc58b40e86875a8657bc45f8329854
8.0K	var/hbase/data/default/wiki/.tabledesc
36K	var/hbase/data/default/wiki
40K	var/hbase/data/default
4.0K	var/hbase/data/hbase/meta/.tmp
4.0K	var/hbase/data/hbase/meta/1588230740/.tmp/info
8.0K	var/hbase/data/hbase/meta/1588230740/.tmp
12K	var/hbase/data/hbase/meta/1588230740/info
4.0K	var/hbase/data/hbase/meta/1588230740/recovered.edits
32K	var/hbase/data/hbase/meta/1588230740
8.0K	var/hbase/data/hbase/meta/.tabledesc
48K	var/hbase/data/hbase/meta
4.0K	var/hbase/data/hbase/namespace/.tmp
4.0K	var/hbase/data/hbase/namespace/7aa5ee0bf49aeebe59263c45a3a8dd60/.tmp/info
8.0K	var/hbase/data/hbase/namespace/7aa5ee0bf49aeebe59263c45a3a8dd60/.tmp
12K	var/hbase/data/hbase/namespace/7aa5ee0bf49aeebe59263c45a3a8dd60/info
4.0K	var/hbase/data/hbase/namespace/7aa5ee0bf49aeebe59263c45a3a8dd60/recovered.edits
32K	var/hbase/data/hbase/namespace/7aa5ee0bf49aeebe59263c45a3a8dd60
8.0K	var/hbase/data/hbase/namespace/.tabledesc
48K	var/hbase/data/hbase/namespace
100K	var/hbase/data/hbase
144K	var/hbase/data
48M	var/hbase/Code language: Bash (bash)

HBase shellでリージョンを調べるには、

hbase(main):008:0> scan 'hbase:meta', { COLUMNS => ['info:server', 'info:regioninfo'] }Code language: Bash (bash)

p115 2日目の宿題 やってみよう

Data.govの「MyPyramid Raw Food Data」のzipファイル

Department of Agriculture - MyPyramid Food Raw Data
MyPyramid Food Data provides information on the total calories; calories from solid fats, added sugars, and alcohol (ext...

p117 モデルを生成する

Hbase.thrift は、https://ftp.riken.jp/net/apache/hbase/1.6.0/hbase-1.6.0-src.tar.gz をダウンロードして展開すると、hbase-1.6.0/hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift に見つかります。

$ cd ~/Downloads
$ wget https://ftp.riken.jp/net/apache/hbase/1.6.0/hbase-1.6.0-src.tar.gz
$ tar xzf hbase-1.6.0-src.tar.gzCode language: Bash (bash)

この src/ を hbase-1.6.0/src/ になるように、mv しました。

$ cd ~/projects/personals/study_7db/hbase
$ mv  ~/Downloads/hbase-1.6.0/hbase-thrift/src  hbase-1.6.0/Code language: Bash (bash)
$ hbase_thrift=/home/aoki/projects/personals/study_7db/hbase/hbase/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift

$ thrift --gen rb  $hbase_thrift

$ ls gen-rb
hbase.rb
hbase_constants.rb
hbase_types.rb
Code language: Bash (bash)

p122 クラスタの起動

Whirrをダウンロードします。

ファイル日付が2015年だから、開発終了しているようね。

$ wget http://archive.apache.org/dist/whirr/whirr-0.8.2/whirr-0.8.2.tar.gz

$ tar xzf whirr-0.8.2.tar.gz

$ cd whirr-0.8.2

$ ./bin/whirr version
Apache Whirr 0.8.2
jclouds 1.5.8

Code language: JavaScript (javascript)

書籍の説明にしたがって、SSHキーを作りました。

次に、hbase.propertiesファイルを作りました。AWSリージョンやCPUタイプの指定はありません。

書籍のスクリーンショットでは、m1.largeが 6台起動しているよ。

停止し忘れたら、結構な料金になるわね!

様子を見るために、1台 + 1台に編集して、おそるおそる起動しました。しかし、次のエラーが...

$ ./bin/whirr launch-clushter --config hbase.properties
Running on provider aws-ec2 using identity (AWS_ACCESS_KEY_ID)
Unable to start the cluster. Terminating all nodes.
com.google.common.util.concurrent.UncheckedExecutionException: com.google.inject.CreationException: Guice creation errors:

1) org.jclouds.rest.RestContext<org.jclouds.aws.ec2.AWSEC2Client, A> cannot be used as a key; It is not fully specified.Code language: HTML, XML (xml)

If you're using JDK version 1.7.0_51 and up, try downgrading it to 1.7.0_45.

https://groups.google.com/forum/#!topic/druid-development/XuTjxKY7qrI

残念ながら、JDK 1.7.0_45以下を持っていないので、ここまでです。と、あきらめかけたら、

Java Archive Downloads - Java SE 7
Java Archive Downloads - Java SE 7

Java SE 7 Archive Downloadsにjdk_1.7.0_40を見つけたので、ダウンロードして試しました。

us-east-1a(バージニア北部)、m1.small で、ubuntu 10.04ベースのインスタンスが作成されました。

クラスタに接続するときの<SERVER_NAME>は、~/.whirr/myhbasecluster/instances を見ます。

クラスタに接続するときの ${USER} は、ローカルPCでターミナル作業しているユーザー名です。sshログインしてから、sudo su -l で、ubuntuユーザーにsuできます。

sshログインすると、/tmp/hbase-site.xml や /etc/hbase/conf/ 、/mnt/hbase などがありましが、/usr/local/hbase-0.90.3/bin/hbase がなく、HBaseシェルを起動できませんでした。hbase.propertiesのwhirr.hbase.tarball.url や whirr.hadoop.tarball.url がリンク切れだからでしょうか。

https://archive.cloudera.com/cdh/3/ を探して、次のように修正しました。

hbase.properties 修正前

# HBase and Hadoop version configuration
whirr.hbase.tarball.url=\
  http://apache.cu.be/hbase/hbase-0.90.3/hbase-0.90.3.tar.gz
whirr.hadoop.tarball.url=\
  http://archive.cloudera.com/cdh/3/hadoop-0.20.2-cdh3u1.tar.gzCode language: PHP (php)

hbase.properties 修正後

# HBase and Hadoop version configuration
whirr.hbase.tarball.url=\
  http://archive.cloudera.com/cdh/3/hbase-0.90.3-cdh3u1.tar.gz
whirr.hadoop.tarball.url=\
  http://archive.cloudera.com/cdh/3/hadoop-0.20.2-cdh3u1.tar.gzCode language: PHP (php)

クラスタを起動してみます。しかし、whirr.logを見ると、apt-get updateに失敗していたり(ununtu 10ベースだから?)、openjdk-6が見つからない、chown hadoopに失敗しているなど、エラーが多いです。

エラーのためか、インスタンスを削除して、新規にインスタンスを起動するといったオートスケールのような動きもありました。何回かクラスタ起動とクラスタ削除をしていたら、EC2インスタンスの残骸が9個になっていました。

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/lucid-security/universe/source/Sources.gz  404  Not Found [IP: 80]

E: Some index files failed to download, they have been ignored, or old ones used instead.

E: Couldn't find package openjdk-6-jdk

chown: invalid user: `hadoop:hadoop'

Code language: PHP (php)

SSHログインはできましたが、HBaseシェルは見つかりませんでした。ここまでです。

クラスタの削除を忘れないでね

タイトルとURLをコピーしました