如何使用 datax 拉取 hive 中的数据到 oracle 中?

您所在的位置:网站首页 oracle脏读sql 如何使用 datax 拉取 hive 中的数据到 oracle 中?

如何使用 datax 拉取 hive 中的数据到 oracle 中?

2023-09-03 04:31| 来源: 网络整理| 查看: 265

需求

将 hive 中的数据拉取到 oracle 中,使用的工具是 datax

步骤

1.先在 hive 中找一张需要拉取的表,然后在 oracle 中创建对应的空表,等待拉取数据 2.在 datax 的 bin 目录下 编写 json 脚本 vi hiveoracle.json

{ "job": { "setting": { "speed": { "byte": 1048576 }, "errorLimit": { "record": 100, "percentage": 0.02 } }, "content": [ { "reader": { "name": "hdfsreader", "parameter": { "defaultFS": "hdfs://192.168.1.54:9000/", "path":"/home/hadoop/hive/warehouse/testdb.db/tea/*", "column":[ {"index":0,"type":"long"}, {"index":1,"type":"string"} ], "fileType": "text", "encoding": "UTF-8", "fieldDelimiter": "\u0001" } }, "writer": { "name": "oraclewriter", "parameter": { "username": "TEXT", "password": "TEXT", "column": [ "id", "name" ], "connection": [ { "jdbcUrl": "jdbc:oracle:thin:@192.168.1.5:1521:orcl", "table": ["tea"] } ] } } } ] } }

3.然后在 datax 的 bin 目录下 运行脚本 python /opt/install/datax/bin/datax.py /opt/install/datax/bin/hiveoracle.json 4.运行成功后,在 oracle 中查看相关表中的数据即可

所遇之坑 在这里插入图片描述 在这里插入图片描述

2021-07-08 16:21:31.376 [0-0-0-reader] ERROR StdoutPluginCollector - 脏数据: {"message":"No enum constant com.alibaba.datax.plugin.unstructuredstorage.reader.UnstructuredStorageReaderUtil.Ty pe.INT","record":[],"type":"reader"} 2021-07-08 16:21:31.380 [0-0-0-reader] ERROR StdoutPluginCollector - 脏数据: {"message":"No enum constant com.alibaba.datax.plugin.unstructuredstorage.reader.UnstructuredStorageReaderUtil.Ty pe.INT","record":[],"type":"reader"} 2021-07-08 16:21:41.182 [job-0] INFO JobContainer - 任务启动时刻 : 2021-07-08 16:21:28 任务结束时刻 : 2021-07-08 16:21:41 任务总计耗时 : 12s 任务平均流量 : 0B/s 记录写入速度 : 0rec/s 读出记录总数 : 2 读写失败总数 : 2

错误原因在于 我们在读取 hive 中的表时候,需要将 int 类型写成 long 类型 在这里插入图片描述



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3