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


Ignore:
Timestamp:
Apr 20, 2010, 1:53:30 PM (14 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • waue/2010/0401

    v6 v7  
    88}}}
    99[[PageOutline]]
     10 = 一、前言 =
     11 * 本篇作業系統為Ubuntu (9.04)
     12 * 假設已經安裝好 Hadoop (0.20 ) Hbase (0.20) ,完成設定,並且已在運作中
    1013
    1114 == 安裝設定 hadoop 0.20 ==
    12 
     15 * 本篇的hadoop 安裝於 /opt/hadoop
    1316 == 安裝設定 hbase 0.20 ==
    14 
    15   == 安裝設定 thrift 0.2 ==
    16 [http://incubator.apache.org/thrift/download/ thrift 下載頁面]
     17 * 本篇的Hbase 安裝於  /opt/hbase
    1718
    18 將原始碼解壓縮後的完整路徑為 /opt/thrift-0.2.0
     19 = 二、安裝 thrift =
     20  == 編譯 thrift  ==
    1921
    20 安裝之前請先確定有裝了 libboost (c++的函式庫),以及make時會用到的yacc flex
     22 * 目前 thrift 最新版本為 0.2
     23   * [http://incubator.apache.org/thrift/download/ thrift 下載頁面]
     24
     25 1. 將原始碼解壓縮後的完整路徑為 /opt/thrift,並進入該目錄
     26{{{
     27$ cd /opt/thrift
     28}}}
     29
     30 2.  安裝之前請先確定有裝了 libboost (c++的函式庫),以及make時會用到的yacc flex
    2131{{{
    2232$ apt-get install libboost1.38-dev automake libtool flex bison
    2333}}}
    2434
    25 接著編譯與安裝thrift
     35 3. 接著編譯與安裝thrift
    2636{{{
    2737$ ./bootstrap.sh
     
    3141}}}
    3242
    33 You 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.
     43 4. 產生出可以存取hbase的php
    3444
    3545{{{
     
    3949}}}
    4050
    41 If 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.
     51 * 以上若動作都確實完成,可以看到已經產生出一個資料夾: gen-php/Hbase/ 並且包含兩個php檔案,此兩個php檔可以幫助你存取hbase,不過此 php 檔還是需要其他檔案當函式庫
    4252
    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 }}}
     53 = 三、透過 thrift 存取 hbase =
    4954
    50 Let's now start Hbase thrift server.
     55 == 檢查hadoop 與 hbase 是否正常運作中 ==
     56 == 啟動 hbase 的 thrift daemon ==
     57
    5158{{{
    5259$ /opt/hbase/bin/hbase thrift start &
    5360}}}
    5461
    55  == test ==
    56  
     62 == 將整個php 專案都複製到 /var/www/hbase 內 ==
     63
    5764{{{
    58 $ cp /opt/hbase/src/examples/thrift/DemoClient.php /var/www/DemoClient.php
     65$ cp -r /opt/thrift-0.2.0/lib/php/src /var/www/hbase/thrift
     66$(請用 chown 指令來改/var/www/hbase 下的權限)
     67$ mkdir /var/www/hbase/thrift/packages
     68$ cp -r hbase_thrift_src/gen-php/* /var/www/hbase/thrift/packages/
    5969}}}
    6070
    61 修改 /var/www/DemoClient.php 的
     71 * 完成後/var/www/hbase /的目錄結構為
    6272{{{
    6373#!text
    64  $GLOBALS['THRIFT_ROOT'] = '/var/www/thrift';
     74./
     75|-- DemoClient.php (下一節會提到)
     76`-- thrift
     77    |-- Thrift.php
     78    |-- autoload.php
     79    |-- ext
     80    |   `-- thrift_protocol
     81    |       |-- config.m4
     82    |       |-- php_thrift_protocol.cpp
     83    |       `-- php_thrift_protocol.h
     84    |-- packages
     85    |   `-- Hbase
     86    |       |-- Hbase.php
     87    |       `-- Hbase_types.php
     88    |-- protocol
     89    |   |-- TBinaryProtocol.php
     90    |   `-- TProtocol.php
     91    `-- transport
     92        |-- TBufferedTransport.php
     93        |-- TFramedTransport.php
     94        |-- THttpClient.php
     95        |-- TMemoryBuffer.php
     96        |-- TNullTransport.php
     97        |-- TPhpStream.php
     98        |-- TSocket.php
     99        |-- TSocketPool.php
     100        `-- TTransport.php
     101}}}
     102
     103 = 四、測試 =
     104 
     105 == 複製DemoClient.php 到測試目錄/var/www/hbase/  ==
     106{{{
     107$ cp /opt/hbase/src/examples/thrift/DemoClient.php /var/www/hbase/DemoClient.php
     108}}}
     109
     110 * 修改 /var/www/hbase/DemoClient.php 的THRIFT_ROOT 參數
     111
     112{{{
     113#!php
     114 $GLOBALS['THRIFT_ROOT'] = '/var/www/hbase/thrift';
    65115 
    66116 $socket = new TSocket( 'secuse.nchc.org.tw', 9090 );
    67117}}}
    68118
    69 == 參考 ==
     119 *  用瀏覽器打開 http://localhost/hbase/DemoClient.php 並檢視網頁內容
     120
     121= 參考 =
    70122
    71123[http://appaquet.blogspot.com/2008/11/thrift-hbase-php.html André-Philippe Paquet's Blog]
    72124
    73125
    74 == 除錯 ==
     126= 除錯 =
    75127
    76128 * 出現錯誤訊息