<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cassandra &#8211; 老范讲故事｜AI、大模型与商业世界的故事</title>
	<atom:link href="https://lukefan.com/tag/cassandra/feed/" rel="self" type="application/rss+xml" />
	<link>https://lukefan.com</link>
	<description>这里是老范讲故事的主站，持续更新 AIGC、大模型、互联网平台、商业冲突与资本市场观察，帮你看清热点背后的底层逻辑。</description>
	<lastBuildDate>Fri, 26 Mar 2010 09:48:32 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://lukefan.com/wp-content/uploads/2026/03/cropped-jimeng-2026-02-28-5245-用图一的人物形象，替换图二中的人物，使用图二的风格。文字替换：老范讲故事，Yo-32x32.jpeg</url>
	<title>cassandra &#8211; 老范讲故事｜AI、大模型与商业世界的故事</title>
	<link>https://lukefan.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>折腾了半天，终于把cassandra跑起来了</title>
		<link>https://lukefan.com/2010/03/26/%e6%8a%98%e8%85%be%e4%ba%86%e5%8d%8a%e5%a4%a9%ef%bc%8c%e9%87%8d%e8%a6%81%e6%8a%8acassandra%e8%b7%91%e8%b5%b7%e6%9d%a5%e4%ba%86/</link>
		
		<dc:creator><![CDATA[Luke Fan]]></dc:creator>
		<pubDate>Fri, 26 Mar 2010 09:48:32 +0000</pubDate>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[cassandra]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">http://lukefan.com/?p=26</guid>

					<description><![CDATA[ubuntu服务器上cassandra的安装和Ruby的调用例子。]]></description>
										<content:encoded><![CDATA[<p>看到很多大牌网站，都离开MySQL转移到Cassandra上了。于是决定自己也试试。</p>
<p>在ubuntu服务器上先安装ruby on rails和java环境：</p>
<p>sudo apt-get install ruby ri irb rdoc ruby-dev rake rubygems1.8 libsqlite3-ruby libopenssl-ruby</p>
<p>sudo gem install rails mongrel mongrel_cluster  -n /usr/bin</p>
<p>sudo apt-get install sun-java6-jdk ant</p>
<p>然后安装ruby的cassandra gem包。</p>
<p>sudo gem install cassandra -n /usr/bin</p>
<p>直到这里，都不需要怎么麻烦。</p>
<p>下一步是下载、编译、安装cassandra，这个就麻烦了。</p>
<p>命令很简单：</p>
<p>cassandra_helper cassandra</p>
<p>第一个遇到的错误，说cassandra的包找不到了。于是上网去查了一下，发现是cassandra的版本更新了，原来是beta2，现在是beta3了。</p>
<p>修改Rakefile：</p>
<div id="_mcePaste">sudo vi /var/lib/gems/1.8/gems/cassandra-0.8.0/Rakefile</div>
<p>将其中的网址改为新的，正确的网址。</p>
<p>重新执行，总说找不到tar包或找不到目录。</p>
<p>后来发现，必须到cassandra默认的目录下去执行:</p>
<p>cd ~/cassandra</p>
<p>这回文件是找到了，却又说一个目录权限不够，再将执行的语句换成： sudo cassandra_helper cassandra ，在经过了漫长的ant编译过程（需要从网上下载不少东西）之后，终于运行起来了。而且，是以debug的方式运行起来的，对其做的各种操作都可以直观的看到。</p>
<p>启动的过程，会显示：</p>
<p>DEBUG &#8211; Estimating compactions for LocationInfo</p>
<p>DEBUG &#8211; Estimating compactions for HintsColumnFamily</p>
<p>DEBUG &#8211; Estimating compactions for Comments</p>
<p>DEBUG &#8211; Estimating compactions for Blogs</p>
<p>DEBUG &#8211; Estimating compactions for InvoiceRelationships</p>
<p>DEBUG &#8211; Estimating compactions for Customers</p>
<p>DEBUG &#8211; Estimating compactions for Appointments</p>
<p>DEBUG &#8211; Estimating compactions for Invoices</p>
<p>DEBUG &#8211; Estimating compactions for CustomersByLastName</p>
<p>DEBUG &#8211; Estimating compactions for InvoicesByNumber</p>
<p>DEBUG &#8211; Estimating compactions for Payments</p>
<p>DEBUG &#8211; Estimating compactions for CustomerRelationships</p>
<p>DEBUG &#8211; Estimating compactions for Comments</p>
<p>DEBUG &#8211; Estimating compactions for Blogs</p>
<p>DEBUG &#8211; Estimating compactions for Users</p>
<p>DEBUG &#8211; Estimating compactions for Index</p>
<p>DEBUG &#8211; Estimating compactions for UserRelationships</p>
<p>DEBUG &#8211; Estimating compactions for StatusAudits</p>
<p>DEBUG &#8211; Estimating compactions for StatusRelationships</p>
<p>DEBUG &#8211; Estimating compactions for Statuses</p>
<p>DEBUG &#8211; Estimating compactions for UserAudits</p>
<p>DEBUG &#8211; Estimating compactions for Usernames</p>
<div>上面写的这些名字，比如Users、Blogs，我们可以把他们直观的理解为表的名字。这些都是默认建好的，可以直接使用。</div>
<div>需要建立自己的表时，可以自己到cassandra_home/conf/storage-conf.xml里面去添加。</div>
<div>现在说起来比较简单，但当时反复试验，非常麻烦。</div>
<div>终于装好了，赶快试试：测试例子来源于 <a href="http://blog.evanweaver.com/articles/2009/07/06/up-and-running-with-cassandra/" target="_blank" rel="noopener">http://blog.evanweaver.com/articles/2009/07/06/up-and-running-with-cassandra/</a></div>
<div>进入irb，然后键入代码：</div>
<div>#添加引用：</div>
<div>
<p>require &#8216;rubygems&#8217;</p>
<p>require &#8216;cassandra&#8217;</p>
<p>include Cassandra::Constants</p>
<p>#建立示例</p>
<p>twitter = Cassandra.new(&#8216;Twitter&#8217;)</p>
<p>#填充数据</p>
<p>user = {&#8216;screen_name&#8217; =&gt; &#8216;buttonscat&#8217;}</p>
<p>twitter.insert(:Users, &#8216;5&#8217;, user)</p>
<p>tweet1 = {&#8216;text&#8217; =&gt; &#8216;Nom nom nom nom nom.&#8217;, &#8216;user_id&#8217; =&gt; &#8216;5&#8217;}</p>
<p>twitter.insert(:Statuses, &#8216;1&#8217;, tweet1)</p>
<p>tweet2 = {&#8216;text&#8217; =&gt; &#8216;@evan Zzzz&#8230;.&#8217;, &#8216;user_id&#8217; =&gt; &#8216;5&#8217;, &#8216;reply_to_id&#8217; =&gt; &#8216;8&#8217;}</p>
<p>twitter.insert(:Statuses, &#8216;2&#8217;, tweet2)</p>
<p>twitter.insert(:UserRelationships, &#8216;5&#8217;, {&#8216;user_timeline&#8217; =&gt; {UUID.new =&gt; &#8216;1&#8217;}})</p>
<p>twitter.insert(:UserRelationships, &#8216;5&#8217;, {&#8216;user_timeline&#8217; =&gt; {UUID.new =&gt; &#8216;2&#8217;}})</p>
<p>#检索查询</p>
<p>timeline = twitter.get(:UserRelationships, &#8216;5&#8217;, &#8216;user_timeline&#8217;, :reversed =&gt; true)</p>
<p>timeline.map { |time, id| twitter.get(:Statuses, id, &#8216;text&#8217;) }</p>
<p>得到结果：</p>
<p>[&#8220;@evan Zzzz&#8230;.&#8221;, &#8220;Nom nom nom nom nom.&#8221;]</p>
<p>退出irb再重新进入，将查询的部分执行一次，没有问题。结果还是正确的。</p>
<p>现在还有一些问题没有解决，那就是，直接运行cassandra还有问题，应该是classpath配置的有问题。这应该是java配置的问题的。每次都必须要执行cassandra_helper cassandra，通过ruby来启动cassandra。还没搞清楚怎么设置开机自动启动。</p>
<p>现在cassandra_helper还无法检测我已经安装过canssandra了，每次都要去下载。我将里面判断的CASSANDRA_INCLUDE设置项，写到了 /etc/environment，好像也还是无效。</p>
<p>到此为止，还不能说是部署完全成功了，只是能够应付一些简单的开发测试工作。</p>
<p>cassandra本身在windwos下安装倒是非常简单：下载，解压，执行cassandra.bat完事。但是，在windows下面安装cassandra的ruby包很麻烦，必须要有nmake，我是在是不想再在机器上装vc了。Mac上面没试过，据说并不复杂。</p>
<p>再接再厉。</p>
</div>
<div><span style="font-family: Georgia; line-height: 21px; color: #0b0d0f;"></p>
<p></span></div>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
