close
Warning:
Can't synchronize with repository "(default)" (Unsupported version control system "svn": /usr/lib/python2.7/dist-packages/libsvn/_fs.so: failed to map segment from shared object: Cannot allocate memory). Look in the Trac log for more information.
- Timestamp:
-
Apr 20, 2010, 1:53:30 PM (14 years ago)
- Author:
-
waue
- Comment:
-
--
Legend:
- Unmodified
- Added
- Removed
- Modified
-
v6
|
v7
|
|
8 | 8 | }}} |
9 | 9 | [[PageOutline]] |
| 10 | = 一、前言 = |
| 11 | * 本篇作業系統為Ubuntu (9.04) |
| 12 | * 假設已經安裝好 Hadoop (0.20 ) Hbase (0.20) ,完成設定,並且已在運作中 |
10 | 13 | |
11 | 14 | == 安裝設定 hadoop 0.20 == |
12 | | 略 |
| 15 | * 本篇的hadoop 安裝於 /opt/hadoop |
13 | 16 | == 安裝設定 hbase 0.20 == |
14 | | 略 |
15 | | == 安裝設定 thrift 0.2 == |
16 | | [http://incubator.apache.org/thrift/download/ thrift 下載頁面] |
| 17 | * 本篇的Hbase 安裝於 /opt/hbase |
17 | 18 | |
18 | | 將原始碼解壓縮後的完整路徑為 /opt/thrift-0.2.0 |
| 19 | = 二、安裝 thrift = |
| 20 | == 編譯 thrift == |
19 | 21 | |
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 |
21 | 31 | {{{ |
22 | 32 | $ apt-get install libboost1.38-dev automake libtool flex bison |
23 | 33 | }}} |
24 | 34 | |
25 | | 接著編譯與安裝thrift |
| 35 | 3. 接著編譯與安裝thrift |
26 | 36 | {{{ |
27 | 37 | $ ./bootstrap.sh |
… |
… |
|
31 | 41 | }}} |
32 | 42 | |
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 |
34 | 44 | |
35 | 45 | {{{ |
… |
… |
|
39 | 49 | }}} |
40 | 50 | |
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 檔還是需要其他檔案當函式庫 |
42 | 52 | |
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 = |
49 | 54 | |
50 | | Let's now start Hbase thrift server. |
| 55 | == 檢查hadoop 與 hbase 是否正常運作中 == |
| 56 | == 啟動 hbase 的 thrift daemon == |
| 57 | |
51 | 58 | {{{ |
52 | 59 | $ /opt/hbase/bin/hbase thrift start & |
53 | 60 | }}} |
54 | 61 | |
55 | | == test == |
56 | | |
| 62 | == 將整個php 專案都複製到 /var/www/hbase 內 == |
| 63 | |
57 | 64 | {{{ |
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/ |
59 | 69 | }}} |
60 | 70 | |
61 | | 修改 /var/www/DemoClient.php 的 |
| 71 | * 完成後/var/www/hbase /的目錄結構為 |
62 | 72 | {{{ |
63 | 73 | #!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'; |
65 | 115 | |
66 | 116 | $socket = new TSocket( 'secuse.nchc.org.tw', 9090 ); |
67 | 117 | }}} |
68 | 118 | |
69 | | == 參考 == |
| 119 | * 用瀏覽器打開 http://localhost/hbase/DemoClient.php 並檢視網頁內容 |
| 120 | |
| 121 | = 參考 = |
70 | 122 | |
71 | 123 | [http://appaquet.blogspot.com/2008/11/thrift-hbase-php.html André-Philippe Paquet's Blog] |
72 | 124 | |
73 | 125 | |
74 | | == 除錯 == |
| 126 | = 除錯 = |
75 | 127 | |
76 | 128 | * 出現錯誤訊息 |