aws rds监控慢sql

In this article, we will review how to migrate database from on-premises SQL Server instance to AWS RDS SQL Server instance and between AWS RDS instances using native backup, restore and amazon simple storage service(S3).

在本文中,我们将回顾如何使用本地备份,还原和亚马逊简单存储服务(S3)将数据库从本地SQL Server实例迁移到AWS RDS SQL Server实例以及在AWS RDS实例之间迁移。

To backup and restore database full backups from simple storage service(S3) bucket to AWS RDS instance we need three important components.

要将数据库完整备份从简单存储服务(S3)存储桶备份和还原到AWS RDS实例,我们需要三个重要组件。

  1. AWS Simple Storage Service(S3) AWS简单存储服务(S3)
  2. AWS Identity access and management (IAM) to access S3 bucket 用于访问S3存储桶的AWS Identity Access and Management(IAM)
  3. Option group with SQLSERVER_BACKUP_RESTORE option enabled 启用了SQLSERVER_BACKUP_RESTORE选项的选项组

创建一个简单的存储服务(S3)存储桶 (Creating a Simple Storage Service (S3) Bucket)

To backup and restore full backups from simple storage service (S3) bucket to RDS instance, we need to create a simple store service (S3) bucket in the same region where RDS instance is created. AWS RDS SQL Server does not support restore or backup to a bucket in a different region.

要将完整备份从简单存储服务(S3)存储桶备份和还原到RDS实例,我们需要在创建RDS实例的同一区域中创建一个简单存储服务(S3)存储桶。 AWS RDS SQL Server不支持还原或备份到其他区域中的存储桶。

To create a simple storage service (S3) bucket, Login to AWS console and Click on Services, Type S3 in the search box and select S3 as shown in the below image which will navigate to Amazon simple storage service (S3) console.

要创建简单存储服务(S3)存储桶,请登录到AWS控制台,然后单击Services ,在搜索框中输入S3并选择S3 ,如下图所示,它将导航到Amazon简单存储服务(S3)控制台。

In Amazon S3 console, Click on Create bucket.

在Amazon S3控制台中,单击创建存储桶。

On the Create bucket pop up window, Input the bucket name and select the region of your choice. Please note that the region you selected should be the same as AWS RDS instance region where you are going to restore the backup or take the backup.

“创建存储桶”弹出窗口中,输入存储桶名称,然后选择所需的区域。 请注意,您选择的区域应与要还原备份或进行备份的AWS RDS实例区域相同。

Click on Next and select other configurations like version settings and permissions as per your choice. Click on Create bucket at the end. Once the bucket is created it will be listed in buckets page as shown in below image.

单击下一步 ,然后根据您的选择选择其他配置,例如版本设置和权限。 单击最后的创建存储桶 。 创建存储桶后,它将在存储桶页面中列出,如下图所示。

创建IAM角色 (Creating an IAM Role)

We need to create an IAM role and attach a policy which will be used by AWS RDS service to access the simple storage service (S3) bucket.

我们需要创建一个IAM角色并附加一个策略,AWS RDS服务将使用该策略来访问简单存储服务(S3)存储桶。

To create an IAM role, Click on Services and type IAM in the search box. Click on IAM as shown in below image which will take you to the IAM console.

要创建IAM角色,请单击“ 服务”,然后在搜索框中键入IAM。 单击IAM,如下图所示,这将带您到IAM控制台。

In IAM console, Click on Policies and click on Create Policy. Select JSON editor and enter as below which will provide the list, read and write permission on the simple storage service(S3) bucket.

在IAM控制台中,单击“ 策略” ,然后单击“创建策略” 。 选择JSON编辑器并输入以下内容,它将提供列表,对简单存储服务(S3)存储桶的读写权限。

{"Version": "2012-10-17","Statement": [{"Effect": "Allow","Action": ["s3:ListBucket","s3:GetBucketLocation"],"Resource": ["arn:aws:s3:::testrdsbackups"]},{"Effect": "Allow","Action": ["s3:GetObjectMetaData","s3:GetObject","s3:PutObject","s3:ListMultipartUploadParts","s3:AbortMultipartUpload"],"Resource": ["arn:aws:s3:::testrdsbackups/*"]}]
}

Replace the ARN of the bucket with your bucket ARN. To know the ARN of the bucket navigate to AWS simple storage service(S3) console and click on Buckets. Now click on the checkbox next to your bucket which will open a pop-up. In the pop up click on copy Bucket ARN.

用存储桶ARN替换存储桶的ARN。 要了解存储桶的ARN,请导航到AWS Simple Storage Service(S3)控制台,然后单击Buckets 。 现在,点击您的存储桶旁边的复选框,这将打开一个弹出窗口。 在弹出窗口中,单击复制Bucket ARN

