您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關如何使用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數據)”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。