dot 快速的未来正在您所在的城市举办的活动中到来。

加入我们参加 Redis 发布会

使用 Terraform 部署 Active-Active Redis 数据库

我们很高兴地宣布 Redis Enterprise Cloud 已发布其 Terraform 资源,用于管理多区域 Active-Active Redis 数据库。

Terraform 是一款流行且灵活的开源基础设施自动化工具,可帮助 DevOps 团队将基础设施配置、配置和管理作为代码 (IaC) 进行处理。IaC 使组织能够使用描述性云操作模型来管理基础设施(例如虚拟机、数据库、负载均衡器和连接拓扑)。Terraform 使跨多个基础设施提供商使用相同的流程更容易规划和创建 IaC,这有助于提高可靠性,确保部署始终保持一致。 

现在,Redis 云 使使用 Terraform 更轻松。

什么是 Active-Active Redis 数据库?

Redis 云 Active-Active 数据库 在多个地理区域同步数据。这项技术使应用程序能够同时将数据写入任何区域,同时具有强最终一致性的可靠性。开发人员可以构建全球分布式应用程序,而无需解决复杂的技术挑战,例如处理跨区域写入冲突。Redis Enterprise 会为您处理这些问题。

Active-Active 数据库在业务需求包括灾难恢复、地理冗余应用程序以及必须将数据提供给更靠近用户物理位置的情况时,其价值最大。

为什么要使用 Terraform 部署 Active-Active Redis?

管理跨多个区域的数据可能很复杂。这就是 Redis Active-Active 架构和 Terraform 可以完美协同工作的地方。借助 Redis Cloud 的全新 Active-Active Terraform 资源,您只需单击一下按钮即可在任何区域创建、更新和删除数据库。

此外,您还可以轻松地在每个区域中定义不同的配置。例如,您可以在一个区域中消耗 50,000 次操作/秒,而在另一个区域中仅消耗 1,000 次操作/秒。

如何开始

要在 Terraform 中创建 Active-Active Redis Cloud 订阅,您需要创建三个 Terraform 资源

  1. rediscloud_active_active_subscription:使用此资源创建和管理 Active-Active 订阅。
  1. rediscloud_active_active_subscription_database:此资源用于在 Redis Enterprise Cloud 帐户中的指定 Active-Active 订阅中创建和管理数据库。使用 override_region 块修改特定区域中的配置,例如密码或持久性。
  2. rediscloud_active_active_subscription_regions: 在此资源中,您创建和管理订阅中的区域。这使 Redis Enterprise Cloud 能够在单独的块中高效地在每个定义的区域中配置您的订阅。

在每个区域内,将每个数据库的读写操作指定为该资源的一部分。

以下是如何在两个区域中部署包含一个数据库的订阅

resource "rediscloud_active_active_subscription" "subscription-resource" {
	name = "subscription-name"
	payment_method_id = xxxxxx
	cloud_provider = "AWS"
   
	creation_plan {
	  memory_limit_in_gb = 50
	  quantity = 1
	  region {
		  region = "us-east-1"
		  networking_deployment_cidr = "192.168.0.0/24"
		  write_operations_per_second = 5000
		  read_operations_per_second = 3000
	  }
	  region {
		  region = "eu-west-1"
		  networking_deployment_cidr = "10.0.1.0/24"
		  write_operations_per_second = 2000
		  read_operations_per_second = 10000
	  }
	}
}

resource "rediscloud_active_active_subscription_database" "database-resource" {
    subscription_id = rediscloud_active_active_subscription.subscription-resource.id
    name = "database-name"
    memory_limit_in_gb = 50
    global_data_persistence = "aof-every-1-second"
    global_alert {
	name = "dataset-size"
	value = 70
    }

    override_region {
    	name = "us-east-1"
    	override_global_data_persistence = "none"    	
   }
}

resource "rediscloud_active_active_subscription_regions" "regions-resource" {
	subscription_id = rediscloud_active_active_subscription.subscription-resource.id
	region {
	  region = "us-east-1"
	  networking_deployment_cidr = "192.168.0.0/24" 
	  database {
		  database_id = rediscloud_active_active_subscription_database.database-resource.db_id
               database_name = rediscloud_active_active_subscription_database.database-resource.name
		  local_write_operations_per_second = 5000
		  local_read_operations_per_second = 3000
	  }
	}
	region {
	  region = "eu-west-1"
	  networking_deployment_cidr = "10.0.1.0/24" 
	  database {
		  database_id = rediscloud_active_active_subscription_database.database-resource.db_id
               database_name = rediscloud_active_active_subscription_database.database-resource.name
		  local_write_operations_per_second = 2000
		  local_read_operations_per_second = 10000
	  }
	}
 }

creation_plan 块允许 API 服务器为集群中的数据库创建经过优化的基础设施。提供程序使用块内的属性创建初始数据库。这些数据库在配置新的订阅后将被删除,然后将作为单独资源定义的数据库附加到订阅。 

您只能将 creation_plan 块用于配置新的订阅。如果进行任何进一步更改或尝试导入资源,则不会使用该块。

准备下一步?

有关更多信息,请咨询 Redis Enterprise Cloud 注册表 文档

需要更多帮助创建第一个使用 Terraform 的 Active-Active Redis 订阅?此视频 演示了如何部署第一个 Active-Active 资源。