Changes between Version 5 and Version 6 of waue/2010/0401


Ignore:
Timestamp:
Apr 1, 2010, 6:14:17 PM (14 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • waue/2010/0401

    v5 v6  
    1616[http://incubator.apache.org/thrift/download/ thrift 下載頁面]
    1717
     18將原始碼解壓縮後的完整路徑為 /opt/thrift-0.2.0
     19
    1820安裝之前請先確定有裝了 libboost (c++的函式庫),以及make時會用到的yacc flex
    1921{{{
    20 $ apt-get install libboost1.38-dev
    21 $ apt-get install byacc flex
     22$ apt-get install libboost1.38-dev automake libtool flex bison
    2223}}}
    2324
     
    2627$ ./bootstrap.sh
    2728$ ./configure
    28 $ ./make
    29 $ ./make install
     29$ make
     30$ sudo make install
    3031}}}
     32
     33You should now have a fresh Thrift installation. We now need to generate PHP files that will be included in your application in order to access Hbase.
     34
     35{{{
     36$ cp -r /opt/hbase/src/java/org/apache/hadoop/hbase/thrift ./hbase_thrift_src
     37$ cd hbase_thrift_src
     38$ thrift --gen php Hbase.thrift
     39}}}
     40
     41If you have followed all above the steps correctly, Thrift should have generated a directory named gen-php/Hbase/ wich contains 2 php files. Those two files contains classes you will use to access hbase. But those files also depends on Thrift base files that you can find in thrift source directory. Following steps assume that your apache home directory is /var/www. Let's copy Thrift base files and create a "packages" directory wich will contains previously generated files.
     42
     43{{{
     44$ cp -r /opt/thrift-0.2.0/lib/php/src /var/www/thrift
     45(請記得改/var/www下的權限)
     46$ mkdir /var/www/thrift/packages
     47$ cp -r hbase_thrift_src/gen-php/* /var/www/thrift/packages/
     48}}}
     49
     50Let's now start Hbase thrift server.
     51{{{
     52$ /opt/hbase/bin/hbase thrift start &
     53}}}
     54
     55 == test ==
     56 
     57{{{
     58$ cp /opt/hbase/src/examples/thrift/DemoClient.php /var/www/DemoClient.php
     59}}}
     60
     61修改 /var/www/DemoClient.php 的
     62{{{
     63#!text
     64 $GLOBALS['THRIFT_ROOT'] = '/var/www/thrift';
     65 
     66 $socket = new TSocket( 'secuse.nchc.org.tw', 9090 );
     67}}}
     68
     69== 參考 ==
     70
     71[http://appaquet.blogspot.com/2008/11/thrift-hbase-php.html André-Philippe Paquet's Blog]
     72
     73
     74== 除錯 ==
     75
     76 * 出現錯誤訊息
     77{{{
     78#!php
     79PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0
     80<html>
     81<head>
     82<title>DemoClient</title>
     83</head>
     84<body>
     85<pre>
     86scanning tables...
     87creating table: demo_table
     88column families in demo_table:
     89  column: entry, maxVer: 10
     90  column: unused, maxVer: 3
     91
     92Fatal error: Uncaught exception 'Exception' with message 'shouldn't get here!' in /var/www/DemoClient.php:158
     93Stack trace:
     94#0 {main}
     95  thrown in /var/www/DemoClient.php on line 158
     96}}}