无法从给定路径读取模式:hdfs://...avsc

时间:2016-07-10 10:20:22

标签: hadoop hive hdfs sqoop

我尝试通过以下步骤创建一个配置单元表:

  1. 使用sqoop(已完成)
  2. 将数据加载到hdfs
  3. sqoop还创建了一个avsc文件,我上传到hdfs
  4. 在hive中我想使用以下语句创建表:
  5. 命令:

    CREATE EXTERNAL TABLE kontoauszug
    ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.avro.AvroSerDe' 
    STORED AS 
    INPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat'
    OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat'
    LOCATION 'hdfs:///user/tki/KONTOAUSZUG'
    TBLPROPERTIES ('avro.schema.url'='hdfs://m1.hdp2/user/tki/KONTOAUSZUG.avsc');
    

    我收到以下错误:

    FAILED: Execution Error, return code 1 from
    org.apache.hadoop.hive.ql.exec.DDLTask. 
    java.lang.RuntimeException: MetaException(message:org.apache.hadoop.hive.serde2.SerDeException 
    Encountered AvroSerdeException determining schema. 
    Returning signal schema to indicate problem: Unable to read schema from given path: hdfs://m1.hdp2/user/tki/KONTOAUSZUG.avsc)
    

    是不是意味着找不到KONTOAUSZUG.avsc?我交叉检查它是否可用。

    它的内容是:

    [hadoop@m1 hive]$ cat KONTOAUSZUG.avsc 
    {
      "type" : "record",
      "name" : "KONTOAUSZUG",
      "doc" : "Sqoop import of KONTOAUSZUG",
      "fields" : [ {
        "name" : "FK_PROCESS_ID_INS",
        "type" : [ "null", "string" ],
        "default" : null,
        "columnName" : "FK_PROCESS_ID_INS",
        "sqlType" : "2"
      }, {
        "name" : "FK_SOURCE_ID",
        "type" : [ "null", "string" ],
        "default" : null,
        "columnName" : "FK_SOURCE_ID",
        "sqlType" : "2"
      }, {
        "name" : "SRC_STM_ID",
        "type" : [ "null", "string" ],
        "default" : null,
        "columnName" : "SRC_STM_ID",
        "sqlType" : "2"
      }, {
        "name" : "FK_PROCESS_ID_UPD",
        "type" : [ "null", "string" ],
        "default" : null,
        "columnName" : "FK_PROCESS_ID_UPD",
        "sqlType" : "2"
      }, {
        "name" : "BUCHUNGSDATUM",
        "type" : [ "null", "long" ],
        "default" : null,
        "columnName" : "BUCHUNGSDATUM",
        "sqlType" : "93"
      }, {
        "name" : "BUCHUNGSTEXT",
        "type" : [ "null", "string" ],
        "default" : null,
        "columnName" : "BUCHUNGSTEXT",
        "sqlType" : "12"
      }, {
        "name" : "SOLL",
        "type" : [ "null", "string" ],
        "default" : null,
        "columnName" : "SOLL",
        "sqlType" : "2"
      }, {
        "name" : "HABEN",
        "type" : [ "null", "string" ],
        "default" : null,
        "columnName" : "HABEN",
        "sqlType" : "2"
      }, {
        "name" : "FK_KONTO_ID",
        "type" : [ "null", "string" ],
        "default" : null,
        "columnName" : "FK_KONTO_ID",
        "sqlType" : "2"
      }, {
        "name" : "EINGABE_MANUELL_F",
        "type" : [ "null", "string" ],
        "default" : null,
        "columnName" : "EINGABE_MANUELL_F",
        "sqlType" : "2"
      } ],
      "tableName" : "KONTOAUSZUG"
    }
    

2 个答案:

答案 0 :(得分:1)

CREATE表语句中,您使用了三个斜杠: hdfs:/// 而不是 hdfs://

(...)'hdfs:/// user / tki / KONTOAUSZUG'TBLPROPERTIES(...)

此外,如果您从namenode服务器获取架构,我认为您应该在主机URL之后编写端口。

'avro.schema.url'= 'HDFS://m1.hdp2:端口 /user/tki/KONTOAUSZUG.avsc'

查看this了解详情。还有,this answer about hdfs ports

答案 1 :(得分:1)

这是一个访问错误。请检查avsc目录以获得适当的许可并重试 HDFS://m1.hdp2/user/tki/KONTOAUSZUG.avsc