使用Sqoop从Postgresql中导入数据到HBase中

栏目: 数据库 · 发布时间: 7年前

内容简介:版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/kongxx/article/details/86531083

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/kongxx/article/details/86531083

接前面的文章 “使用Sqoop从Postgresql中导入数据到Hive中”,今天看看怎样从 Postgresql 入数据到 HBase 中。

这里有一点需要注意的是 Sqoop 1.4.7 目前不支持 HBase 2.x,所以准备了一个 hbase 1.4.9 的环境来做测试。

进入 sqoop 的 conf 目录,修改 sqoop-env.sh 文件,如下:

#Set path to where bin/hadoop is available
export HADOOP_COMMON_HOME=/apps/hadoop-2.7.7

#Set path to where hadoop-*-core.jar is available
export HADOOP_MAPRED_HOME=/apps/hadoop-2.7.7

#set the path to where bin/hbase is available
export HBASE_HOME=/apps/hbase-1.4.9

#Set the path to where bin/hive is available
export HIVE_HOME=/apps/apache-hive-2.3.2-bin

#Set the path for where zookeper config dir is
export ZOOCFGDIR=/apps/zookeeper-3.4.10/conf

从 postgresql 向 HBase 导入数据

使用项目的命令来向 HBase 导入数据

$ bin/sqoop import --connect jdbc:postgresql://localhost:5432/test --username test --password test --table users --hbase-table user --column-family base --hbase-row-key id --hbase-create-table --m 1

导入数据后,登录到 hbase 中查看一下结果

$ bin/hbase shell

hbase(main):001:0> list
TABLE
user
1 row(s) in 0.0330 seconds

=> Hbase::Table - user
hbase(main):002:0> scan 'user'
ROW                              COLUMN+CELL
 1                               column=base:name, timestamp=1547609241178, value=user1
 1                               column=base:password, timestamp=1547609241178, value=password1
 2                               column=base:name, timestamp=1547609241178, value=user2
 2                               column=base:password, timestamp=1547609241178, value=password2
 3                               column=base:name, timestamp=1547609241178, value=user3
 3                               column=base:password, timestamp=1547609241178, value=password3
3 row(s) in 0.1540 seconds

其它导入参数可以参考

http://sqoop.apache.org/docs/1.4.7/SqoopUserGuide.html


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Wireshark网络分析实战

Wireshark网络分析实战

[以色列 Yoram Orzach / 古宏霞、孙余强 / 人民邮电出版社 / 2015-1 / 79.00元

本书采用步骤式为读者讲解了一些使用Wireshark来解决网络实际问题的技巧。 本书共分为14章,其内容涵盖了Wireshark的基础知识,抓包过滤器的用法,显示过滤器的用法,基本/高级信息统计工具的用法,Expert Info工具的用法,Wiresahrk在Ethernet、LAN及无线LAN中的用法,ARP和IP故障分析,TCP/UDP故障分析,HTTP和DNS故障分析,企业网应用程序行......一起来看看 《Wireshark网络分析实战》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

MD5 加密
MD5 加密

MD5 加密工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器