dot Redis 8 来了——它是开源的

了解更多

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

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

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

现在,Redis Cloud 使使用 Terraform 变得更加容易。

什么是 Active-Active Redis 数据库?

Redis Cloud Active-Active 数据库跨多个地理区域同步数据。这项技术使得应用程序可以将数据同时写入任何区域,并能自信地实现强最终一致性。开发人员可以构建全局分布式应用程序,而无需解决复杂的技术挑战,例如处理跨区域写入冲突。Redis Enterprise 会为您处理好这一切。

在业务需求包括灾难恢复、地理冗余应用程序以及需要将数据提供给离用户物理位置更近的场景时,Active-Active 数据库最有价值。

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

管理跨多个区域的数据可能很复杂。这就是 Redis Active-Active 架构和 Terraform 精妙协作之处。借助 Redis Cloud 新的 Active-Active Terraform 资源,您只需按一下按钮,即可在任何区域创建、更新和删除数据库。

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

如何开始

要在 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 registry 文档

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