Hadoop Execution Shell Script

Source: Internet
Author: User
Tags hadoop fs

Share a shell script executed by your own Hadoop,

But for those who write shell scripts, it's not going to work.

People who can't write shell scripts seem to be confused.

If you are interested in learning, you can contact in private. As for

The related files (source code/compile.sh) involved in the script could not be uploaded.

Make a record so that it is convenient for you to review later.

Because it is only for their own testing, it is more coarse

At the time of execution:

Direct execution procedure

Hadoop@namenode#./hadooprunaveragepower

Recompile execution

Hadoop@namenode#./hadooprunaveragepower y script files are as follows:

#!/bin/sh

#HadoopRunAveragePower isstandalone=0 #isStandalone: 0 Hadoop clust; 1 Standalone
Compilefile= "Averagepowercompile.sh"
Sourcefolder= "workspace/averagepower/"
Jarfolder= "."
Inputpath= "input2/"
Outputpath= "output/"
Jarfile= "Averagepower.jar"
Jarmainclass= "Workdir. Averagepower "
Compressornot= "true"
maptasknum=2
Reducetasknum=1


Isrebuild= "n"
If ["$#"-GT 0];then
#echo do your want to run rebuild this application[y/n]?
echo "Ready to Rebuild Source"
If ["$" = "Y"];then
Isrebuild=$1
elif ["$" = "Y"];then
Isrebuild=$1
Fi
Case "$isRebuild" in
[yy]*)

echo do:find $SOURCEFOLDER-name *.java~-exec rm-f {} \;
Find $SOURCEFOLDER-name *.java~-exec rm-f {} \;
echo do:find $SOURCEFOLDER-name *.class-exec rm-f {} \;
Find $SOURCEFOLDER-name *.class-exec rm-f {} \;

Echo DO:RM-VF $JARFILE
RM-VF $JARFILE
Echo Do:bash $COMPILEFILE
Bash $COMPILEFILE
echo DO:JAR-CVF $JARFILE-C $SOURCEFOLDER $JARFOLDER
JAR-CVF $JARFILE-C $SOURCEFOLDER $JARFOLDER
echo "Rebuild application Successfully"
;;
*)
echo "Parameter Error"
echo "Not Rebuild application"
exit;;
Esac




Else
echo "Not Rebuild application"
Fi


echo do your want to run this application[y/n]?
Read answer
Case "$answer" in
[yy]*)
If ["$isStandalone"-eq 0];then
echo Do:bin/hadoop FS-RMR $OUTPUTPATH
Bin/hadoop FS-RMR $OUTPUTPATH
Else
Echo DO:RM-RVF $OUTPUTPATH
RM-RVF $OUTPUTPATH
Fi
The echo do:bin/hadoop jar $JARFILE $JARMAINCLASS-C $COMPRESSORNOT-M $MAPTASKNUM-R $REDUCETASKNUM $INPUTPATH $OUTPUTPATH
Bin/hadoop jar $JARFILE $JARMAINCLASS-C $COMPRESSORNOT-M $MAPTASKNUM-R $REDUCETASKNUM $INPUTPATH $OUTPUTPATH
echo Input_dir: $INPUTPATH
echo Input_dir: $OUTPUTPATH
echo application Success done and exited.
;;
*) exit;;
Esac

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.