sqoop 1.4

sqoop import --connect jdbc:oracle:thin:@192.168.31.222:1521:orcl --username shebaouser --password shebaouser --table ORG_PAY_INFO --num-mappers 2  --delete-target-dir --hive-import --hive-database bdd --hive-table ORG_PAY_INFO --hive-overwrite --fields-terminated-by '\t'
1.995 s BY01
sqoop import --connect jdbc:oracle:thin:@192.168.31.222:1521:orcl --username shebaouser --password shebaouser --table IY02 --num-mappers 10 --direct --target-dir /user/hive/warehouse/shebaouser --delete-target-dir --hive-import --hive-database bdd --hive-table IY02 --hive-overwrite --fields-terminated-by '\t'
2S iy02
sqoop import --connect jdbc:oracle:thin:@192.168.31.222:1521:orcl --username shebaouser --password shebaouser --table IY11 --num-mappers 10 --direct --target-dir /user/hive/warehouse/shebaouser --delete-target-dir --hive-import --hive-database bdd --hive-table IY11 --hive-overwrite --fields-terminated-by '\t'

--------------------------
a.sqoop create-hive-table --connect jdbc:oracle:thin:@192.168.31.222:1521:orcl --username shebaouser --password shebaouser --hive-table PEOPLE_BASE_INFO --table PEOPLE_BASE_INFO --fields-terminated-by '\t'

b.hive修改列类型,double格式在kettl中没法支持,需要修改为string
alter table org_base_info change id旧列名 id新列名 string comment 'id注释' first;

c.sqoop导入数据
sqoop import --connect jdbc:oracle:thin:@192.168.31.222:1521:orcl --username shebaouser --password shebaouser --table PEOPLE_PAY_INFO --num-mappers 2  --delete-target-dir --hive-import --hive-database default --hive-table PEOPLE_PAY_INFO --hive-overwrite --fields-terminated-by '\t'

如果没有主键,则需要指定--m 1,一个mapper

空值处理--null-string '\\N' --null-non-string '\\N'

d.hive 从hdfs中导入表数据

load data inpath '/user/hive/warehouse/shebaouser/org_base_info.txt' into table org_base_info;


e.如果hive执行where语句半天都没有结果,一直处于hang的状态时,检查各个组件的配置,如果是CDH,检查配置问题,纠正配置问题后就可以正常执行了。

------------------------------------------

spoon转换设置不传对应的头,分隔符使用\t

创建一个hive表,

create table 。。。。 ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';

------------------------------------------

如果出现用户权限的问题$ sudo -u hive sqoop import ...

你可能感兴趣的:(更新)