分享

使用sqoop文件 --options-file 导入hive数据

bob007 发表于 2015-5-9 22:34:15 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 0 15104
本帖最后由 bob007 于 2015-5-9 22:35 编辑

如何使用sqoop通过文件导入hive,下面给大家分享下:

使用sqoop --options-file直接导入hive数据,把操作命令语句写在文件中,便于管理及管理

1、创建hive数据库及表
create database DB_TEST;
CREATE TABLE
    UserRegLoginLog
    (
        ID BIGINT,
        fld_date TIMESTAMP,
        fld_ip string,
        fld_server_ip string,
        fld_UA string,
        UserId BIGINT ,
        UserName string,
        PassWord string,
        ActionType INT ,
        ActionTime TIMESTAMP ,
        ActionIP string,
        FromHost string,
        UrlRefer string,
        RemotePort string
    )
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' ;




2、编写sqoop操作文件,注意做分隔符需要与hive的一致
vi UserRegLoginLog_hive.opt  
[mw_shl_code=java,true]import
--connect
jdbc:jtds:sqlserver://localhost:1433;;DatabaseName=DB_TEST
--username
sa
--password
123456
--table
UserRegLoginLog
--where
1=1
--columns
" ID ,fld_date ,fld_ip ,fld_server_ip ,fld_UA ,UserId  ,UserName ,PassWord ,ActionType  ,ActionTime  ,ActionIP ,FromHost ,UrlRefer,RemotePort "
--fields-terminated-by
'\t'
--hive-import
--hive-overwrite
--hive-drop-import-delims
--hive-table
DB_TELECAST.UserRegLoginLog[/mw_shl_code]
使用sqoop --options-file 执行操作文本

sqoop --options-file ./UserRegLoginLog_hive.opt

3、指定hive的数据库,格式为: 数据库.表名
DB_TEST.UserRegLoginLog












没找到任何评论,期待你打破沉寂

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条