LoginSignup
14
15

More than 5 years have passed since last update.

embulkのインストール・アップデート方法

Last updated at Posted at 2015-04-14

並列データのバッチ処理ツール「embulk」の手軽なインストール・アップデート方法をまとめました。
公式とは少し違いますが、次の要望に応えられるインストール方法です。

  • インストールにroot権限が不要
  • インストール手順が簡素である
  • ユーザランドにインストールできる
  • 長くなりがちなbash_profileやPATHを書き換えなくとも使える

Javaの確認

Javaがまだインストールされていない場合には、JDKまたはJREが必要です。
java.png

次のページから、Java 8をダウンロードします。Java 9はまだembulkでサポートしていません。
http://www.oracle.com/technetwork/java/javase/downloads/index.html

javaの実行さえできれば良い場合には、JREを選ぶと容量が少なくて良いでしょう。

インストール

$ curl --create-dirs -o ~/bin/embulk -L http://dl.embulk.org/embulk-latest.jar
$ chmod +x ~/bin/embulk

Linux環境であればこれだけで良いのですが、
OSX環境の場合は次のように.bash_profileを編集します。
公式手順のように.embulk/binに入れるかは適宜判断してください。

$ cat << 'EOF' >> ~/.bash_profile
# User specific environment and startup programs
export PATH=$PATH:$HOME/bin
EOF
$ source ~/.bash_profile

インストール出来たバージョンを確認します。
次の通り、v0.9.4がインストールできました。

$ embulk
Embulk v0.9.4
Usage: embulk [-vm-options] <command> [--options]
Commands:
   mkbundle   <directory>                             # create a new plugin bundle environment.
   bundle     [directory]                             # update a plugin bundle environment.
   run        <config.yml>                            # run a bulk load transaction.
   cleanup    <config.yml>                            # cleanup resume state.
   preview    <config.yml>                            # dry-run the bulk load without output and show preview.
   guess      <partial-config.yml> -o <output.yml>    # guess missing parameters to create a complete configuration file.
   gem        <install | list | help>                 # install a plugin or show installed plugins.
   new        <category> <name>                       # generates new plugin template
   migrate    <path>                                  # modify plugin code to use the latest Embulk plugin API
   example    [path]                                  # creates an example config file and csv file to try embulk.
   selfupdate [version]                               # upgrades embulk to the latest released version or to the specified version.

VM options:
   -E...                            Run an external script to configure environment variables in JVM
                                    (Operations not just setting envs are not recommended nor guaranteed.
                                     Expect side effects by running your external script at your own risk.)
   -J-O                             Disable JVM optimizations to speed up startup time (enabled by default if command is 'run')
   -J+O                             Enable JVM optimizations to speed up throughput
   -J...                            Set JVM options (use -J-help to see available options)
   -R...                            Set JRuby options (use -R--help to see available options)

Use `<command> --help` to see description of the commands.

アップデート

selfupdateというサブコマンドがあるので、それを利用します。

$ embulk selfupdate
2016-02-21 13:04:03.550 +0900: Embulk v0.8.5
Checking the latest version...
Already up-to-date. 0.8.5 is the latest version.

古いバージョンでは、インストール手順と同様に上書きします。

# 既存のバイナリを上書きします
$ curl --create-dirs -o ~/bin/embulk -L http://dl.embulk.org/embulk-latest.jar

トラブルシューティング

Mac OSX 10.9(OS X Mavericks)の素の環境では次のエラーが起きることがあります。
これは、Java 1.7以上の新しいバージョンを入れる事で解決します。

次の記事でも説明があるように、セキュリティを高める上でもアップデートした方が良いですね。
https://support.apple.com/ja-jp/HT202678

# エラー内容
$ embulk
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/embulk/cli/Main : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
# Javaのバージョンを確認
$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

MacOSX用のJDKをダウンロードしてきて、インストールすれば次の通り新しいバージョンに切り替わりました。

$ java -version
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)

なお、CentOSの場合は次のようにインストールしましょう。

## CentOSの場合
$ sudo yum install java-1.8.0-openjdk
14
15
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
14
15