shell学习记录
shell学习
https://www.cnblogs.com/yangyanfei/p/6386831.html
使用shell执行hadoop命令
https://www.cnblogs.com/xyliao/p/5711768.html
./bin/hadoop jar ./myapp/HDFSExample.jar
====================================
假设保存为test.sh,java文件为wc.java,【注:会打包成1.jar】,main函数所在类为wc,hdfs上输入目录地址为input,hdfs上输出目录地址为output【注:输入目录和输出目录非必须】
运行程序:
./test.sh wc.java wc input output
#!/bin/bash
#echo "$# $0 $1 $2"
HH=$Hadoop_HOME
if [ $# -lt 2 ];then
echo "usage: jc.sh source.java ClassName [InputFile] [OutputFile]"
exit 0
elif [ ${1##*.} != "java" ];then
echo "Notice: source.java java!"
exit 0
else
rm -r ./classes/*
javac -classpath $HH/hadoop-mapred-0.22.0.jar:$HH/hadoop-hdfs-0.22.0.jar:$HH/hadoop-common-0.22.0.jar:$HH/lib/commons-cli-1.2.jar -d classes ./$1
jar -cvf 1.jar -C classes/ .
echo "==============Output====================="
if [ $# -eq 2 ];then
hadoop jar 1.jar $2
elif [ $# -eq 3 ];then
hadoop jar 1.jar $2 $3
elif [ $# -eq 4 ];then
hadoop jar 1.jar $2 $3 $4
fi
echo "========================================="
rm 1.jar
fi
-------------------------