10 | | = 一、前言 = |
11 | | |
| 10 | = 零、前言 = |
| 11 | * 程式安裝測試方法已紀錄於: [wiki:waue/2010/0401 安裝編譯及測試 ] |
| 12 | * 因此目錄結構為 |
| 13 | || hadoop || /opt/hadoop || || |
| 14 | || hbase || /opt/hbase || || |
| 15 | || 網頁根目錄 || /var/www/ || || |
| 16 | || hbase 的php碼目錄 || /var/www/hbase || || |
| 17 | || thrift php || /var/www/hbase/thrift || || |
| 18 | |
| 19 | * 測試程式之前,請先確定 |
| 20 | * hbase , hadoop 都有正常運作中 |
| 21 | * $ bin/hbase thrift start 尚在執行 |
| 22 | |
| 23 | = 一、php引用thrift lib = |
| 24 | |
| 25 | {{{ |
| 26 | #!php |
| 27 | <? |
| 28 | $GLOBALS['THRIFT_ROOT'] = '/var/www/hbase/thrift'; |
| 29 | |
| 30 | require_once( $GLOBALS['THRIFT_ROOT'].'/Thrift.php' ); |
| 31 | require_once( $GLOBALS['THRIFT_ROOT'].'/transport/TSocket.php' ); |
| 32 | require_once( $GLOBALS['THRIFT_ROOT'].'/transport/TBufferedTransport.php' ); |
| 33 | require_once( $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php' ); |
| 34 | require_once( $GLOBALS['THRIFT_ROOT'].'/packages/Hbase/Hbase.php' ); |
| 35 | |
| 36 | $socket = new TSocket( 'secuse.nchc.org.tw', 9090 ); |
| 37 | $socket->setSendTimeout( 10000 ); // Ten seconds (too long for production, but this is just a demo ;) |
| 38 | $socket->setRecvTimeout( 20000 ); // Twenty seconds |
| 39 | $transport = new TBufferedTransport( $socket ); |
| 40 | $protocol = new TBinaryProtocol( $transport ); |
| 41 | $client = new HbaseClient( $protocol ); |
| 42 | $transport->open(); |
| 43 | ?> |
| 44 | ........ |
| 45 | 其他程式碼 |
| 46 | ....... |
| 47 | <? |
| 48 | $transport->close(); |
| 49 | ?> |
| 50 | }}} |
| 51 | |
| 52 | |
| 53 | |