首页 > 代码库 > Hello Cassandra
Hello Cassandra
QuickStart
$ cd soft/apache-cassandra-2.1.2
$ bin/cassandra
上面的命令会在后台启动cassandra, 即使你Ctl+C, cassandra的进程仍然存在
初次启动时, 不存在data目录, cassandra会帮我们创建
hadoop@hadoop:~/soft/apache-cassandra-2.1.2$ jps -lm
9635 sun.tools.jps.Jps -lm
8139 org.jetbrains.idea.maven.server.RemoteMavenServer
9520 org.apache.cassandra.service.CassandraDaemon
hadoop@hadoop:~/soft/apache-cassandra-2.1.2$ pkill -f CassandraDaemon
hadoop@hadoop:~/soft/apache-cassandra-2.1.2$ jps -lm
9665 sun.tools.jps.Jps -lm
前台方式启动: 当中断当前窗口时, cassandra进程就会结束
$ bin/cassandra -f
cqlsh查询交互
nodetool工具使用
quick-start demo日志
INFO 02:38:32 Create new Keyspace: KSMetaData{name=mykeyspace, strategyClass=SimpleStrategy, strategyOptions={replication_factor=1}, cfMetaData=http://www.mamicode.com/{}, durableWrites=true, userTypes=org.apache.cassandra.config.UTMetaData@6aacf99a}
INFO 02:38:32 Enqueuing flush of schema_keyspaces: 955 (0%) on-heap, 0 (0%) off-heap
INFO 02:38:32 Writing Memtable-schema_keyspaces@1970062192(251 serialized bytes, 7 ops, 0%/0% of on/off-heap limit)
INFO 02:38:32 Completed flushing /home/hadoop/soft/apache-cassandra-2.1.2/data/data/system/schema_keyspaces-b0f2235744583cdb9631c43e59ce3676/system-schema_keyspaces-ka-2-Data.db (219 bytes) for commitlog position ReplayPosition(segmentId=1418092448594, position=99620)
INFO 02:38:53 Create new ColumnFamily: org.apache.cassandra.config.CFMetaData@6f7b1c0b[cfId=83b33780-7f4c-11e4-ae5d-4d9bbe2972d1,ksName=mykeyspace,cfName=users,cfType=Standard,comparator=org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.UTF8Type),comment=,readRepairChance=0.0,dcLocalReadRepairChance=0.1,gcGraceSeconds=864000,defaultValidator=org.apache.cassandra.db.marshal.BytesType,keyValidator=org.apache.cassandra.db.marshal.Int32Type,minCompactionThreshold=4,maxCompactionThreshold=32,columnMetadata=http://www.mamicode.com/[ColumnDefinition{name=lname, type=org.apache.cassandra.db.marshal.UTF8Type, kind=REGULAR, componentIndex=0, indexName=null, indexType=null}, ColumnDefinition{name=user_id, type=org.apache.cassandra.db.marshal.Int32Type, kind=PARTITION_KEY, componentIndex=null, indexName=null, indexType=null}, ColumnDefinition{name=fname, type=org.apache.cassandra.db.marshal.UTF8Type, kind=REGULAR, componentIndex=0, indexName=null, indexType=null}],compactionStrategyClass=class org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy,compactionStrategyOptions={},compressionParameters={sstable_compression=org.apache.cassandra.io.compress.LZ4Compressor},bloomFilterFpChance=0.01,memtableFlushPeriod=0,caching={"keys":"ALL", "rows_per_partition":"NONE"},defaultTimeToLive=0,minIndexInterval=128,maxIndexInterval=2048,speculativeRetry=99.0PERCENTILE,droppedColumns={},triggers=[],isDense=false]
INFO 02:38:53 Initializing mykeyspace.users
INFO 02:39:28 Compacting [SSTableReader(path=‘/home/hadoop/soft/apache-cassandra-2.1.2/data/data/system/schema_keyspaces-b0f2235744583cdb9631c43e59ce3676/system-schema_keyspaces-ka-4-Data.db‘), SSTableReader(path=‘/home/hadoop/soft/apache-cassandra-2.1.2/data/data/system/schema_keyspaces-b0f2235744583cdb9631c43e59ce3676/system-schema_keyspaces-ka-2-Data.db‘), SSTableReader(path=‘/home/hadoop/soft/apache-cassandra-2.1.2/data/data/system/schema_keyspaces-b0f2235744583cdb9631c43e59ce3676/system-schema_keyspaces-ka-1-Data.db‘), SSTableReader(path=‘/home/hadoop/soft/apache-cassandra-2.1.2/data/data/system/schema_keyspaces-b0f2235744583cdb9631c43e59ce3676/system-schema_keyspaces-ka-3-Data.db‘)]
INFO 02:39:28 Completed flushing /home/hadoop/soft/apache-cassandra-2.1.2/data/data/system/schema_columnfamilies-45f5b36024bc3f83a3631034ea4fa697/system-schema_columnfamilies-ka-4-Data.db (864 bytes) for commitlog position ReplayPosition(segmentId=1418092448594, position=105542)
INFO 02:39:28 Compacting [SSTableReader(path=‘/home/hadoop/soft/apache-cassandra-2.1.2/data/data/system/schema_columnfamilies-45f5b36024bc3f83a3631034ea4fa697/system-schema_columnfamilies-ka-3-Data.db‘), SSTableReader(path=‘/home/hadoop/soft/apache-cassandra-2.1.2/data/data/system/schema_columnfamilies-45f5b36024bc3f83a3631034ea4fa697/system-schema_columnfamilies-ka-2-Data.db‘), SSTableReader(path=‘/home/hadoop/soft/apache-cassandra-2.1.2/data/data/system/schema_columnfamilies-45f5b36024bc3f83a3631034ea4fa697/system-schema_columnfamilies-ka-4-Data.db‘), SSTableReader(path=‘/home/hadoop/soft/apache-cassandra-2.1.2/data/data/system/schema_columnfamilies-45f5b36024bc3f83a3631034ea4fa697/system-schema_columnfamilies-ka-1-Data.db‘)]
INFO 02:39:28 Enqueuing flush of schema_columns: 1962 (0%) on-heap, 0 (0%) off-heap
INFO 02:39:28 Writing Memtable-schema_columns@2010850686(265 serialized bytes, 7 ops, 0%/0% of on/off-heap limit)
INFO 02:39:28 Compacted 4 sstables to [/home/hadoop/soft/apache-cassandra-2.1.2/data/data/system/schema_keyspaces-b0f2235744583cdb9631c43e59ce3676/system-schema_keyspaces-ka-5,]. 761 bytes to 259 (~34% of original) in 275ms = 0.000898MB/s. 6 total partitions merged to 3. Partition merge counts were {1:1, 2:1, 3:1, }
INFO 02:39:28 Completed flushing /home/hadoop/soft/apache-cassandra-2.1.2/data/data/system/schema_columns-296e9c049bec3085827dc17d3df2122a/system-schema_columns-ka-4-Data.db (241 bytes) for commitlog position ReplayPosition(segmentId=1418092448594, position=105542)
INFO 02:39:28 Compacting [SSTableReader(path=‘/home/hadoop/soft/apache-cassandra-2.1.2/data/data/system/schema_columns-296e9c049bec3085827dc17d3df2122a/system-schema_columns-ka-2-Data.db‘), SSTableReader(path=‘/home/hadoop/soft/apache-cassandra-2.1.2/data/data/system/schema_columns-296e9c049bec3085827dc17d3df2122a/system-schema_columns-ka-3-Data.db‘), SSTableReader(path=‘/home/hadoop/soft/apache-cassandra-2.1.2/data/data/system/schema_columns-296e9c049bec3085827dc17d3df2122a/system-schema_columns-ka-4-Data.db‘), SSTableReader(path=‘/home/hadoop/soft/apache-cassandra-2.1.2/data/data/system/schema_columns-296e9c049bec3085827dc17d3df2122a/system-schema_columns-ka-1-Data.db‘)]
INFO 02:39:28 Compacted 4 sstables to [/home/hadoop/soft/apache-cassandra-2.1.2/data/data/system/schema_columnfamilies-45f5b36024bc3f83a3631034ea4fa697/system-schema_columnfamilies-ka-5,]. 14,024 bytes to 6,931 (~49% of original) in 303ms = 0.021815MB/s. 5 total partitions merged to 3. Partition merge counts were {1:1, 2:2, }
INFO 02:39:28 Initializing mykeyspace.users.users_lname_idx
INFO 02:39:28 Submitting index build of users.users_lname_idx for data in SSTableReader(path=‘/home/hadoop/soft/apache-cassandra-2.1.2/data/data/mykeyspace/users-83b337807f4c11e4ae5d4d9bbe2972d1/mykeyspace-users-ka-1-Data.db‘)
INFO 02:39:29 Index build of users.users_lname_idx complete
Hello Cassandra