Once you replace the ARN of bucket click on Review policy. Enter the name and description of the policy and click on Create Policy.

更换存储桶的ARN后,请点击审核政策 。 输入策略的名称和描述,然后单击创建策略。

Now we need to create a role and attach the policy you created above. Navigate to IAM Console, Click on Roles and Click on Create Role.

现在,我们需要创建一个角色并附加您在​​上面创建的策略。 导航到IAM控制台,单击“ 角色”,然后单击“ 创建角色”

In create role page, select the AWS Service as a type of trusted identity and choose RDS service to use this role.

在“创建角色”页面中,选择AWS服务作为一种受信任身份,然后选择RDS服务以使用此角色。

In select use case page, select RDS -Add Role to Database and click on Next: Permissions.

在“选择用例”页面中,选择“ RDS-向数据库添加角色”,然后单击“ 下一步:权限”。

Search for the policy you created above, select the policy and click on Next: Tags

搜索您在上面创建的策略,选择该策略,然后单击下一步:标记

Enter tags if required and click on Next: Review. Enter role name and descriptions. Click on Create role.

如果需要,请输入标签,然后单击“ 下一步:查看”。 输入角色名称和描述。 单击创建角色。

创建选项组 (Creating Option Groups)

We need to create an option group to use native backup and restore option in AWS RDS instance. Navigate to RDS console and click on Option groups. Click on Create Group.

我们需要创建一个选项组以在AWS RDS实例中使用本机备份和还原选项。 导航到RDS控制台,然后单击“ 选项组” 。 单击创建组。

Enter the name, description of the option group. Select the database engine and major engine version. Click on Create.

输入名称,选项组的描述。 选择数据库引擎和主引擎版本。 单击创建。

Navigate to Option groups, select the option you created earlier and click on Add option.

导航到“ 选项组” ,选择您先前创建的选项,然后单击“ 添加选项”。

In Add Option page, Select SQLSERVER_BACKUP_RESTORE option and select the role you created above. You can also create a new role by selecting “Yes” which will automatically create a role and policy to access the simple storage service (S3) bucket.

在“ 添加选项”页面中,选择“ SQLSERVER_BACKUP_RESTORE”选项,然后选择您在上面创建的角色。 您还可以通过选择“ 是”来创建新角色,这将自动创建角色和策略以访问简单存储服务(S3)存储桶。

Select apply immediately and click on Add Option.

选择立即应用,然后单击添加选项。

Navigate to Databases in RDS console, select the database instance and click on Modify.

在RDS控制台中导航到“ 数据库” ,选择数据库实例,然后单击“ 修改”。

In Modify DB instance page, change the option group to the option group you created above and click on continue at the bottom of the page.

在修改数据库实例页面中,将选项组更改为上面创建的选项组,然后单击页面底部的继续。

Select Apply Immediately and Click on Modify DB instance. The database instance will go into Modifying Status. Once the modification is complete, the database instance will be back in Available status.

选择立即应用,然后单击修改数据库实例。 数据库实例将进入“ 修改状态”。 修改完成后,数据库实例将恢复为“ 可用”状态。

从本地迁移到RDS (Migrating from on-premises to RDS)

To migrate the database from on-premises SQL Server to AWS RDS instance, take a full backup of your on-premises SQL server database and upload the full backup(.bak) file to the bucket which you created earlier.

要将数据库从本地SQL Server迁移到AWS RDS实例,请对本地SQL Server数据库进行完整备份,然后将完整backup.bak文件上传到您之前创建的存储桶中。

To upload full backup(.bak) file to the bucket, navigate to Amazon S3 console, Click on Buckets. Click on the simple storage service(S3) bucket you created earlier. Click on Upload

要将完整备份(.bak)文件上传到存储桶,请导航至Amazon S3控制台,单击存储桶。 单击您之前创建的简单存储服务(S3)存储桶。 点击上传

In upload pop up window, Click on Add files and select the database backup or you can even drag and drop files. Click on Next and configure permissions, properties. In the end, click on Upload.

在上载弹出窗口中,单击添加文件并选择数据库备份,或者甚至可以拖放文件。 单击下一步,然后配置权限,属性。 最后,单击上载。

Now login to AWS RDS instance using SQL Server management studio. Use stored procedure rds_restore_database to restore a backup from S3 bucket. This procedure should be run on msdb. database.

现在,使用SQL Server Management Studio登录到AWS RDS实例。 使用存储过程rds_restore_database从S3存储桶中还原备份。 此过程应在msdb上运行。 数据库。

