hbase與phoenix整合(使用phoenix操作hbase資料)
phoenix與hbase版本對應:
phoenix下載地址:
phoenix安裝文件:
1.下載安裝phoenix(版本與hbase對應)
[root@node1 ~]# wget
[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:
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>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25854343/viewspace-2638600/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- HBase學習的第五天--HBase進階結尾和phoenix開頭
- 職位畫像中phoenix連結HBase異常之版本不匹配
- 大資料技術 - Phoenix大資料
- Hbase(二)Hbase常用操作
- 使用phoenix踩的坑與設計思考
- 66666,phoenix的簡介和安裝,Hbase的進階,看了這篇,我竟然都懂了
- phoenix安裝
- HBase 基本操作
- Phoenix 二級索引索引
- DBeaver連線Phoenix
- Phoenix二級索引索引
- HBase2實戰:HBase Flink和Kafka整合Kafka
- '林子雨大資料' 實驗3 HBase操作與介面程式設計大資料程式設計
- spark與hbaseSpark
- Hbase shell的基本操作
- php使用hbasePHP
- 《HBase 不睡覺》第三章 – HBase 基本操作
- 《HBase 不睡覺》第三章 - HBase 基本操作
- 大資料——HBase基礎大資料
- 大資料技術 - Hbase大資料
- phoenix API服務釋出API
- CF1515F Phoenix and Earthquake
- hbase之hbase shell
- CDH+HBase Indexer+Solr為HBase資料建立二級索引IndexSolr索引
- 一條資料HBase之旅,簡明HBase入門教程開篇
- Hbase學習二:Hbase資料特點和架構特點架構
- Hadoop(四)C#操作HbaseHadoopC#
- spark讀取hbase的資料Spark
- HBase資料的讀寫流程
- Hbase資料庫安裝部署資料庫
- HBase 資料儲存結構
- hbase - [04] java訪問hbaseJava
- HBase 教程:什麼是 HBase?
- HBase
- 淺談HBase的資料分佈
- 《分散式資料庫HBase案例教程》分散式資料庫
- HBase資料庫效能調優OW資料庫
- [題解]CF1515I Phoenix and Diamonds