aws rds监控慢sql_使用AWS Backup备份AWS RDS SQL Server数据库

aws rds监控慢sql

This article gives you an overview of creating backups of AWS RDS SQL Server database instances using AWS Backup service.

本文为您概述了使用AWS Backup服务创建AWS RDS SQL Server数据库实例的备份。

介绍 (Introduction)

Database backups and restoring is a very standard process and an integral part of any database administration job. In real-life scenarios, there can be tens to hundreds of database instances, in various environments like development, testing, and production. Although one can perform individual database backups, often it’s not an efficient process and cannot be easily scaled. Administrators often group databases and perform backups in batch modes instead of performing individual backups as part of their routine backup process. AWS RDS service supports SQL Server as one of the databases. Organizations routinely create a large number of AWS RDS SQL Server database instances as part of their production workloads, and with it comes the need to back up these database instances. AWS RDS for SQL Server provides options to create backups using AWS RDS itself. There is a specialized service in AWS to perform volume backups on not only AWS RDS databases but many other resources as well. This service is known as AWS Backup which addresses the exact scenario mentioned above. In this article, we will be exploring the process of creating on-demand backups on AWS SQL Server database instances using AWS Backup service.

数据库备份和还原是非常标准的过程,并且是任何数据库管理工作的组成部分。 在现实生活中,在诸如开发,测试和生产等各种环境中,可能存在数十至数百个数据库实例。 尽管可以执行单个数据库备份,但是通常这不是一个有效的过程,因此无法轻松扩展。 管理员通常将数据库分组并以批处理模式执行备份,而不是在日常备份过程中执行单个备份。 AWS RDS服务支持将SQL Server作为数据库之一。 组织通常会在其生产工作负载中创建大量的AWS RDS SQL Server数据库实例,因此需要备份这些数据库实例。 适用于SQL Server的AWS RDS提供了使用AWS RDS本身创建备份的选项。 AWS中有一项专门服务,不仅可以在AWS RDS数据库上执行卷备份,而且还可以在许多其他资源上执行卷备份。 该服务称为AWS Backup ,可解决上述确切情况。 在本文中,我们将探讨使用AWS Backup服务在AWS SQL Server数据库实例上创建按需备份的过程。

AWS RDS SQL Server实例 (AWS RDS SQL Server Instance)

It’s assumed that a functional instance of Amazon RDS SQL Server is already in place. Beginners on AWS RDS for SQL Server, can read this article, Getting started with AWS RDS SQL Server, to create a new instance. Once you have a working instance, it would look as shown below. For this exercise, any SQL Server instance using any edition of SQL Server will work. It is assumed that you have the required privileges to administer the SQL Server database instance.

假设已经存在Amazon RDS SQL Server的功能实例。 适用于SQL Server的AWS RDS的初学者可以阅读本文“ AWS RDS SQL Server入门”以创建新实例。 一旦有了工作实例,它的外观将如下所示。 对于本练习,使用任何版本SQL Server的任何SQL Server实例都将起作用。 假定您具有管理SQL Server数据库实例所需的特权。

AWS RDS SQL Server instance

AWS备份 (AWS Backup)

Now let’s say that we intend to backup the AWS RDS SQL Server instance. Navigate to AWS Backup by opening the AWS Console home page, search for the word backup, and open the service titled AWS Backup. Once you navigate to the home page of AWS Backup, you can see the dashboard as shown below. This dashboard offers different functionalities like creating a new on-demand backup, creating scheduled backup plans, restoring a backup and other backup related functionalities.

现在,我们要备份AWS RDS SQL Server实例。 通过打开AWS控制台主页导航到AWS Backup,搜索单词backup,然后打开标题为AWS Backup的服务。 导航到AWS Backup的主页后,您将看到如下所示的仪表板。 该仪表板提供了不同的功能,例如创建新的按需备份,创建计划的备份计划,还原备份以及其他与备份相关的功能。

AWS Backup home page

We intend to create an on-demand backup of AWS RDS SQL Server instance, so click on create an on-demand backup. After clicking, we would be navigated to a page where we can start providing the details.

我们打算创建AWS RDS SQL Server实例的按需备份,因此请单击创建按需备份。 单击之后,我们将导航到一个页面,我们可以开始提供详细信息。

First, we need to select the type of resource we intend to backup. AWS Backup supports different types of resources like RDS, EC2, DynamoDB and few others. For our exercise, we need to select RDS as the resource type as shown below.

首先,我们需要选择要备份的资源类型。 AWS Backup支持不同类型的资源,例如RDS,EC2,DynamoDB和其他一些资源。 对于我们的练习,我们需要选择RDS作为资源类型,如下所示。

