参数说明:
--append 将数据追加到HDFS上一个已存在的数据集上
--as-avrodatafile将数据导入到Avro数据文件
--as-sequencefile将数据导入到SequenceFile
--as-textfile将数据导入到普通文本文件(默认)
--boundary-query <statement>边界查询,用于创建分片(InputSplit)
--columns <col,col,col…>从表中导出指定的一组列的数据
--delete-target-dir如果指定目录存在,则先删除掉
--direct使用直接导入模式(优化导入速度)
--direct-split-size <n>分割输入stream的字节大小(在直接导入模式下)
--fetch-size <n>从数据库中批量读取记录数
--inline-lob-limit <n> 设置内联的LOB对象的大小
-m,--num-mappers <n>使用n个map任务并行导入数据
-e,--query <statement>导入的查询语句
--split-by <column-name>指定按照哪个列去分割数据
--table <table-name>导入的源表表名
--target-dir <dir> 导入HDFS的目标路径
--warehouse-dir <dir>HDFS存放表的根路径
--where <where clause>指定导出时所使用的查询条件
-z,--compress启用压缩
--compression-codec <c>指定Hadoop的codec方式(默认gzip)
--null-string <null-string>果指定列为字符串类型,使用指定字符串替换值为null的该类列的值
--null-non-string <null-string>如果指定列为非字符串类型,使用指定字符串替换值为null的该类列的值
--hive-overwrite 重写插入
--as-parquetfile 指定parquet格式
--hive-home 重写$HIVE_HOME
--create-hive-table 建表,如果表已经存在,该操作会报错!
--hive-table [table] 设置到hive当中的表名
--hive-drop-import-delims 导入到hive时删除 \n, \r, and \01
--hive-delims-replacement 导入到hive时用自定义的字符替换掉 \n, \r, and \01
--hive-partition-key hive分区的key
--hive-partition-value hive分区的值
--map-column-hive 类型匹配,sql类型对应到hive类型
从mysql拉取导入Hive:
方式一:
sqoop import --connect jdbc:mysql://172.***.***34/linj --username ***--password ***--table T_GW_*** --hive-import --hive-database os --hive-table os_shanghai_***1 --hive-overwrite --hive-drop-import-delims -z --compression-codec org.apache.hadoop.io.compress.SnappyCodec --delete-target-dir -m 5 --as-parquetfile
sqoop import --connect jdbc:mysql://***.***.***.***/databasename \
--username *** \
--password *** \
--table t_table1 \
--hive-import \
--hive-database hivedbname \
--hive-table hive_t_table1 \
--hive-overwrite \
--hive-drop-import-delims \
--delete-target-dir \
-m 1 \
--as-parquetfile
方式二:使用sql语句先将数据导入HDF