Sqoop导出hive的parquet格式数据到mysql报错

1.1 在本地mysql建表

create table if not exists ads_nshop_flowpu_stat(
uv bigint NOT NULL COMMENT '独立访客数',
pv bigint NOT NULL COMMENT '页面访客数',
pv_avg double NOT NULL COMMENT '人均页面访问数',
bdp_day varchar(12) NOT NULL COMMENT '日期'
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
1.2 初次导数据 报错

在使用Sqoop抽取Hive Parquet表,脚本如下
sqoop export --connect jdbc:mysql://10.0.15.23:3306/test \
--driver com.mysql.jdbc.Driver \
--table ads_nshop_flowpu_stat \
-m 1 \
--username root --password root \
--input-fields-terminated-by '\t' \
--input-null-string '\\N' \
--input-null-non-string '\\N' \
--export-dir /hive/db/qf_shi.db/ads_nshop_flowpu_stat/*
报错如下
ERROR sqoop.Sqoop: Got exception running Sqoop: org.kitesdk.data.DatasetNotFoundException: Descriptor location does not exist: hdfs://qf/hive/db/qf_shi.db/ads_nshop_flowpu_stat/*/.metadata
org.kitesdk.data.DatasetNotFoundException: Descriptor location does not exist: hdfs://qf/hive/db/qf_shi.db/ads_nshop_flowpu_stat/*/.metadata


解决方法

  使用--hcatalog-database、--hcatalog-table替换--export-dir参数,修改命令如下

解决方法

使用–hcatalog-database、–hcatalog-table替换–export-dir参数,修改命令如下

1.3 第二次导数据 使用--hcatalog-XXXX

sqoop export --connect jdbc:mysql://10.0.15.23:3306/test \
--driver com.mysql.jdbc.Driver \
--table ads_nshop_flowpu_stat \
--username root --password root \
--hcatalog-database qf_shi \
--hcatalog-table ads_nshop_flowpu_stat \
-m 1


各种报错 缺jar包

1.4 各种报错 缺jar包 
java.lang.NoClassDefFoundError: org/apache/hive/hcatalog/mapreduce/HCatOutputFormat
java.lang.ClassNotFoundException: org.apache.hive.hcatalog.mapreduce.HCatOutputFormat

cp hive-hcatalog-core-2.1.1.jar /home/framework/sqoop-1.4.7/lib/

Caused by: java.lang.ClassNotFoundException: org.datanucleus.NucleusContext

 cp datanucleus-core-4.1.6.jar /home/framework/sqoop-1.4.7/lib/

然后还是报错!!!!
然后看到这篇博客
http://blog.yikesz.com/2017/08/30/spark-%E6%8F%90%E7%A4%BAcould-not-initialize-class-org-apache-derby-jdbc-embeddeddriver/


1.5解决办法  直接将hive的配置文件拖到sqoop的conf下!!!

竟然好了 哦了

[root@node245 conf]# cp /home/framework/hive-2.1.1/conf/hive-site.xml ./


1.6重新运行 成功 mysql有数据

总结
1.可能第一步就是将hive下面的hcatalog的hive-hcatalog-core-2.1.1.jar包放到sqoop下
2.然后将hive的配置文件复制到sqoop的conf下(或者将hive的jar包都复制到sqoop下)!!!
因为我的配置文件最后面配置了hive的jar包路径 猜想可能是这样
因为使用–hcatalog-XXX 后报错就是缺各种jar包 所以使用这样的解决办法

附录:服务器的hive配置文件

[root@node245 conf]# cat /home/framework/hive-2.1.1/conf/hive-site.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<configuration>
  <property>
                <name>hive.metastore.warehouse.dir</name>
                <value>hdfs://qf/hive/db</value>
        </property>
        <property>
                <name>hive.metastore.local</name>
                <value>true</value>
        </property>

        <property>
                <name>hive.metastore.schema.verification</name>
                <value>false</value>
        </property>

        <property>
                <name>datanucleus.schema.autoCreateAll</name>
                <value>true</value>
        </property>

        <property>
                <name>javax.jdo.option.ConnectionURL</name>
                <value>jdbc:mysql://node245:3306/hive?createDatabaseIfNotExist=true&amp;characterEncoding=UTF-8&amp;useSSL=false</value>
        </property>
        <property>
                <name>javax.jdo.option.ConnectionDriverName</name>
                <value>com.mysql.jdbc.Driver</value>
        </property>
        <property>
                <name>javax.jdo.option.ConnectionUserName</name>
                <value>root</value>
        </property>
        <property>
                <name>javax.jdo.option.ConnectionPassword</name>
                <value>12345678</value>
        </property>

        <property>
          <name>hive.metastore.authorization.storage.checks</name>
          <value>false</value>
        </property>

        <!-- metastore -->
    <property>
       <name>hive.metastore.uris</name>
       <value>thrift://node245:9083</value>
    </property>

    <!-- thrift -->
    <property>
       <name>hive.server2.thrift.port</name>
       <value>10001</value>
    </property>

    <property>
      <name>hive.server2.thrift.bind.host</name>
      <value>node245</value>
    </property>

    <property>
      <name>hive.server2.webui.host</name>
      <value>node245</value>
    </property>
    <property>
      <name>hive.server2.webui.port</name>
      <value>10002</value>
    </property>
    <!--spark engine -->
    <property>
        <name>hive.execution.engine</name>
        <value>mr</value>
    </property>

    <!-- spark engine
    <property>
        <name>hive.enable.spark.execution.engine</name>
        <value>true</value>
    </property>
    -->

    <!--sparkcontext
    <property>
        <name>spark.master</name>
        <value>yarn</value>
    </property>
    <property>
        <name>spark.serializer</name>
        <value>org.apache.spark.serializer.KryoSerializer</value>
    </property>

    <property>
        <name>spark.executor.instances</name>
        <value>2</value>
    </property>
    <property>
        <name>spark.executor.cores</name>
        <value>2</value>
    </property>
    <property>
        <name>spark.executor.memory</name>
        <value>512m</value>
    </property>
    <property>
        <name>spark.driver.cores</name>
        <value>2</value>
    </property>
    <property>
        <name>spark.driver.memory</name>
        <value>1024m</value>
    </property>
    <property>
        <name>spark.yarn.queue</name>
        <value>default</value>
    </property>
    <property>
        <name>spark.app.name</name>
        <value>hive-app</value>
    </property>

    <property>
        <name>hive.support.concurrency</name>
        <value>true</value>
    </property>
    <property>
        <name>hive.enforce.bucketing</name>
        <value>true</value>
    </property>
    <property>
        <name>hive.exec.dynamic.partition.mode</name>
        <value>nonstrict</value>
    </property>
    <property>
        <name>hive.txn.manager</name>
        <value>org.apache.hadoop.hive.ql.lockmgr.DbTxnManager</value>
    </property>
    <property>
        <name>hive.compactor.initiator.on</name>
        <value>true</value>
    </property>
    <property>
        <name>hive.compactor.worker.threads</name>
        <value>1</value>
    </property>
    <property>
        <name>spark.executor.extraJavaOptions</name>
        <value>-XX:+PrintGCDetails -Dkey=value -Dnumbers="one two three"
        </value>
    </property>
    -->

        <property>
          <name>hive.server2.enable.doAs</name>
          <value>false</value>
        </property>
        <property>
          <name>hive.cli.print.current.db</name>
          <value>true</value>

        </property>
         <property>
          <name>hive.cli.print.header</name>
          <value>true</value>

        </property>

<property>
   <name>hive.exec.mode.local.auto</name>
   <value>true</value>
</property>

<property>
        <name>hive.aux.jars.path</name>
        <value>/home/framework/hive-2.1.1/lib/</value>
</property>
</configuration>

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值