wiki:jazz/12-10-04

2012-10-04

Hadoop + HBase + Thrift

  1. 建立 Ubuntu 12.04 Server 環境
  2. 建立 Hadoop 1.0.3 環境
    jazz@precise:~$ wget http://hadoop.nchc.org.tw/~jazz/temp/install-hadoop-1.0.3-precise
    jazz@precise:~$ chmod a+x install-hadoop-1.0.3-precise
    jazz@precise:~$ ./install-hadoop-1.0.3-precise
    
  3. 建立 HBase 0.94.1 環境
    jazz@precise:~$ wget http://hadoop.nchc.org.tw/~jazz/temp/install-hbase-0.94.1-precise
    jazz@precise:~$ chmod a+x install-hbase-0.94.1-precise
    jazz@precise:~$ ./install-hbase-0.94.1-precise
    
  4. 下載 Thrift 0.8
    jazz@precise:~$ sudo apt-get install make libboost-dev libboost-test-dev libboost-program-options-dev libevent-dev automake libtool flex bison pkg-config g++ libssl-dev
    jazz@precise:~$ wget https://dist.apache.org/repos/dist/release/thrift/0.8.0/thrift-0.8.0.tar.gz
    jazz@precise:~$ tar zxvf thrift-0.8.0.tar.gz
    jazz@precise:~$ cd thrift-0.8.0/
    jazz@precise:~/thrift-0.8.0$ ./configure 
    jazz@precise:~/thrift-0.8.0$ make
    jazz@precise:~/thrift-0.8.0$ sudo make install
    
    或者如果未來希望可以包成套件,以後還可以反安裝,可以裝 checkinstall
    jazz@precise:~$ sudo apt-get install make libboost-dev libboost-test-dev libboost-program-options-dev libevent-dev automake libtool flex bison pkg-config g++ libssl-dev
    jazz@precise:~$ wget https://dist.apache.org/repos/dist/release/thrift/0.8.0/thrift-0.8.0.tar.gz
    jazz@precise:~$ tar zxvf thrift-0.8.0.tar.gz
    jazz@precise:~$ cd thrift-0.8.0/
    jazz@precise:~/thrift-0.8.0$ ./configure 
    jazz@precise:~/thrift-0.8.0$ checkinstall
    
  5. 安裝設定 PHP & Apache2
    jazz@precise:~/thrift-0.8.0$ sudo apt-get -y libapache2-mod-php5
    
  6. 編譯 HBase 的 Thrift PHP 介面
    jazz@precise:~/thrift-0.8.0$ cp -r /opt/hbase/src/main/resources/org/apache/hadoop/hbase/thrift hbase_thrift_src
    jazz@precise:~/thrift-0.8.0$ cd hbase_thrift_src/
    jazz@precise:~/thrift-0.8.0/hbase_thrift_src$ thrift --gen php Hbase.thrift
    
  7. 建立 HBase 的 Thrift PHP 目錄
    jazz@precise:~/thrift-0.8.0/hbase_thrift_src$ sudo mkdir -p /var/www/hbase
    jazz@precise:~/thrift-0.8.0/hbase_thrift_src$ sudo cp -r ~/thrift-0.8.0/lib/php/src /var/www/hbase/thrift
    jazz@precise:~/thrift-0.8.0/hbase_thrift_src$ sudo chown -R $USER:$USER /var/www/hbase/
    jazz@precise:~/thrift-0.8.0/hbase_thrift_src$ mkdir -p /var/www/hbase/thrift/packages
    jazz@precise:~/thrift-0.8.0/hbase_thrift_src$ cp -r gen-php/* /var/www/hbase/thrift/packages/
    
  8. 測試
    jazz@precise:~/thrift-0.8.0/hbase_thrift_src$ cp /opt/hbase/src/examples/thrift/DemoClient.php /var/www/hbase/DemoClient.php
    jazz@precise:~/thrift-0.8.0/hbase_thrift_src$ sed -i 's#/Users/irubin/Thrift/thrift-20080411p1/lib/php/src#/var/www/hbase/thrift#g' /var/www/hbase/DemoClient.php
    jazz@precise:~/thrift-0.8.0/hbase_thrift_src$ /opt/hbase/bin/hbase-daemon.sh start thrift -nonblocking
    jazz@precise:~/thrift-0.8.0/hbase_thrift_src$ w3m http://localhost/hbase/DemoClient.php
    
Last modified 12 years ago Last modified on Oct 4, 2012, 10:56:07 PM