华为平台loader从关系型数据库到hive

使用华为平台loader将数据从mysql或者oracle中导入至hive中,中间是有过渡的,并不是直接将数据导入至hive中,loader导入完成后,数据会在hdfs上,在导出的文件夹下会有n个文件,假设文件夹为/app/test/,那么还需要执行以下语句才能将数据导入至hive库中:

load data inpath '/app/test' into table table_name


注意在loader平台转换步骤中的hive输出中选择好分隔符,字段值中最好不含有此字符。


hive建表语句:

create table table_name

(

column_name string comment '备注'

)

row format serde

'org.apache.hadoop.hive.serde2.OpenCSVSerde'

with 

SERDEPROPERTIES

("separatorChar"="~")

STORED AS TEXTFILE

;


1、使用sqoop将数据从oracle导入到hive中命令:

    sqoop import --connect 'jdbc:oracle:thin://@192.168.132.123:1521/test' --username bobo --password boge --table table_name -hive-import --hive-database db_name --hive-table table_name -m 1


2、使用sqoop将数据从mysql导入到hive中命令:

    sqoop import --connect 'jdbc:mysql://192.168.12.123:3306/db' --username bobo --password boge --table table_name -hive-import --hive-database db_name --hive-table table_name -m 1


3、使用sqoop从hive导入到mysql:

    sqoop export --connect jdbc:mysql://192.168.174.123:3306/db --username bobo --password boge --table table_name --hcatalog-database db_name --hcatalog-table table_name


4、从mysql导出数据到csv文件:

    select * from table_name into outfile '/app/test.csv' fields terminated by ',' lines terminated by '\r\n';


5、将csv文件导入hive:

    load data local inpath '/app/test.csv' into table table_name;

    




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值