使用es-hadoop

时间:2016-04-13 07:29:49

标签: hadoop elasticsearch elasticsearch-hadoop

当我尝试使用带有es-hadoop的mapreduce程序写入Elasticsearch时,会出现此异常。我试图写信给我的Elasticsearch集群中已存在的 index = employee和type = basic

我的堆栈跟踪: -

  

线程“main”中的异常   org.elasticsearch.hadoop.EsHadoopIllegalArgumentException:没有资源   指定的['es.resource'](索引/查询/位置)   org.elasticsearch.hadoop.util.Assert.hasText(Assert.java:30)at   org.elasticsearch.hadoop.mr.EsOutputFormat.init(EsOutputFormat.java:257)     在   org.elasticsearch.hadoop.mr.EsOutputFormat.checkOutputSpecs(EsOutputFormat.java:233)     在   org.apache.hadoop.mapreduce.JobSubmitter.checkSpecs(JobSubmitter.java:266)     在   org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:139)     在org.apache.hadoop.mapreduce.Job $ 10.run(Job.java:1290)at at   org.apache.hadoop.mapreduce.Job $ 10.run(Job.java:1287)at at   java.security.AccessController.doPrivileged(Native Method)at   javax.security.auth.Subject.doAs(Subject.java:422)at   org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657)     在org.apache.hadoop.mapreduce.Job.submit(Job.java:1287)at   org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:1308)at at   com.mstack.mapreduce.DIGDriver.main(DIGDriver.java:22)at   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:497)at   org.apache.hadoop.util.RunJar.run(RunJar.java:221)at   org.apache.hadoop.util.RunJar.main(RunJar.java:136)

驱动程序类: -

Configuration conf = new Configuration();
Job job = Job.getInstance(conf, "es-hadoop");
job.setJarByClass(DIGDriver.class);
conf.set("es.nodes", "localhost:9200");
conf.set("es.port", "9200");
conf.set("es.resource", "employee/basic");
job.setNumReduceTasks(0);
job.setOutputFormatClass(EsOutputFormat.class);
job.setMapperClass(DIGMapper.class);
job.setMapOutputValueClass(MapWritable.class);
conf.setBoolean("mapreduce.map.speculative", false);
conf.setBoolean("mapreduce.reduce.speculative", false);
boolean status = job.waitForCompletion(true);
if (status) {
System.exit(0);
} else {
System.out.println("Job Failed : Some error!");
System.exit(1);
}

1 个答案:

答案 0 :(得分:1)

通过更改配置解决了自己: -

conf.set("es.nodes", "localhost");
conf.set("es.port", "9200");