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 AWS CLI.

本文探讨了使用Web控制台和AWS CLI停止AWS RDS SQL Server的过程。

介绍 (Introduction)

AWS RDS provides managed database instances for SQL Server, Oracle, MySQL, MariaDB and PostgreSQL. You can easily create, configure and manage the AWS RDS SQL Server. You can refer to these useful articles related to AWS RDS SQL Server on SQLShack.

AWS RDS为SQL Server,Oracle,MySQL,MariaDB和PostgreSQL提供托管数据库实例。 您可以轻松创建,配置和管理AWS RDS SQL Server。 您可以在SQLShack上参考与AWS RDS SQL Server相关的这些有用文章。

AWS provides a free-tier account to try the RDS instance for the development, testing purposes. It does not charge any minimum cost for you and uses pay as you model. It means that if your instance is running 24*7, you pay a higher cost. You can manage the RDS SQL cost by stopping the instance while you are not using it. You should always plan the resource usage and estimated cost using the Amazon RDS Pricing calculators.

AWS提供了免费层帐户来尝试RDS实例,以进行开发和测试。 它不会为您收取任何最低费用,而是在您建模时使用付款。 这意味着,如果您的实例运行24 * 7,则需要支付更高的费用。 您可以通过在不使用实例时停止实例来管理RDS SQL成本。 您应该始终使用Amazon RDS定价计算器来计划资源使用情况和估计成本。

We get the following benefits in the free tier accounts for 12 months from the account registration date.

自帐户注册之日起12个月内,我们的免费套餐帐户将获得以下好处。

  • AWS RDS SQL Server for single availability zone (AZ) service for 750 hours usage for SQL server express edition

    适用于单个可用性区域(AZ)服务的AWS RDS SQL Server可以使用750小时,适用于SQL Server Express Edition
  • General-purpose SSD database storage – 20 GB

    通用SSD数据库存储– 20 GB
  • You can also get 20 GB storage for database backups (snapshots)

    您还可以获得20 GB的存储空间用于数据库备份(快照)

Suppose you create an RDS SQL for the development or testing purpose. You stop instances once you complete learning about RDS. You do not regularly access the SQL instance so it should be in Stopped state. You did not use RDS for 10 days and once you log in again, you are surprised that RDS instance is in running status. You might be worried, right!

假设您出于开发或测试目的创建了RDS SQL。 一旦您完全了解了RDS,就可以停止实例。 您不会定期访问SQL实例,因此它应该处于“已停止”状态。 您有10天没有使用RDS,并且再次登录后,您会惊讶于RDS实例处于运行状态。 您可能会担心,对!

In this article, we will focus on stopping an AWS RDS SQL Server, costs associated with it and why it comes online automatically if you do not start it manually.

在本文中,我们将重点关注停止AWS RDS SQL Server,与之相关的成本以及如果不手动启动它就会自动联机的原因。

停止AWS RDS SQL Server (Stopping an AWS RDS SQL Server)

You can quickly start or stop SQL instance in AWS using AWS web console or AWS CLI. In the following screenshot, we see that instance is in Available status.

您可以使用AWS Web Console或AWS CLI在AWS中快速启动或停止SQL实例。 在以下屏幕截图中,我们看到该实例处于可用状态。

RDS dashboard

In the RDS dashboard, select the instance and go to Actions.

在RDS仪表板中,选择实例并转到Actions

Stop AWS RDS SQL Server

Here, you get the following options.

在这里,您可以获得以下选项。

  • Stop: To stop the RDS instance 停止:停止RDS实例
  • Reboot: To restart RDS instance services 重新启动 :重新启动RDS实例服务
  • Delete: if we want to remove the RDS database permanently, we can choose this option 删除 :如果我们要永久删除RDS数据库,可以选择此选项
  • Take Snapshot: RDS automatically takes snapshots to recover data in case of any issues. You can use this option to take a manual snapshot 拍摄快照:如果发生任何问题,RDS会自动拍摄快照以恢复数据。 您可以使用此选项进行手动快照
  • Restore to point in time: We can restore RDS instance to a specific point in time to recover data 还原到时间点:我们可以将RDS实例还原到特定的时间点以恢复数据

We want to stop the RDS SQL Server instance, so click on the Stop option, and you get the following wizard to stop DB instance.

我们想要停止RDS SQL Server实例,因此单击Stop选项,您将获得以下向导来停止数据库实例。

We specify whether we want to create a snapshot before stopping AWS RDS SQL Server. You also get a piece of information that you can stop a DB instance for up to seven days. If you do not start it manually, AWS automatically starts an instance for you.

我们指定是否要在停止AWS RDS SQL Server之前创建快照。 您还将获得一条信息,可以将数据库实例最多停止七天。 如果您不手动启动它,AWS会自动为您启动一个实例。

