把 Apache Cassandra 在 Ubuntu 9.10 & Ruby 1.9.2(-dev) 上跑起來

因為 Ubuntu & Debian GNU/Linux 內的 /usr/include/string.h 不似 *BSD,沒有 strlcpy() 函數可用,但是 Ruby 1.9.2 又會自以為系統有這個函數,造成 gem install cassandra 時踩到雷(參考這裡),所以我用了很 dirty 的解法:

(我的 Ruby 1.9.2dev 是裝在 $HOME 裡,以下提到的路徑請替換成您自己安裝 Ruby 的實際所在)

  1. 先安裝 libbsd-dev (sudo apt-get install libbsd-dev)
  2. 修改 lib/ruby/gems/1.9.1/gems/thrift-0.2.0/ext/struct.c,自己加上 #include <bsd/string.h>
  3. 改好之後直接 make 測試編譯,在此 compiler 應該已經不會抱怨 implicit declaration of function ‘strlcpy’
  4. 到上一層去 ruby ./setup.rb 手動安裝,之後 lib/ruby/site_ruby/1.9.1/thrift 應該要有相關檔案
  5. gem spec ../../cache/thrift-0.2.0.gem –ruby > ../../specifications/thrift-0.2.0.gemspec,做好這步後 gem list 應該會看到已安裝的 gems 裡頭有 thrift (0.2.0)
  6. 回頭再跑一次 gem install cassandra ,安裝過程應該會順利完成
  7. 接著跑 cassandra_helper cassandra,ant 編譯過程順利的話就會把 Cassandra 跑起來

See also: up and running with cassandra :: snax


已發佈

分類:

作者:

標籤: