您的位置:首页 > 其它

Install Cassandra on windows

2016-05-25 16:28 232 查看
1. Prerequisites: install latest
JRE and an unzip utility that supports tar files.
Make sure that you've lasted 64bit JRE installed JRE in your machine. JRE version as following:

2. Download Cassandra from: http://www.apache.org/dyn/closer.lua/cassandra/3.5/apache-cassandra-3.5-bin.tar.gz (or latest version)

The alternate download site is http://cassandra.apache.org/download/
3. Use the unzip tool to extract tar.gz to local disk, such as c:\Cassandra,

Once it is extracted as apache-cassandra-3.5-bin.tar, extract it again.

Once the extraction is completed, you will see the following folders.

4. Change the 2 environment variables in either the
Cassandra.bat file or in windows (add system environment):

SET JAVA_HOME=C:\Program Files\Java\jre1.8.0_74\

SET CASSANDRA_HOME=C:\Cassandra\apache-cassandra-3.5

Or

5. Change optionally the output directories by editing files in conf directory:

(Note: need create data, commitlog folder in root folder, otherwise Cassandra can't start. )

a. Cassandra.yaml:

data_file_directories:

- c:/cassandra/apache-cassandra-2.0.9/data

commitlog_directory: c:/cassandra/apache-cassandra-2.0.9/commitlog

6. Start Cassandra Service.

Go to the bin directory and execute the "cassandra.bat" file using a command prompt. Always run the command window with "Run as administrator",
\bin>cassandra

You'll get the following screen if everything worked fine.

(If you don't see any error or fatal log messages or Java stack traces, then chances are you've succeeded.) Before running "cassandra.bat", make sure you're "JAVA_HOME" and "CASSANDRA_HOME" variable is created.

You can check as below:

Close the current cmd window to stop Cassandra service;

7. Using the nodetool to check whether Cassandra is started:
bin>nodetool -h localhost status

8. Start Cassandra Client: bin>cqlsh, if can't start, need install python first

9. Download python for windows: https://www.python.org/downloads/windows/ .

10. Install Python and set path in system environment.

11. Execute the step 7), if still can't start, set the path of python in
cqlsh.bat

12. Run cqlsh:

13. Operate Cassandra using CQL:

Refer to CQL help document: http://cassandra.apache.org/doc/cql3/
14. Using Cassandra in VS: Install package in VS: Install-Package CassandraCSharpDriver (note need open a solution)

usingglobal::Cassandra;



string keyspaceName =
"analytics";

Cluster cluster =
Cluster.Builder().AddContactPoint("127.0.0.1").Build();

ISession session = cluster.Connect(keyspaceName);

var result = session.Execute("select count(*) from users").First();

Console.WriteLine(string.Format("{0}
records in table", result[0]));

Q & A:If Cassandra cannot be started because JVM cannot reserve enough space, install the latest 64-bit JRE on your machine.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: