MySQL Amazon RDS:将快照还原到现有实例

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24278220/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 20:39:27  来源:igfitidea点击:

Amazon RDS: Restore snapshot to existing instance

mysqlamazon-web-servicesamazon-rds

提问by SmxCde

I have created a snapshot of my instance and made some unwanted changes in DB.

我已经创建了我的实例的快照并在数据库中进行了一些不需要的更改。

Now I want to restore my instance from this snapshot.

现在我想从这个快照恢复我的实例。

When I try to do it - it creates me one more instance, additionally to the one I have.

当我尝试这样做时 - 除了我拥有的实例之外,它还会为我创建一个实例。

I specify "DB Instance Identifier" and after that I get two instances with the same ID.

我指定了“数据库实例标识符”,然后我得到了两个具有相同 ID 的实例。

So my question: Is there any way to restore snapshot to existing instance?

所以我的问题:有没有办法将快照恢复到现有实例?

Because in other case - new instance is created with differrent endpoint (hostname) and I need to change my configs to access database. Or there is a better way to manage such cases?

因为在其他情况下 - 新实例是使用不同的端点(主机名)创建的,我需要更改我的配置以访问数据库。或者有更好的方法来管理此类案件?

采纳答案by Naveen Vijay

No you can't restore back your existing DB instance to any of the either manual backup or point-in-time snapshot.

不,您无法将现有数据库实例恢复到任何手动备份或时间点快照。

The only way you can make use of the manual backup or automated snapshot is to create a new RDS DB instance using that. Once the new DB instance is created, you can change the endpoint of DB in your app / code and delete the old DB instance.

您可以使用手动备份或自动快照的唯一方法是使用它创建一个新的 RDS 数据库实例。创建新的数据库实例后,您可以在应用程序/代码中更改数据库的端点并删除旧的数据库实例。

Bottomline : You have to change the config settings in your app. No other option.

底线:您必须更改应用程序中的配置设置。没有其他选择。

回答by Katti

If anyone came here (just like me) to just restore data without altering your configuration.

如果有人来这里(就像我一样)只是在不更改配置的情况下恢复数据。

Here are the steps :

以下是步骤:

  • Create a new instance(temp) from your automatic snapshots or manually created ones.
  • Connect to this instance from either Sequel pro or Mysql workbench.
  • Take SQL dump of whatever data you needed from this temp instance.
  • Connect your production instance and restore it.
  • Now delete the temp instance you created.
  • 从您的自动快照或手动创建的快照创建一个新实例(临时)。
  • 从 Sequel pro 或 Mysql 工作台连接到此实例。
  • 从这个临时实例中获取您需要的任何数据的 SQL 转储。
  • 连接您的生产实例并恢复它。
  • 现在删除您创建的临时实例。

回答by MaXimus

Rename original instance and name new instance with original name

重命名原始实例并使用原始名称命名新实例

https://aws.amazon.com/blogs/aws/endpoint-renaming-for-amazon-rds/

https://aws.amazon.com/blogs/aws/endpoint-renaming-for-amazon-rds/

回答by Hyman.chen.job

I had the same issue today. I think you have two options without changing the application's configuration setting.

我今天遇到了同样的问题。我认为您有两个选择而无需更改应用程序的配置设置。

  1. delete the old instance as Mike suggested, then restore it.

  2. rename the old instance first ( need to check "Apply immediately" option when rename it).

  1. 按照 Mike 的建议删除旧实例,然后恢复它。

  2. 首先重命名旧实例(重命名时需要选中“立即应用”选项)。

回答by cjuroz

As @MaXimus said (I cannot add comments yet) you can:

正如@MaXimus 所说(我还不能添加评论)你可以:

  1. rename original instance first
  2. restore from snapshot and assign original instance name
  1. 首先重命名原始实例
  2. 从快照恢复并分配原始实例名称

As it's specified in Renaming to Replace an Existing DB Instancehere: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_RenameInstance.html

正如Renaming to Replace an Existing DB Instance此处指定的那样:https: //docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_RenameInstance.html

回答by Franky

After you created the restored db with a new name you can rename the current instance to ...-old, this also renames the db url. After the url is also changed, you have to rename the restored db to the befored used name, wait until the url of the db changes. Then you have to restart your services, and they will connect to the restored db.

使用新名称创建还原的 db 后,您可以将当前实例重命名为 ...-old,这也会重命名 db url。url也更改后,您必须将恢复的db重命名为之前使用的名称,等待db的url更改。然后你必须重新启动你的服务,它们将连接到恢复的数据库。

This causes no outage at all.

这根本不会导致中断。