CQL을 사용하여 다중 지역 테이블 생성 및 관리 - Amazon Keyspaces(Apache Cassandra용)

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

CQL을 사용하여 다중 지역 테이블 생성 및 관리

카산드라 쿼리 언어 (CQL) 를 사용하여 Amazon Keyspace에서 멀티 리전 키스페이스와 테이블을 생성하고 관리할 수 있습니다.

이 섹션에서는 CQL을 사용하여 다중 지역 테이블을 생성하고 관리하는 방법에 대한 예를 제공합니다. 다중 리전 키스페이스에서 생성하는 모든 테이블은 키스페이스의 다중 지역 설정을 자동으로 상속합니다. CQL에 대한 자세한 내용은 Amazon Keyspaces CQL 언어 참조를 참조하십시오.

지원되는 구성 및 기능에 대한 자세한 내용은 Amazon Keyspaces 다중 리전 복제 사용 노트 섹션을 참조하세요.

다중 리전 키스페이스 생성(CQL)

다중 리전 키스페이스를 생성하려면 AWS 리전 키스페이스가 복제될 NetworkTopologyStrategy 키스페이스를 지정하는 데 사용하십시오. 현재 리전과 하나 이상의 추가 리전을 포함해야 합니다. 다음 CQL 문은 이에 대한 예입니다.

CREATE KEYSPACE mykeyspace WITH REPLICATION = {'class':'NetworkTopologyStrategy', 'us-east-1':'3', 'ap-southeast-1':'3','eu-west-1':'3' };

키스페이스의 모든 테이블은 키스페이스와 동일한 복제 전략을 사용합니다. 테이블 수준에서는 복제 전략을 변경할 수 없습니다.

NetworkTopologyStrategy— Amazon Keyspace는 기본적으로 동일한 AWS 리전 가용 영역 내 세 개의 가용 영역에 데이터를 복제하기 때문에 각 지역의 복제 인자는 3입니다.

참고

다중 리전 키스페이스를 생성할 때 Amazon Keyspaces는 계정의 이름 AWSServiceRoleForAmazonKeyspacesReplication을 사용하여 서비스 연결 역할을 생성합니다. 이 역할을 통해 Amazon Keyspaces는 사용자를 대신하여 다중 리전 테이블의 모든 복제본에 쓰기를 복제할 수 있습니다. 자세한 내용은 Amazon Keyspaces 다중 리전 복제에 역할 사용를 참조하세요.

CQL 문을 사용하여 system_multiregion_info 키스페이스의 tables 테이블을 쿼리하여 지정한 다중 지역 테이블의 지역과 상태를 프로그래밍 방식으로 나열할 수 있습니다. 다음 코드는 이에 대한 예입니다.

SELECT * from system_multiregion_info.tables WHERE keyspace_name = 'mykeyspace' AND table_name = 'mytable';

명령문의 출력은 다음과 같습니다.

keyspace_name | table_name | region | status ----------------+----------------+----------------+-------- mykeyspace | mytable | us-east-1 | ACTIVE mykeyspace | mytable | ap-southeast-1 | ACTIVE mykeyspace | mytable | eu-west-1 | ACTIVE

기본 설정 (CQL) 이 포함된 다중 지역 테이블 만들기

기본 설정으로 다중 지역 테이블을 만들려면 다음 예제를 사용할 수 있습니다.

CREATE TABLE mykeyspace.mytable(pk int, ck int, PRIMARY KEY (pk, ck)) WITH CUSTOM_PROPERTIES = { 'capacity_mode':{ 'throughput_mode':'PAY_PER_REQUEST' }, 'point_in_time_recovery':{ 'status':'enabled' }, 'encryption_specification':{ 'encryption_type':'AWS_OWNED_KMS_KEY' }, 'client_side_timestamps':{ 'status':'enabled' } };

프로비저닝된 용량 모드 및 CQL (Auto Scaling) 을 사용하여 멀티 리전 테이블 생성

Auto Scaling을 사용하여 프로비저닝 모드에서 멀티 리전 테이블을 생성하려면 먼저 테이블에 CUSTOM_PROPERTIES 대한 정의를 통해 용량 모드를 지정해야 합니다. 프로비저닝된 용량 모드를 지정한 후 를 사용하여 테이블에 대한 Auto Scaling 설정을 구성할 수 있습니다. AUTOSCALING_SETTINGS

