WARN util.NativeCodeLoader:无法为您的平台加载native-hadoop库...使用适用的builtin-java类

时间:2013-12-03 14:09:36

标签: java mysql eclipse hadoop

我正在运行一个与Hadoop和MySQL通信的Java代码。代码是...... 这里有4个我创建的clacess命名 DBInputWritable,DBOutputWritable,Map,Reduce。

package example;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.db.DBConfiguration;
import org.apache.hadoop.mapreduce.lib.db.DBInputFormat;
import org.apache.hadoop.mapreduce.lib.db.DBOutputFormat;
import org.apache.hadoop.mapreduce.lib.db.DBWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
public class Main
{
   @SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception
   {
     Configuration conf = new Configuration();
     DBConfiguration.configureDB(conf,
     "com.mysql.jdbc.Driver",   // driver class
     "jdbc:mysql://localhost:3306/test", // db url
     "root",    // user name
     "root"); //password

     Job job = new Job(conf);
     job.setJarByClass(Main.class);
     job.setMapperClass(Map.class);
     job.setReducerClass(Reduce.class);
     job.setMapOutputKeyClass(Text.class);
     job.setMapOutputValueClass(IntWritable.class);
     job.setOutputKeyClass(DBOutputWritable.class);
     job.setOutputValueClass(NullWritable.class);
     job.setInputFormatClass(DBInputFormat.class);
     job.setOutputFormatClass(DBOutputFormat.class);

     System.out.println("Checkpoint 1");
     DBInputFormat.setInput(job,  DBInputWritable.class, "studentinfo", null, null, new String[] {"id", "name"});
     System.out.println("Checkpoint 2");
     DBOutputFormat.setOutput(job, "output", new String[] {"name", "count"});
     System.out.println("Checkpoint 3");

     //Getting Exception after executing this line
     System.exit(job.waitForCompletion(true) ? 0 : 1);//Getting
   }
}

输出控制台

Checkpoint 1
Checkpoint 2
Checkpoint 3
13/12/03 19:27:04 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
13/12/03 19:27:04 ERROR security.UserGroupInformation: PriviledgedActionException as:313159 cause:java.io.IOException: Failed to set permissions of path: \tmp\hadoop-313159\mapred\staging\313159-992402185\.staging to 0700
Exception in thread "main" java.io.IOException: Failed to set permissions of path: \tmp\hadoop-313159\mapred\staging\313159-992402185\.staging to 0700
    at org.apache.hadoop.fs.FileUtil.checkReturnValue(FileUtil.java:689)
    at org.apache.hadoop.fs.FileUtil.setPermission(FileUtil.java:662)
    at org.apache.hadoop.fs.RawLocalFileSystem.setPermission(RawLocalFileSystem.java:509)
    at org.apache.hadoop.fs.RawLocalFileSystem.mkdirs(RawLocalFileSystem.java:344)
    at org.apache.hadoop.fs.FilterFileSystem.mkdirs(FilterFileSystem.java:189)
    at org.apache.hadoop.mapreduce.JobSubmissionFiles.getStagingDir(JobSubmissionFiles.java:116)
    at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:918)
    at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:912)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:415)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1149)
    at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:912)
    at org.apache.hadoop.mapreduce.Job.submit(Job.java:500)
    at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:530)
    at example.Main.main(Main.java:56)

运行上面的代码后,我可以得到的控制台显示在第二个代码部分。 请有人建议我

0 个答案:

没有答案