Apache-pig-installation

提供:Dev Guides
移動先:案内検索

Apache Pig-インストール

この章では、システムで Apache Pig をダウンロード、インストール、およびセットアップする方法について説明します。

前提条件

Apache Pigを使用する前に、HadoopとJavaをシステムにインストールしておくことが重要です。 したがって、Apache Pigをインストールする前に、次のリンクに記載されている手順に従ってHadoopとJavaをインストールします-

http://www.finddevguides.com/hadoop/hadoop_enviornment_setup

Apache Pigをダウンロードする

まず、次のWebサイト(https://pig.apache.org/)からApache Pigの最新バージョンをダウンロードします。

ステップ1

Apache Pig Webサイトのホームページを開きます。 次のスナップショットに示すように、[*ニュース] *セクションの下にある[リリースページ]リンクをクリックします。

ホームページ

ステップ2

指定されたリンクをクリックすると、* Apache Pigリリース*ページにリダイレクトされます。 このページの[ダウンロード]セクションには、* Pig 0.8以降*および* Pig 0.7以前*の2つのリンクがあります。 * Pig 0.8以降*のリンクをクリックすると、ミラーのセットがあるページにリダイレクトされます。

Apache Pigリリース

ステップ3

以下に示すように、これらのミラーのいずれかを選択してクリックします。

ミラーをクリック

ステップ4

これらのミラーは、 Pig Releases ページに移動します。 このページには、Apache Pigのさまざまなバージョンが含まれています。 それらの中で最新バージョンをクリックします。

豚リリース

ステップ5

これらのフォルダー内には、Apache Pigのソースファイルとバイナリファイルがさまざまなディストリビューションで含まれています。 Apache Pig 0.15、 pig0.15.0-src.tar.gz 、および* pig-0.15.0.tar.gz。*のソースファイルとバイナリファイルのtarファイルをダウンロードします。

インデックス

Apache Pigをインストールする

Apache Pigソフトウェアをダウンロードしたら、以下の手順に従ってLinux環境にインストールします。

ステップ1

  • Hadoop、Java、およびその他のソフトウェアのインストールディレクトリがインストールされたのと同じディレクトリに、Pigという名前のディレクトリを作成します。 (チュートリアルでは、Hadoopという名前のユーザーにPigディレクトリを作成しました)。
$ mkdir Pig

ステップ2

以下に示すように、ダウンロードしたtarファイルを解凍します。

$ cd Downloads/
$ tar zxvf pig-0.15.0-src.tar.gz
$ tar zxvf pig-0.15.0.tar.gz

ステップ3

以下に示すように、 pig-0.15.0-src.tar.gz ファイルの内容を以前に作成した Pig ディレクトリに移動します。

$ mv pig-0.15.0-src.tar.gz/*/home/Hadoop/Pig/

Apache Pigを構成する

Apache Pigをインストールしたら、構成する必要があります。 設定するには、 bashrcとpig.properties の2つのファイルを編集する必要があります。

.bashrcファイル

*.bashrc* ファイルで、次の変数を設定します-
  • PIG_HOME フォルダーをApache Pigのインストールフォルダーに、
  • PATH 環境変数からbinフォルダー、および
  • PIG_CLASSPATH 環境変数をHadoopインストールのetc(設定)フォルダー(core-site.xml、hdfs-site.xml、mapred-site.xmlファイルを含むディレクトリ)に。
export PIG_HOME =/home/Hadoop/Pig
export PATH  = $PATH:/home/Hadoop/pig/bin
export PIG_CLASSPATH = $HADOOP_HOME/conf

pig.propertiesファイル

Pigの conf フォルダーには、 pig.properties という名前のファイルがあります。 pig.propertiesファイルでは、以下に示すようにさまざまなパラメーターを設定できます。

pig -h properties

次のプロパティがサポートされています-

Logging: verbose = true|false; default is false. This property is the same as -v
       switch brief=true|false; default is false. This property is the same
       as -b switch debug=OFF|ERROR|WARN|INFO|DEBUG; default is INFO.
       This property is the same as -d switch aggregate.warning = true|false; default is true.
       If true, prints count of warnings of each type rather than logging each warning.

Performance tuning: pig.cachedbag.memusage=<mem fraction>; default is 0.2 (20% of all memory).
       Note that this memory is shared across all large bags used by the application.
       pig.skewedjoin.reduce.memusagea=<mem fraction>; default is 0.3 (30% of all memory).
       Specifies the fraction of heap available for the reducer to perform the join.
       pig.exec.nocombiner = true|false; default is false.
           Only disable combiner as a temporary workaround for problems.
       opt.multiquery = true|false; multiquery is on by default.
           Only disable multiquery as a temporary workaround for problems.
       opt.fetch=true|false; fetch is on by default.
           Scripts containing Filter, Foreach, Limit, Stream, and Union can be dumped without MR jobs.
       pig.tmpfilecompression = true|false; compression is off by default.
           Determines whether output of intermediate jobs is compressed.
       pig.tmpfilecompression.codec = lzo|gzip; default is gzip.
           Used in conjunction with pig.tmpfilecompression. Defines compression type.
       pig.noSplitCombination = true|false. Split combination is on by default.
           Determines if multiple small files are combined into a single map.

       pig.exec.mapPartAgg = true|false. Default is false.
           Determines if partial aggregation is done within map phase, before records are sent to combiner.
       pig.exec.mapPartAgg.minReduction=<min aggregation factor>. Default is 10.
           If the in-map partial aggregation does not reduce the output num records by this factor, it gets disabled.

Miscellaneous: exectype = mapreduce|tez|local; default is mapreduce. This property is the same as -x switch
       pig.additional.jars.uris=<comma seperated list of jars>. Used in place of register command.
       udf.import.list=<comma seperated list of imports>. Used to avoid package names in UDF.
       stop.on.failure = true|false; default is false. Set to true to terminate on the first error.
       pig.datetime.default.tz=<UTC time offset>. e.g. +08:00. Default is the default timezone of the host.
           Determines the timezone used to handle datetime datatype and UDFs.
Additionally, any Hadoop property can be specified.

インストールの検証

versionコマンドを入力して、Apache Pigのインストールを確認します。 インストールが成功すると、以下に示すバージョンのApache Pigが取得されます。

$ pig –version

Apache Pig version 0.15.0 (r1682971)
compiled Jun 01 2015, 11:44:35