环境:
CentOS 7.4
hadoop-2.7.4
下载:
# pig-0.17.0 依赖 hadoop-2.7.x
wget http://apache.mirrors.nublue.co.uk/pig/latest/pig-0.17.0.tar.gz
tar xvf pig-0.17.0.tar.gz
cd pig-0.17.0/
环境变量:
echo "export PATH=`pwd`/bin:\$PATH" | sudo tee /etc/profile.d/pig.sh
source /etc/profile.d/pig.sh
验证是否可用:
pig –help
Pig 有多种执行模式:
pig -x local ... # 本地模式
pig ... # mapreduce 模式
pig -x mapreduce ... # mapreduce 模式
样例:
pig -x local
grunt> A = load '/etc/passwd' using PigStorage(':');
grunt> B = foreach A generate $0 as id;
grunt> dump B;