Auto Scaling 설정, 대상 추적 정책, 대상 값 및 선택적 설정에 대한 자세한 내용은 을 참조하십시오CQL을 사용하여 자동 크기 조정이 가능한 새 테이블을 생성합니다..

다중 지역 테이블을 생성할 때 테이블의 각 복제본에 대해 서로 다른 읽기 용량과 읽기 Auto Scaling 설정을 지정할 수도 있습니다. 지정한 설정이 지정된 항목에 대한 테이블의 일반 설정을 덮어씁니다. AWS 리전 하지만 쓰기 용량은 모든 지역에서 쓰기를 복제하기에 충분한 용량을 확보할 수 있도록 모든 복제본 간에 동기화된 상태로 유지됩니다.

특정 지역의 테이블 복제본에 대한 읽기 용량을 정의하려면 다음 파라미터를 테이블의 일부로 구성할 수 있습니다. replica_updates

  • 리전

  • 프로비저닝된 읽기 용량 단위 (선택 사항)

  • 읽기 용량 자동 조정 설정 (선택 사항)

다음 예제는 프로비저닝 모드의 다중 지역 테이블에 대한 CREATE TABLE 명령문을 보여줍니다. 일반적인 쓰기 및 읽기 용량 Auto Scaling 설정은 동일합니다. 하지만 읽기 Auto Scaling 설정에서는 테이블의 읽기 용량을 늘리거나 줄이기 전에 60초의 추가 휴지 기간을 지정합니다. 또한 미국 동부 (버지니아 북부) 지역의 읽기 용량 Auto Scaling 설정은 다른 복제본의 읽기 용량 Auto Scaling 설정보다 높습니다. 또한 목표값은 50% 가 아닌 70% 로 설정되어 있습니다.

CREATE TABLE mykeyspace.mytable(pk int, ck int, PRIMARY KEY (pk, ck)) WITH CUSTOM_PROPERTIES = { 'capacity_mode': { 'throughput_mode': 'PROVISIONED', 'read_capacity_units': 5, 'write_capacity_units': 5 } } AND AUTOSCALING_SETTINGS = { 'provisioned_write_capacity_autoscaling_update': { 'maximum_units': 10, 'minimum_units': 5, 'scaling_policy': { 'target_tracking_scaling_policy_configuration': { 'target_value': 50 } } }, 'provisioned_read_capacity_autoscaling_update': { 'maximum_units': 10, 'minimum_units': 5, 'scaling_policy': { 'target_tracking_scaling_policy_configuration': { 'target_value': 50, 'scale_in_cooldown': 60, 'scale_out_cooldown': 60 } } }, 'replica_updates': { 'us-east-1': { 'provisioned_read_capacity_autoscaling_update': { 'maximum_units': 20, 'minimum_units': 5, 'scaling_policy': { 'target_tracking_scaling_policy_configuration': { 'target_value': 70 } } } } } };

멀티 리전 테이블 (CQL) 의 프로비저닝된 용량 및 Auto Scaling 설정 업데이트

를 사용하여 ALTER TABLE 기존 테이블의 용량 모드 및 Auto Scaling 설정을 업데이트할 수 있습니다. 현재 온디맨드 용량 모드인 테이블을 업데이트하려는 경우에는 capacity_mode 필수입니다. 테이블이 이미 프로비저닝된 용량 모드에 있는 경우 이 필드를 생략할 수 있습니다.

Auto Scaling 설정, 대상 추적 정책, 대상 값 및 선택적 설정에 대한 자세한 내용은 을 참조하십시오CQL을 사용하여 자동 크기 조정이 가능한 새 테이블을 생성합니다..

마찬가지로 테이블의 replica_updates 속성을 업데이트하여 특정 리전에 있는 테이블 복제본의 읽기 용량 및 Auto Scaling 설정을 업데이트할 수도 있습니다. 다음 문은 이에 대한 예입니다.

ALTER TABLE mykeyspace.mytable WITH CUSTOM_PROPERTIES = { 'capacity_mode': { 'throughput_mode': 'PROVISIONED', 'read_capacity_units': 1, 'write_capacity_units': 1 } } AND AUTOSCALING_SETTINGS = { 'provisioned_write_capacity_autoscaling_update': { 'maximum_units': 10, 'minimum_units': 5, 'scaling_policy': { 'target_tracking_scaling_policy_configuration': { 'target_value': 50 } } }, 'provisioned_read_capacity_autoscaling_update': { 'maximum_units': 10, 'minimum_units': 5, 'scaling_policy': { 'target_tracking_scaling_policy_configuration': { 'target_value': 50, 'scale_in_cooldown': 60, 'scale_out_cooldown': 60 } } }, 'replica_updates': { 'us-east-1': { 'provisioned_read_capacity_autoscaling_update': { 'maximum_units': 20, 'minimum_units': 5, 'scaling_policy': { 'target_tracking_scaling_policy_configuration': { 'target_value': 70 } } } } } };

