Вы находитесь на странице: 1из 4

Running Cassandra on Eclipse(Juno).

Prerequisites:

1. Eclipse. It can be downloaded from http://www.eclipse.org/downloads/. "Eclipse IDE for Java


Developers" is ok.

2. JDK6 http://www.oracle.com/technetwork/java/javase/downloads/jdk6downloads-1902814.html
3. Ant http://ant.apache.org/
4. Git http://git-scm.com/download/win
Please set JAVA_HOME, ANT_HOME and CASSANDRA_HOME
I used WINDOWS as an operating system.
Check out Cassandra code:
1. From the command prompt, check-out the latest code using Git.
2. git clone http://git-wip-us.apache.org/repos/asf/cassandra.git cassandra-trunk
3. Build the code.
4. cd cassandra-trunk
5. ant build
6. ant generate-eclipse-files

7. If the command successfully runs, code build is done.


Setup code in Eclipse:

1. Start eclipse and create a new Java Project.


2. Enter "cassandra-trunk" as the project name.
3. Untick "Use default location" and browse to the top-level folder you just checked out (cassandratrunk).

4. Click "Next"
5. Verify that the Default Output Folder is cassandra-trunk/build/classes/main. Eclipse normally
defaults to bin which we DO NOT want for Cassandra.

6. Click "Finish"

7. If there is no error the our work is done.


Basic Configurations:The Cassandra configuration files can be found in the conf directory of binary and
source distributions.
Directories Used by Cassandra:We have to check the following config settings.
In conf/cassandra.yaml we will find the following configuration options: data_file_directories
(/var/lib/cassandra/data), commitlog_directory (/var/lib/cassandra/commitlog), and
saved_caches_directory (/var/lib/cassandra/saved_caches). We have to make sure these directories exist
and can be written to.
By default, Cassandra will log write its logs in /var/log/cassandra/. Make sure this directory exists and is
writeable, or change this line in conf/log4j-server.properies:
log4j.appender.R.File=/var/log/cassandra/system.log

Run Cassandra:
Click "Run" -> "Run Configurations...". Select org.apache.cassandra.thrift.CassandraDaemon as you
Main class, make sure that your cassandra project is selected in the "Project" field. Under the Arguments
tab you can specify VM arguments. Below are VM arguments for running Cassandra 0.7+ in Windows.
-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
or
-Dcassandra.config=file:/home/david/programming/java/cassandra/conf/cassandra.yaml
-Dcassandra-foreground
-ea -Xmx1G
-Dlog4j.configuration=file:/home/david/programming/java/cassandra/conf/log4j-server.properties
That should be it. After running the newly created run configuration you should see something like this in
the console view.
INFO 01:22:15,227 Log replay complete, 12 replayed mutations
INFO 01:22:16,025 Cassandra version: Unknown
INFO 01:22:16,025 Thrift API version: 19.36.0
INFO 01:22:16,041 CQL supported versions: 2.0.0,3.0.1 (default: 3.0.1)
INFO 01:22:16,182 Loading persisted ring state
INFO 01:22:16,182 Starting up server gossip
INFO 01:22:16,213 Enqueuing flush of Memtable-local@873551122(253/253 serialized/live bytes, 9 ops)
INFO 01:22:16,213 Writing Memtable-local@873551122(253/253 serialized/live bytes, 9 ops)
INFO 01:22:16,416 Completed flushing data\cassandra\data\system\local\system-local-ic-123-Data.db (246 bytes) for commitlog position
ReplayPosition(segmentId=1362216132917, position=58913)
INFO 01:22:16,698 Starting Messaging Service on port 7000
INFO 01:22:16,870 Using saved token [-6159406281237189176]
INFO 01:22:16,870 Enqueuing flush of Memtable-local@1370440457(84/84 serialized/live bytes, 4 ops)
INFO 01:22:16,886 Writing Memtable-local@1370440457(84/84 serialized/live bytes, 4 ops)
INFO 01:22:17,089 Completed flushing data\cassandra\data\system\local\system-local-ic-124-Data.db (124 bytes) for commitlog position
ReplayPosition(segmentId=1362216132917, position=59188)
INFO 01:22:17,089 Enqueuing flush of Memtable-local@673795938(51/51 serialized/live bytes, 2 ops)
INFO 01:22:17,105 Writing Memtable-local@673795938(51/51 serialized/live bytes, 2 ops)
INFO 01:22:17,386 Completed flushing data\cassandra\data\system\local\system-local-ic-125-Data.db (108 bytes) for commitlog position
ReplayPosition(segmentId=1362216132917, position=59363)
INFO 01:22:17,386 Compacting [SSTableReader(path='data\cassandra\data\system\local\system-local-ic-122-Data.db'),
SSTableReader(path='data\cassandra\data\system\local\system-local-ic-125-Data.db'),
SSTableReader(path='data\cassandra\data\system\local\system-local-ic-123-Data.db'),
SSTableReader(path='data\cassandra\data\system\local\system-local-ic-124-Data.db')]
INFO 01:22:17,433 Node localhost/127.0.0.1 state jump to normal
INFO 01:22:17,449 Startup completed! Now serving reads.
INFO 01:22:17,606 Not starting native transport as requested. Use JMX (StorageService->startNativeTransport()) to start it
INFO 01:22:17,621 Binding thrift service to localhost/127.0.0.1:9160
INFO 01:22:17,621 Compacted 4 sstables to [data\cassandra\data\system\local\system-local-ic-126,]. 1,016 bytes to 558 (~54% of original)
in 220ms = 0.002419MB/s. 4 total rows, 1 unique. Row merge counts were {1:0, 2:0, 3:0, 4:1, }
INFO 01:22:17,699 Using TFramedTransport with a max frame size of 15728640 bytes.
INFO 01:22:17,731 Using synchronous/threadpool thrift server on localhost : 9160
INFO 01:22:17,731 Listening for thrift clients...

===========

Cassandra and Eclipse


To work with Cassandra in eclipse two primary steps are followed 1.Install Cassandra(Windows installation)
2.Install required plugins

Install Cassandra
Steps

First download a stable and current release of Cassandra from here

Extract the zip file in a folder

Set the following environment variables -

PATH=Path to bin folder of jre(E.g. PATH=%PATH%;C:\Program Files\Java\jre6\bin)


JAVA_HOME=Path to the jre folder(E.g. JAVA_HOME= C:\Program Files\Java\jre6)
CASSANDRA_HOME=Path to the extracted cassandra folder(E.g. D:\apachecassandra-1.1.2)
(To set the variables right click on My Computer->Properties->Change settings->Advanced>Environment Variables)

Go to Command Prompt and the extracted Cassandra folder->bin directory

Starting Server - Type cassandra and execute. The Cassandra Server should start working
without any Java exceptions and you should see something like "listening to thrift clients
at the end....."

Starting Client - Again open command prompt and go to bin folder and execute
cassandra.cli. This should start the client instance.

Type connect 127.0.0.1/9160 which should give connected to "Test Cluster" message

You can execute Cassandra commands now.....

Install required plugins


Steps

Open Eclipse editor

Goto Help->Eclipse Marketplace

Search for Maven Integration for Eclipse and Install it.

Create a new Maven Project.

Modify the pom.xml file (search google)

Start coding.....

Вам также может понравиться