#!/bin/sh
source /etc/profile
source ~/.bash_profile
sqoop import --connect jdbc:mysql://ip:3306/数据库名称
--username 用户名称 --password 密码 --table '表名'
--columns 'columns1,colums2,colums3'
--target-dir /FINBB/ODS/表名
--delete-target-dir
--fields-terminated-by ' 01'
--lines-terminated-by 'n'
--null-string '\N'
--null-non-string '\N'
--hive-drop-import-delims
--num-mappers 1
[ $? -eq 0 ] || exit
impala-shell -q 'refresh 库名.表名;'
参数含义注释:
1)--target-dir:导入HDFS的目标路径
2)--null-string:字符串类型如果为null,替换成指定字符串
3) --null-non-string:非字符串类型如果为null,替换成指定字符串
4) --delete-target-dir:如果指定目录存在,则先删除掉
5) --columns:从表中导出指定的一组列的数据
6)--hive-drop-import-delims:导入到hive时删除 n, r, and 1
2.从impala倒数到oracle#!/bin/bash
source /etc/profile
source ~/.bash_profile
sqoop eval -connect jdbc:oracle:thin:@//ip:1521/数据库名称
-username 用户名 -password 密码 --e "TRUNCATE TABLE 表名"
[[ $? -eq 0 ]] || exit
sqoop export --connect jdbc:oracle:thin:@//ip:1521/数据库名称
--username 用户名 --password 密码
--table 表名
--columns "colum1,colum2,colum3"
--fields-terminated-by ' 01'
--hcatalog-database 数据库名称 --hcatalog-table 表名 --num-mappers 8
参数含义注释:
1)sqoop eval:可使用SQL语句对关系数据库进行操作。后面接 –e或者 –query
查询数据实例
2) --table:要导入到的关系数据库表
3) --columns:导出的字段
4) --hcatalog-database:指定database
5) --hcatalog-table:指定hive表名



