zhouying23 发表于 2017-7-2 13:03:57

cassandra command lines

  1. create keyspace



>>create keyspace packt
with replication =
{'class':'SimpleStrategy','replication_factor':1}
  2. create table



>>use packt;
>>create table stock_ticker_by_exchange_date {
exchange   varchar,
symbol       varchar,
descriptionvarchar,
tick_date    varchar,
close      decimal,
primary key ((exchange,tick_date), symbol)   
}
  exchange, tick_date 两个字段作为row key / partition key;
  exchange, tick_date, symbol 3个字段作为(compound)primary key,复合主键,称之为wide row;单列主键,称之为skinny row。
  默认primary key第一个字段作为row key。
  3. cassandra特有的支持集合数据类型
  在一个字段中存放小量的数据集,支持set,list,map格式。
  4. 创建二级索引



create index dayquote06_sector_idx on dayqoute06(sector)
  5. load SSTable



sstableloader -d ubtc01 packtcdma/qutoe
  6. nodetool



#cluster status
nodetool status
nodetool netstats
nodetool info
nodetool tpstats
nodetool cfstats
#take snapshot
nodetool snapshot packtcdma
nodetool tablestats #keyspace#.#table#
  7. tables



describe tables;
describe #table_name#
页: [1]
查看完整版本: cassandra command lines