Stop DB instance

Let’s take a DB snapshot before stopping the instance. Once you click on Yes, specify a snapshot name. You should give an appropriate snapshot name to identify it quickly.

让我们在停止实例之前进行数据库快照。 单击“是”后,指定快照名称。 您应提供适当的快照名称以快速识别它。

DB snapshot

Specify a snapshot name and click on Yes, Stop Now. It starts stopping the RDS instance.

指定快照名称,然后单击“ 是,立即停止” 。 它开始停止RDS实例。

Stopping status

You can click on Snapshots in the RDS SQL dashboard, and it shows you available manual snapshots. We can see the snapshot that we specified while stopping the RDS instance.

您可以单击RDS SQL仪表板中的“ 快照 ”,它显示可用的手动快照。 我们可以看到在停止RDS实例时指定的快照。

Verify manual snapshot

It takes some time to stop AWS RDS SQL Server. You can refresh the RDS dashboard or web console, and it shows STOPPED status.

停止AWS RDS SQL Server需要一些时间。 您可以刷新RDS仪表板或Web控制台,并显示STOPPED状态。

Refresh AWS console

Once you stop RDS DB instance, AWS charges you only for the provisioned storage as well as for the backup storage. Backup storage includes automated backups and manual snapshots within the specified retention window.

停止RDS数据库实例后,AWS仅向预配置存储和备份存储收费。 备份存储包括指定保留窗口内的自动备份和手动快照。

使用AWS CLI命令停止AWS RDS SQL Server实例 (STOP AWS RDS SQL Server instance using AWS CLI commands)

We use the command-line interface (CLI) for working with the RDS services programmatically. It provides you flexibility in managing the resources without going through the AWS web console process such as login, manage AWS resources.

我们使用命令行界面(CLI)以编程方式使用RDS服务。 它为您提供了管理资源的灵活性,而无需执行诸如登录,管理AWS资源之类的AWS Web控制台过程。

In the article, Learn AWS CLI: An Overview of AWS CLI (AWS Command Line Interface), we took an overview and installed it on the Windows OS. You should go through this article and set up a profile with your access key, secret key and AWS region in which your resources exist.

在文章学习AWS CLI:AWS CLI概述(AWS命令行界面)中 ,我们进行了概述并将其安装在Windows OS上。 您应该仔细阅读本文,并使用访问密钥,秘密密钥和资源所在的AWS区域设置配置文件。

In my case, the RDS instance is already in the STOPPED state. Therefore, let’s first start it using CLI commands. To start an RDS instance, we use start-db-instance command and specify the instance identifier.

就我而言,RDS实例已经处于STOPPED状态。 因此,让我们首先使用CLI命令启动它。 要启动RDS实例,我们使用start-db-instance命令并指定实例标识符。

You can get the RDS identifier from the RDS dashboard as shown below.

您可以从RDS仪表板获取RDS标识符,如下所示。

RDS identifier

We use the following command to start RDS instance SSASInRDS with CLI profile Production.

我们使用以下命令通过CLI配置文件Production启动RDS实例SSASInRDS。

>aws rds start-db-instance –db-instance-identifier ssasinrds –profile production

> aws rds start-db-instance –db-instance-identifier ssasinrds –配置文件制作

If your RDS instance is in a different region, you cannot stop, start using CLI because it cannot find the DB instance. You get the error, as shown below.

如果RDS实例位于其他区域,则无法停止,请开始使用CLI,因为它找不到数据库实例。 您得到错误,如下所示。

AWS CLI Stop

You can either create a new profile with the correct region or modify the existing profile to point towards the appropriate region. You can get more information about the CLI profile using the article link listed above.

您可以使用正确的区域创建新的配置文件,也可以修改现有的配置文件以指向适当的区域。 您可以使用上面列出的文章链接来获取有关CLI配置文件的更多信息。

CLI profile

As shown below, my config file and RDS instance both showing the correct AWS region us-east-1.

如下所示,我的配置文件和RDS实例都显示了正确的AWS区域us-east-1

Profile region

Let’s execute this command using AWS CLI.

让我们使用AWS CLI执行此命令。

>aws rds start-db-instance –db-instance-identifier ssasinrds –profile production

> aws rds start-db-instance –db-instance-identifier ssasinrds –配置文件制作

It gives JSON output, and a few useful columns as shown below.

它提供了JSON输出,以及一些有用的列,如下所示。

JSON output

Required output

It gives information about DB instance, instance class, status, matter user name, endpoint, allocated storage, VPC, security group, BackupRetentionPeriod, PreferredBackupWindow, DBParameterGroups, AvailabilityZone, EngineVersion.

它提供有关数据库实例,实例类,状态,事务用户名,端点,分配的存储,VPC,安全组,BackupRetentionPeriod,PreferredBackupWindow,DBParameterGroups,AvailableZone,EngineVersion的信息。

