wiki:waue/2011/1107
cassandra 1.0 + Cassandra-PHP-Client-Library

前言

  • 透過官方頁面得知,若使用以下專案可以免去安裝thrift的困擾

http://wiki.apache.org/cassandra/ClientOptions

  • Cassandra PHP Client Library:

https://github.com/kallaspriit/Cassandra-PHP-Client-Library API Library Graph

  • 順便對照以前寫得內容

hadoop + Hbase + thrift + php 安裝設定與程式設計

Cassandra

  • 下載 cassandra 1.0 解開到 /opt/cassandra-1.0.1
  • 安裝設定與啟動 cassandra 1.0
    sudo mkdir /var/lib/cassandra  /var/log/cassandra; sudo chmod 777 /var/lib/cassandra /var/log/cassandra
    
    cd /opt/cassandra-1.0.1
    ./configure; make ; sudo make install
    
    bin/cassandra
    

PHP

  • 下載 Cassandra-PHP-Client-Library (下載) ,解壓縮到 /var/www/cassandra/ 下
  • 驗證
    bin/cassandra-cli -h localhost
    
    use CassandraExample;
    show schema;
    list user;
    
  • 結果
    [default@CassandraExample] list user;  
    Using default limit of 100
    -------------------
    RowKey: 6a616e652e646f65
    => (column=age, value=24, timestamp=-126335541)
    => (column=email, value=jane@doe.com, timestamp=-126335541)
    => (column=name, value=Jane Doe, timestamp=-126335541)
    -------------------
    RowKey: 636875636b
    => (column=age, value=24, timestamp=-126333665)
    => (column=email, value=chuck@norris.com, timestamp=-126333665)
    => (column=name, value=Chuck Norris, timestamp=-126333665)
    -------------------
    RowKey: 6a6f686e
    => (column=age, value=34, timestamp=-126397246)
    => (column=email, value=john@smith.com, timestamp=-126397246)
    => (column=name, value=John Smith, timestamp=-126397246)
    
    3 Rows Returned.
    

移除

清除以下兩個目錄

  • /var/lib/cassandra
  • /var/log/cassandra

cassandra 1.0 + Thrift 0.7
sudo apt-get install libboost-dev automake libtool flex bison pkg-config g++
專案 安裝目錄
cassandra 1.0 /opt/cassandra-1.0.1/
thrift 0.7 /opt/cassandra-1.0.1/thrift-0.7.0/

備註:

  • 並非 thrift 必定得放在 cassandra 的目錄底下,而是因為版本有對應關係,因此這樣放比較不會搞錯
cd /opt/cassandra-1.0.1/thrift-0.7.0
bash ./contrib/fb303/bootstrap.sh
./configure
make
sudo make install

但從此之後有些怪怪的地方,如沒有

./compiler/cpp/thrift -gen php ../PATH-TO-CASSANDRA/interface/cassandra.thrift

可以產生 gen-php 的地方,以下的作法使用 thrift 0.6 搭配 cassandra 0.8 可行 https://wiki.fourkitchens.com/display/PF/Using+Cassandra+with+PHP

Last modified 10 years ago Last modified on Nov 9, 2011, 5:09:38 PM

Attachments (1)

Download all attachments as: .zip