AWS Backup supported data sources

Now we need to select the instance name i.e. the database name as shown below. Generally, AWS Backup discovers your instance and lists it. In case you have many instances in your AWS RDS environment, you can also search for your instance by typing the instance name.

现在,我们需要选择实例名称,即数据库名称,如下所示。 通常,AWS Backup发现您的实例并将其列出。 如果您的AWS RDS环境中有许多实例,您还可以通过键入实例名称来搜索实例。

AWS RDS SQL Server database instance name

We intend to create the backup immediately, so we would select the option Create backup now. If you want to create a window when the backup should start, you can select the Customize backup window. We can ignore the transition storage option for now as it would not apply. The next setting is regarding when the backup should be considered as expired so that it can be removed. You can select any option as per the requirements. We would be deleting the backup immediately after creating a backup successfully. So you can select any setting or keep the default value.

我们打算立即创建备份,因此我们将选择“立即创建备份”选项。 如果要在备份应开始时创建一个窗口,则可以选择“自定义备份”窗口。 我们暂时可以忽略过渡存储选项,因为它不适用。 下一个设置是关于何时应将备份视为过期,以便可以将其删除。 您可以根据要求选择任何选项。 成功创建备份后,我们将立即删除备份。 因此,您可以选择任何设置或保留默认值。

AWS Backup expiration duration

All the backups that are created by AWS Backup are stored in a logical container called a backup vault. You can logically group backups in the vault and perform batch operations on objects stored in a vault. For now, we can use the vault that is already created by default. Alternatively, you can also create a new backup vault by clicking on the Create new backup vault button and providing the required details.

由AWS Backup创建的所有备份都存储在称为备份库的逻辑容器中。 您可以对保管库中的备份进行逻辑分组,并对保管库中存储的对象执行批处理操作。 现在,我们可以使用默认情况下已创建的保管库。 或者,您也可以通过单击创建新备份保管库按钮并提供所需的详细信息来创建新的备份保管库。

AWS Backup IAM Role

The next setting is regarding the IAM role which will be used by AWS Backup to communicate with AWS RDS SQL Server instance and perform the administrative action to create a backup. Use the default role and click on the Create Backup button.

下一个设置与IAM角色有关,AWS Backup将使用该角色与AWS RDS SQL Server实例通信并执行管理操作以创建备份。 使用默认角色,然后单击“创建备份”按钮。

AWS Backup Error

As we used the default IAM role, which is the AWSBackupDefaultRole, it may not have the required privileges to perform administrative actions like Backup on RDS. The solution is either to create a new role that has the required privileges, or you can modify the existing IAM role and add the AWS RDS required privileges as shown below. Here we added AmazonRDSFullAccess privileges to the IAM Role AWSBackupDefaultRole as a quick fix, but ideally, you may want to add a more restrictive policy to this role.

当我们使用默认的IAM角色AWSBackupDefaultRole时,它可能没有执行RDS上的备份之类的管理操作所需的特权。 解决方案是创建具有所需特权的新角色,或者您可以修改现有IAM角色并添加AWS RDS所需特权,如下所示。 在这里,我们将IAS角色AWSBackupDefaultRole的AmazonRDSFullAccess特权添加为快速修复,但理想情况下,您可能希望向该角色添加限制性更强的策略。

AWS Backup IAM Role

Navigate back to the AWS Backup page, and using the default IAM role, click on the Create Backup button and you would be able to create the backup job successfully as shown below. The backup job would be in Creating status and the job has just started the backup process.

浏览回到AWS Backup页面,并使用默认的IAM角色,单击Create Backup按钮,您将能够成功创建备份作业,如下所示。 备份作业将处于“正在创建”状态,并且该作业刚刚开始备份过程。

AWS Backup Job Creation

Click on the backup job name, and you would find the details as shown below. Recovery point ARN (Amazon Resource Name) is the link to the actual backup when it would be created. If for some reason one needs to stop the backup, one can click on the Stop button to terminate the backup job. The job can take some time to complete the backup on the AWS RDS SQL Server instance.

单击备份作业名称,您将找到如下所示的详细信息。 恢复点ARN(Amazon资源名称)是创建实际备份时的链接。 如果出于某种原因需要停止备份,则可以单击“停止”按钮以终止备份作业。 该作业可能需要一些时间才能在AWS RDS SQL Server实例上完成备份。

AWS Backup Job Status - Running

Once the backup job is complete, you would be able to see the status of the job as Completed. As shown below, if you navigate to the Backup vaults from the left pane and open the default vault as shown below, you would find the backup job listed with its status as Completed.

