Hive安装

1.Mysql配置

service mysqld start
mysql -uroot
create user 'hive' identified by 'hive';
create database tpin;
grant all privileges on *.* to  'hive'@'localhost' identified by 'hive';
grant all privileges on tpin.* to  'hive'@'%' identified by 'hive';
grant all privileges on tpin.* to  'hive'@'cloud-03' identified by 'hive';
flush privileges;
mysql -uhive -p

2.Hive配置:修改hive-site.xml文件

:%s#${system:java.io.tmpdir}/${system:user.name}#/opt/hive/tmp/hive#g
:%s#${system:java.io.tmpdir}#/opt/hive/tmp/hive#g

将javax.jdo.option.ConnectionURL设置为

jdbc:mysql://cloud-03:3306/tpin

将javax.jdo.option.ConnectionPassword设置为

hive

将javax.jdo.option.ConnectionUserName设置为

hive

将javax.jdo.option.ConnectionDriverName设置为

com.mysql.jdbc.Driver

3.Hive建表

CREATE TABLE nsr_tzf(zjhm string,nsrdzdah string,tzbl double,tzje double,tzfxz_id int) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'WITH SERDEPROPERTIES ("separatorChar" = ",", "quoteChar"     = "\\"", "escapeChar"    = "\\\\") STORED AS TEXTFILE;

CREATE TABLE tpin_vertex_wwd(
id BIGINT,
type INT,
sbh STRING,
ishuman Boolean,
community_id BIGINT
);

4.载入csv文件

LOAD DATA LOCAL INPATH '/root/tpinDataCsv/nsr_tzf.csv' INTO TABLE nsr_tzf;

5.导出文本文件

INSERT OVERWRITE LOCAL DIRECTORY 'tpinDataCsv/tpin_vertex_wwd' SELECT * FROM tpin_vertex_wwd;

6.导入文本文件

LOAD DATA LOCAL INPATH 'tpinDataHive/tpin_vertex_wwd/00000*_0' INTO TABLE tpin_vertex_wwd;

7、sqoop导出到Oracle

sqoop export --connect jdbc:oracle:thin:@202.117.16.188:1521:tpin --username myTpin --password myTpin --table TPIN_VERTEX_WWD --export-dir /user/hive/warehouse/tpin_vertex_wwd --input-fields-terminated-by '\\001' --input-null-string '\\\\N' --input-null-non-string '\\\\N'

8.从sqoop Oracle导入hive表(hive表不必事先建)

sqoop import --hive-import --connect jdbc:oracle:thin:@202.117.16.188:1521:tpin --username myTpin --password myTpin --verbose --hive-database default --m 1 --table TPIN_2015_FP

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值