Terraform을 사용하여 전역 활성 테이블 업데이트
지역별 복제본 추가
기존 전역 활성 테이블의 지역 복제본을 추가할 수 있습니다.
mr_test이 이미 존재하며 Canada Southeast(Montreal) 영역에 지역 복제본이 있습니다. 다른 지역 캐나다 남동부(토론토)에 이 테이블의 지역 복제본을 추가하려면 다음 nosql.tf 파일을 사용합니다.
주:
테이블 및 복제본이 이미 있는 경우에도 테이블(CREATE TABLE IF NOT EXISTS mr_test...) 및 기존 복제본의 정의는 항상 terraform 스크립트에 포함되어야 합니다. Terraform 스크립트에서 CREATE TABLE 정의를 제거하면 해당 영역에서 테이블이 삭제됩니다. 마찬가지로 terraform 스크립트에서 기존 복제본 정의를 제거하면 지역 테이블 복제본이 삭제됩니다.
variable "compartment_ocid" {
}
variable "table_ddl_statement" {
default = "CREATE TABLE IF NOT EXISTS mr_test(id INTEGER,
name STRING, info JSON,PRIMARY KEY(id))
using TTL 10 days with schema frozen"
}
resource "oci_nosql_table" "mr_test" {
#Required
compartment_id = var.compartment_ocid
ddl_statement = var.table_ddl_statement
name = "mr_test"
table_limits {
#Required
max_read_units = 51
max_write_units = 51
max_storage_in_gbs = 2
}
}
resource "oci_nosql_table_replica" "replica_montreal" {
table_name_or_id = oci_nosql_table.mr_test.id
region = "ca-montreal-1"
#Optional
max_read_units = "60"
max_write_units = "60"
}
#add a regional replica
resource "oci_nosql_table_replica" "replica_toronto" {
compartment_id = var.compartment_ocid
table_name_or_id = "mr_test"
region = "ca-toronto-1"
depends_on = [oci_nosql_table.mr_test]
}
terraform applyDo you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve. 확인하면 Terraform이 토론토 지역에 글로벌 활성 테이블의 새 지역 복제본을 추가합니다. 이 영역의 복제본에 대해 명시적으로 제공된 읽기 및 쓰기 단위가 없으므로 값은 US East (Ashburn) 영역의 mr_test 테이블에서 인계됩니다. 위의 예에서 Canada Southeast(Toronto) 영역에 있는 복제 테이블의 읽기 및 쓰기 단위는 51입니다.
지역 복제본 삭제
기존 전역 활성 테이블의 지역 복제본을 삭제할 수 있습니다.
mr_test은 이미 존재하며 Canada Southeast(Montreal) 및 Canada Southeast(Toronto) 영역에 복제본이 있습니다. Canada Southeast(Toronto) 영역에서 복제본을 삭제하려면 Canada Southeast(Toronto)에서 복제본을 추가하는 것과 관련된 코드를 주석 처리(또는 제거)해야 하는 다음 nosql.tf 파일을 사용합니다.
주:
테이블 정의(CREATE TABLE IF NOT EXISTS mr_test...)는 테이블이 이미 있는 경우에도 항상 terraform 스크립트에 포함되어야 합니다. Terraform 스크립트에서 CREATE TABLE 정의를 제거하면 해당 영역에서 테이블이 삭제됩니다.
variable "compartment_ocid" {
}
variable "table_ddl_statement" {
default = "CREATE TABLE IF NOT EXISTS mr_test(id INTEGER,
name STRING, info JSON,PRIMARY KEY(id))
using TTL 10 days with schema frozen"
}
resource "oci_nosql_table" "mr_test" {
#Required
compartment_id = var.compartment_ocid
ddl_statement = var.table_ddl_statement
name = "mr_test"
table_limits {
#Required
max_read_units = 51
max_write_units = 51
max_storage_in_gbs = 2
}
}
resource "oci_nosql_table_replica" "replica_montreal" {
table_name_or_id = oci_nosql_table.mr_test.id
region = "ca-montreal-1"
#Optional
max_read_units = "60"
max_write_units = "60"
}
#resource "oci_nosql_table_replica" "replica_toronto" {
# compartment_id = var.compartment_ocid
# table_name_or_id = "mr_test"
# region = "ca-toronto-1"
# depends_on = [oci_nosql_table.mr_test]
#}
terraform applyDo you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve.확인하면 Terraform이 캐나다 남동부(토론토) 지역의 복제본을 삭제합니다.
Global Active Table의 TTL 및 테이블 제한 변경
Terraform을 사용하여 전역 활성 테이블에 대한 읽기 단위, 쓰기 단위, 스토리지 용량 및 테이블 TTL을 변경할 수 있습니다.
전역 활성 테이블에서 읽기 용량 제한 또는 쓰기 용량 제한 변경은 변경된 영역에만 적용됩니다. 그러나 저장 영역 용량을 변경하거나 테이블 레벨 TTL 값을 변경하면 로컬 테이블 및 테이블의 모든 지역 복제본에 변경 사항이 적용됩니다.
mr_test 테이블의 테이블 용량을 변경하려면 다음 nosql.tf 파일을 사용합니다.variable "compartment_ocid" {
}
variable "table_ddl_statement" {
default = "CREATE TABLE IF NOT EXISTS mr_test(id INTEGER,
name STRING, info JSON,PRIMARY KEY(id))
using TTL 15 days with schema frozen"
}
resource "oci_nosql_table" "mr_test" {
#Required
compartment_id = var.compartment_ocid
ddl_statement = var.table_ddl_statement
name = "mr_test"
table_limits {
#Required
max_read_units = 70
max_write_units = 70
max_storage_in_gbs = 2
}
}
resource "oci_nosql_table_replica" "replica_montreal" {
table_name_or_id = oci_nosql_table.mr_test.id
region = "ca-montreal-1"
#Optional
max_read_units = 60
max_write_units = 60
}
resource "oci_nosql_table_replica" "replica_toronto" {
compartment_id = var.compartment_ocid
table_name_or_id = "mr_test"
region = "ca-toronto-1"
depends_on = [oci_nosql_table.mr_test]
}terraform applyDo you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve.us-ashburn-1)에 있는 테이블의 읽기 및 쓰기 단위가 70으로 변경됩니다. 다른 영역에 있는 복제본의 테이블 제한은 변경되지 않습니다. 그러나 로컬 테이블과 모든 복제본에서 TTL 값이 15일로 변경됩니다.
주:
Global Active 테이블에는 모든 지역 복제본의 스키마, 인덱스, TTL 및 저장 영역 크기를 포함하는 대칭 테이블 정의가 있습니다. 한 지역 복제본에서 인덱스, TTL 또는 스토리지 크기를 변경하면 다른 모든 지역 복제본에 자동으로 적용됩니다. 따라서 이러한 테이블 정의는 한 영역에서만 관리하는 것이 좋습니다.지역 복제본의 테이블 제한 편집
Terraform의 OCI 제공자는 단일 리전에 대해 구성됩니다. 테이블 제한 업데이트는 영역마다 다르므로 토론토 지역에서만 ca-toronto-1에 생성된 복제본의 읽기 및 쓰기 단위를 관리할 수 있습니다. 마찬가지로 전역 활성 테이블의 여러 영역에 대한 테이블 제한을 관리하려는 경우 아래와 같이 테라폼으로 모듈을 구성하는 것이 좋습니다. 여기에서 영역 1, 영역 2 등은 Terraform 디렉토리 내의 디렉토리입니다. Terraform 디렉토리는 Terraform을 설치할 때 생성되는 디렉토리입니다.
Terraform 디렉토리에서 각 영역에 대해 별도의 디렉토리를 유지 관리하고 영역별 테이블 제한이 포함된 구성(위 다이어그램에서 nosql.tf으로 표시됨)을 유지 관리합니다. Terraform 상태 파일(terraform.tfstate)도 각 지역에 대해 별도로 생성 및 관리됩니다.
이 경우 세 영역 us-ashburn-1, ca-montreal-1 및 ca-toronto-1에 해당하는 Terraform 디렉토리 내에 세 개의 디렉토리가 있습니다. 디렉토리 Ashburn, Montreal 및 Toronto를 호출해 보겠습니다.
ca-toronto-1 영역에서 복제 테이블의 읽기/쓰기 단위를 수정하는 단계:
Toronto디렉토리로 이동합니다. 미국 동부(애슈번) 지역에 사용된 구성에서oci_nosql_table리소스 정의를 복제하여 Terraform 구성(여기서nosql.tf)을 생성합니다.- 필요에 따라 테이블의 읽기 및/또는 쓰기 단위를 갱신합니다.
resource "oci_nosql_table" "mr_test" { #Required compartment_id = var.compartment_ocid ddl_statement = "CREATE TABLE IF NOT EXISTS mr_test(id INTEGER, name STRING, info JSON, PRIMARY KEY(id)) with schema frozen" name = "mr_test" table_limits { #Required max_read_units = 100 max_write_units = 90 max_storage_in_gbs = 1 } } - 기존 테이블을 Terraform 상태로 임포트합니다. 위 다이어그램에 표시된 것처럼 상태 파일도 영역별로 다르므로 테이블을 임포트해도 상태 충돌이 발생하지 않습니다. OCI 콘솔에서 Canada Southeast(Toronto) 영역에 있는 복제 테이블의
ocid을 가져올 수 있습니다.terraform import oci_nosql_table.mr_test <ocid-of-replica-table-in-ca-toronto-1> - 변경사항 적용
terraform apply Terraform shows the plan to be applied and prompts for confirmation as shown below. Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve.확인 시
ca-toronto-1영역의 복제본에 대해 읽기 및 쓰기 단위가 각각 100 및 90으로 수정됩니다.
