

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

# 从 Couchbase Server 迁移至 AWS 上的 Couchbase Capella
<a name="migrate-from-couchbase-server-to-couchbase-capella-on-aws"></a>

*Battulga Purevragchaa 和 Saurabh Shanbhag，Amazon Web Services*

*Mark Gamble，无*

## Summary
<a name="migrate-from-couchbase-server-to-couchbase-capella-on-aws-summary"></a>

Couchbase Capella 是一个完全托管的 NoSQL 数据库即服务，适用于任务关键型应用程序（例如，用户配置文件或在线目录和库存管理）。DBaaCouchbase Capella 在 Couchbase 管理的亚马逊网络服务 (AW DBaa S) 账户中管理你的 S 工作负载。Capella 可以让您在单个界面中轻松运行和管理多集群、多 AWS 区域、多云和混合云复制。

Couchbase Capella 可帮助您立即扩展 Couchbase Server 应用程序，帮助您在几分钟内创建多节点集群。Couchbase Capella 支持所有 Couchbase Server 功能，包括 [SQL\$1\$1](https://www.couchbase.com/products/n1ql)、[全文搜索](https://www.couchbase.com/products/full-text-search)、[事件服务](https://docs.couchbase.com/server/current/eventing/eventing-overview.html)和[分析服务](https://www.couchbase.com/products/analytics)。它还消除了管理安装、升级、备份和一般数据库维护的需要。 

本示例介绍了将自托管的 [Couchbase Server](https://www.couchbase.com/products/server) 环境迁移之 Amazon Web Services Cloud 的最佳做法。该模式提供了一个可重复的过程，用于将数据和索引从本地或云中运行的 Couchbase Server 集群迁移到 Couchbase Capella。使用这些步骤可帮助您避免迁移期间出现问题并加快整个迁移过程。

此模式提供以下两个迁移项：
+ 如果要迁移的索引少于 50 个，则**选项 1** 是合适的。 
+ 如果要迁移的索引超过 50 个，则**选项 2** 是合适的。 

您还可以在自托管 Couchbase 服务器上[设置示例数据](https://docs.couchbase.com/server/current/manage/manage-settings/install-sample-buckets.html)，以便按照迁移指南进行操作。

如果您选择迁移**选项 2**，或者您使用的范围或集合不是默认值，则应参见示例配置文件*其他信息*部分。

## 先决条件和限制
<a name="migrate-from-couchbase-server-to-couchbase-capella-on-aws-prereqs"></a>

**先决条件**
+ 现有 Couchbase Capella 付费账户。您还可以在 [AWS 上创建 Couchbase Capella](https://aws.amazon.com/marketplace/pp/prodview-xrhx5zgue5c26) 账户，并使用 Couchbase Capella 免费试用版，然后升级到付费账户来配置集群以进行迁移。要从试用版开始，请按照 [Couchbase Capella 入门](https://docs.couchbase.com/cloud/get-started/create-account.html)中的说明进行操作。
+ 现有的自托管 Couchbase Server 环境，可以在本地部署或部署在云服务提供商上。 
+ 对于迁移选项 2，使用 Couchbase Shell 和配置文件。若要创建配置文件，可以使用*其他信息*部分中的示例文件。
+ 熟悉管理 Couchbase Server 和 Couchbase Capella。
+ 熟悉打开 TCP 端口及在命令行界面（CLI）中运行命令。

迁移过程还需要下表中描述的角色和专业知识。


| 
| 
|  角色 | 专业知识 | 责任 | 
| --- |--- |--- |
| Couchbase 管理员 | 熟悉 Couchbase Server 和 Couchbase Capella基本的命令行知识很有帮助，但非必需的 | Couchbase Server 与 Capella 特定任务 | 
| 系统管理员、IT 管理员 | 熟悉自托管的 Couchbase 服务器系统环境和管理 | 在自托管的 Couchbase Server 集群节点上打开端口并确定 IP 地址 | 

 

**限制**
+ 这种模式用于将数据、索引和 [Couchbase 全文搜索](https://docs.couchbase.com/server/current/fts/full-text-intro.html)索引从 Couchbase Server 迁移到 AWS 上的 Couchbase Capella。这种模式不适用于迁移 [Couchbase Eventing Service](https://docs.couchbase.com/server/current/eventing/eventing-overview.html) 或 [Couchbase Analytics](https://docs.couchbase.com/server/current/analytics/introduction.html)。
+ Couchbase Capella 在多个 AWS 区域可用。有关 Capella 支持的区域 up-to-date的信息，请参阅 Couchbase 文档中的[亚马逊 Web Services](https://docs.couchbase.com/cloud/reference/aws.html)。

**产品版本**
+ [Couchbase Server（Community Edition 或企业版）版本 5.x 或更高版本](https://docs.couchbase.com/server/current/release-notes/relnotes.html)

## 架构
<a name="migrate-from-couchbase-server-to-couchbase-capella-on-aws-architecture"></a>

**源技术堆栈**
+ Couchbase Server

**目标技术堆栈**
+ Couchbase Capella

**目标架构**

![\[只需四步，即可将 Couchbase Capella 迁移到 AWS Capella 数据面板上的 Couchbase 集群。\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/images/pattern-img/14ac5a81-eade-4708-9335-f5602fa07824/images/95cd7f33-742e-4d10-8e2c-37c7b4d9df45.png)


1. 您可使用**Capella 控制面板**访问 Couchbase Capella。您可使用 Capella 控制面板来执行以下操作：
   + 控制和监控账户。
   + 管理集群和数据、索引、用户和组、访问权限、监控和事件。

1. 创建集群。

1. **Capella 数据面板**位于 Couchbase 管理的 Amazon Web Services account 中。创建新集群后，Couchbase Capella 会将其部署至所选 AWS 区域的多个可用区。

1. 您可在 Amazon Web Services account 的 VPC 中开发和部署 Couchbase 应用程序。通常，此 VPC 通过 [VPC 对等连接](https://docs.couchbase.com/cloud/clouds/private-network.html)访问 Capella 数据面板。

## 工具
<a name="migrate-from-couchbase-server-to-couchbase-capella-on-aws-tools"></a>
+ [Couchbase Cross Data Center Replication (XDCR)](https://docs.couchbase.com/cloud/current/clusters/xdcr/xdcr.html) 有助于在位于不同云提供商和不同数据中心的集群之间复制数据。它用于将数据从自托管的 Couchbase Server 集群迁移至 Couchbase Capella。
**注意**  
XDCR 不能与 Couchbase Server Community Edition 一起用于迁移至 Couchbase Capella。相反，您可以使用 [cbexport](https://docs.couchbase.com/server/current/tools/cbexport.html)。有关更多信息，请参阅*从 Community Edition 迁移数据*操作说明。
+ [Couchbase Shell](https://couchbase.sh/docs/) 是 Couchbase Server 和 Couchbase Capella 访问本地和远程 Couchbase 集群的命令行外壳。在这种模式中，Couchbase Shell 可用于迁移索引。
+ [cbexport](https://docs.couchbase.com/server/current/tools/cbexport.html) 是 Couchbase 实用程序，用于从 Couchbase 集群中导出数据。包含在 [Couchbase Server CLI 工具](https://docs.couchbase.com/server/current/cli/cli-intro.html)中。

## 操作说明
<a name="migrate-from-couchbase-server-to-couchbase-capella-on-aws-epics"></a>

### 准备迁移
<a name="prepare-the-migration"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 评估自托管的 Couchbase Server 集群的大小。 | 登录适用于 Couchbase Server 的 [Couchbase Web 控制台](https://docs.couchbase.com/server/current/manage/manage-ui/manage-ui.html)，然后评测自托管的集群的节点和存储桶。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/migrate-from-couchbase-server-to-couchbase-capella-on-aws.html)您将使用自托管的 Couchbase Server 集群配置作为在 Couchbase Capella 上调整和配置目标集群的通用指南。如需有关更详细的 Couchbase Capella 缩放练习的帮助，请[联系 Couchbase](https://www.couchbase.com/contact)。 | Couchbase 管理员 | 
| 在自托管的 Couchbase 服务器集群上记录 Couchbase 服务分发情况。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/migrate-from-couchbase-server-to-couchbase-capella-on-aws.html) | Couchbase 管理员 | 
| 记录自托管的 Couchbase Server 集群节点的 IP 地址。 | （如果您使用的是Community Edition，请忽略此步骤。） 记录集群中每个节点 IP 地址。稍后它们将被添加到您的 Couchbase Capella 集群上的允许列表中。 | Couchbase 管理员、系统管理员 | 

### 在 Couchbase Capella 上部署和配置资源
<a name="deploy-and-configure-resources-on-couchbase-capella"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| Choose a template。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/migrate-from-couchbase-server-to-couchbase-capella-on-aws.html) | Couchbase 管理员 | 
| 选择和配置节点。 | 选择和配置节点以匹配您的自托管的 Couchbase Server 集群环境，包括节点数量、服务分布、计算或 RAM 以及存储。Couchbase Capella 使用[多维缩放最佳实践](https://docs.couchbase.com/cloud/clusters/scale-cluster.html#scale-a-cluster)。只能根据部署最佳实践来选择服务与节点。这可能意味着您无法完全匹配自托管 Couchbase Server 集群配置。 | Couchbase 管理员 | 
| 部署集群。 | 选择支持区域与支持包，然后部署集群。有关详细步骤和说明，请参阅 Couchbase 文档中的[创建集群](https://docs.couchbase.com/cloud/clusters/create-cluster.html)。如果您使用的是 Couchbase Capella 免费试用版，则必须先将其转换为付费账户，然后才能开始迁移。要转换您的账户，请打开 Couchbase Capella 控制面板的**账单**部分，然后选择**添加激活 ID**。在您与 Couchbase 销售人员签订购买协议后，或者在您通过 [Amazon Web Services Marketplace](https://aws.amazon.com/marketplace/pp/prodview-xrhx5zgue5c26) 进行购买之后，激活编号将发送到您的账单联系人电子邮件地址。 | Couchbase 管理员 | 
| 创建数据库凭证用户。 | 数据库凭证用户特定于集群，由用户名、密码和一组存储桶权限组成。此用户是创建存储桶和访问存储桶数据的必要条件 在 Couchbase Capella 控制面板中，按照 Couchbase Capella 文档中[配置数据库凭证](https://docs.couchbase.com/cloud/clusters/manage-database-users.html)中的说明为新集群创建数据库凭证。如果组织用户想要远程或通过 Couchbase Capella 用户界面访问特定集群上的存储桶数据，则需要为其分配组织角色证书。这与数据库凭证是分开的，后者通常由应用程序与集成使用。创建组织用户允许您在 Couchbase Capella 集群创建和管理目标存储桶。 | Couchbase 管理员 | 
| 如果使用迁移选项 2，请安装 Couchbase Shell。 | 您可将 Couchbase Shell 安装在任何能够通过网络访问自托管的 Couchbase 服务器和 Couchbase Capella 集群的系统上。有关更多信息，请参阅 Couchbase Shell 文档中的[安装 Couchbase Shell 版本 1.0.0-beta.5](https://couchbase.sh/docs/#_installation)。通过在命令行终端中[测试与自托管集群的连接](https://couchbase.sh/docs/#_connecting_to_a_cluster)，确认已安装 Couchbase Shell。 | Couchbase 管理员、系统管理员 | 
| 允许 IP 地址。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/migrate-from-couchbase-server-to-couchbase-capella-on-aws.html)有关允许的 IP 地址的更多信息，请参阅 Couchbase 文档中的[配置允许 IP 地址](https://docs.couchbase.com/cloud/get-started/configure-cluster-access.html#allow-ip-address)。 | Couchbase 管理员、系统管理员 | 
| 配置证书。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/migrate-from-couchbase-server-to-couchbase-capella-on-aws.html) | Couchbase 管理员、系统管理员 | 
| 创建 Couchbase Shell 的配置文件。 | 在 Couchbase Shell 安装的主目录中创建配置点文件（例如 `/<HOME_DIRECTORY>/.cbsh/config`）。有关更多信息，请参阅 Couchbase 文档中的 [Config dotfiles](https://couchbase.sh/docs/#_the_config_dotfiles)。将源集群和目标集群连接属性添加到配置文件中。您可使用*其他信息*部分中的示例配置文件并编辑集群的设置。 将包含更新设置的配置文件保存到 `.cbsh` 文件夹（例如 `/<HOME_DIRECTORY>/.cbsh/config`）。 | Couchbase 管理员、系统管理员 | 
| 创建目标存储桶。 | 对于每个源存储桶，请按照 Couchbase 文档中创建存储桶中的说明在您的 Couchbase Capella 集群中[创建目标存储桶](https://docs.couchbase.com/cloud/clusters/data-service/manage-buckets.html#add-bucket)。您的目标存储桶配置必须与您自托管的 Couchbase Server 集群中存储桶的存储桶名称、内存设置和冲突解决设置相匹配。 | Couchbase 管理员 | 
| 创建范围和集合。 | 每个存储桶都包含一个默认作用域和带有密钥空间 `_default._default` 的集合。如果您在作用域和集合中使用任何其他密钥空间，则必须在目标 Capella 集群中创建相同的密钥空间。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/migrate-from-couchbase-server-to-couchbase-capella-on-aws.html)<pre>scopes --clusters "On-Prem-Cluster" --bucket <BUCKET_NAME> | select scope | where scope != "_default" | each { |it| scopes create $it.scope --clusters "Capella-Cluster" }<br />collections --clusters "On-Prem-Cluster" --bucket <BUCKET_NAME> | select scope collection | where $it.scope != "_default" | where $it.collection != "_default" | each { |it| collections create $it.collection --clusters "Capella-Cluster" --bucket <BUCKET_NAME> --scope $it.scope }</pre> | Couchbase 管理员 | 

### 从 Enterprise Edition 迁移数据
<a name="migrate-the-data-from-enterprise-edition"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 在自托管的 Couchbase 服务器集群节点上打开 TCP 端口。 | 确保在自托管的 Couchbase Server 集群的节点上打开相应的端口，以便进行 XDCR 通信。有关更多信息，请参阅 [Couchbase Server 端口文档](https://docs.couchbase.com/server/current/install/install-ports.html#ports-listed-by-communication-path)。 | Couchbase 管理员、系统管理员 | 
| 如果您使用的是 Couchbase Server 企业版，请设置 Couchbase XDCR。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/migrate-from-couchbase-server-to-couchbase-capella-on-aws.html) | Couchbase 管理员 | 
| 启动 Couchbase XDCR。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/migrate-from-couchbase-server-to-couchbase-capella-on-aws.html) | Couchbase 管理员 | 

### 使用选项 1 迁移索引
<a name="migrate-the-indexes-by-using-option-1"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 将自托管的集群索引迁移至 Couchbase Capella。 | 如果要迁移的索引少于 50 个，我们建议您执行此过程。如果您要迁移的索引超过 50 个，建议您使用迁移选项 2。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/migrate-from-couchbase-server-to-couchbase-capella-on-aws.html) | Couchbase 管理员、系统管理员 | 

### 使用选项 2 迁移索引
<a name="migrate-the-indexes-by-using-option-2"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 迁移索引定义。 | 如果要迁移的索引超过 50 个，我们建议您执行此过程。如果您要迁移的索引少于 50 个，建议您使用迁移选项 1。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/migrate-from-couchbase-server-to-couchbase-capella-on-aws.html) | Couchbase 管理员、系统管理员 | 
| 生成索引定义。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/migrate-from-couchbase-server-to-couchbase-capella-on-aws.html) | Couchbase 管理员、系统管理员 | 

### 迁移全文搜索索引
<a name="migrate-full-text-search-indexes"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 将自托管的集群全文搜索索引迁移至 Couchbase Capella。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/migrate-from-couchbase-server-to-couchbase-capella-on-aws.html) | Couchbase 管理员 | 

### 从 Couchbase Community Edition 迁移
<a name="migrate-data-from-couchbase-community-edition"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 从自托管的 Couchbase Server Community Edition 导出数据。 | 加密 XDCR 在 Couchbase Community Edition 中不可用。您可以从 Couchbase Community Edition 导出数据，然后手动将数据导入 Couchbase Capella。要从源存储桶导出数据，请在命令行中使用 `cbexport`。以下命令是一个示例。<pre>cbexport json \<br />--cluster localhost \<br />--bucket <SOURCE BUCKET NAME> \<br />--format lines \<br />--username <USERNAME> \<br />--password <PASSWORD> \<br />--include-key cbkey \<br />--scope-field cbscope \<br />--collection-field cbcoll \<br />--output cbexported_data.json</pre>请注意，`cbkey`、`cbscope`、`cbcoll` 和 `cbexported_data.json` 是任意标签。稍后将在此过程中引用它们，因此如果您选择以不同的方式命名它们，请记下它。 | Couchbase 管理员 | 
| 将数据导入 Couchbase Capella。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/migrate-from-couchbase-server-to-couchbase-capella-on-aws.html)对于大文件，Couchbase Capella 支持使用 curl 执行命令行导入。您可以在 Couchbase Capella 文档中的[导入数据](https://docs.couchbase.com/cloud/clusters/data-service/import-data-documents.html)中更详细地探索导入选项。 | Couchbase 管理员 | 

### 测试和验证迁移
<a name="test-and-verify-the-migration"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 验证数据迁移。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/migrate-from-couchbase-server-to-couchbase-capella-on-aws.html) | Couchbase 管理员 | 
| 验证索引迁移。 | 在 Couchbase Capella 控制面板，在目标集群的**工具**下拉列表中，选择**索引**。验证索引是否已完成迁移和构建。 | Couchbase 管理员 | 
| 验证查询结果。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/migrate-from-couchbase-server-to-couchbase-capella-on-aws.html) | Couchbase 管理员 | 
| 验证全文搜索结果（如果您迁移了 FTS 索引，则适用）。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/migrate-from-couchbase-server-to-couchbase-capella-on-aws.html) | Couchbase 管理员 | 

## 相关资源
<a name="migrate-from-couchbase-server-to-couchbase-capella-on-aws-resources"></a>

**准备迁移**
+ [开始使用 Couchbase Capella 免费试用版](https://cloud.couchbase.com/sign-up)
+ [云提供程序对 Couchbase Capella 的要求](https://docs.couchbase.com/cloud/reference/aws.html)
+ [Couchbase Capella 缩放指南](https://docs.couchbase.com/cloud/clusters/sizing.html)

**迁移数据和索引**
+ [Couchbase XDCR](https://docs.couchbase.com/cloud/clusters/xdcr/xdcr.html)
+ [Couchbase Shell 文档](https://couchbase.sh/docs/)

**Couchbase Cap SLAs ella 和支援**
+ [Couchbase Capella 服务](https://www.couchbase.com/capellasla)等级协议 () SLAs
+ [Couchbase Capella 服务支持策略](https://www.couchbase.com/support-policy/cloud)

## 附加信息
<a name="migrate-from-couchbase-server-to-couchbase-capella-on-aws-additional"></a>

以下代码是 [Couchbase Shell 的配置文件](https://couchbase.sh/docs/#_the_config_dotfiles)示例。 

```
Version = 1
 
[[clusters]]
identifier = "On-Prem-Cluster"
hostnames = ["<SELF_MANAGED_COUCHBASE_CLUSTER>"]
default-bucket = "travel-sample"
username = "<SELF_MANAGED_ADMIN>"
password = "<SELF_MANAGED_ADMIN_PWD>"
tls-cert-path = "/<ABSOLUTE_PATH_TO_SELF_MANAGED_ROOT_CERT>"
data-timeout = "2500ms"
connect-timeout = "7500ms"
query-timeout = "75s"
 
[[clusters]]
identifier = "Capella-Cluster"
hostnames = ["<COUCHBASE_CAPELLA_ENDPOINT>"]
default-bucket = "travel-sample"
username = "<CAPELLA_DATABASE_USER>"
password = "<CAPELLA_DATABASE_USER_PWD>"
tls-cert-path = "/<ABSOLUTE_PATH_TO_COUCHBASE_CAPELLA_ROOT_CERT>"
data-timeout = "2500ms"
connect-timeout = "7500ms"
query-timeout = "75s"
```

在保存配置文件之前，请使用下表，以确保您添加了自己的源和目标集群信息。

 


|  |  | 
| --- |--- |
| <SELF\$1MANAGED\$1COUCHBASE\$1CLUSTER> | 使用自托管 Couchbase 服务器集群的 IP 地址。 | 
| <SELF\$1MANAGED\$1ADMIN> | 使用管理员用户来管理您的自托管的 Couchbase 服务器集群。 | 
| <ABSOLUTE\$1PATH\$1TO\$1SELF\$1MANAGED\$1ROOT\$1CERT> | 使用您自托管的 Couchbase Server 集群保存的根证书文件的绝对路径。 | 
| <COUCHBASE\$1CAPELLA\$1ENDPOINT> | 使用您的 Couchbase Capella 集群的连接端点。 | 
| <CAPELLA\$1DATABASE\$1USER> | 使用您的 Couchbase Capella 集群数据库用户。 | 
| <CAPELLA\$1DATABASE\$1USER\$1PWD> | 使用 Couchbase Capella 集群的数据库用户密码。 | 
| <ABSOLUTE\$1PATH\$1TO\$1COUCHBASE\$1CAPELLA\$1ROOT\$1CERT> | 使用为 Couchbase Capella 集群保存的根证书文件的绝对路径。 | 