在eclipse中运行cassandra
对于要研究cassandra的同学来说,在eclipse里面运行cassandra当然是万里长征的第一步啦。cassandra的官网中给出了步骤,网址是http://wiki.apache.org/cassandra/RunningCassandraInEclipse。 博客园中http://www.cnblogs.com/gpcuster/archive/2010/06/06/1752665.html这篇文章也写了配置步骤,但是可能版本问题,按照这个方法我没有配置成功。于是我就按照官网上的步骤严格执行,终于可以了,下面分享下过程。
配置环境
1 安装jdk6,ant。
2 安装Eclipse
3 SVN工具,我用的是TortoiseSVN-1.7.1.22161-win32-svn-1.7.1.msi客户端工具,而不是eclipse svn插件。
检出cassandra工程,并ant
用SVN工具将项目检出,SVN的地址是http://svn.apache.org/repos/asf/cassandra/ ,用小乌龟检出项目到本地,这里我取名为cassandra-ld
检出项目后,要ant一下,生成其他文件.在cmd命令行中,进入项目目录下,并执行ant.
cd cassandra-ld
ant build
ant generate-eclipse-files
这个ant过程可能要执行10分钟左右。注意,在这个过程中需要访问到一些国外网站,所以校园网用户可能不能成功。我之前试过用GAE,貌似由于proxy的原因,也不能成功。最后是用了VPN才成功的。
在eclipse中导入项目
- 打开eclipse
- 点击File->New->Java Project
- 输入cassandra-ld作为项目名(应该与你检出的时候项目名一致)
- 取消"use defalt location",选择刚才放检出项目的目录
- 按next
- 检查下Default Output Folder 是不是 cassandra-trunk/build/classes/main
- 点击“Finish”
这个时候,项目中会有些错误提示,不要紧,继续下面的操作
- 关掉eclipse
- 编辑项目中的.project文件,在<buildCommand></buildCommand>下加入这一段
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
- 重启eclipse,并刷新(F5)
运行cassandra
- 修改conf/cassandra.yaml中的配置参数,自定义数据存储的位置:
# directories where Cassandra should store data on disk.
data_file_directories:
- C:\lindan\cassandraData\data
# commit log
commitlog_directory: C:\lindan\cassandraData\commitlog
# saved caches
saved_caches_directory: C:\lindan\cassandraData\saved_caches
- 点击"run"-"run congigurations"
- 选择org.apache.cassandra.thrift.CassandraDaemon作为main class.
- 在VM argument 下填入下面参数
-Dcassandra.config=file:C:\Users\Joaquin\workspace\cassandra-3\conf\cassandra.yaml
-Dcassandra-foreground
-ea -Xmx1G
-Dlog4j.configuration=file:C:\Users\Joaquin\workspace\cassandra-3\conf\log4j-server.properties
当然,这里的cassandra.yaml和log4j-server.properties都应该写成你自己的路径。
点击"run",如果看到下面的代码,就说明已经成功启动了你本机node了
INFO 15:54:42,191 JVM vendor/version: Java HotSpot(TM) Client VM/1.6.0_10-rc2
INFO 15:54:42,196 Heap size: 5177344/1065484288
INFO 15:54:42,197 Classpath: C:\lindan\cassandra-ld\build\classes\main;C:\lindan\cassandra-ld\build\classes\thrift;C:\lindan\cassandra-ld\build\test\classes;C:\lindan\cassandra-ld\test\conf;C:\lindan\cassandra-ld\lib\antlr-3.2.jar;C:\lindan\cassandra-ld\lib\avro-1.4.0-fixes.jar;C:\lindan\cassandra-ld\lib\avro-1.4.0-sources-fixes.jar;C:\lindan\cassandra-ld\lib\commons-cli-1.1.jar;C:\lindan\cassandra-ld\lib\commons-codec-1.2.jar;C:\lindan\cassandra-ld\lib\commons-lang-2.4.jar;C:\lindan\cassandra-ld\lib\compress-lzf-0.8.4.jar;C:\lindan\cassandra-ld\lib\concurrentlinkedhashmap-lru-1.2.jar;C:\lindan\cassandra-ld\lib\guava-r08.jar;C:\lindan\cassandra-ld\lib\high-scale-lib-1.1.2.jar;C:\lindan\cassandra-ld\lib\jackson-core-asl-1.4.0.jar;C:\lindan\cassandra-ld\lib\jackson-mapper-asl-1.4.0.jar;C:\lindan\cassandra-ld\lib\jamm-0.2.5.jar;C:\lindan\cassandra-ld\lib\jline-0.9.94.jar;C:\lindan\cassandra-ld\lib\json-simple-1.1.jar;C:\lindan\cassandra-ld\lib\libthrift-0.6.jar;C:\lindan\cassandra-ld\lib\log4j-1.2.16.jar;C:\lindan\cassandra-ld\lib\servlet-api-2.5-20081211.jar;C:\lindan\cassandra-ld\lib\slf4j-api-1.6.1.jar;C:\lindan\cassandra-ld\lib\slf4j-log4j12-1.6.1.jar;C:\lindan\cassandra-ld\lib\snakeyaml-1.6.jar;C:\lindan\cassandra-ld\lib\snappy-java-1.0.4.1.jar;C:\lindan\cassandra-ld\build\lib\jars\ant-1.6.5.jar;C:\lindan\cassandra-ld\build\lib\jars\apache-rat-0.6.jar;C:\lindan\cassandra-ld\build\lib\jars\apache-rat-core-0.6.jar;C:\lindan\cassandra-ld\build\lib\jars\apache-rat-tasks-0.6.jar;C:\lindan\cassandra-ld\build\lib\jars\asm-3.2.jar;C:\lindan\cassandra-ld\build\lib\jars\commons-beanutils-1.7.0.jar;C:\lindan\cassandra-ld\build\lib\jars\commons-beanutils-core-1.8.0.jar;C:\lindan\cassandra-ld\build\lib\jars\commons-cli-1.2.jar;C:\lindan\cassandra-ld\build\lib\jars\commons-codec-1.4.jar;C:\lindan\cassandra-ld\build\lib\jars\commons-collections-3.2.jar;C:\lindan\cassandra-ld\build\lib\jars\commons-configuration-1.6.jar;C:\lindan\cassandra-ld\build\lib\jars\commons-digester-1.8.jar;C:\lindan\cassandra-ld\build\lib\jars\commons-el-1.0.jar;C:\lindan\cassandra-ld\build\lib\jars\commons-httpclient-3.0.1.jar;C:\lindan\cassandra-ld\build\lib\jars\commons-lang-2.1.jar;C:\lindan\cassandra-ld\build\lib\jars\commons-logging-1.1.1.jar;C:\lindan\cassandra-ld\build\lib\jars\commons-math-2.1.jar;C:\lindan\cassandra-ld\build\lib\jars\commons-net-1.4.1.jar;C:\lindan\cassandra-ld\build\lib\jars\core-3.1.1.jar;C:\lindan\cassandra-ld\build\lib\jars\hadoop-core-0.20.203.0.jar;C:\lindan\cassandra-ld\build\lib\jars\hsqldb-1.8.0.10.jar;C:\lindan\cassandra-ld\build\lib\jars\jasper-compiler-5.5.12.jar;C:\lindan\cassandra-ld\build\lib\jars\jasper-runtime-5.5.12.jar;C:\lindan\cassandra-ld\build\lib\jars\jets3t-0.7.1.jar;C:\lindan\cassandra-ld\build\lib\jars\jetty-6.1.26.jar;C:\lindan\cassandra-ld\build\lib\jars\jetty-util-6.1.26.jar;C:\lindan\cassandra-ld\build\lib\jars\jna-3.2.7.jar;C:\lindan\cassandra-ld\build\lib\jars\jopt-simple-3.2.jar;C:\lindan\cassandra-ld\build\lib\jars\jsp-2.1-6.1.14.jar;C:\lindan\cassandra-ld\build\lib\jars\jsp-api-2.1-6.1.14.jar;C:\lindan\cassandra-ld\build\lib\jars\junit-4.6.jar;C:\lindan\cassandra-ld\build\lib\jars\kfs-0.3.jar;C:\lindan\cassandra-ld\build\lib\jars\oro-2.0.8.jar;C:\lindan\cassandra-ld\build\lib\jars\paranamer-ant-2.1.jar;C:\lindan\cassandra-ld\build\lib\jars\paranamer-generator-2.1.jar;C:\lindan\cassandra-ld\build\lib\jars\qdox-1.10.jar;C:\lindan\cassandra-ld\build\lib\jars\servlet-api-2.5-20081211.jar;C:\lindan\cassandra-ld\build\lib\jars\servlet-api-2.5-6.1.14.jar;C:\lindan\cassandra-ld\build\lib\jars\xmlenc-0.52.jar
INFO 15:54:42,440 Unable to link C library. Native methods will be disabled.
INFO 15:54:42,455 Loading settings from file:C:/lindan/cassandra-ld/conf/cassandra.yaml
INFO 15:54:42,634 DiskAccessMode 'auto' determined to be standard, indexAccessMode is standard
INFO 15:54:42,650 Global memtable threshold is enabled at 338MB
INFO 15:54:43,276 Couldn't detect any schema definitions in local storage.
INFO 15:54:43,277 Found table data in data directories. Consider using the CLI to define your schema.
INFO 15:54:43,297 No commitlog files found; skipping replay
INFO 15:54:43,304 Cassandra version: 1.1-dev-SNAPSHOT
INFO 15:54:43,305 Thrift API version: 19.19.0
INFO 15:54:43,305 Loading persisted ring state
INFO 15:54:43,311 Starting up server gossip
INFO 15:54:43,340 Enqueuing flush of Memtable-LocationInfo@12273995(126/157 serialized/live bytes, 3 ops)
INFO 15:54:43,342 Writing Memtable-LocationInfo@12273995(126/157 serialized/live bytes, 3 ops)
INFO 15:54:43,686 Completed flushing C:\lindan\cassandraData\data\system\LocationInfo-hc-1-Data.db (234 bytes)
INFO 15:54:43,719 Starting Messaging Service on port 7000
INFO 15:54:43,727 This node will not auto bootstrap because it is configured to be a seed node.
WARN 15:54:44,108 Generated random token 54250380678275102317396627807575728052. Random tokens will result in an unbalanced ring; see http://wiki.apache.org/cassandra/Operations
INFO 15:54:44,160 Enqueuing flush of Memtable-LocationInfo@18615648(53/66 serialized/live bytes, 2 ops)
INFO 15:54:44,161 Writing Memtable-LocationInfo@18615648(53/66 serialized/live bytes, 2 ops)
INFO 15:54:44,742 Completed flushing C:\lindan\cassandraData\data\system\LocationInfo-hc-2-Data.db (163 bytes)
INFO 15:54:44,773 Node localhost/127.0.0.1 state jump to normal
INFO 15:54:44,783 Bootstrap/Replace/Move completed! Now serving reads.
INFO 15:54:44,783 Will not load MX4J, mx4j-tools.jar is not in the classpath
INFO 15:54:44,855 Binding thrift service to localhost/127.0.0.1:9160
INFO 15:54:44,867 Using TFastFramedTransport with a max frame size of 15728640 bytes.
INFO 15:54:44,874 Using synchronous/threadpool thrift server on localhost/127.0.0.1 : 9160
INFO 15:54:44,875 Listening for thrift clients...
posted on 2011-12-07 19:13 lindan_xmu 阅读(1840) 评论(3) 编辑 收藏 举报