exec msdb.dbo.rds_restore_database
@restore_db_name='SampleDatabase',
@s3_arn_to_restore_from='arn:aws:s3:::testrdsbackups/SampleDatabase.bak'

Once you run the procedure a restore task is created and task id is returned in the result set. We can monitor the status of the task using the stored procedure rds_task_status.

运行该过程后,将创建一个还原任务,并在结果集中返回任务ID。 我们可以使用存储过程rds_task_status监视任务的状态。

exec msdb.dbo.rds_task_status @db_name='SampleDatabase';

This will show the status of all tasks in a particular database. If you want to monitor specific task in AWS RDS SQL Server instance, pass task id as a parameter to the above mentioned stored procedure.

这将显示特定数据库中所有任务的状态。 如果要监视AWS RDS SQL Server实例中的特定任务,请将任务ID作为参数传递给上述存储过程。

Once the restore task is a success, you can see the database in SQL Server management studio.

还原任务成功完成后,您可以在SQL Server Management Studio中查看数据库。

If you want to cancel the restore backup task, use the stored procedure rds_cancel_task. Pass the task id as a parameter to the stored procedure. Below is the sample T-SQL script.

如果要取消还原备份任务,请使用存储过程rds_cancel_task。 将任务id作为参数传递给存储过程。 下面是示例T-SQL脚本。

exec rds_cancel_task @task_id =11

在RDS实例之间迁移数据库 (Migrating database between RDS instances)

Login to source RDS instance using SQL Server management studio and take the backup using stored procedure rds_backup_database.

使用SQL Server Management Studio登录到源RDS实例,并使用存储过程rds_backup_database进行备份。

EXEC msdb.dbo.rds_backup_database @source_db_name = 'SampleDatabase'
,@s3_arn_to_backup_to = 'arn:aws:s3:::testrdsbackups/SampleDatabase_May5.bak'

After executing the above procedure, a backup task is created. Once the backup task is a success the backup file is stored in simple storage service (s3) bucket.

执行上述步骤后,将创建一个备份任务。 备份任务成功完成后,备份文件将存储在简单存储服务(s3)存储桶中。

Now login to the destination AWS RDS SQL Server instance using SQL Server management studio and execute the restore procedure to restore the backup from S3 bucket. Please note that the destination RDS instance should be associated with option group which has SQLSERVER_BACKUP_RESTORE option enabled and an IAM role which has access to the bucket where the backup file is stored.

现在,使用SQL Server Management Studio登录到目标AWS RDS SQL Server实例,并执行还原过程以从S3存储桶还原备份。 请注意,目标RDS实例应与启用了SQLSERVER_BACKUP_RESTORE选项的选项组和有权访问存储备份文件的存储区的IAM角色相关联。

We can also back up the database with encryption to simple storage service (S3) bucket. We need to create a KMS key and give the DescribeKey, GenerateDataKey, Encrypt, Decrypt permissions to the role that is being used in the option group. When we restore the backup to another AWS RDS SQL Server instance, we need to give the same KMS key which is used to take backup. Below is the sample syntax to take backup and restore with encryption using the KMS key.

我们还可以通过加密将数据库备份到简单存储服务(S3)存储桶。 我们需要创建一个KMS密钥,并为选项组中使用的角色授予DescribeKey,GenerateDataKey,Encrypt,Decrypt权限。 当我们将备份还原到另一个AWS RDS SQL Server实例时,我们需要提供用于进行备份的相同KMS密钥。 以下是使用KMS密钥进行加密备份和还原的示例语法。

exec msdb.dbo.rds_backup_database
@source_db_name='SampleDatabase',
@s3_arn_to_backup_to='arn:aws:s3:::testrdsbackups/SampleDatabase_May6.bak',
@kms_master_key_arn='your key here'exec msdb.dbo.rds_restore_database
@restore_db_name='SampleDatabase_May6',
@s3_arn_to_restore_from='arn:aws:s3:::testrdsbackups/SampleDatabase_May6.bak',
@kms_master_key_arn='your key here which is used to take backup'

The role used which is begin used in option group associated with destination AWS RDS instance should have DescribeKey, GenerateDataKey, Encrypt, Decrypt permissions on the KMS key.

在与目标AWS RDS实例相关联的选项组中开始使用的角色应该对KMS密钥具有DescribeKey,GenerateDataKey,Encrypt,Decrypt权限。

