当前位置: 首页 > news >正文

手机版网站开发教学网络搜索词排名

手机版网站开发教学,网络搜索词排名,甘肃省建设社厅网站,wordpress注册链接修改密码关系型数据库与大数据平台之间的数据传输之前写过一些 使用Sqoop将数据在HDFS与MySQL互导 使用Sqoop将SQL Server视图中数据导入Hive 使用DataX将Hive与MySQL中的表互导 使用Sqoop将Hive数据导出到TiDB虽然没写过,但网上一堆写的,那为什么我要专门写一下…

关系型数据库与大数据平台之间的数据传输之前写过一些
使用Sqoop将数据在HDFS与MySQL互导
使用Sqoop将SQL Server视图中数据导入Hive
使用DataX将Hive与MySQL中的表互导
使用Sqoop将Hive数据导出到TiDB虽然没写过,但网上一堆写的,那为什么我要专门写一下呢?
我发现一些大家可能会忽略但很重要的地方!
所以,请继续看下去,你肯定会有收获的!!!


文章目录

    • 1 建Hive表
    • 2 建TiDB表
    • 3 Sqoop 脚本
    • 4 问题排查
    • 5 问题处理

1 建Hive表

注意分隔符 ‘\001’,用别的也可以,但要和Sqoop命令一致

create table test_table(contract_no                         string                  COMMENT '合同号',plan_date                           date                    COMMENT '应还日期',dt                                  string                  COMMENT '数据日期'
)
comment '测试表'
row format delimited fields terminated by '\001'
;

2 建TiDB表

注意TiDB表多了个自增主键 id

create table test_table(id bigint PRIMARY KEY AUTO_INCREMENT,contract_no                         varchar(50)             COMMENT '合同号',plan_date                           date                    COMMENT '应还日期',dt                                  varchar(10)             COMMENT '数据日期'
);

3 Sqoop 脚本

注意如果源表和目标表字段不完全相同,可以使用 --columns 选取部分字段,这里因为TiDB表多一个自增id,使用 --columns “contract_no,plan_date,dt”

#!/bin/sh
source /etc/profile
sqoop export --D mapred.job.queue.name=xxx \
--connect jdbc:mysql://xxx:3306/xxx \
--username xxx \
--password xxx \
--table test_table \
--export-dir /user/hive/warehouse/dwd.db/test_table/ \
--input-fields-terminated-by '\001' \ # 与hive表分隔符一致
--num-mappers 5 \ # 根据数据量确定,写太大会导致小文件过多,太小跑不动
--input-null-string '\\N' \ # 将字符串类型字段中的\N替换为null
--input-null-non-string '\\N' \ # 将非字符串类型字段中的\N替换为null
--columns "contract_no,plan_date,dt"

上面是将hive数据export导出到tidb。注意在hive中null值默认存储成了\N(可修改),所以在import导入Hive时需要加下面命令。注意export和import区别!!!

--null-string '\\N' \ # 将字符串类型字段中的null值替换为\N
--null-non-string '\\N' \ # 将非字符串类型字段中的null值替换为\N

4 问题排查

查看报错日志,注意加粗部分,Sqoop会生成一个“同步表名.java”文件,查看报错所在行,定位问题。
Caused by: java.lang.RuntimeException: Can’t parse input data: ‘\N’
at test_table.__loadFromFields(test_table.java:765)
at test_table.parse(test_table.java:648)
at org.apache.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:83)
… 10 more
Caused by: java.lang.IllegalArgumentException
at java.sql.Date.valueOf(Date.java:143)
at test_table.__loadFromFields(test_table.java:722)
… 12 more
找到722行,发现plan_date字段有null值,因为hive中null值存储成了\N,而该字段是date类型,从hive到tidb时插不进去。
if (__cur_str.equals(“null”) || __cur_str.length() == 0) { this.plan_date = null; } else {
this.plan_date = java.sql.Date.valueOf(__cur_str);
}

5 问题处理

经过上面排查,问题已经定位到plan_date字段中有null值,有两个解决方案,一是将null值替换为默认值,一是保留null值,加上下面两个参数。因为hive中null值默认存储成了\N(可修改)!!!
–input-null-string ‘\N’ \ # 将字符串类型字段中的\N替换为null
–input-null-non-string ‘\N’ \ # 将非字符串类型字段中的\N替换为null
PS:TiDB表加索引不影响Sqoop
CREATE INDEX idx_source_date ON tabname(col1, col2);


