Apache Pig – 安装

Apache Pig – 安装


本章解释了如何在您的系统中下载、安装和设置Apache Pig

先决条件

在使用 Apache Pig 之前,您的系统上必须安装 Hadoop 和 Java,这一点至关重要。因此,在安装 Apache Pig 之前,请按照以下链接中给出的步骤安装 Hadoop 和 Java –

http://www.tutorialspoint.com/hadoop/hadoop_enviornment_setup.htm

下载 Apache Pig

首先,从以下网站下载最新版本的 Apache Pig – https://pig.apache.org/

步骤1

打开 Apache Pig 网站的主页。新闻部分下单击链接发布页面,如下面的快照所示。

主页

第2步

单击指定的链接后,您将被重定向到Apache Pig 发布页面。在此页面上的“下载”部分下,您将有两个链接,即Pig 0.8 及更高版本Pig 0.7 及之前版本单击链接Pig 0.8 and later,然后您将被重定向到具有一组镜像的页面。

Apache Pig 发布

第 3 步

选择并单击这些镜像中的任何一个,如下所示。

单击镜像

第四步

这些镜像将带您进入Pig Releases页面。此页面包含 Apache Pig 的各种版本。单击其中的最新版本。

猪放生

第 5 步

在这些文件夹中,您将拥有各种发行版中 Apache Pig 的源文件和二进制文件。下载Apache Pig 0.15、pig0.15.0-src.tar.gzpig-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

.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 文件

Pigconf文件夹中,我们有一个名为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

觉得文章有用?

点个广告表达一下你的爱意吧 !😁