Cassandra version:apache-cassandra-2.1.3
Os:ubuntu 14.10
Enter Cassandra Command line
$./cassandra-cli
View node Status
$./nodetool Status
Datacenter:datacenter1
=======================
Status=up/down
|/state=normal/leaving/joining/moving
--Address Load Tokens owns Host ID Rack
UN 127.0.0.1 71.23 KB 256? 61129023-a5c0-4331-98ce-7cb24d6ddb28 Rack1
Note:non-system keyspaces don ' t has the same replication settings, effective ownership information is meaningless
Create Keyspace:
[[email protected]] Create Keyspace mykeyspace with strategy_options={replication_factor:1} and placement_strategy = ' Org.apache.cassandra.locator.SimpleStrategy ';
Enter the keyspace you just created:
[[email protected]] use mykeyspace;
Create a column cluster
[[email protected]] Create column family User;
See Keyspace for more information
[[email protected]] describe mykeyspace;
WARNING:CQL3 tables is intentionally omitted from ' describe 'output. See https://issues.apache.org/jira/browse/cassandra-4377 for details.Keyspace:mykeyspace:Replication Strategy:org.apache.cassandra.locator.SimpleStrategy Durable writes:trueOptions: [Replication_factor:1] Column Families:ColumnFamily:User Key Validation Class:org.apache.cassandra.db.marshal.BytesType De Fault column value Validator:org.apache.cassandra.db.marshal.BytesType Cells sorted by:org.apache.cassandra.db.mars Hal. Bytestype GC Grace seconds:864000compaction min/max THRESHOLDS:4/32Read Repair chance:0.0DC Local Read repair chance:0.1caching:keys_only Default time to live:0Bloom Filter FP chance:defaultIndex interval:defaultSpeculative Retry:none Built indexes: [] compaction Strategy:org.apache.cassandra.db.compaction.Size Tieredcompactionstrategy Compression Options:sstable_compression:org.apache.cassandra.io.compress.LZ4Compres Sor
Insert a row of data
[[email protected]] set user[' Me ' [' fname ']= ' Lynch ';
Org.apache.cassandra.serializers.MarshalException:cannot Parse ' fname ' as hex bytes
An error, Khan.
Solve:
[[email protected]] set User[ascii (' Me ')][ascii (' fname ')]=ascii (' Lynch ');
Value inserted.
Elapsed time:133 msec (s).
Number of rows to query column
[[email protected]] count user[ascii (' me ')];
2 cells
Querying the value of a column family
[[email protected]] get User[ascii (' me ')];
= = (name=656d61696c, [email protected], timestamp=1437685470045000)
= = (Name=666e616d65, value=lynch, timestamp=1437685481604000)
Returned 2 results.
Elapsed time:31 msec (s).
To delete a row:
[[email protected]] del user[ascii (' Me ')][ascii (' email ')];
Cell removed.
Elapsed time:32 msec (s).
[[email protected]] get User[ascii (' me ')];
= = (Name=666e616d65, value=lynch, timestamp=1437685481604000)
Returned 1 results.
Elapsed time:2.78 msec (s).
Cassandra Basic Operation