使用 Amazon Keyspaces 中的键空间 - Amazon Keyspaces(Apache Cassandra 兼容)
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用 Amazon Keyspaces 中的键空间

本节详细介绍如何使用 Amazon Keyspaces(Apache Cassandra 兼容)中的键空间。

使用 Amazon Keyspaces 中的系统键空间

Amazon Keyspaces 使用四个系统键空间:

  • system

  • system_schema

  • system_schema_mcs

  • system_multiregion_info

以下各节详细介绍了 Amazon Keyspaces 支持的系统密钥空间和系统表。

system

这是一个 Cassandra 键空间。Amazon Keyspaces 使用以下表。

表名称 列名称 注释

local

key, bootstrapped, broadcast_address, cluster_name, cql_version, data_center, gossip_generation, host_id, listen_address, native_protocol_version, partitioner, rack, release_version, rpc_address, schema_version, thrift_version, tokens, truncated_at

有关本地键空间的信息。

peers

peer, data_center, host_id, preferred_ip, rack, release_version, rpc_address, schema_version, tokens

查询此表可查看可用的端点。例如,如果您通过公共终端节点进行连接,则会看到包含九个可用 IP 地址的列表。如果您通过 FIPS 端点进行连接,则会看到三个 IP 地址的列表。如果您通过 Amazon PrivateLink VPC 终端节点进行连接,则会看到已配置的 IP 地址列表。有关更多信息,请参阅使用接口 VPC 端点信息填充 system.peers 表条目

size_estimates

keyspace_name, table_name, range_start, range_end, mean_partition_size, partitions_count

此表定义了每个表的每个令牌范围的总大小和分区数。Apache Cassandra Spark Connector 需要此表,它使用估算的分区大小来分配工作。

prepared_statements

prepared_id, logged_keyspace, query_string

此表包含有关已保存查询的信息。

system_schema

这是一个 Cassandra 键空间。Amazon Keyspaces 使用以下表。

表名称 列名称 注释

keyspaces

keyspace_name, durable_writes, replication

有关特定键空间的信息。

tables

keyspace_name, table_name, bloom_filter_fp_chance, caching, comment, compaction, compression, crc_check_chance, dclocal_read_repair_chance, default_time_to_live, extensions, flags, gc_grace_seconds, id, max_index_interval, memtable_flush_period_in_ms, min_index_interval, read_repair_chance, speculative_retry

有关特定表的信息。

columns

keyspace_name, table_name, column_name, clustering_order, column_name_bytes, kind, position, type

有关特定列的信息。

system_schema_mcs

这是一个 Amazon Keyspaces 密钥空间,用于存储有关或 Amazon 亚马逊密钥空间特定设置的信息。

表名称 列名称 注释

keyspaces

keyspace_name, durable_writes, replication

查询此表可以编程方式了解是否已创建键空间。有关更多信息,请参阅在 Amazon Keyspaces 中创建键空间

tables

keyspace_name, creation_time, speculative_retry, cdc, gc_grace_seconds, crc_check_chance, min_index_interval, bloom_filter_fp_chance, flags, custom_properties, dclocal_read_repair_chance, table_name, caching, default_time_to_live, read_repair_chance, max_index_interval, extensions, compaction, comment, id, compression, memtable_flush_period_in_ms, status

查询此表可了解特定表的状态。有关更多信息,请参阅在 Amazon Keyspaces 中创建表

您也可以查询此表,列出特定于 Amazon Keyspaces 且存储为的设置。custom_properties例如:

  • capacity_mode

  • client_side_timestamps

  • encryption_specification

  • point_in_time_recovery

  • ttl

tables_history

keyspace_name, table_name, event_time, creation_time, custom_properties, event

查询此表可了解特定表的模式更改。

columns

keyspace_name, table_name, column_name, clustering_order, column_name_bytes, kind, position, type

此表与 system_schema 键空间中的 Cassandra 表相同。

tags

resource_id, keyspace_name, resource_name, resource_type, tags

查询此表可了解键空间是否具有标签。有关更多信息,请参阅使用 CQL 向新的或现有的键空间和表添加标签

autoscaling

keyspace_name, table_name, provisioned_read_capacity_autoscaling_update, provisioned_write_capacity_autoscaling_update

查询此表以获取已配置表的 auto Scaling 设置。请注意,在表格处于活动状态之前,这些设置才可用。要查询此表,必须在 WHERE 子句中指定 keyspace_nametable_name。有关更多信息,请参阅使用 Cassandra 查询语言 (CQL) 管理 Amazon Keyspaces 自动扩展

system_multiregion_info

这是一个 Amazon Keyspaces 键空间,用于存储有关多区域复制的信息。

表名称 列名称 注释

tables

keyspace_name, table_name, region, status

此表包含有关多区域表的信息,例如,复制 Amazon Web Services 区域 该表的位置和表的状态。您也可以查询此表,列出存储为 Amazon Keyspaces 的特定设置。custom_properties例如:

  • capacity_mode

要查询此表,必须在 WHERE 子句中指定 keyspace_nametable_name。有关更多信息,请参阅创建多区域键空间 (CQL)

autoscaling

keyspace_name, table_name, provisioned_read_capacity_autoscaling_update, provisioned_write_capacity_autoscaling_update, region

查询此表以获取多区域预配置表的 auto scaling 设置。请注意,在表格处于活动状态之前,这些设置才可用。要查询此表,必须在 WHERE 子句中指定 keyspace_nametable_name。有关更多信息,请参阅使用 CQL 创建和管理多区域表

在 Amazon Keyspaces 中创建键空间

Amazon Keyspaces 以异步方式执行数据定义语言 (DDL) 操作,例如创建和删除键空间。

您可以在中监控新密钥空间的创建状态 Amazon Web Services Management Console,该状态会指示密钥空间何时处于待处理状态或处于活动状态。您还可以使用 system_schema_mcs 键空间以编程方式监控新键空间的创建状态。当密钥空间准备就绪可供使用时,system_schema_mcskeyspaces表中就会变为可见。

要检查新键空间何时可供使用,推荐的设计模式是轮询 Amazon Keyspaces system_schema_mcs keyspaces 表 (system_schema_mcs.*)。有关键空间的 DDL 语句列表,请参阅 CQL 语言参考中的Keyspaces部分。

以下查询显示是否已成功创建键空间。

SELECT * FROM system_schema_mcs.keyspaces WHERE keyspace_name = 'mykeyspace';

对于已成功创建的密钥空间,查询的输出如下所示。

keyspace_name | durable_writes | replication --------------+-----------------+-------------- mykeyspace | true |{...} 1 item