备份作业完成后,您将能够看到作业的状态为“已完成”。 如下所示,如果从左窗格导航到“备份保管库”并按如下所示打开默认保管库,则会发现列出的备份作业的状态为“已完成”。

AWS Backup Job Completed Status

Interestingly, if you navigate to AWS RDS and open the AWS RDS SQL Server database instance, open the backup tab from the dashboard, you would be able to find this backup listed in the Snapshot section as well. You can view restore this snapshot but you won’t find an option to delete the snapshot from this console, as this is controlled by AWS Backup service.

有趣的是,如果您导航到AWS RDS并打开AWS RDS SQL Server数据库实例,从仪表板中打开“备份”选项卡,那么您也可以在“快照”部分中找到该备份。 您可以查看还原此快照,但找不到从该控制台删除快照的选项,因为它由AWS Backup服务控制。

AWS RDS Snapshot

Navigate back up the recovery point in the completed AWS Backup Job as shown below. From here, you can copy this backup, restore it as well as delete the backup. Now that we have learned how to create a backup of AWS RDS SQL Server instance, we can remove this backup. Click on the Delete button, and provide confirmation to delete this backup.

导航回到完成的AWS Backup作业中的恢复点,如下所示。 从这里,您可以复制此备份,还原它以及删除备份。 现在,我们已经学习了如何创建AWS RDS SQL Server实例的备份,我们可以删除此备份。 单击删除按钮,并提供确认以删除此备份。

AWS RDS Recovery Point

Once the backup is deleted, you would receive the confirmation message and the backup section would be empty as shown below. As the backup is removed, we would not incur any charges for the backup.

删除备份后,您将收到确认消息,并且备份部分将为空,如下所示。 删除备份后,我们不会为备份产生任何费用。

AWS Backup Deletion Success

If you cross-check again in AWS RDS by navigating to the Backup section, you would find that the backup entry which we saw earlier would not appear now in the backup section as we have deleted it.

如果您通过导航至“备份”部分再次在AWS RDS中进行交叉检查,您会发现我们先前看到的备份条目不会因为删除而现在出现在备份部分中。

AWS RDS Snapshot

In this way, we can administer backups of multiple AWS RDS SQL Server instances and other resources using AWS Backup service.

通过这种方式,我们可以使用AWS Backup服务管理多个AWS RDS SQL Server实例和其他资源的备份。

结论 (Conclusion)

In this article, we learned how to use the AWS Backup service to create on-demand backups for AWS RDS SQL Server instances. We also learned how to configure the IAM roles required by AWS Backup service to create backups of AWS RDS database instances. Consider creating backups and restoring those backups in your database instances, as well as scheduling backup jobs using the steps explained above.

在本文中,我们学习了如何使用AWS Backup服务为AWS RDS SQL Server实例创建按需备份。 我们还学习了如何配置AWS Backup服务所需的IAM角色,以创建AWS RDS数据库实例的备份。 考虑在数据库实例中创建备份并还原这些备份,以及使用上述步骤安排备份作业。

翻译自: https://www.sqlshack.com/backing-up-aws-rds-sql-server-databases-with-aws-backup/

aws rds监控慢sql

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,关于MySQL数据库备份文件的下载,可以使用Python的boto3库来实现从RDS上下载备份文件。 首先,需要安装boto3库,可以使用pip安装: ``` pip install boto3 ``` 然后,需要在AWS控制台上创建一个IAM用户,并生成该用户的Access Key和Secret Access Key,并将该用户加入RDS的访问策略组中。 接着,可以使用以下Python代码来下载MySQL备份文件: ``` python import boto3 # 配置AWS访问密钥 aws_access_key_id = 'your_access_key_id' aws_secret_access_key = 'your_secret_access_key' # 创建rds client对象 client = boto3.client('rds', aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, region_name='your_rds_region') # 获取最近的mysql备份文件 response = client.describe_db_log_files( DBInstanceIdentifier='your_db_instance_id', FilenameContains='mysql', FileLastWritten=0 ) # 下载mysql备份文件 if len(response['DescribeDBLogFiles']) > 0: file = response['DescribeDBLogFiles'][0] filename = file['LogFileName'] download_response = client.download_db_log_file_portion( DBInstanceIdentifier='your_db_instance_id', LogFileName=filename ) with open('mysql_backup.sql', 'wb') as f: f.write(download_response['LogFileData']) ``` 需要将上面代码中的 `your_access_key_id`,`your_secret_access_key`,`your_rds_region`,`your_db_instance_id` 替换成自己的AWS访问密钥、RDS所在区域和实例ID。 这样,就可以通过PythonRDS上下载MySQL备份文件了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值