Phoenix安装配置

1、Phoenix是Apache项目,可实现SQL语句查询Hbase数据
2、下载并解压,并配置环境变量
3、复制Phoenix的JAR文件到Hbase的lib目录中
  1. grid@master1:~/phoenix/common$ cp phoenix-core-3.3.1.jar /home/grid/hbase/lib/
  2. grid@master1:~/phoenix/common$ scp phoenix-core-3.3.1.jar slave1:/home/grid/hbase/lib/
  3. phoenix-core-3.3.1.jar 100% 2380KB 2.3MB/s 00:00
  4. grid@master1:~/phoenix/common$ scp phoenix-core-3.3.1.jar slave2:/home/grid/hbase/lib/
  5. phoenix-core-3.3.1.jar 100% 2380KB 2.3MB/s 00:00
  6. grid@master1:~/phoenix/common$ scp phoenix-core-3.3.1.jar slave3:/home/grid/hbase/lib/
  7. phoenix-core-3.3.1.jar 100% 2380KB 2.3MB/s 00:00
4、重启Hbase
5、使用Phonenix的sqlline.py连接zookeeper上的Hbase
  1. grid@master1:~$ sqlline.py master1
  2. Setting property: [isolation, TRANSACTION_READ_COMMITTED]
  3. issuing: !connect jdbc:phoenix:master1 none none org.apache.phoenix.jdbc.PhoenixDriver
  4. Connecting to jdbc:phoenix:master1
  5. Connected to: Phoenix (version 3.3)
  6. Driver: PhoenixEmbeddedDriver (version 3.3)
  7. Autocommit status: true
  8. Transaction isolation: TRANSACTION_READ_COMMITTED
  9. Building list of tables and columns for tab-completion (set fastconnect to true to skip)...
  10. 68/68 (100%) Done
  11. Done
  12. sqlline version 1.1.8
  13. 0: jdbc:phoenix:master1>
6、查看Hadoop上的文件
  1. drwxr-xr-x - grid supergroup 0 2015-09-24 11:58 /hbase/SYSTEM.CATALOG
  2. -rw-r--r-- 1 grid supergroup 1924 2015-09-24 11:58 /hbase/SYSTEM.CATALOG/.tableinfo.0000000002
  3. drwxr-xr-x - grid supergroup 0 2015-09-24 11:58 /hbase/SYSTEM.CATALOG/.tmp
  4. drwxr-xr-x - grid supergroup 0 2015-09-24 11:42 /hbase/SYSTEM.CATALOG/ce23398bbf72dc695a5ab2f6f1960654
  5. -rw-r--r-- 1 grid supergroup 249 2015-09-24 11:42 /hbase/SYSTEM.CATALOG/ce23398bbf72dc695a5ab2f6f1960654/.regioninfo
  6. drwxr-xr-x - grid supergroup 0 2015-09-24 11:42 /hbase/SYSTEM.CATALOG/ce23398bbf72dc695a5ab2f6f1960654/0
  7. drwxr-xr-x - grid supergroup 0 2015-09-24 11:58 /hbase/SYSTEM.SEQUENCE
  8. -rw-r--r-- 1 grid supergroup 2042 2015-09-24 11:58 /hbase/SYSTEM.SEQUENCE/.tableinfo.0000000001
  9. drwxr-xr-x - grid supergroup 0 2015-09-24 11:58 /hbase/SYSTEM.SEQUENCE/.tmp
  10. drwxr-xr-x - grid supergroup 0 2015-09-24 11:58 /hbase/SYSTEM.SEQUENCE/00803cd5c775e83a54ab8216d241c498
  11. -rw-r--r-- 1 grid supergroup 312 2015-09-24 11:58 /hbase/SYSTEM.SEQUENCE/00803cd5c775e83a54ab8216d241c498/.regioninfo
  12. drwxr-xr-x - grid supergroup 0 2015-09-24 11:58 /hbase/SYSTEM.SEQUENCE/00803cd5c775e83a54ab8216d241c498/0
  13. drwxr-xr-x - grid supergroup 0 2015-09-24 11:58 /hbase/SYSTEM.SEQUENCE/020a89f81ce905b72d7d22dbb5cc26bb
  14. -rw-r--r-- 1 grid supergroup 312 2015-09-24 11:58 /hbase/SYSTEM.SEQUENCE/020a89f81ce905b72d7d22dbb5cc26bb/.regioninfo

  15. .........................................................................................................................
  16. -rw-r--r-- 1 grid supergroup 312 2015-09-24 11:58 /hbase/SYSTEM.SEQUENCE/ff74f65e383d89652ca1cfd12134bfe2/.regioninfo
  17. drwxr-xr-x - grid supergroup 0 2015-09-24 11:58 /hbase/SYSTEM.SEQUENCE/ff74f65e383d89652ca1cfd12134bfe2/0
  18. drwxr-xr-x - grid supergroup 0 2015-09-24 11:58 /hbase/SYSTEM.SEQUENCE/fffe41c42ea32dc1ef97befcf90b220c
  19. -rw-r--r-- 1 grid supergroup 312 2015-09-24 11:58 /hbase/SYSTEM.SEQUENCE/fffe41c42ea32dc1ef97befcf90b220c/.regioninfo
  20. drwxr-xr-x - grid supergroup 0 2015-09-24 11:58 /hbase/SYSTEM.SEQUENCE/fffe41c42ea32dc1ef97befcf90b220c/0
  21. drwxr-xr-x - grid supergroup 0 2015-09-24 11:58 /hbase/SYSTEM.STATS
  22. -rw-r--r-- 1 grid supergroup 1760 2015-09-24 11:58 /hbase/SYSTEM.STATS/.tableinfo.0000000001
  23. drwxr-xr-x - grid supergroup 0 2015-09-24 11:58 /hbase/SYSTEM.STATS/.tmp
  24. drwxr-xr-x - grid supergroup 0 2015-09-24 11:58 /hbase/SYSTEM.STATS/b8f4908021c3ce0053947ae7fd92525e
  25. -rw-r--r-- 1 grid supergroup 243 2015-09-24 11:58 /hbase/SYSTEM.STATS/b8f4908021c3ce0053947ae7fd92525e/.regioninfo
  26. drwxr-xr-x - grid supergroup 0 2015-09-24 11:58 /hbase/SYSTEM.STATS/b8f4908021c3ce0053947ae7fd92525e/0
增加了 SYSTEM.CATALOG、SYSTEM .SEQUENCE、SYSTEM .STATS这几个目录
7、Phoenix创建表
  1. 0: jdbc:phoenix:master1> create table test(id integer primary key,name varchar(50));
  2. No rows affected (1.423 seconds)
  3. 0: jdbc:phoenix:master1> upsert into test values (1,'aaa');
  4. 1 row affected (0.137 seconds)
  5. 0: jdbc:phoenix:master1> upsert into test values (2,'bbb');
  6. 1 row affected (0.013 seconds)
8、在Hbase中查询Phoenix中创建的表
  1. hbase(main):007:0> scan 'test'
  2. ROW COLUMN+CELL

  3. ERROR: Unknown table

  4. .....................................
报错信息显示未知的表,其实是Hbase对表名区分大小写,Phoenix中创建的表test,在Hbase中成了’TEST‘
  1. hbase(main):003:0> scan 'TEST'
  2. ROW COLUMN+CELL
  3.  \x80\x00\x00\x01 column=0:NAME, timestamp=1443097208715, value=aaa
  4.  \x80\x00\x00\x01 column=0:_0, timestamp=1443097208715, value=
  5.  \x80\x00\x00\x02 column=0:NAME, timestamp=1443097216122, value=bbb
  6.  \x80\x00\x00\x02 column=0:_0, timestamp=1443097216122, value=
  7. 2 row(s) in 0.0800 seconds

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12219480/viewspace-1808565/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/12219480/viewspace-1808565/

你可能感兴趣的:(Phoenix安装配置)