【发布时间】:2023-04-06 18:22:01
【问题描述】:
我可以使用什么 cqlsh 命令来快速查看集群中的键空间? cqlsh 不提供show keyspaces 和describe cluster 没有我想要的简洁。
我正在使用以下规范:
cqlsh 2.2.0、Cassandra 1.1.10、CQL 规范 2.0.0、Thrift 协议 19.33.0
【问题讨论】:
我可以使用什么 cqlsh 命令来快速查看集群中的键空间? cqlsh 不提供show keyspaces 和describe cluster 没有我想要的简洁。
我正在使用以下规范:
cqlsh 2.2.0、Cassandra 1.1.10、CQL 规范 2.0.0、Thrift 协议 19.33.0
【问题讨论】:
非常简单。只需在您的 cqlsh shell 中输入此命令即可享受
select * from system.schema_keyspaces;
在 C*3.x 中,我们可以简单地使用
describe keyspaces
【讨论】:
试试这个:
describe keyspaces
不过,您可能需要大约以下规格(而不是自己 those mentioned Crowie)
[cqlsh 4.1.1 |卡桑德拉 2.0.6 | CQL 规范 3.1.1 | Thrift 协议 19.39.0]
【讨论】:
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'}
【讨论】:
Cassandra 3.0。您可以使用以下查询验证您的版本:SELECT release_version from system.local; 参考:Querying from system.schema_keyspaces generates code=2200
C* 3.x 系列的正确做法是:
List<KeyspaceMetadata> keyspaces = Cluster.getMetadata().getKeyspaces()
然后在 KeyspaceMetadata 实例上使用getName()。
【讨论】: