运行hadoop时磁盘已满
我运行了一个递归map/reduce程序。出了问题,它几乎消耗了C驱动器中所有可用的磁盘空间。因此,我关闭了资源管理器,节点管理器,名称节点,数据节点控制台。 现在我有一个C驱动器,它几乎满了,我不知道如何清空磁盘空间,使我的C驱动器和以前一样。我现在该怎么办。感谢您的帮助。 这是密码 公共类先验{运行hadoop时磁盘已满,hadoop,mapreduce,diskspace,Hadoop,Mapreduce,Diskspace,我运行了一个递归map/reduce程序。出了问题,它几乎消耗了C驱动器中所有可用的磁盘空间。因此,我关闭了资源管理器,节点管理器,名称节点,数据节点控制台。 现在我有一个C驱动器,它几乎满了,我不知道如何清空磁盘空间,使我的C驱动器和以前一样。我现在该怎么办。感谢您的帮助。 这是密码 公共类先验{ public static class CandidateGenMap extends Mapper<LongWritable, Text, Text, Text> { priv
public static class CandidateGenMap extends Mapper<LongWritable, Text, Text, Text>
{
private Text word = new Text();
private Text count = new Text();
private int Support = 5;
public void CandidatesGenRecursion(Vector<String> in, Vector<String> out,
int length, int level, int start,
Context context) throws IOException {
int i,size;
for(i=start;i<length;i++) {
if(level==0){
out.add(in.get(i));
} else {
out.add(in.get(i));
int init=1;
StringBuffer current = new StringBuffer();
for(String s:out)
{
if(init==1){
current.append(s);
init=0;
} else {
current.append(" ");
current.append(s);
}
}
word.set(current.toString());
count.set(Integer.toString(1));
try {
context.write(word, count);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(i < length-1) {
CandidatesGenRecursion(in, out, length,level+1,i+1, context);
}
size = out.size();
if(size>0){
out.remove(size-1);
}
}
}
@Override
public void map(LongWritable key,Text value,Context context) throws IOException
{
String line = value.toString();
StringTokenizer tokenizer = new StringTokenizer(line);
String[] token=new String[2];
int i=0;
while(tokenizer.hasMoreTokens()){
token[i]= tokenizer.nextToken();
++i;
}
StringTokenizer urlToken = new StringTokenizer(token[1],",");
Vector<String> lst = new Vector<String>();
int loop=0;
while (urlToken.hasMoreTokens()) {
String str = urlToken.nextToken();
lst.add(str);
loop++;
}
Vector<String> combinations = new Vector<String>();
if(!lst.isEmpty()) {
CandidatesGenRecursion(lst, combinations, loop,0,0, context);
}
}
}
public static class CandidateGenReduce extends Reducer<Text, IntWritable, Text, IntWritable>
{
public void reduce(Text key,Iterator<IntWritable> values,Context context) throws IOException
{
int sum = 0;
while (values.hasNext()) {
sum += values.next().get();
}
try {
context.write(key, new IntWritable(sum));
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) throws Exception
{
Date dt;
long start,end; // Start and end time
//Start Timer
dt = new Date();
start = dt.getTime();
Configuration conf1 = new Configuration();
System.out.println("Starting Job2");
Job job2 = new Job(conf1, "apriori candidate gen");
job2.setJarByClass(apriori.class);
job2.setMapperClass(CandidateGenMap.class);
job2.setCombinerClass(CandidateGenReduce.class); //
job2.setReducerClass(CandidateGenReduce.class);
job2.setMapOutputKeyClass(Text.class);
job2.setMapOutputValueClass(Text.class);
job2.setOutputKeyClass(Text.class);
job2.setOutputValueClass(IntWritable.class);
job2.setInputFormatClass(TextInputFormat.class);
job2.setOutputFormatClass(TextOutputFormat.class);
FileInputFormat.addInputPath(job2, new Path(args[0]));
FileOutputFormat.setOutputPath(job2, new Path(args[1]));
job2.waitForCompletion(true);
//End Timer
dt = new Date();
end = dt.getTime();
}
公共静态类CandidateMap扩展了映射器
{
私有文本字=新文本();
私有文本计数=新文本();
私人int支持=5;
public void CandidatesGenRecursion(向量输入、向量输出、,
整数长度,整数级别,整数开始,
上下文)抛出IOException{
int i,大小;
用于(i=开始;i0){
取出。取出(尺寸1);
}
}
}
@凌驾
公共void映射(LongWritable键、文本值、上下文)引发IOException
{
字符串行=value.toString();
StringTokenizer标记器=新的StringTokenizer(行);
字符串[]标记=新字符串[2];
int i=0;
while(tokenizer.hasMoreTokens()){
token[i]=tokenizer.nextToken();
++一,;
}
StringTokenizer urlToken=新的StringTokenizer(标记[1],“,”);
向量lst=新向量();
int循环=0;
while(urlToken.hasMoreTokens()){
String str=urlToken.nextToken();
第一次添加(str);
loop++;
}
向量组合=新向量();
如果(!lst.isEmpty()){
候选源递归(lst,组合,循环,0,0,上下文);
}
}
}
公共静态类CandidateGenReduce扩展了Reducer
{
公共void reduce(文本键、迭代器值、上下文)引发IOException
{
整数和=0;
while(values.hasNext()){
sum+=values.next().get();
}
试试{
write(key,newintwriteable(sum));
}捕获(中断异常e){
e、 printStackTrace();
}
}
}
公共静态void main(字符串[]args)引发异常
{
日期dt;
长时间开始,结束;//开始和结束时间
//启动计时器
dt=新日期();
start=dt.getTime();
Configuration conf1=新配置();
System.out.println(“开始作业2”);
Job job2=新工作(conf1,“先验候选基因”);
job2.setJarByClass(apriori.class);
job2.setMapperClass(CandidateGenMap.class);
job2.setCombinerClass(CandidateGenReduce.class)//
作业2.SetReduceClass(CandidateGenReduce.class);
job2.setMapOutputKeyClass(Text.class);
job2.setMapOutputValueClass(Text.class);
job2.setOutputKeyClass(Text.class);
job2.setOutputValueClass(IntWritable.class);
job2.setInputFormatClass(TextInputFormat.class);
job2.setOutputFormatClass(TextOutputFormat.class);
addInputPath(作业2,新路径(args[0]);
setOutputPath(作业2,新路径(args[1]);
作业2.等待完成(true);
//结束计时器
dt=新日期();
end=dt.getTime();
}
}Hadoop在每个阶段(映射、还原等)都需要足够的磁盘空间进行i/0操作。检查HDFS作业输出路径并删除内容 列表内容:
$ sudo -u hdfs hadoop fs -ls [YourJobOutputPath]
使用的磁盘:
$ sudo -u hdfs hadoop fs -du -h [YourJobOutputPath]
删除内容(小心!这是递归的):
删除输出目录可能有助于从MapReduce作业创建的文件中释放磁盘 修复代码是一个堆栈溢出问题,但修复硬盘可能是服务器故障或超级用户。转到namenode ui,浏览文件系统。检查将有文件已消耗大量空间。使用hdfs dfs-rm/path_to_file_to_delete命令删除文件
$ sudo -u hdfs hadoop fs -rm -R [YourJobOutputPath]