Apache-phoenix安装和使用操作HBase

实验环境

操作系统: window 7 ip:192.168.199.247  计算机名称:admin-pc

HBase: hbase-1.2.6 (单机,自带zookeeper) 

Hadoop:hadoop-2.7.6 (单机) 

操作系统: centos 7  ip:192.168.199.144
phoenix:apache-phoenix-4.14.0-HBase-1.2 

phoenix版本选择

Current release 4.14 can run on Apache HBase 0.98, 1.1, 1.2, 1.3 and 1.4 and CDH HBase 5.11, 5.12, 5.13 and 5.14. Apache HBase 2.0 is supported by 5.0.0. Please follow the appropriate link depending on your HBase version.

phoenix下载地址

phoenix 安装

1) centos7 下载解压  /usr/local/apache-phoenix-4.14.0-HBase-1.2-bin

2)进入apache-phoenix-4.14.0-HBase-1.2-bin目录把phoenix-4.14.0-HBase-1.2-server.jar拷贝到集群中每个节点( 主节点也要拷贝 )的 hbase 的 lib 目录下。本实验环境虽然是单机也拷贝到  D:\Soft\hbase-1.2.6\lib目录中即可。

3)重新启动HBase 服务

4)进入phoenix的bin目录中执行启动命令

[root@localhost bin]# ./sqlline.py 192.168.199.247:2181

 5)连接成功显示如下

[root@localhost bin]# ./sqlline.py 192.168.199.247:2181
Setting property: [incremental, false]
Setting property: [isolation, TRANSACTION_READ_COMMITTED]
issuing: !connect jdbc:phoenix:192.168.199.247:2181 none none org.apache.phoenix.jdbc.PhoenixDriver
Connecting to jdbc:phoenix:192.168.199.247:2181
18/10/17 01:19:59 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Connected to: Phoenix (version 4.14)
Driver: PhoenixEmbeddedDriver (version 4.14)
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

6)如果连接出错

     1) 关闭防火墙     

systemctl stop firewalld

     2) 配置host

    Apache-phoenix安装和使用操作HBase_第1张图片

    为啥配置 admin-pc.lan,连接zookeeper发现meta-region-server中的服务器名称为 admin-pc.lan

[zk: 192.168.199.247:2181(CONNECTED) 4] get  /hbase/meta-region-server
�regionserver:53604W�υ�-PBUF


admin-PC.lan������,

       3) 保证能 ping通 192.168.199.247admin-pc.lan

7) 执行sql命令

0: jdbc:phoenix:192.168.199.247:2181> create table test (id varchar primary key,name varchar,age integer );
No rows affected (2.387 seconds)
0: jdbc:phoenix:192.168.199.247:2181> select * from test;
+-----+-------+------+
| ID  | NAME  | AGE  |
+-----+-------+------+
+-----+-------+------+
No rows selected (0.198 seconds)
0: jdbc:phoenix:192.168.199.247:2181> upsert into test(id,name,age) values('000001','liubei',43);
1 row affected (0.015 seconds)
0: jdbc:phoenix:192.168.199.247:2181> select * from test;
+---------+---------+------+
|   ID    |  NAME   | AGE  |
+---------+---------+------+
| 000001  | liubei  | 43   |
+---------+---------+------+
1 row selected (0.061 seconds)

 

你可能感兴趣的:(大数据)