cassandra 客户端命令操作流程:
具体流程:
首先,启动cassandra:
进入安装目录,使用命令:bin/cassandra
然后,连接到一个节点上:
|
$ ./cassandra-cli -host localhost -port 9160 Connected to: "Test Cluster" on localhost/9160
Welcome to cassandra CLI. Type 'help;' or '?' for help. Type 'quit;' or 'exit;' to quit.
|
之后创建一个key space和CF:
|
[ default @unknown] create keyspace twissandra with replication_factor=1
and placement_strategy= 'org.apache.cassandra.locator.SimpleStrategy' ;
[ default @unknown] use twissandra;
Authenticated to keyspace: twissandra ------------ ... schemas agree across the cluster [ default @twissandra] create column family users with comparator = UTF8Type;
c21f48d5-8748-11e0-8afd-e700f669bcfc Waiting for schema agreement...
... schemas agree across the cluster [ default @twissandra] set users[ 'Bob' ][ 'phone' ]= '1251892983' ;
Value inserted. [ default @twissandra] set users[ 'Bob' ][ 'address' ]= 'Haidian,Beijing' ;
Value inserted. [ default @twissandra] set users[ 'Bob' ][ 'birthday' ]= '1980-08-09' ;
Value inserted. [ default @twissandra] get users[ 'Bob' ];
=> (column=address, value=4861696469616e2c4265696a696e67, timestamp=1306380804182000) => (column=birthday, value=313938302d30382d3039, timestamp=1306380831152000) => (column=phone, value=31323531383932393833, timestamp=1306380777399000) Returned 3 results. |
评论