自动编译并运行mapreduce程序的脚本
来源:互联网 发布:简单计算器c语言 编辑:程序博客网 时间:2024/05/02 00:00
为了方便大家编写mapreduce程序,我特地编写了一个脚本,可以直接通过他编译并运行mapreduce程序,用bash awk编写的。
使用方法如下
1.cd hadoop/ 到hadoop的目录下
2.如果是第一次使用脚本,需要新建playground目录,及子目录src。(详细步骤:mkdir playground/ mkdir playground/src)
3.然后将代码复制到 playground/src/下
4.将如下代码保存到make.sh文件当中,并放到hadoop的根目录中。
5.如果是第一次使用,chmod +x make.sh
6.(如果写好的java文件名字叫做wordcount.java 那么通过在hadoop目录下打命令./make.sh wordcount ) 即可
注意事项:由于一般的mapreduce程序需要输入要处理的文件名,和处理后的结果的文件名,你就按照提示一步一步的输入就好了,要确保输出文件目录不存在,否则java会抛出异常,但是这一切的前提需要你运行start-all.sh脚本开启hadoop环境
./make.sh wordcount
Please input your input file's name
input
Please input your output file's name
ooo
如果你的版本不是hadoop-0.20.2 请在脚本中的javac -classpath hadoop-0.20.2-core.jar:lib/commons-cli-1.2.jar -d playground/classes playground/src/$1.java里做相应的修改
#!/bin/sh
if [ $# = 0 ]; then
echo "Usage:./make.sh [file-name]"
exit 1
fi
result=`grep package playground/src/$1.java`
if [ "$result" = "" ];then
echo "ERROR:not include in package org.apache.hadoop.examples"
exit 1
fi
check=`awk '$1=="public"&&$2=="class" {print $3}' playground/src/$1.java`
if [ $check==$1 ];then
echo "check finished"
else
echo "they are not same"
echo "$1"
echo "$check"
fi
javac -classpath hadoop-0.20.2-core.jar:lib/commons-cli-1.2.jar -d playground/classes playground/src/$1.java
jar -cvf playground/$1.jar -C playground/classes/ .
echo "Please input your input file's name"
read inputname
echo "Please input your output file's name"
read outputname
bin/hadoop jar playground/$1.jar org.apache.hadoop.examples.$1 $inputname $outputname
使用方法如下
1.cd hadoop/ 到hadoop的目录下
2.如果是第一次使用脚本,需要新建playground目录,及子目录src。(详细步骤:mkdir playground/ mkdir playground/src)
3.然后将代码复制到 playground/src/下
4.将如下代码保存到make.sh文件当中,并放到hadoop的根目录中。
5.如果是第一次使用,chmod +x make.sh
6.(如果写好的java文件名字叫做wordcount.java 那么通过在hadoop目录下打命令./make.sh wordcount ) 即可
注意事项:由于一般的mapreduce程序需要输入要处理的文件名,和处理后的结果的文件名,你就按照提示一步一步的输入就好了,要确保输出文件目录不存在,否则java会抛出异常,但是这一切的前提需要你运行start-all.sh脚本开启hadoop环境
./make.sh wordcount
Please input your input file's name
input
Please input your output file's name
ooo
如果你的版本不是hadoop-0.20.2 请在脚本中的javac -classpath hadoop-0.20.2-core.jar:lib/commons-cli-1.2.jar -d playground/classes playground/src/$1.java里做相应的修改
#!/bin/sh
if [ $# = 0 ]; then
echo "Usage:./make.sh [file-name]"
exit 1
fi
result=`grep package playground/src/$1.java`
if [ "$result" = "" ];then
echo "ERROR:not include in package org.apache.hadoop.examples"
exit 1
fi
check=`awk '$1=="public"&&$2=="class" {print $3}' playground/src/$1.java`
if [ $check==$1 ];then
echo "check finished"
else
echo "they are not same"
echo "$1"
echo "$check"
fi
javac -classpath hadoop-0.20.2-core.jar:lib/commons-cli-1.2.jar -d playground/classes playground/src/$1.java
jar -cvf playground/$1.jar -C playground/classes/ .
echo "Please input your input file's name"
read inputname
echo "Please input your output file's name"
read outputname
bin/hadoop jar playground/$1.jar org.apache.hadoop.examples.$1 $inputname $outputname
- 自动编译并运行mapreduce程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- 开机自动启动控制台并运行自己编译好的c++程序
- 自动下载并运行的VBS脚本代码
- Eclipse编译运行MapReduce程序 Hadoop
- 使用Eclipse编译运行MapReduce程序
- 使用Eclipse编译运行MapReduce程序
- 使用Eclipse编译运行MapReduce程序
- apache对象池技术
- 问题
- wince中oal需要实现的电源管理函数
- 赵雅智_java GUI字体和颜色的控制
- “connection as SYS should be as SYSDBA or SYSOPER”解决办法
- 自动编译并运行mapreduce程序的脚本
- 11级_Java_曹建波5.07 字体和颜色的设置&常用AWT组件的使用
- Jquery实现表格光棒效果
- VS2010 C#创建ActiveX控件
- PHPExcel使用实例
- Oracle 索引结构、内部管理
- postgresql修改表
- 围观tangram
- 由浅入深理解索引的实现