

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

# 将 ELK 堆栈迁移至 Elastic Cloud on AWS
<a name="migrate-an-elk-stack-to-elastic-cloud-on-aws"></a>

*Battulga Purevragchaa 和 Antony Prasad Thevaraj，Amazon Web Services*

*uday reddy，无*

## Summary
<a name="migrate-an-elk-stack-to-elastic-cloud-on-aws-summary"></a>

[Elastic](https://www.elastic.co/) 多年来一直提供服务，其用户和客户通常在本地自行管理 Elastic。[Elastic Cloud](https://www.elastic.co/cloud) 是一种托管的 [Elasticsearch 服务](https://www.elastic.co/elasticsearch/service)，提供了一种使用 Elastic Stack (ELK Stack) 的方式，以及[企业搜索](https://www.elastic.co/enterprise-search)、[可观测性](https://www.elastic.co/observability)和[安全](https://www.elastic.co/security)的解决方案。您可以使用日志、指标、APM（应用程序性能监控）和 SIEM（安全信息和事件管理）等应用程序访问 Elastic 解决方案。您可以使用机器学习、索引生命周期管理、Kibana Lens（用于拖放可视化）等集成功能。

当你从自我管理的 Elasticsearch 迁移至 Elasticsearch 时，Elasticsearch 服务会处理以下几点：
+ 配置和管理基础架构
+ 创建和管理 Elasticsearch 集群
+ 向上和向下扩展集群
+ 升级、修补以及拍摄快照

这使您有更多时间专注解决其他挑战。

此模式定义了如何在 Amazon Web Services (AWS) 上将本地 Elasticsearch 7.13 迁移至 Elastic Cloud on Amazon Web Services (AWS)。其他版本可能需要对此模式中描述的过程稍作修改。有关更多信息，请您联系 Elastic 代表。

## 先决条件和限制
<a name="migrate-an-elk-stack-to-elastic-cloud-on-aws-prereqs"></a>

**先决条件**
+ 具有访问[Amazon Simple Storage Service](https://aws.amazon.com/s3/) (Amazon S3)以获取快照的有效的 [Amazon Web Services account](https://aws.amazon.com/account/)
+ 一个安全、带宽足够高的[私有链接](https://docs.aws.amazon.com/vpc/latest/userguide/vpn-connections.html)，用于将快照数据文件复制至 Amazon S3
+ [Amazon S3 Transfer Acceleration](https://aws.amazon.com/s3/transfer-acceleration/)
+ [Elastic Snapshot 策略](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/getting-started-snapshot-lifecycle-management.html)，确保定期将数据摄取存档到足够大的本地数据存储或远程存储 (Amazon S3)

开始迁移之前，您必须了解本地快照的大小以及随附索引的[生命周期策略](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-management.html)。有关更多信息，[请联系 Elastic](https://www.elastic.co/contact)。

**角色与技能**

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


| 
| 
|  角色 | 专业知识 | 责任 | 
| --- |--- |--- |
| App support | 熟悉本地部署的 Elastic Cloud 和 Elastic | 所有 Elastic 相关任务 | 
| 系统管理员或 数据库管理员 | 深入了解本地 Elastic 环境及配置 | 能够预配置存储空间、安装和使用 AWS 命令行界面（AWS CLI），并识别在本地提供 Elastic 的所有数据来源 | 
| 网络管理员 | 了解本地与 AWS 的网络连接、安全以及性能 | 在了解连接带宽的前提下，建立从本地至 Amazon S3 的网络链接 | 

**限制**
+ Elastic Cloud 上的 Elasticsearch 仅在[支持的 AWS 区域](https://www.elastic.co/guide/en/cloud/current/ec-regions-templates-instances.html#ec-aws_regions) 可用。

**产品版本**
+ Elasticsearch 7.13

## 架构
<a name="migrate-an-elk-stack-to-elastic-cloud-on-aws-architecture"></a>

**源技术堆栈**

本地 Elasticsearch 7.13 或更高版本：
+ 集群快照
+ 索引快照
+ [Beats](https://www.elastic.co/beats/) 配置

**源技术架构**

下图显示了具有不同摄取方法、节点类型以及 Kibana 的典型本地架构。不同的节点类型反映了 Elasticsearch 集群、身份验证以及可视化角色。

![包括 Beats、Logstash、Elasticsearch 和 Kibana 的八步流程。](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/images/pattern-img/23d1b437-22ff-420e-80ac-834f1116d234/images/937c4d22-429f-4673-86df-ae491d68389c.png)


1. 从 Beats 摄取至 Logstash

1. 从 Beats 摄取至 Apache Kafka 消息队列

1. 从 Filebeat 摄取至 Logstash

1. 从 Apache Kafka 消息队列摄取至 Logstash

1. 从 Logstash 摄取至 Elasticsearch 集群

1. Elasticsearch 集群

1. 身份验证以及通知节点

1. Kibana 和 blob 节点

**目标技术堆栈**

Elastic Cloud 通过跨集群复制功能部署到您在多个 AWS 区域的软件即服务（SaaS）账户。
+ 集群快照
+ 索引快照
+ Beats 配置
+ Elastic Cloud
+ Network Load Balancer
+ Amazon Route 53
+ Amazon S3

**目标架构**

![Route 53 端点将流量路由到两个不同区域的多可用区环境。](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/images/pattern-img/23d1b437-22ff-420e-80ac-834f1116d234/images/16cbac49-0adb-4469-b546-ae4b1ca35357.png)


 

托管 Elastic Cloud 基础架构是：
+ 高度可用，存在于多个[可用区](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/)和多个 AWS 区域。
+ 由于数据（索引和快照）是使用 Elastic Cloud [跨集群复制 (CCR) ](https://www.elastic.co/guide/en/elasticsearch/reference/7.14/xpack-ccr.html)，因此可以容忍区域故障
+ 存档，因为快照存档至 [Amazon S3](https://aws.amazon.com/s3/?p=pm&c=s3&z=4)
+ 通过[网络负载均衡器](https://aws.amazon.com/elasticloadbalancing/network-load-balancer/)和 [Route 53](https://aws.amazon.com/route53/) 的组合实现分区容错性
+ 源自（但不限于）[Elastic APM](https://www.elastic.co/apm/)、[Beats](https://www.elastic.co/beats/)、[Logstash](https://www.elastic.co/guide/en/logstash/current/index.html) 的数据摄取

**高级迁移步骤**

Elastic 开发了自己的规范性方法，用于将本地 Elastic Cluster 迁移至 Elastic Cloud。Elastic 方法与 AWS 迁移指南和最佳实践（[架构完善的框架](https://aws.amazon.com/architecture/well-architected/?wa-lens-whitepapers.sort-by=item.additionalFields.sortDate&wa-lens-whitepapers.sort-order=desc)和 [AWS 迁移加速计划](https://aws.amazon.com/migration-acceleration-program/) (MAP)）直接一致并互为补充。通常，三个 AWS 迁移阶段如下：
+ 评测
+ 动员
+ 迁移与现代化

Elastic 遵循类似迁移阶段，术语互补：
+ 启动
+ 规划
+ 实施
+ 交付
+ Close

Elastic 使用 Elastic 实施方法促进项目成果交付。这在设计上具有包容性，可确保 Elastic、咨询团队和客户团队能清晰地协同工作，共同实现预期成果。

Elastic 方法在实施阶段将传统瀑布项目分阶段与 Scrum 相结合。技术需求的配置以协作方式迭代交付，同时最大限度降低风险。

![该图介绍了 Elastic 实施方法的五个阶段。](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/images/pattern-img/23d1b437-22ff-420e-80ac-834f1116d234/images/b041c61d-980e-49a0-a721-791c20edde64.png)


 

## 工具
<a name="migrate-an-elk-stack-to-elastic-cloud-on-aws-tools"></a>

**Amazon Web Services**
+ [Amazon Route 53](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/Welcome.html) 是一项高度可用且可扩展的域名系统（DNS）Web 服务。您可以使用 Route 53 以任意组合执行三个主要功能：域注册、DNS 路由和运行状况检查。
+ [Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html) – Amazon Simple Storage Service (Amazon S3) 是一项对象存储服务。您可以通过 Amazon S3 随时在 Web 上的任何位置存储和检索的任意大小的数据。此模式使用 S3 存储桶和 [Amazon S3 Transfer Acceleration](https://docs.aws.amazon.com/AmazonS3/latest/userguide/transfer-acceleration-examples.html)。
+ [Elastic L](https://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/what-is-load-balancing.html) oad Balancing — Elastic Load Balancing 会自动将您的传入流量分配到一个或多个可用区的多个目标，例如 EC2 实例、容器和 IP 地址。

**其他工具**
+ [Beats](https://www.elastic.co/beats/) – Beats 发布来自 Logstash 或 Elasticsear
+ [Elastic Cloud](https://www.elastic.co/cloud/) – Elastic Cloud 是一项用于托管 Elasticsearch 的托管服务。
+ [Elasticsearch](https://www.elastic.co/elasticsearch/) – Elasticsearch 是一个搜索和分析引擎，它使用 Elastic Stack 集中存储您的数据，以便进行大规模的搜索和分析。此模式还使用快照创建与跨集群复制。
+ [Logstash](https://www.elastic.co/logstash/) — Logstash 是一项服务器端数据处理管道，它从多个来源摄取数据，对其进行转换，然后将其发送到您的数据存储。

## 操作说明
<a name="migrate-an-elk-stack-to-elastic-cloud-on-aws-epics"></a>

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


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 识别可运行本地 Elastic 解决方案的服务器。 | 确认可支持弹性迁移。 | 应用程序所有者 | 
| 了解本地的服务器配置。 | 要了解成功驱动本地工作负载所需服务器配置，请查找当前使用的服务器硬件占用空间、网络配置和存储特性 | App Support | 
| 收集用户和应用程序的账户信息。 | 识别本地 Elastic 环境使用的用户名以及应用程序名称。 | 系统管理员，App support | 
| 记录 Beats 以及数据采集器配置。 | 若要记录配置，请查看现有的数据来源和接收器。有关更多信息，请参阅 [Elastic 文档](https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html)。 | App support | 
| 确定数据的速度与数量。 | 为集群处理数据量设定基准。 | 系统管理员，App support | 
| 记录 RPO 与 RTO 方案。 | 记录中断和服务级别协议方面的恢复点目标 (RPO) 和恢复时间目标 (RTO) 情景 (SLAs)。 | 应用程序所有者、系统管理员、应用程序支持 | 
| 确定最佳快照生命周期设置。 | 定义在迁移*期间和之后*，需要使用 Elastic 快照保护数据的频率。 | 应用程序所有者、系统管理员、应用程序支持 | 
| 定义迁移后的性能预计。 | 生成有关当前和预期屏幕刷新、查询运行时以及用户界面行为的指标。 | 系统管理员，App support | 
| 记录互联网接入传输、带宽以及可用性要求。 | 确定将快照复制到 Amazon S3 的互联网连接的速度、延迟以及弹性。 | 网络管理员 | 
| 记录 Elastic 本地运行时系统的当前成本。 | 确保 AWS 目标环境的规模设计高性能且具有成本效益。 | 数据库管理员、系统管理员、App support | 
| 确定身份验证以及授权需求。 | Elastic Stack 安全功能提供了内置领域，例如 Lightweight Directory Access Protocol (LDAP)、Security Assertion Markup Language (SAML) 和 OpenID Connect (OIDC). | 数据库管理员、系统管理员、App support | 
| 根据地理位置了解具体监管要求。 | 确保根据您的要求和任何相关的国家要求，对数据进行导出和加密。 | 数据库管理员、系统管理员、App support | 

### 实施迁移
<a name="implement-the-migration"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 在 Amazon S3 准备暂存区。 | 若要在 Amazon S3 上接收快照，[请创建一个 S3 存储桶](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html)和一个具有对新创建存储桶具有完全访问权限的临时 AWS Identity and Access Management (IAM) 角色。有关更多信息，请参阅[创建向 IAM 用户委派权限的角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user.html)。使用 AWS Security Token Service [请求临时安全凭证](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html)。确保访问密钥 ID、秘密访问密钥和会话令牌安全。<br />在存储桶上启用 [Amazon S3 Transfer Acceleration](https://docs.aws.amazon.com/AmazonS3/latest/userguide/transfer-acceleration-examples.html)。 | AWS 管理员 | 
| 在本地安装 AWS CLI 和Amazon S3 插件。 | 在每个 Elasticsearch 节点上运行以下命令。<pre>sudo bin/elasticsearch-plugin install repository-s3</pre><br />然后重新启动该节点。 | AWS 管理员 | 
| 配置 Amazon S3 客户端的访问权限。 | 通过运行以下命令，添加之前创建的密钥。<pre>elasticsearch-keystore add s3.client.default.access_key</pre><pre>elasticsearch-keystore add s3.client.default.secret_key</pre><pre>elasticsearch-keystore add s3.client.default.session_token</pre> | AWS 管理员 | 
| 为 Elastic 数据注册快照存储库 | 使用 [Kibana Dev Tools](https://www.elastic.co/guide/en/kibana/current/console-kibana.html) 告诉本地集群要写入哪个远程 S3 存储桶。 | AWS 管理员 | 
| 配置快照策略。 | 要配置快照生命周期管理，请在 Kibana **策略**选项卡选择 **SLM 策略**，然后定义应包含哪些时间、数据流或索引以及要使用的名称。<br />配置频繁拍摄快照策略。快照是增量，可有效利用存储空间。与准备情况评测决定相匹配。策略还可指定[保留策略](https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-retention.html)，并在不再需要快照时自动删除它们。 | App support | 
| 验证快照是否有效。 | 在 Kibana 开发人员工具，运行以下命令。<pre>GET _snapshot/<your_repo_name>/_all</pre> | AWS 管理员，App support  | 
| 在 Elastic Cloud 上部署新集群。 | [登录 Elastic](https://cloud.elastic.co/login?redirectTo=%2Fhome)，根据准备情况评测中的业务调查发现，选择“可观测性、搜索性或安全性”集群。 | AWS 管理员，App support | 
| 设置集群密钥存储访问权限。 | 新集群需访问用于存储快照的 S3 存储桶。在 Elasticsearch Service Console 上，选择**安全**，然后输入您之前创建的访问和私有 IAM 密钥。 | AWS 管理员 | 
| 将 Elastic Cloud 托管集群配置为访问 Amazon S3。 | 设置对先前在 Amazon S3 中创建的快照存储库新集群的访问权限。使用 Kibana 执行以下操作：[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/migrate-an-elk-stack-to-elastic-cloud-on-aws.html) | AWS 管理员，App support | 
| 验证新 Amazon S3 存储库。 | 确保您可访问托管在 Elastic Cloud 集群中的新存储库。 | AWS 管理员 | 
| 初始化 Elasticsearch 服务集群。 | 在 Elasticsearch Service Console，从 S3 快照初始化 Elasticsearch 服务集群。<br />运行以下“发布”命令。<pre>*/_close?expand_wildcards=all</pre><pre>/_snapshot/<your-repo-name>/  <your-snapshot-name>/_restore</pre><pre>*/_open?expand_wildcards=all</pre> | App Support | 

### 完成迁移
<a name="complete-the-migration"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 验证快照恢复是否成功。 | 使用 Kibana 开发人员工具运行以下命令。<pre>GET _cat/indices</pre> | App support | 
| 重新部署摄取服务。 | 将 Beats 和 Logstash 的端点连接至新的 Elasticsearch 服务端点。 | App support | 

### 测试集群环境并清理
<a name="test-the-cluster-environment-and-clean-up"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 验证集群环境。 | 将本地 Elastic 集群环境迁移至 AWS 后，您可以连接到该环境并使用自己的用户验收测试 (UAT) 工具验证新环境。 | App support | 
| 清除资源。 | 验证集群成功迁移后，移除用于迁移的 S3 存储桶以及 IAM 角色。 | AWS 管理员 | 

## 相关资源
<a name="migrate-an-elk-stack-to-elastic-cloud-on-aws-resources"></a>

**Elastic references**
+ [Elastic Cloud](https://www.elastic.co/cloud/)
+ [在 AWS 上托管 Elasticsearch 和 Kibana](https://www.elastic.co/elasticsearch/service)
+ [弹性企业搜索](https://www.elastic.co/enterprise-search)
+ [弹性集成](https://www.elastic.co/integrations?search=amazon)
+ [弹性可观测性](https://www.elastic.co/observability)
+ [弹性安全](https://www.elastic.co/security)
+ [Beats](https://www.elastic.co/beats/)
+ [Elastic APM](https://www.elastic.co/apm/)
+ [迁移至索引生命周期管理](https://www.elastic.co/guide/en/cloud-enterprise/current/ece-migrate-index-management.html)
+ [弹性订阅](https://www.elastic.co/subscriptions)
+ [接触弹性](https://www.elastic.co/contact)

*弹性博文*
+ [如何在 AWS 上从自我管理的 Elasticsearch 迁移至 Elastic Cloud](https://www.elastic.co/blog/how-to-migrate-from-self-managed-elasticsearch-to-elastic-cloud-on-aws)（博客文章）
+ [迁移至 Elastic Cloud](https://www.elastic.co/blog/migrating-to-elastic-cloud)（博客文章）

*Elastic 文档*
+ [教程：使用 SLM 自动备份](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/getting-started-snapshot-lifecycle-management.html)
+ [ILM：管理索引生命周期](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-management.html)
+ [Logstash](https://www.elastic.co/guide/en/logstash/current/index.html)
+ [跨集群复制 (CCR)](https://www.elastic.co/guide/en/elasticsearch/reference/7.14/xpack-ccr.html)
+ [采集管道](https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html)
+ [运行 Elasticsearch API 请求](https://www.elastic.co/guide/en/kibana/current/console-kibana.html)
+ [快照保留](https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-retention.html)

*Elastic 视频和网络研讨会*
+ [Elastic 云迁移](https://www.youtube.com/watch?v=WbPJi-APZ_Q)
+ [Elastic Cloud：客户为什么要迁移](https://www.elastic.co/webinars/elastic-cloud-why-customers-are-migrating-now)（网络研讨会）

**AWS 参考**
+ [Amazon Web Services Marketplace 上的弹性云](https://aws.amazon.com/marketplace/seller-profile?id=d8f59038-c24c-4a9d-a66d-6711d35d7305)
+ [AWS Command Line Interface](https://docs.aws.amazon.com/AmazonS3/latest/userguide/setup-aws-cli.html)
+ [AWS Direct Connect](https://aws.amazon.com/directconnect/)
+ [AWS 迁移加速计划](https://aws.amazon.com/migration-acceleration-program/)
+ [网络负载均衡器](https://aws.amazon.com/elasticloadbalancing/network-load-balancer/)
+ [区域和可用区](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/)
+ [Amazon Route 53](https://aws.amazon.com/route53/)
+ [Amazon Simple Storage Service](https://aws.amazon.com/s3/)
+ [Amazon S3 Transfer Acceleration](https://aws.amazon.com/s3/transfer-acceleration/)
+ [VPN 连接](https://docs.aws.amazon.com/vpc/latest/userguide/vpn-connections.html)
+ [架构完善的框架](https://aws.amazon.com/architecture/well-architected/?wa-lens-whitepapers.sort-by=item.additionalFields.sortDate&wa-lens-whitepapers.sort-order=desc)

## 附加信息
<a name="migrate-an-elk-stack-to-elastic-cloud-on-aws-additional"></a>

如果您计划迁移复杂的工作负载，请使用 [Elastic Consulting Services](https://www.elastic.co/consulting/engage)。如果您有与配置和服务相关的基本问题，请联系 [Elastic Support](mailto:support@elastic.co) 团队。