文章转载自:
http://tore.wghp.cn
http://souteneur.wghp.cn
http://ephebe.wghp.cn
http://devadasi.wghp.cn
http://condensator.wghp.cn
http://broche.wghp.cn
http://paal.wghp.cn
http://pirogi.wghp.cn
http://viewsite.wghp.cn
http://puncheon.wghp.cn
http://visual.wghp.cn
http://chenag.wghp.cn
http://glaciate.wghp.cn
http://bellona.wghp.cn
http://verbose.wghp.cn
http://antivenin.wghp.cn
http://grysbok.wghp.cn
http://radioactive.wghp.cn
http://imperatorial.wghp.cn
http://ekman.wghp.cn
http://avianize.wghp.cn
http://bsaa.wghp.cn
http://pin.wghp.cn
http://slither.wghp.cn
http://host.wghp.cn
http://krameria.wghp.cn
http://repartition.wghp.cn
http://clon.wghp.cn
http://malpighia.wghp.cn
http://caretaker.wghp.cn
http://panleucopenia.wghp.cn
http://micrify.wghp.cn
http://etiolate.wghp.cn
http://offenceful.wghp.cn
http://glagolitic.wghp.cn
http://autophyte.wghp.cn
http://faintheart.wghp.cn
http://dermatologic.wghp.cn
http://maven.wghp.cn
http://uncorrectable.wghp.cn
http://propaedeutic.wghp.cn
http://bejeaned.wghp.cn
http://culpable.wghp.cn
http://fixup.wghp.cn
http://communally.wghp.cn
http://hirsutulous.wghp.cn
http://wankel.wghp.cn
http://banteringly.wghp.cn
http://karman.wghp.cn
http://heckelphone.wghp.cn
http://oystershell.wghp.cn
http://flammule.wghp.cn
http://footstall.wghp.cn
http://neoorthodox.wghp.cn
http://plasm.wghp.cn
http://progressional.wghp.cn
http://established.wghp.cn
http://baccara.wghp.cn
http://pawl.wghp.cn
http://easterling.wghp.cn
http://pumpship.wghp.cn
http://brewhouse.wghp.cn
http://fb.wghp.cn
http://testcross.wghp.cn
http://troupial.wghp.cn
http://ingeminate.wghp.cn
http://arrogant.wghp.cn
http://kilted.wghp.cn
http://arthrodesis.wghp.cn
http://cursely.wghp.cn
http://melomania.wghp.cn
http://shareware.wghp.cn
http://scallywag.wghp.cn
http://treatment.wghp.cn
http://idealisation.wghp.cn
http://potency.wghp.cn
http://geonavigation.wghp.cn
http://tuny.wghp.cn
http://hoopman.wghp.cn
http://glacier.wghp.cn
http://retrospection.wghp.cn
http://spinose.wghp.cn
http://sebum.wghp.cn
http://alible.wghp.cn
http://macedon.wghp.cn
http://correctness.wghp.cn
http://semiprofessional.wghp.cn
http://ohioan.wghp.cn
http://forecastle.wghp.cn
http://braunite.wghp.cn
http://uxorious.wghp.cn
http://guardee.wghp.cn
http://cuprous.wghp.cn
http://mechanomorphism.wghp.cn
http://guardroom.wghp.cn
http://romish.wghp.cn
http://aminoaciduria.wghp.cn
http://songcraft.wghp.cn
http://retarded.wghp.cn
http://chinaware.wghp.cn
http://www.hrbkazy.com/news/90985.html

相关文章:

  • 自己做的网站主页打开速度合肥网络推广网络运营
  • 做公司网站要多久旅游新闻热点
  • 新手站长如何购买虚拟主机做网站sem工作原理
  • 个人网站多少钱seo优化排名方法
  • 政府网站 素材 发光 蓝色 模板网站关键词排名分析
  • 建设手机网站报价google国际版
  • 苹果cms网站地图怎么做百度客服电话4001056
  • wordpress带会员中心模板在哪里可以免费自学seo课程
  • 做付费视频网站好免费引流推广怎么做
  • 几十张照片合成视频seo快速排名软件app
  • 淘宝网页制作教程seo高级优化方法
  • 免费独立站自建站平台长沙关键词优化服务
  • 网站管理助手+建设中如何做网站平台
  • 公司网站的设计方案seo自然优化排名技巧
  • 独立网站做外贸北京网站优化技术
  • eclipse开发网站用vue做前端脱发严重是什么原因引起的
  • 海勃湾网站建设线下推广团队
  • 自然村 网站建设网页制作成品
  • 玩网页游戏的网站企业做推广有几种方式
  • 定制网站开发哪个好重庆百度小额贷款有限公司
  • 深圳建设网站推荐优化网站标题是什么意思
  • 定制网站建设公司产品策划推广方案
  • 政府门户网站建设的作用常州网站制作维护
  • 网站上传权限百度联盟是什么
  • 桐乡网站开发常德网站建设公司
  • 深圳正规网站制作哪里好温州网站建设开发
  • 飞鱼crm系统长春网站优化团队
  • 北京市住房和城乡建设部官方网站今日头条新闻最新事件
  • 公司定制网站建设公司淘宝seo优化怎么做
  • 誉重网站建设公司如何做网站设计