Install Cassandra with Ruby 1.9.1 on Windows

To get it done is not easy. I spent a whole day to figure out the various compatibility issues along the way out.
Now there still might be potential issues, but it works by my rough test.

Step 1: Install Apache Cassandra
  You may know that the Ruby gem cassandra will do it for you.
  To me, I simply want to keep Cassandra independent from Ruby stuff, to ease the upgrade and administration.
  Refer to my blog "Setup Cassandra on Windows"

  (http://blog.csdn.net/goodxp/archive/2010/02/26/5327732.aspx) for details.

Step 2: Install Thrift (0.2.0)
  If you do "gem install cassandra", it should install thrift automatically (being a dependency).
  However, there is a compatibility issue on thrift with Ruby 1.9, so to fail Cassandra gem installation.
  It will be better to install thrift first and fix it before installing cassandra gem.
  Refer to my blog "fix thrift 0.2.0 installation with ruby 1.9.1"

  (http://blog.csdn.net/goodxp/archive/2010/02/28/5333145.aspx) for details.
 
Step 3: Install gem Cassandra
  This part is easy:
 
  $ gem install cassandra

  Do NOT do this: "$ cassandra_helper cassandra". It does not work.
  I did not dig deeper since I already have a working up-to-date version of Cassandra 0.5.0 installed.
  Switch to Cassandra bin folder and start cassandra server:

  $ cassandra -f
 
  Open another command console window:
 
  $ irb
  irb> require 'rubygems'
  irb> require 'cassandra'
 
  If you see a warning pop-up window asking for "msvcrt-ruby18.dll", do this:
 
  irb> quit
  $ gem uninstall json
 
  Don't worry, Ruby 1.9 has a good json support.
  Now run irb again as above, and then:
 
  irb> include Cassandra::Constants
  irb> db = Cassandra.new 'Keyspace1'
  irb> niceguy = {'name' => 'goodxp'}
  irb> db.insert (:Standard1, '10', niceguy)
 
  Keyspace1 and Standard1 are the sample config for Cassandra. This should work if you did not change schema yet.
  Now we can check whether the data were inserted. To be sure, let's use cassandra command line client:
 
  irb> quit
  $ cassandra-cli
  cassandra> connect localhost/9160
  cassandra> get Keyspace1.Standard1['10']
 
  You should see the niceguy 'name' 'goodxp' shows up. It means your Ruby API just works.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值