2013-05-17 17 views
40

Quale comando cqlsh posso utilizzare per visualizzare rapidamente gli spazi delle chiavi in ​​un cluster? cqlsh non fornisce show keyspaces e describe cluster non è così conciso come voglio.Esiste un chiaro equivalente di "show keyspaces" in cqlsh 2?


sto lavorando con le seguenti specifiche:

cqlsh 2.2.0, 1.1.10 Cassandra, CQL spec 2.0.0, protocollo Thrift 19.33.0

risposta

85

Molto semplice . Basta inserire questo comando nella shell cqlsh e godere

select * from system.schema_keyspaces; 

In C * 3.x, possiamo semplicemente usare

describe keyspaces 
+0

scoperto che di istruzioni elencate in fondo a questo: http://www.datastax.com/docs/1.1/dml/using_cql – Crowie

+5

La tabella system.schema_keyspaces sembrano essere stati rimossi da c * 3.x serie – BSB

39

Basta provare questo:

describe keyspaces 


Tuttavia è possibile che richieda specifiche di circa il seguente (anziché lo those mentioned da soli Crowie)

[cqlsh 4.1.1 | Cassandra 2.0.6 | Specifiche CQL 3.1.1 | Protocollo Thrift 19.39.0]

4

Il modo corretto con C * serie 3.x è:

List<KeyspaceMetadata> keyspaces = Cluster.getMetadata().getKeyspaces() 

Quindi utilizzare getName() sulle istanze KeyspaceMetadata.

7
cqlsh> select * from system_schema.keyspaces; 

keyspace_name  | durable_writes | replication 
--------------------+----------------+------------------------------------------------------------------------------------- 
     system_auth |   True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '1'} 
     system_schema |   True |        {'class': 'org.apache.cassandra.locator.LocalStrategy'} 
system_distributed |   True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '3'} 
      system |   True |        {'class': 'org.apache.cassandra.locator.LocalStrategy'} 
     system_traces |   True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '2'} 
Problemi correlati