1. 从apache官网下载Cassandra,我用的版本是2.1.8。压缩包解压,这里的目录是D:cassandraapache-cassandra-2.1.8
2. 配置环境变量
添加环境变量CASSANDRA_HOME,值为D:cassandraapache-cassandra-2.1.8,环境变量path后面添加%CASSANDRA_HOME%in
3. 修改配置文件 conf/cassandra.yaml
data_file_directories: D:cassandradata
commitlog_directory: D:cassandracommitlog
saved_caches_directory: D:cassandrasaved_caches
原来的是:
# Directories where Cassandra should store data on disk. Cassandra # will spread data evenly across them, subject to the granularity of # the configured compaction strategy. # If not set, the default directory is $CASSANDRA_HOME/data/data. # data_file_directories: # - /var/lib/cassandra/data # commit log. when running on magnetic HDD, this should be a # separate spindle than the data directories. # If not set, the default directory is $CASSANDRA_HOME/data/commitlog. # commitlog_directory: /var/lib/cassandra/commitlog # saved caches # If not set, the default directory is $CASSANDRA_HOME/data/saved_caches. # saved_caches_directory: /var/lib/cassandra/saved_caches
4. 修改conf/logback.xml
将${cassandra.logdir} 改为你想要存放的位置,我的是 D:cassandralogsystem.log
5.修改Cassandra.bat文件
找到下面这部分
REM ----------------------------------------------------------------------------- REM JVM Opts we'll use in legacy run or installation set JAVA_OPTS=-ea^ -javaagent:"%CASSANDRA_HOME%libjamm-0.3.0.jar"^ -Xms2G^ -Xmx2G^ -XX:+HeapDumpOnOutOfMemoryError^ -XX:+UseParNewGC^ -XX:+UseConcMarkSweepGC^ -XX:+CMSParallelRemarkEnabled^ -XX:SurvivorRatio=8^ -XX:MaxTenuringThreshold=1^ -XX:CMSInitiatingOccupancyFraction=75^ -XX:+UseCMSInitiatingOccupancyOnly^ -Dlogback.configurationFile=logback.xml^ -Dcassandra.jmx.local.port=7199
修改-Xms2G^和-Xmx2G^为适合你机器的大小,我改为 -Xms512M^和Xmx512M^
如果上面不改,可能会由于内存不足而启动失败:
Could not reserve enough space for 2097152KB object heap
6. 启动
进入命令行,输入cassandra,看到下图则启动成功
参考资料:
NoSql之旅--Cassandra安装篇(一): http://www.cnblogs.com/chyu/p/4600183.html