重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
这篇文章将为大家详细讲解有关如何使用phoenix操作hbase数据),小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
创新互联专注于珲春网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供珲春营销型网站建设,珲春网站制作、珲春网页设计、珲春网站官网定制、小程序定制开发服务,打造珲春网络公司原创品牌,更为您提供珲春网站排名全网营销落地服务。
1.下载安装phoenix(版本与hbase对应)
[root@node1 ~]# wget http://mirrors.shu.edu.cn/apache/phoenix/apache-phoenix-5.0.0-HBase-2.0/bin/apache-phoenix-5.0.0-HBase-2.0-bin.tar.gz
[root@node1 ~]# tar xvf apache-phoenix-5.0.0-HBase-2.0-bin.tar.gz -C /opt/
[root@node1 opt]# mv apache-phoenix-5.0.0-HBase-2.0-bin/ phoenix-5.0.0
2.考贝jar包
[root@node1 opt]# cd phoenix-5.0.0/
[root@node1 phoenix-5.0.0]# cp -a phoenix-5.0.0-HBase-2.0-server.jar phoenix-core-5.0.0-HBase-2.0.jar /opt/hbase-2.0.4/lib/
[root@node1 phoenix-5.0.0]# scp phoenix-5.0.0-HBase-2.0-server.jar phoenix-core-5.0.0-HBase-2.0.jar node2:/opt/hbase-2.0.4/lib/ --考贝到其它节点
[root@node1 phoenix-5.0.0]# cd /opt/hbase-2.0.4/conf/
[root@node1 conf]# cp -a hbase-site.xml /opt/phoenix-5.0.0/bin/
[root@node1 conf]# cd /opt/hadoop-2.8.5/etc/hadoop/
[root@node1 hadoop]# cp hdfs-site.xml core-site.xml /opt/phoenix-5.0.0/bin/
3.重启hbase服务
[root@node1 conf]# stop-hbase.sh
[root@node1 conf]# start-hbase.sh
4.登陆hbase和phoenix
[root@node1 phoenix-5.0.0]# hbase shell
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell
Version 2.0.4, r205e39c5704bf38568b34926dde9f1ee76e6b5d0, Fri Dec 28 22:13:42 PST 2018
Took 0.0066 seconds
hbase(main):001:0> list --在hbase中查看表
TABLE
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数据)”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。