阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Phoenix 3.1 + HBase 0.94.21 的安装和使用

104次阅读
没有评论

共计 5864 个字符,预计需要花费 15 分钟才能阅读完成。

Apache Phoenix 是 HBase 的 SQL 驱动。Phoenix 使得 HBase 支持通过 JDBC 的方式进行访问,并将你的 SQL 查询转成 HBase 的扫描和相应的动作。

兼容性:

  • Phoenix 2.x – HBase 0.94.x
  • Phoenix 3.x – HBase 0.94.x
  • Phoenix 4.x – HBase 0.98.1+

1:hbase 0.94.21 的安装

参考 http://www.linuxidc.com/Linux/2014-09/106534.htm

2:下载 phoenix 3.1

[linuxidc@linuxidc02 ~]# wget http://mirrors.hust.edu.cn/apache/phoenix/phoenix-3.1.0/bin/phoenix-3.1.0-bin.tar.gz
–2014-09-12 22:03:44–  http://mirrors.hust.edu.cn/apache/phoenix/phoenix-3.1.0/bin/phoenix-3.1.0-bin.tar.gz
正在解析主机 mirrors.hust.edu.cn… 202.114.18.160
正在连接 mirrors.hust.edu.cn|202.114.18.160|:80… 已连接。
已发出 HTTP 请求,正在等待回应 … 200 OK
长度:55480477 (53M) [application/octet-stream]
正在保存至:“phoenix-3.1.0-bin.tar.gz”
2014-09-12 22:16:29 (70.8 KB/s) – 已保存“phoenix-3.1.0-bin.tar.gz”[55480477/55480477])

3:解压

[linuxidc@linuxidc02 ~]$ tar zxf phoenix-3.1.0-bin.tar.gz
[linuxidc@linuxidc02 ~]$ cd phoenix-3.1.0-bin
[linuxidc@linuxidc02 phoenix-3.1.0-bin]$ ls
CHANGES  common  examples  Hadoop1  hadoop2  LICENSE  NOTICE  README

4:配置

参考:http://phoenix.apache.org/download.html

我这里使用的是 Phoenix 3.x

To install a pre-built phoenix, use these directions:

  • Download and expand the latest phoenix-[version]-bin.tar. Use either hadoop1 and hadoop2 artifacts which match your HBase installation.
  • 下载,根据安装的 HBase 选择 hadoop1 或 hadoop2
  • Add the phoenix-[version]-server.jar to the classpath of every HBase region server and remove any previous version. An easy way to do this is to copy it into the HBase lib directory (use phoenix-core-[version].jar for Phoenix 3.x)
  • 把 phoenix-core-3.1.0.jar 复制到所有 HBase region server 的 lib 目录
  • Restart all region servers.
  • 重启所有的 Hbase region servers.
  • Add the phoenix-[version]-client.jar to the classpath of any Phoenix client.
  • Phoenix client 服务器的 CLASSPATH 加上 phoenix-3.1.0-client-hadoop1.jar

[linuxidc@linuxidc02 phoenix-3.1.0-bin]$ cd common
[linuxidc@linuxidc02 common]$ ls
phoenix-3.1.0-client-minimal.jar  phoenix-3.1.0-client-without-hbase.jar  phoenix-core-3.1.0.jar
[linuxidc@linuxidc02 common]$ cp ./phoenix-core-3.1.0.jar /home/linuxidc/hbase-0.94.21/lib
[linuxidc@linuxidc02 common]$ scp ./phoenix-core-3.1.0.jar linuxidc@linuxidc01:/home/linuxidc/hbase-0.94.21/lib
phoenix-core-3.1.0.jar            100% 2178KB  2.1MB/s  00:00   
[linuxidc@linuxidc02 common]$ cd ..

在配置文件 /home/linuxidc/.bash_profile 中

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:/home/linuxidc/phoenix-3.1.0-bin/hadoop1/phoenix-3.1.0-client-hadoop1.jar

然后重启 HBase

[linuxidc@linuxidc01 hbase-0.94.21]$ bin/stop-hbase.sh
stopping hbase…………….
linuxidc01: stopping zookeeper.
linuxidc02: stopping zookeeper.
[linuxidc@linuxidc01 hbase-0.94.21]$ bin/start-hbase.sh
linuxidc01: starting zookeeper, logging to /home/linuxidc/hbase-0.94.21/bin/../logs/hbase-linuxidc-zookeeper-linuxidc01.out
linuxidc02: starting zookeeper, logging to /home/linuxidc/hbase-0.94.21/bin/../logs/hbase-linuxidc-zookeeper-linuxidc02.out
starting master, logging to /home/linuxidc/hbase-0.94.21/logs/hbase-linuxidc-master-linuxidc01.out
linuxidc01: starting regionserver, logging to /home/linuxidc/hbase-0.94.21/bin/../logs/hbase-linuxidc-regionserver-linuxidc01.out
linuxidc02: starting regionserver, logging to /home/linuxidc/hbase-0.94.21/bin/../logs/hbase-linuxidc-regionserver-linuxidc02.out

5:启动和简单操作

[linuxidc@linuxidc02 bin]$ sqlline.py localhost
Setting property: [isolation, TRANSACTION_READ_COMMITTED]
issuing: !connect jdbc:phoenix:localhost none none org.apache.phoenix.jdbc.PhoenixDriver
Connecting to jdbc:phoenix:localhost
Connected to: Phoenix (version 3.1)
Driver: org.apache.phoenix.jdbc.PhoenixDriver (version 3.1)
Autocommit status: true
Transaction isolation: TRANSACTION_READ_COMMITTED
Building list of tables and columns for tab-completion (set fastconnect to true to skip)…
59/59 (100%) Done
Done
sqlline version 1.1.2
0: jdbc:phoenix:localhost> select * from b_month
. . . . . . . . . . . . .> ;
Error: ERROR 1012 (42M03): Table undefined. tableName=B_MONTH (state=42M03,code=1012)
0: jdbc:phoenix:localhost> create table test (a integer primary key, b integer) ;
No rows affected (1.534 seconds)
0: jdbc:phoenix:localhost> UPSERT INTO TEST VALUES (1, 1);
1 row affected (0.018 seconds)
0: jdbc:phoenix:localhost> UPSERT INTO TEST VALUES (2, 12);
1 row affected (0.01 seconds)
0: jdbc:phoenix:localhost> select * from test;
+————+————+
|    A      |    B      |
+————+————+
| 1          | 1          |
| 2          | 12        |
+————+————+
2 rows selected (0.056 seconds)
0: jdbc:phoenix:localhost>

6:查看 hbase 中的表 test

[linuxidc@linuxidc01 hbase-0.94.21]$ hbase shell
HBase Shell; enter ‘help<RETURN>’ for list of supported commands.
Type “exit<RETURN>” to leave the HBase Shell
Version 0.94.21, r83b4a1ee9b9a2fa4c7ae1739259e041cabe8edc2, Fri Jun 27 16:14:16 UTC 2014

hbase(main):001:0> list
TABLE                                                                                                                             
SYSTEM.CATALOG                                                                                                                     
SYSTEM.SEQUENCE                                                                                                                   
TEST                                                                                                                               
b_month                                                                                                                           
mytable                                                                                                                           
5 row(s) in 0.6250 seconds

hbase(main):003:0> scan ‘TEST’
ROW                                COLUMN+CELL                                                                                     
 \x80\x00\x00\x01                  column=0:B, timestamp=1410534991931, value=\x80\x00\x00\x01                                     
 \x80\x00\x00\x01                  column=0:_0, timestamp=1410534991931, value=                                                   
 \x80\x00\x00\x02                  column=0:B, timestamp=1410535001115, value=\x80\x00\x00\x0C                                     
 \x80\x00\x00\x02                  column=0:_0, timestamp=1410535001115, value=                                                   
2 row(s) in 0.0770 seconds

hbase(main):004:0>

Hadoop+HBase 搭建云存储总结 PDF http://www.linuxidc.com/Linux/2013-05/83844.htm

HBase 结点之间时间不一致造成 regionserver 启动失败 http://www.linuxidc.com/Linux/2013-06/86655.htm

Hadoop+ZooKeeper+HBase 集群配置 http://www.linuxidc.com/Linux/2013-06/86347.htm

Hadoop 集群安装 &HBase 实验环境搭建 http://www.linuxidc.com/Linux/2013-04/83560.htm

基于 Hadoop 集群的 HBase 集群的配置 http://www.linuxidc.com/Linux/2013-03/80815.htm‘

Hadoop 安装部署笔记之 -HBase 完全分布模式安装 http://www.linuxidc.com/Linux/2012-12/76947.htm

单机版搭建 HBase 环境图文教程详解 http://www.linuxidc.com/Linux/2012-10/72959.htm 

HBase 的详细介绍 :请点这里
HBase 的下载地址 :请点这里

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计5864字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中