멀티 리전 테이블 (CQL) 의 프로비저닝된 용량 및 Auto Scaling 설정 보기

다중 지역 테이블의 Auto Scaling 구성을 보려면 다음 명령을 사용하십시오.

SELECT * FROM system_multiregion_info.autoscaling WHERE keyspace_name = 'mykeyspace' AND table_name = 'mytable';

이 명령의 출력은 다음과 같습니다.

keyspace_name | table_name | region | provisioned_read_capacity_autoscaling_update | provisioned_write_capacity_autoscaling_update ----------------+------------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- mykeyspace | mytable | ap-southeast-1 | {'minimum_units': 5, 'maximum_units': 10, 'scaling_policy': {'target_tracking_scaling_policy_configuration': {'scale_out_cooldown': 60, 'disable_scale_in': false, 'target_value': 50, 'scale_in_cooldown': 60}}} | {'minimum_units': 5, 'maximum_units': 10, 'scaling_policy': {'target_tracking_scaling_policy_configuration': {'scale_out_cooldown': 0, 'disable_scale_in': false, 'target_value': 50, 'scale_in_cooldown': 0}}} mykeyspace | mytable | us-east-1 | {'minimum_units': 5, 'maximum_units': 20, 'scaling_policy': {'target_tracking_scaling_policy_configuration': {'scale_out_cooldown': 60, 'disable_scale_in': false, 'target_value': 70, 'scale_in_cooldown': 60}}} | {'minimum_units': 5, 'maximum_units': 10, 'scaling_policy': {'target_tracking_scaling_policy_configuration': {'scale_out_cooldown': 0, 'disable_scale_in': false, 'target_value': 50, 'scale_in_cooldown': 0}}} mykeyspace | mytable | eu-west-1 | {'minimum_units': 5, 'maximum_units': 10, 'scaling_policy': {'target_tracking_scaling_policy_configuration': {'scale_out_cooldown': 60, 'disable_scale_in': false, 'target_value': 50, 'scale_in_cooldown': 60}}} | {'minimum_units': 5, 'maximum_units': 10, 'scaling_policy': {'target_tracking_scaling_policy_configuration': {'scale_out_cooldown': 0, 'disable_scale_in': false, 'target_value': 50, 'scale_in_cooldown': 0}}}

다중 지역 테이블 (CQL) 의 자동 크기 조정 끄기

를 사용하여 ALTER TABLE 기존 테이블의 Auto Scaling을 끌 수 있습니다. 참고로 개별 테이블 복제본에 대해서는 Auto Scaling을 끌 수 없습니다.

다음 예시에서는 테이블의 읽기 용량에 대해 Auto Scaling이 꺼져 있습니다.

ALTER TABLE mykeyspace.mytable WITH AUTOSCALING_SETTINGS = { 'provisioned_read_capacity_autoscaling_update': { 'autoscaling_disabled': true } };
참고

Application Auto Scaling에서 사용하는 서비스 연결 역할을 삭제하려면 모든 AWS 리전에 걸쳐 계정 내 모든 테이블에서 Auto Scaling을 비활성화해야 합니다.

다중 지역 테이블의 프로비저닝 용량 수동 설정 (CQL)

다중 지역 테이블에 대한 Auto Scaling을 해제해야 ALTER TABLE 하는 경우, 를 사용하여 복제 테이블에 대한 테이블의 읽기 용량을 수동으로 프로비저닝할 수 있습니다.

ALTER TABLE mykeyspace.mytable WITH CUSTOM_PROPERTIES = { 'capacity_mode': { 'throughput_mode': 'PROVISIONED', 'read_capacity_units': 1, 'write_capacity_units': 1 }, 'replica_updates': { 'us-east-1': { 'read_capacity_units': 2 } } };
참고

프로비저닝된 용량을 사용하는 멀티 리전 테이블에는 Auto Scaling을 사용하는 것이 좋습니다. 자세한 내용은 Amazon Keyspaces에서 멀티 리전 테이블 사용하기을(를) 참조하세요.