The pig version used in this article is pig-0.12.0.tar.gz, and the installation method reference for Hadoop,hadoop has been installed before installationhadoop-1.2.1 Installation Method Detailed
Pig's installation method is simple, configure the environment, Pig has two modes of operation: Local mode and MapReduce mode (default).
1. Upload and unzip pig-0.12.0.tar.gz
[email protected] temp]$tar zxf pig-0.12.0.tar.gz
2. Configure the environment variables of pig and make them effective
Export Pig_home=/home/hadoop/pig-0.12.0export path= $PATH: $JAVA _home/bin: $HADOOP _home/bin: $HBASE _home/bin: $HIVE _ Home/bin: $PIG _home/bin
3. Verify the installation with the Pig command (local mode)
[email protected] ~]$Pig-x Local
2015-06-12 00:23:30,823 [main] INFO Org.apache.pig.main-apache pig version 0.12.0 (r1529718) compiled Oct 07 2013, 12:20:14
2015-06-12 00:23:30,824 [main] INFO org.apache.pig.main-logging error messages to:/home/hadoop/pig_1434093810822. Log
2015-06-12 00:23:30,876 [main] INFO org.apache.pig.impl.util.utils-default bootup file/home/hadoop/.pigbootup not Found
2015-06-12 00:23:30,964 [main] INFO Org.apache.pig.backend.hadoop.executionengine.HExecutionEngine-connecting to Hadoop file system at:file:///
grunt>quit;
[email protected] ~]$
can seegrunt>indicates that it has been configured successfully,file:///indicates that now is the local mode, to use MapReduce mode, you need to properly configure the startup Hadoop cluster, and pig can read to the Hadoop configuration file (files under the Conf directory of Hadoop)
4. Configure the Pig_classpath in the. bashrc file and use it as valid
Export pig_classpath=/home/hadoop/hadoop-1.2.1/conf
5. Verify Installation with pig command (mapreduce mode)
[email protected] ~]$ Pig
2015-06-12 00:35:43,322 [main] INFO Org.apache.pig.main-apache pig version 0.12.0 (r1529718) compiled Oct 07 2013, 12:20:14
2015-06-12 00:35:43,322 [main] INFO org.apache.pig.main-logging error messages to:/home/hadoop/pig_1434094543321. Log
2015-06-12 00:35:43,342 [main] INFO org.apache.pig.impl.util.utils-default bootup file/home/hadoop/.pigbootup not Found
2015-06-12 00:35:43,463 [main] INFO Org.apache.pig.backend.hadoop.executionengine.HExecutionEngine-connecting to Hadoop file system at:hdfs://master:9000
2015-06-12 00:35:43,613 [main] INFO Org.apache.pig.backend.hadoop.executionengine.HExecutionEngine-connecting to Map-reduce job Tracker at:master:9001
grunt> quit;
[email protected] ~]$
As can be seen from the red section above, the file system is the HDFs file system, not the same as the local mode
Now that we have installed pig, because the pig log file is saved to the execution Pig command under the directory (different directory into the Pig log location is not the same), not conducive to the analysis and management of the log, so usually specify a specific directory, the method is as follows:
1. Create a log directory of pig, I put it under the Pig/logs folder under the Hadoop user
[email protected] ~]$mkdir-p/home/hadoop/pig/logs
2, modify the/home/hadoop/pig-0.12.0/conf/pig.properties file, remove the configuration Pig.logfile parameter comments, and configure the following
Pig.logfile=/home/hadoop/pig/logs
so the pig's log is written to the specified directory, as follows:
[email protected] conf]$ Pig
2015-06-12 00:51:12,399 [main] INFO Org.apache.pig.main-apache pig version 0.12.0 (r1529718) compiled Oct 07 2013, 12:20:14
2015-06-12 00:51:12,399 [main] INFO Org.apache.pig.Main-Logging error messages to:/home/hadoop/pig/logs/pig_1434095472397.log
2015-06-12 00:51:12,418 [main] INFO org.apache.pig.impl.util.utils-default bootup file/home/hadoop/.pigbootup not Found
2015-06-12 00:51:12,524 [main] INFO org.apache.pig.backend.hadoop.executionengine.hexecutionengine-connecting To Hadoop file system at:hdfs://master:9000
2015-06-12 00:51:12,659 [main] INFO org.apache.pig.backend.hadoop.executionengine.hexecutionengine-connecting To Map-reduce job Tracker at:master:9001
grunt>
Copyright NOTICE: This article is the original blogger article, reproduced please indicate this article link.
How to install and use pig