It starts the RDS instance, as shown below. It might take some time to change status from Starting to Available so that users can connect to the database.

它将启动RDS实例,如下所示。 从启动状态更改为可用状态可能需要一些时间,以便用户可以连接到数据库。

Start RDS using CLI

Once an RDS instance is available, we can use stop-rds-instance CLI command to stop it.

一旦RDS实例可用,我们就可以使用stop-rds-instance CLI命令停止它。

>aws rds stop-db-instance –db-instance-identifier ssasinrds –profile production

> aws rds stop-db-instance –db-instance-identifier ssasinrds –配置文件制作

This command also gives output similar to the start of RDS using CLI.

该命令还提供类似于使用CLI启动RDS的输出。

Output

It follows the same process for stopping RDS and goes through Stopping to Stopped status.

它遵循与停止RDS相同的过程,并从“ 停止”变为“已停止”状态。

Stopping to Stopped status

STOP AW RDS SQL Server的要点 (Essential points to STOP AW RDS SQL Server)

We can note the following points for stopping an AWS RDS SQL Server.

我们可以注意到以下有关停止AWS RDS SQL Server的要点。

  • You can stop RDS instance irrespective of the AWS regions, DB class, version

    无论AWS区域,数据库类,版本如何,都可以停止RDS实例
  • DB instance should be configured in the Single Availability zone

    数据库实例应在“单一可用性”区域中配置
  • We cannot stop the RDS instance configured in a multi availability zone. RDS uses database mirroring or Always on for a stand by a copy of the DB instance for Multi-AZ. You can refer to Multi-AZ Configuration for AWS RDS SQL Server for Multi-AZ configuration
  • 我们无法停止在多可用性区域中配置的RDS实例。 RDS使用数据库镜像或始终启用来支持多可用区的数据库实例的副本。 您可以参考AWS RDS SQL Server的多可用区配置以了解多可用区配置
  • We cannot stop RDS instance having a read replica configuration

    我们无法停止具有只读副本配置的RDS实例
  • Once we click on stop RDS, it performs a normal shutdown and goes through Stopping to Stopped state

    一旦我们单击停止RDS,它将执行正常关闭并进入“停止到已停止”状态
  • AWS retains the storage volume attached to RDS along with their data while the instance is in the STOPPED state. It clears the data stored in the cache

    当实例处于STOPPED状态时,AWS会保留附加到RDS的存储卷及其数据。 清除缓存中存储的数据
  • If you do not star RDS for seven days, AWS automatically starts it to perform required maintenance. If you do not need an available status, you can stop it again

    如果您七天不给RDS加上星号,AWS会自动启动它以执行所需的维护。 如果不需要可用状态,可以再次将其停止
  • AWS retains RDS instance name, ID, Domain Name Server ( DNS), security group, option group

    AWS保留RDS实例名称,ID,域名服务器(DNS),安全组,选项组
  • AWS also retains the transaction log backups to provide a point-in-time restoration

    AWS还保留事务日志备份,以提供时间点还原
  • We cannot make any configuration changes while RDS is in STOPPED status

    当RDS处于STOPPED状态时,我们无法进行任何配置更改
  • We cannot remove the option group, parameter group associated with the RDS instance while it is in STOPPED status

    当RDS实例处于STOPPED状态时,我们无法删除与之关联的选项组和参数组
  • We can modify the option and parameter group, but its changes get applied immediately to RDS once we start the instance

    我们可以修改选项和参数组,但是一旦启动实例,其更改将立即应用于RDS。
  • AWS always retains the RDS endpoint even instance is in Amazon Virtual Private Cloud or not. You should always use the endpoint to connect it with the SSMS or client applications. RDS IP might get changed depending upon the VPC

    即使实例是否在Amazon Virtual Private Cloud中,AWS仍会保留RDS终端节点。 您应该始终使用端点将其与SSMS或客户端应用程序连接。 根据VPC,RDS IP可能会更改

结论 (Conclusion)

In this article, we explored AWS RDS SQL Server using both web console, and the CLI commands. You should always stop the RDS instance if it is not in use. You must note that AWS does not stop RDS for indefinite. It gets the auto start after seven days. We will cover the process to automate the stop and start RDS in the upcoming articles.

在本文中,我们同时使用Web控制台和CLI命令探索了AWS RDS SQL Server。 如果未使用RDS实例,则应始终停止它。 您必须注意,AWS不会无限期停止RDS。 7天后自动启动。 在接下来的文章中,我们将介绍自动停止和启动RDS的过程。

翻译自: https://www.sqlshack.com/how-to-stop-an-aws-rds-sql-server-using-web-console-and-aws-cli/

aws rds监控慢sql

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值