调用Grunt Shell
您可以使用-x选项以所需的方式(本地/MapReduce)调用Grunt shell,如下所示。
本地模式 |
MapReduce 模式 |
命令 − $ ./pig –x local |
命令$ ./pig -x mapreduce |
jc2182@debian:~/pig$ pig -x local
2021-01-11 15:09:08,420 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2021-01-11 15:09:08,690 INFO pig.ExecTypeProvider: Trying ExecType : LOCAL
2021-01-11 15:09:08,690 INFO pig.ExecTypeProvider: Picked LOCAL as the ExecType
2021-01-11 15:09:08,825 [main] INFO org.apache.pig.Main - Apache Pig version 0.17.0 (r1797386) compiled Jun 02 2017, 15:41:58
2021-01-11 15:09:08,825 [main] INFO org.apache.pig.Main - Logging error messages to: /home/jc2182/pig/pig_1610348948819.log
2021-01-11 15:09:08,939 [main] INFO org.apache.pig.impl.util.Utils - Default bootup file /home/jc2182/.pigbootup not found
2021-01-11 15:09:09,131 [main] INFO org.apache.hadoop.conf.Configuration.deprecation - mapred.job.tracker is deprecated. Instead, use mapreduce.jobtracker.address
2021-01-11 15:09:09,133 [main] INFO org.apache.pig.backend.hadoop.executionengine.HExecutionEngine - Connecting to hadoop file system at: file:///
2021-01-11 15:09:09,537 [main] INFO org.apache.hadoop.conf.Configuration.deprecation - io.bytes.per.checksum is deprecated. Instead, use dfs.bytes-per-checksum
2021-01-11 15:09:09,618 [main] INFO org.apache.pig.PigServer - Pig Script ID for the session: PIG-default-47ff99a2-5aab-497f-9966-0ffebd44f115
2021-01-11 15:09:09,618 [main] WARN org.apache.pig.PigServer - ATS is disabled since yarn.timeline-service.enabled set to false
grunt>
|
jc2182@debian:~/pig$ pig -x mapreduce
2021-01-11 15:11:00,724 INFO pig.ExecTypeProvider: Trying ExecType : LOCAL
2021-01-11 15:11:00,726 INFO pig.ExecTypeProvider: Trying ExecType : MAPREDUCE
2021-01-11 15:11:00,726 INFO pig.ExecTypeProvider: Picked MAPREDUCE as the ExecType
2021-01-11 15:11:00,816 [main] INFO org.apache.pig.Main - Apache Pig version 0.17.0 (r1797386) compiled Jun 02 2017, 15:41:58
2021-01-11 15:11:00,816 [main] INFO org.apache.pig.Main - Logging error messages to: /home/jc2182/pig/pig_1610349060803.log
2021-01-11 15:11:00,856 [main] INFO org.apache.pig.impl.util.Utils - Default bootup file /home/jc2182/.pigbootup not found
2021-01-11 15:11:01,150 [main] WARN org.apache.hadoop.util.NativeCodeLoader - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2021-01-11 15:11:01,179 [main] INFO org.apache.hadoop.conf.Configuration.deprecation - mapred.job.tracker is deprecated. Instead, use mapreduce.jobtracker.address
2021-01-11 15:11:01,179 [main] INFO org.apache.pig.backend.hadoop.executionengine.HExecutionEngine - Connecting to hadoop file system at: hdfs://localhost:9000
2021-01-11 15:11:02,161 [main] INFO org.apache.pig.PigServer - Pig Script ID for the session: PIG-default-424e89f8-dc16-49eb-89dc-5584cb0c47f7
2021-01-11 15:11:02,161 [main] WARN org.apache.pig.PigServer - ATS is disabled since yarn.timeline-service.enabled set to false
grunt>
|
注意:MapReduce模式必需启动Hadoop
这两个命令都会为您提供Grunt shell提示符,如下所示。
您可以使用'ctrl + d'退出Grunt shell。
调用Grunt shell之后,您可以通过直接在其中输入Pig Latin语句来执行Pig脚本。
grunt> customers = LOAD 'customers.txt' USING PigStorage(',');