2014-11-03 5 views
0

안녕하세요,이 hcatalog 예제를 다음 링크에서 수행하려고합니다. 내가 작업을 실행할 때Hcatalog 하이브 발행 java.lang.IllegalArgumentException : URI : 스키마가 없습니다.

http://www.cloudera.com/content/cloudera/en/documentation/cdh4/v4-2-0/CDH4-Installation-Guide/cdh4ig_topic_19_6.html

나는 다음과 같은 예외를 얻고있다.

java.lang.IllegalArgumentException가 : URI : 방안이없는

자바 클래스 :이 라인에서 예외를 받고

import java.io.IOException; 
import java.util.*; 

import org.apache.hadoop.fs.Path; 
import org.apache.hadoop.conf.*; 
import org.apache.hadoop.io.*; 
import org.apache.hadoop.mapreduce.*; 
import org.apache.hadoop.util.*; 
import org.apache.hcatalog.common.*; 
import org.apache.hcatalog.mapreduce.*; 
import org.apache.hcatalog.data.*; 
import org.apache.hcatalog.data.schema.*; 
import org.apache.hadoop.util.GenericOptionsParser; 
//import org.apache.commons.cli.Options; 

public class UseHCat extends Configured implements Tool { 

    public static class Map extends Mapper<WritableComparable, HCatRecord, Text, IntWritable> { 
     String groupname; 

     @Override 
     protected void map(WritableComparable key, 
          HCatRecord value, 
          org.apache.hadoop.mapreduce.Mapper<WritableComparable, HCatRecord, 
          Text, IntWritable>.Context context) 
      throws IOException, InterruptedException { 
      // The group table from /etc/group has name, 'x', id 
      groupname = (String) value.get(0); 
      int id = (Integer) value.get(2); 
      // Just select and emit the name and ID 
      context.write(new Text(groupname), new IntWritable(id)); 
     } 
    } 

    public static class Reduce extends Reducer<Text, IntWritable, 
             WritableComparable, HCatRecord> { 

     protected void reduce(Text key, 
           java.lang.Iterable<IntWritable> values, 
           org.apache.hadoop.mapreduce.Reducer<Text, IntWritable, 
           WritableComparable, HCatRecord>.Context context) 
      throws IOException, InterruptedException { 
      // Only expecting one ID per group name 
      Iterator<IntWritable> iter = values.iterator(); 
      IntWritable iw = iter.next(); 
      int id = iw.get(); 
      // Emit the group name and ID as a record 
      HCatRecord record = new DefaultHCatRecord(2); 
      record.set(0, key.toString()); 
      record.set(1, id); 
      context.write(null, record); 
     } 
    } 

    @SuppressWarnings("deprecation") 
    public int run(String[] args) throws Exception { 
     Configuration conf = getConf(); 
     args = new GenericOptionsParser(conf, args).getRemainingArgs(); 

     // Get the input and output table names as arguments 
     String inputTableName = args[0]; 
     String outputTableName = args[1]; 
     // Assume the default database 
     String dbName = "hadooppracticedb"; 

     Job job = new Job(conf, "UseHCat"); 
     HCatInputFormat.setInput(job, InputJobInfo.create(dbName, 
       inputTableName, null)); 
     job.setJarByClass(UseHCat.class); 
     job.setMapperClass(Map.class); 
     job.setReducerClass(Reduce.class); 

     // An HCatalog record as input 
     job.setInputFormatClass(HCatInputFormat.class); 

     // Mapper emits a string as key and an integer as value 
     job.setMapOutputKeyClass(Text.class); 
     job.setMapOutputValueClass(IntWritable.class); 

     // Ignore the key for the reducer output; emitting an HCatalog record as value 
     job.setOutputKeyClass(WritableComparable.class); 
     job.setOutputValueClass(DefaultHCatRecord.class); 
     job.setOutputFormatClass(HCatOutputFormat.class); 

     HCatOutputFormat.setOutput(job, OutputJobInfo.create(dbName, 
        outputTableName, null)); 
     HCatSchema s = HCatOutputFormat.getTableSchema(job); 
     System.err.println("INFO: output schema explicitly set for writing:" + s); 
     HCatOutputFormat.setSchema(job, s); 
     return (job.waitForCompletion(true) ? 0 : 1); 
    } 

    public static void main(String[] args) throws Exception { 
     int exitCode = ToolRunner.run(new UseHCat(), args); 
     System.exit(exitCode); 
    } 
} 

HCatInputFormat.setInput(job, InputJobInfo.create(dbName, 
      inputTableName, null)); 

하둡 jar 명령 :

hadoop jar Hcat.jar com.otsi.hcat.UseHCat -files $ HCATJAR -libjars $ {LIBJ ARS} 그룹은 내가 하이브를 site.xml에

하이브-site.xml 파일을 다음과 같은 속성을 설정 한

groupids :

<property> 
     <name>hive.metastore.uris</name> 
     <value>thrift://localhost:9083</value> 
    </property> 

나는 "hadooppracticedb"의 2 개 테이블 그룹 groupids을 만들었습니다.

를 제안하십시오.

답변

0

메타 스토어 로컬 속성을 정의하지 않았습니까?

독립 실행 형 MetaStore 서버를 실행하는 경우에만 hive.metastore.uris 속성을 설정해야합니다.이 경우 hive.metastore.local = false를 설정하고 hive.metastore.uris를 Thrift URI로 설정해야합니다.

자세한 내용은이 문서를 참조하십시오

https://cwiki.apache.org/confluence/display/Hive/AdminManual+MetastoreAdmin

+0

안녕하세요, 저는 하이브가 메타 데이터 요청을하려면 다음의 URI 중 하나에 연결 하이브 0.13.0..hive.metastore.uris 를 사용하고 원격 Metastore (쉼표로 구분 된 URI 목록) hive.metastore.local 로컬 또는 원격 메타 스토어 (하이브 0.10에서 제거됨 : hive.metastore.uris가 비어있는 경우 로컬 모드로 가정, 그렇지 않은 경우 원격 ...) 2 노드 클러스터에서 .. – user1217694

+0

hive-site.xml; 하이브. metastore.uris thrift : // NameNode : 9083 user1217694

관련 문제