这篇文章将为大家详细讲解有关如何使用凤凰操作hbase数据),小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
1.下载安装凤凰城(版本与hbase对应)
[root @ node 1 ~]# wget http://镜像。舒。edu。cn/Apache/phoenix/Apache-phoenix-5。0 .0-HbASe-2.0/bin/Apache-phoenix-5。0 .0-HBase-2.0-bin。焦油。地面零点
[root @ node 1 ~]# tar xvf Apache-phoenix-5 . 0 . 0-HbASe-2.0-bin . tar . gz-C/opt/
[root @ node 1 opt]# mv Apache-phoenix-5。0 .0-HBase-2.0-bin/phoenix-5。0 .0
2.考贝冲突包
[root @ node 1 opt]# CD phoenix-5。0 .0/
[根@节点1 phoenix-5。0 .0]# CP-一只凤凰-5。0 .0-HbBase-2.0-服务器。罐子凤凰-核心-5。0 .0-HBase-2。0 .jar/opt/HBase-2。0 .4/lib/
[根@节点1 phoenix-5。0 .0]# scp凤凰-5。0 .0-HbBase-2.0-服务器。罐子凤凰-核心-5。0 .0-HBase-2。0 .jar节点2:/opt/HBase-2。0 .4/lib/-考贝到其它节点
[根@节点1 phoenix-5。0 .0]# CD/opt/hbase-2。0 .4/conf/
[root @ node 1 conf]# CP-a hbase-site。XML/opt/phoenix-5。0 .0/bin/
[root @ node 1 conf]# CD/opt/Hadoop-2。8 .5/etc/Hadoop/
[根@节点1 Hadoop]# CP HDFS-站点。XML核心网站。XML/opt/phoenix-5。0 .0/bin/
3.重启hbase服务
[root@node1 conf]# stop-hbase.sh
[root @ node 1 conf]# start-hbase。嘘
4.登陆hbase和凤凰
[根@节点1 phoenix-5。0 .0]# hbase外壳
糖化血红蛋白外壳
使用"帮助"获取支持的命令列表。
使用"退出"退出此交互式外壳。
作为参考,请访问: http://hbase.apache.org/2.0/book.html#shell
版本2.0.4,r 205 e 39 c 5704 BF 38568 b 34926 DD e9 f1 e 76 e6b 5d 0,Fri 2018年12月28日22:13:42 PST
耗时0.0066秒
hbase(主):001:0列表-在hbase中查看表
表铌
sp;
t1
1 row(s)
Took 1.1812 seconds
=> ["t1"]
hbase(main):002:0> exit
[root@node1 bin]# ./sqlline.py node1,node2,node3:2181
Setting property: [incremental, false]
Setting property: [isolation, TRANSACTION_READ_COMMITTED]
issuing: !connect jdbc:phoenix:node1,node2,node3:2181 none none org.apache.phoenix.jdbc.PhoenixDriver
Connecting to jdbc:phoenix:node1,node2,node3:2181
19/03/17 15:22:31 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Connected to: Phoenix (version 5.0)
Driver: PhoenixEmbeddedDriver (version 5.0)
Autocommit status: true
Transaction isolation: TRANSACTION_READ_COMMITTED
Building list of tables and columns for tab-completion (set fastconnect to true to skip)...
133/133 (100%) Done
Done
sqlline version 1.2.0
0: jdbc:phoenix:node1,node2,node3:2181> !tables --显示所有表
+------------+--------------+-------------+---------------+----------+------------+----------------------------+-----------------+--------------+
| TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_NAME | SELF_REFERENCING_COL_NAME | REF_GENERATION | INDEX_STATE |
+------------+--------------+-------------+---------------+----------+------------+----------------------------+-----------------+--------------+
| | SYSTEM | CATALOG | SYSTEM TABLE | | | | | |
| | SYSTEM | FUNCTION | SYSTEM TABLE | | | | | |
| | SYSTEM | LOG | SYSTEM TABLE | | | | | |
| | SYSTEM | SEQUENCE | SYSTEM TABLE | | | | | |
| | SYSTEM | STATS | SYSTEM TABLE | | | | | |
+------------+--------------+-------------+---------------+----------+------------+----------------------------+-----------------+--------------+
0: jdbc:phoenix:node1,node2,node3:2181>
5.导入表结构和数据
[root@node1 bin]# ./psql.py node1:2181 ../examples/STOCK_SYMBOL.sql ../examples/STOCK_SYMBOL.csv
19/03/17 15:33:27 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
no rows upserted
Time: 2.85 sec(s)
1 row upserted
Time: 0.35 sec(s)
SYMBOL COMPANY
---------------------------------------- ----------------------------------------
CRM SalesForce.com
Time: 0.074 sec(s)
csv columns from database.
CSV Upsert complete. 9 rows upserted
Time: 0.065 sec(s)
[root@node1 bin]# ./sqlline.py node1,node2,node3:2181
Setting property: [incremental, false]
Setting property: [isolation, TRANSACTION_READ_COMMITTED]
issuing: !connect jdbc:phoenix:node1,node2,node3:2181 none none org.apache.phoenix.jdbc.PhoenixDriver
Connecting to jdbc:phoenix:node1,node2,node3:2181
19/03/17 15:22:31 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Connected to: Phoenix (version 5.0)
Driver: PhoenixEmbeddedDriver (version 5.0)
Autocommit status: true
Transaction isolation: TRANSACTION_READ_COMMITTED
Building list of tables and columns for tab-completion (set fastconnect to true to skip)...
133/133 (100%) Done
Done
sqlline version 1.2.0
0: jdbc:phoenix:node1,node2,node3:2181> !tables
+------------+--------------+---------------+---------------+----------+------------+----------------------------+-----------------+------------+
| TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_NAME | SELF_REFERENCING_COL_NAME | REF_GENERATION | INDEX_STAT |
+------------+--------------+---------------+---------------+----------+------------+----------------------------+-----------------+------------+
| | SYSTEM | CATALOG | SYSTEM TABLE | | | | | |
| | SYSTEM | FUNCTION | SYSTEM TABLE | | | | | |
| | SYSTEM | LOG | SYSTEM TABLE | | | | | |
| | SYSTEM | SEQUENCE | SYSTEM TABLE | | | | | |
| | SYSTEM | STATS | SYSTEM TABLE | | | | | |
| | | STOCK_SYMBOL | TABLE | | | | | |
+------------+--------------+---------------+---------------+----------+------------+----------------------------+-----------------+------------+
0: jdbc:phoenix:node1,node2,node3:2181> select * from STOCK_SYMBOL;
+---------+-----------------------+
| SYMBOL | COMPANY |
+---------+-----------------------+
| AAPL | APPLE Inc. |
| CRM | SALESFORCE |
| GOOG | Google |
| HOG | Harlet-Davidson Inc. |
| HPQ | Hewlett Packard |
| INTC | Intel |
| MSFT | Microsoft |
| WAG | Walgreens |
| WMT | Walmart |
+---------+-----------------------+
9 rows selected (0.112 seconds)
0: jdbc:phoenix:node1,node2,node3:2181>
关于“如何使用phoenix操作hbase数据)”这篇文章就分享到这里了,希望
内容来源网络,如有侵权,联系删除,本文地址:https://www.230890.com/zhan/138989.html