Opensearch集群跨账号迁移

迁移学习
数据迁移
开源
Amazon OpenSearch Service
0
0
# 迁移背景 因公司部门组织结构发生调整,同时业务也需要进行相应的拆分,为了更好的对云资源进行管理和成本核算,需要将AWS公有云账号A的托管Opensearch集群:content-index迁移到AWS公有云B账号(实际上就是跨AWS账号对Opensearch集群进行迁移)。 # 迁移操作 ## 制作迁移快照 #### 1. 在A账号操作 - 创建S3桶:arn:aws:s3:::es-s3-repository-bigdata,用于注册opensearch仓库,保存快照使用。 - 创建策略:es-s3-repository-bigdata-policy,授权对s3桶:es-s3-repository-bigdata的读写操作。 ```JSON { "Version": "2012-10-17", "Statement": [ { "Action": [ "s3:ListBucket" ], "Effect": "Allow", "Resource": [ "arn:aws:s3:::es-s3-repository-bigdata" ] }, { "Action": [ "s3:GetObject", "s3:PutObject", "s3:DeleteObject" ], "Effect": "Allow", "Resource": [ "arn:aws:s3:::es-s3-repository-bigdata/*" ] } ] } ``` * 创建角色:es-s3-repository-bigdata-role,编辑信任关系: ```JSON "Version": "2012-10-17", "Statement": [ { "Sid": "Statement1", "Effect": "Allow", "Principal": { "Service": "opensearchservice.amazonaws.com" }, "Action": "sts:AssumeRole" } ] } ``` * 并将上述策略:es-s3-repository-bigdata-policy 附加到角色:es-s3-repository-bigdata-role * 创建策略:eventlog-migration-policy,用户可使用上述角色es-s3-repository-bigdata-role对opensearch的contentos-explorer授权put操作 ```JSON { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iam:PassRole", "Resource": "arn:aws:iam::316XXXXXXXXX:role/es-s3-repository-bigdata-role" }, { "Effect": "Allow", "Action": "es:ESHttpPut", "Resource": "arn:aws:es:us-east-1:316XXXXXXXXX:domain/contentos-explorer/*" } ] } ``` * 创建用户:eventlog-migration-user-A,将上述策略eventlog-migration-policy附加到该用户 * 对用户:eventlog-migration-user-A 创建访问密钥AK/SK #### 2. 在postman执行操作: * 添加认证信息,在Authorization选项卡添加如下内容: 认证信息(用户eventlog-migration-user-A): AKIA2SQHRUUVBMBBCBVD Mp4b01+MVgBD3gltxaZwLlLDRDU+8D/B4MoL0CCA us-east-1 Es 如下截图所示: ![1.png](https://dev-media.amazoncloud.cn/a5290d751fb8496ebd00c10e617afd5f_1.png "1.png") * 在Headers选项卡添加信息: Content-Type:application/json 如下截图所示: ![2.png](https://dev-media.amazoncloud.cn/52bd8e697da2457c9b1a807993b26589_2.png "2.png") * 在Body选项卡添加如下信息: ```JSON body: { "type" : "s3", "settings" : { "bucket" : "es-s3-repository-bigdata", "base_path" : "eventlog_backup", "region" : "us-east-1", "role_arn" : "arn:aws:iam::316XXXXXXXXX:role/es-s3-repository-bigdata", "compress" : "true" } } ``` 如下截图所示: ![3.png](https://dev-media.amazoncloud.cn/b0fb7510d2b74455a25eaef9cef6308e_3.png "3.png") #### 3. kibana执行快照操作: PUT \_snapshot/eventlog_backup/eventlog_snapshot\_20230707?wait_for_completion=true #### 4.快照完毕后校验检查: ![4.png](https://dev-media.amazoncloud.cn/261ed8bf51584fe6b21c0e6535ed1bfd_4.png "4.png") 快照与原数据大小一致 ![5.png](https://dev-media.amazoncloud.cn/e9f44c89884346448753002a7d8a4d3c_5.png "5.png") 查看快照信息 GET \_snapshot/eventlog_backup/\_all ![6.png](https://dev-media.amazoncloud.cn/9e8560ac46cb483293be39cfe0aa7623_6.png "6.png") ## 快照数据实现S3跨账号传输 #### 1. 在账号B操作: * 创建 IAM 用户,并配置该用户的访问密钥 具体操作步骤可以参考以下官方文档: <https://docs.aws.amazon.com/zh_cn/IAM/latest/UserGuide/id_users_create.html> 注意:请把用户的访问密钥(访问密钥 ID 和秘密访问密钥)下载下来,后续会用到。 * 创建 IAM 客户托管策略 将以下 IAM 策略复制进去,并修改以下相关配置: **source*****bucket*****name**替换为账号A源存储桶的名称,即账户 A 中创建 S3 存储桶名称:es-s3-repository-bigdata; **destination*****bucket*****name**替换为目标存储桶名称,即账户 B 中创建 S3 存储桶名称:es-s3-repository-bigdata-dst。 这条策略是允许 IAM 用户将对象从账户 A 中的源存储桶复制到账户 B 中的目标存储桶。 ```JSON { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:ListBucket", "s3:GetObject" ], "Resource": [ "arn:aws:s3:::es-s3-repository-bigdata", "arn:aws:s3:::es-s3-repository-bigdata/*" ] }, { "Effect": "Allow", "Action": [ "s3:ListBucket", "s3:PutObject", "s3:PutObjectAcl" ], "Resource": [ "arn:aws:s3:::es-s3-repository-bigdata-dst", "arn:aws:s3:::es-s3-repository-bigdata-dst/*" ] } ] } ``` * IAM 的托管策略附加到该IAM用户 #### 2. 在账号A操作: * 将存储桶策略附加到账户 A 的源存储桶:es-s3-repository-bigdata (1)操作如下:选择创建的 S3 存储桶,选择 **权限**,找到 **存储桶策略**,点击 **编辑**。 (2)将以下存储桶策略复制进去,并修改以下相关配置: **arn:****aws****:iam::11111111111:user/s3-demo** 替换为**账户 B 中 IAM 用户的 ARN:arn:aws:iam::173123465421:user/eventlog-migration-tmp**; **source*****bucket*****name **替换为**在账号 A 中创建的 ****S3**** 存储桶名:es-s3-repository-bigdata****;** 其他配置保留默认。 ```JSON { "Version": "2012-10-17", "Statement": [ { "Sid": "DelegateS3Access", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::173XXXXXXXXX:user/eventlog-migration-tmp" }, "Action": [ "s3:ListBucket", "s3:GetObject" ], "Resource": [ "arn:aws:s3:::es-s3-repository-bigdata/*", "arn:aws:s3:::es-s3-repository-bigdata" ] } ] } ``` #### 3. 在本地电脑安装Aws cli工具: 具体操作步骤可以参考以下官方文档: <https://docs.aws.amazon.com/zh_cn/cli/latest/userguide/cli-chap-install.html> <https://docs.aws.amazon.com/zh_cn/cli/latest/userguide/cli-chap-configure.html> 配置如下参考: aws configure AWS Access Key ID \[None]: ***`AKI*****************`*** AWS Secret Access Key \[None]: ***`wJa*************************************`*** Default region name \[None]: ***`us-west-2`*** Default output format \[None]: ***`json`*** #### 4.在本地电脑执行传输操作: 将账户 A 中源存储桶的所有内容同步到账户 B 中的目标存储桶**:** ```JSON {aws s3 sync s3://es-s3-repository-bigdata s3://es-s3-repository-bigdata-dst ``` ## 还原快照 #### 1.在账号B操作: * 创建S3桶,用于注册opensearch仓库,保存快照使用,在步骤《快照数据实现S3跨账号传输》已创建: arn:aws:s3:::es-s3-repository-bigdata-dst * 创建策略:es-s3-repository-bigdata-dst-policy,授权对s3桶es-s3-repository-bigdata-dst的操作 ```JSON { "Version": "2012-10-17", "Statement": [ { "Action": [ "s3:ListBucket" ], "Effect": "Allow", "Resource": [ "arn:aws:s3:::es-s3-repository-bigdata-dst" ] }, { "Action": [ "s3:GetObject", "s3:PutObject", "s3:DeleteObject" ], "Effect": "Allow", "Resource": [ "arn:aws:s3:::es-s3-repository-bigdata-dst/*" ] } ] } ``` * 创建角色:es-s3-repository-bigdata-dst-role 编辑信任关系: ```JSON { "Version": "2012-10-17", "Statement": [ { "Sid": "Statement1", "Effect": "Allow", "Principal": { "Service": "opensearchservice.amazonaws.com" }, "Action": "sts:AssumeRole" } ] } ``` 并将上述策略:es-s3-repository-bigdata-dst-policy 附加到该角色 * 创建策略:eventlog-migration-dst-policy,用户可使用上述角色es-s3-repository-bigdata-dst-role和对opensearch的contentos-explorer的put操作 ```JSON { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iam:PassRole", "Resource": "arn:aws:iam::316XXXXXXXXX:role/es-s3-repository-bigdata-dst" }, { "Effect": "Allow", "Action": "es:ESHttpPut", "Resource": "arn:aws:es:us-east-1:316XXXXXXXXX:domain/contentos-explorer/*" } ] } ``` * 创建用户:eventlog-migration-tmp-dst,同时创建访问密钥AK/SK,将上述策略eventlog-migration-policy-dst附加到该用户 * #### 2. 在postman执行操作(操作步骤与制作迁移快照第2步一样) #### 3. 还原快照 还原快照并改名.kibana\_1(因为当前.kibana\_1已有) ```Plaintext curl -XPOST -H 'Content-Type: application/json' 'https://search-contentos-explorer-c6ovoubkxltjkx3cxpnjdvji.us-east-1.es.amazonaws.com/_snapshot/eventlog_backup/eventlog_snapshot_20230711/_restore' -d' { "indices": "*", "ignore_unavailable": true, "include_global_state": false, "rename_pattern": ".kibana_1", "rename_replacement": "restored_.kibana_1" }' ``` ## 最终数据质量校验 在kibana上对账号A/B两端的Opensearch的index进行校验,执行如下命令观察count数量是否一致 ![7.png](https://dev-media.amazoncloud.cn/aa3e45347da84bc58342a643b9d2b877_7.png "7.png")
目录
亚马逊云科技解决方案 基于行业客户应用场景及技术领域的解决方案
联系亚马逊云科技专家
亚马逊云科技解决方案
基于行业客户应用场景及技术领域的解决方案
联系专家
0
目录
关闭