Wednesday, December 29, 2010

[nosql] Cassandra 0.7 Cassandra-CLI example @ Windows

Notice : English is not my mother language, so.... you know it :P

Cassandra-CLI have many change on ver 0.7 , let's talk about it.

- Starting Cassandra-CLI :

Usage: cassandra-cli.bat --host hostname [--port ] [--file ] [--unframed] [--debug] [--username username] [--password password] [--keyspace keyspace] [--batch] [--help]

Example:

cassandra-cli.bat --host localhost --port 9160

If you enabled authentication

Example:
cassandra-cli.bat --host localhost --port 9160 --username jsmith --password havebadpass --keyspace Keyspace1


- Switch keyspace :

Usage: use <keyspace> [<username> 'password'];

Example:
use Keyspace1;


- Create Column Family with the specified attribute :

Usage: create column family <cf> [with <att1>=<value1> [and <att2>=<value2> ...]];

Example: Create standard CF with Secondary indexes on column 'NewsDate'
create column family News with comparator=UTF8Type and column_metadata=[{column_name: Title, validation_class: UTF8Type},{column_name: Body, validation_class: BytesType},{column_name: NewsDate, validation_class: LongType, index_type: KEYS}];

Example: Create a CF with SuperColumn
create column family NewsVote with column_type = Super and comparator = BytesType


At Cassandra 0.7 , you can realtime change your schema by using "create keyspace","update keyspace","create column family","update column family" without shut down Cassandra.

No comments:

Post a Comment