本机备份和还原的局限性 (Limitations of native backup and restore)

  • We cannot restore a backup from the s3 bucket of the cross region 我们无法从跨区域的s3存储桶中还原备份
  • FILESTREAM data as AWS RDS SQL Server does not support FILESTREAM数据的数据库的备份,因为AWS RDS SQL Server不支持FILESTREAM FILESTREAM
  • RDS supports native restores of databases up to 5TB RDS支持高达5TB的数据库本机还原
  • If the instance is Multi-AZ, we can restore backups of databases that are in full recovery mode 如果实例是多可用区,我们可以还原处于完全恢复模式的数据库的备份

翻译自: https://www.sqlshack.com/aws-rds-sql-server-migration-using-native-backups/

aws rds监控慢sql

aws rds监控慢sql_使用本机备份的AWS RDS SQL Server迁移相关推荐

  1. aws rds监控慢sql_如何使用Web控制台和AWS CLI停止AWS RDS SQL Server

    aws rds监控慢sql This article explores the process to stop an AWS RDS SQL Server using web console and ...

  2. aws rds监控慢sql_在AWS RDS SQL Server上的SSAS中部署表格数据库

    aws rds监控慢sql In this article, we are going to explore Analysis Service for AWS RDS SQL Server in de ...

  3. AWS 发布新一代Amazon Aurora Serverless,更方便 SQL Server迁移

    (1)Aurora Serverless v2 可在不到一秒内扩展至支持数十万个事务,与按业务高峰需求进行容量配置的方式相比可节省高达90%的成本:(2)Babelfish for Aurora Po ...

  4. aws rds监控慢sql_使用AWS Database迁移服务进行AWS RDS SQL Server迁移

    aws rds监控慢sql In this article, we will review how to migrate database from on-premise SQL Server ins ...

  5. aws rds监控慢sql_估算AWS RDS SQL Server成本

    aws rds监控慢sql This article explores estimating the AWS RDS SQL Server cost so that you can plan reso ...

  6. aws rds监控慢sql_如何将AWS RDS SQL Server与AWS Glue连接

    aws rds监控慢sql This article gives you an overview of configuring AWS RDS SQL Server with AWS Glue ser ...

  7. aws rds监控慢sql_在AWS RDS SQL Server上使用SSIS包

    aws rds监控慢sql In the first part of the article, Explore SQL Server Integration Services (SSIS) on AW ...

  8. aws rds监控慢sql_使用AWS CLI部署AWS RDS SQL Server

    aws rds监控慢sql This article deploys a new AWS RDS SQL Server using the AWS CLI command: create-db-ins ...

  9. aws rds监控慢sql_将AWS S3存储桶与AWS RDS SQL Server集成

    aws rds监控慢sql This article gives you an overview of integrating AWS S3 buckets with AWS RDS SQL Serv ...

最新文章

  1. MySQL定义条件和处理程序_MySQL教程111-MySQL定义条件和处理程序
  2. Nordic nRF5 SDK和softdevice介绍
  3. Java方法中的参数太多,第6部分:方法返回
  4. 整理JS+FLASH幻灯片播放图片脚本代码
  5. hiveserver2总是启动不起来
  6. Redis系列(七)--Sentinel哨兵模式
  7. 鸿蒙不如安卓PPT,被吐槽为PPT、“哄蒙”、安卓套壳,华为鸿蒙一路走来真不容易...
  8. C# 简单连接数据库并执行SQL查询语句
  9. Java项目 学生信息管理系统 DAO设计模式
  10. QSIP驱动W25Q256调试记录
  11. 大数据综合实验的踩坑总结(林子雨)
  12. mysql如何批量添加数据_mysql如何大批量插入数据 mysql大批量插入数据4种方法
  13. 微信小程序下拉刷新事件无效原因
  14. 小刘同学的第一百二十二篇博文
  15. win8.1删除桌面的IE图标
  16. 计算请假时间(不算节假日)
  17. hdu 4438 la 6389
  18. 《自控力》-- 精华摘抄
  19. [最大生成树Kruskal/倍增LCA] 火车运输 洛谷P1967
  20. 公司内部打印机自动安装批处理文件

热门文章

  1. linux xargs命令
  2. XML读写演示程序(2)
  3. c# 中const 和 static readonly 的区别
  4. 联想340c笔记本cpu能升级吗_高性价比十大笔记本电脑(由高到低价格),有一台五五开也有.........
  5. 1过程流程图 3 apqp_干货 | APQP过程流程图及最新版全套表格汇总,收藏备用!
  6. python color属性_Python turtle.color方法代码示例
  7. 进程调度的时机,切换与过程,方式
  8. 40岁了,突然公司黄了,怎么办?
  9. 三年期定期存款利率多少?
  10. 月薪五万挖过来的高管第二天就离职了,为何公司总留不住优秀人才?