3:关闭cassandra的进程
$ /opt/cassandra/bin/nodetool stopdaemon
Cassandra has shutdown.
error: Connection refused
-- StackTrace --
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
4:查看各个列的数据详细信息、读写次数,响应时间等
$ /opt/cassandra/bin/nodetool cfstats
Keyspace: system_traces
Read Count: 0
Read Latency: NaN ms.
Write Count: 0
Write Latency: NaN ms.
Pending Flushes: 0
Table: events
SSTable count: 0
Space used (live): 0
Space used (total): 0
Space used by snapshots (total): 0
Off heap memory used (total): 0
SSTable Compression Ratio: 0.0
Number of keys (estimate): 0
Memtable cell count: 0
Memtable data size: 0
Memtable off heap memory used: 0
Memtable switch count: 0
(2)cqlsh 命令行工具
cqlsh是cassandra的客户端命令行工具,替代了之前版本中的cassandra-cli,能实现对数据的增删改查等一些列的操作。
$ /opt/cassandra/bin/cqlsh
Usage: cqlsh [options] [host [port]]
CQL Shell for Apache Cassandra
1:安装Python2.7(依赖python)
$ yum install openssl-devel #防止python编译后没有ssl模块,导致cqlsh不可用
$ wget https://www.python.org/ftp/python/2.7/Python-2.7.tgz
$ tar xf Python-2.7.tgz
$ cd Python-2.7
$ mkdir /usr/local/python27
$ ./configure --prefix=/usr/local/python27
$ make&&make install
$ ln -s /usr/local/python27/bin/python2.7 /usr/bin/python2.7
如果遇到 ImportError: No module named _ssl ,就安装openssl-devel,然后再编译安装python
spacer.gif
2:连接host
$ /opt/cassandra/bin/cqlsh 10.10.8.3 9042
Connected to My Cluster at 10.10.8.3:9042.
[cqlsh 5.0.1 | Cassandra 3.0.9 | CQL spec 3.4.0 | Native protocol v4]
Use HELP for help.
cqlsh> show version
[cqlsh 5.0.1 | Cassandra 3.0.9 | CQL spec 3.4.0 | Native protocol v4]
cqlsh> show host
Connected to My Cluster at 10.10.8.3:9042.
3:help命令可以看到 CQL数据操作语言的相关命令
cqlsh> help
Documented shell commands:
===========================
CAPTURE CLS COPY DESCRIBE EXPAND LOGIN SERIAL SOURCE UNICODE
CLEAR CONSISTENCY DESC EXIT HELP PAGING SHOW TRACING
CQL help topics:
================
AGGREGATES CREATE_KEYSPACE DROP_TRIGGER TEXT
ALTER_KEYSPACE CREATE_MATERIALIZED_VIEW DROP_TYPE TIME
ALTER_MATERIALIZED_VIEW CREATE_ROLE DROP_USER TIMESTAMP
ALTER_TABLE CREATE_TABLE FUNCTIONS TRUNCATE
ALTER_TYPE CREATE_TRIGGER GRANT TYPES
ALTER_USER CREATE_TYPE INSERT UPDATE
APPLY CREATE_USER INSERT_JSON USE
ASCII DATE INT UUID
BATCH DELETE JSON
BEGIN DROP_AGGREGATE KEYWORDS
BLOB DROP_COLUMNFAMILY LIST_PERMISSIONS
BOOLEAN DROP_FUNCTION LIST_ROLES
COUNTER DROP_INDEX LIST_USERS
CREATE_AGGREGATE DROP_KEYSPACE PERMISSIONS
CREATE_COLUMNFAMILY DROP_MATERIALIZED_VIEW REVOKE
CREATE_FUNCTION DROP_ROLE SELECT
CREATE_INDEX DROP_TABLE SELECT_JSON
cqlsh>