Phoenix单线程psql方式导入csv数据到hbase

一、准备阶段

1、建表语句

create table student(id integer not null primary key,"cf"."name" varchar,"cf"."age" integer,"cf"."address" varchar);

2、数据准备

说明:这里准备600条测试数据

3、将student01.csv数据放入本地/home/test目录下

二、导入方式一

1、先手动建表

create table student(id integer not null primary key,"cf"."name" varchar,"cf"."age" integer,"cf"."address" varchar);

2、命令

[root@master bin]# ./psql.py -t STUDENT master,slaves1,slaves2:2181 /home/test/student01.csv
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/softWare/phoenix/apache-phoenix-4.12.0-HBase-1.2-bin/phoenix-4.12.0-HBase-1.2-client.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/softWare/hadoop/hadoop-2.7.3/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
20/03/17 10:01:04 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
csv columns from database.
CSV Upsert complete. 600 rows upserted
Time: 0.506 sec(s)

3、效果

三、导入方式二

1、在/home/test/下创建创建表的aa.sql文件

create table stu(id integer not null primary key,"cf"."name" varchar,"cf"."age" integer,"cf"."address" varchar);

2、命令

[root@master bin]# ./psql.py -t STU 192.168.230.21 /home/test/aa.sql /home/test/student01.csv
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/softWare/phoenix/apache-phoenix-4.12.0-HBase-1.2-bin/phoenix-4.12.0-HBase-1.2-client.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/softWare/hadoop/hadoop-2.7.3/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
20/03/17 10:37:15 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
no rows upserted
Time: 2.517 sec(s)

csv columns from database.
CSV Upsert complete. 600 rows upserted
Time: 0.372 sec(s)

注意:当数据的文件名为stu.csv时,不用指定-t STU参数;因为如果在不指定-t参数的情况下,会默认把.csv的文件名当作表明;

[root@master bin]# ./psql.py 192.168.230.21 /home/test/aa.sql /home/test/stu.csv
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/softWare/phoenix/apache-phoenix-4.12.0-HBase-1.2-bin/phoenix-4.12.0-HBase-1.2-client.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/softWare/hadoop/hadoop-2.7.3/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
20/03/17 10:40:54 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
no rows upserted
Time: 2.536 sec(s)

csv columns from database.
CSV Upsert complete. 600 rows upserted
Time: 0.415 sec(s)

3、效果

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

郝少

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值