3

我对使用 AWS 的东西很陌生。我想拍摄当前 SQL Server 实例的快照,并使用 AWS Cloud Formation 创建另一个具有相同快照的实例(以便迁移所有现有数据库和数据)和更多存储容量。

我在亚马逊上看到了一些东西,比如https://s3-us-west-2.amazonaws.com/cloudformation-templates-us-west-2/RDS_MySQL_With_Read_Replica.template

但无法根据我的需要定制它。我不想要所有的 EC2 实例和额外的东西。只是我现有的快照 ID 和将使用快照 ID 克隆的新 SQL Server RDS 实例详细信息

4

1 回答 1

3

使用 CLI 或 PowerShell 手动拍摄现有数据库的快照,并记下 DBSnapshotIdentifier。

使用 PowerShell 它看起来像这样:

New-RDSDBSnapshot -DBSnapshotIdentifier "NameOfYourNewSnapshot" -DBInstanceIdentifier "YourExistingDbIdentifier"

好的,现在您有了快照,您需要更改 CloudFormation 模板以使用 DBSnapshotIdentifier。

更改现有模板以创建 SqlServer 数据库并指定新属性DBSnapshotIdentifier

"MyDB" : {
 "Type" : "AWS::RDS::DBInstance",
 "Properties" : {
     "DBSecurityGroups" : [
        {"Ref" : "MyDbSecurityByEC2SecurityGroup"}, {"Ref" : "MyDbSecurityByCIDRIPGroup"} ],
     "AllocatedStorage" : "20",
     "DBInstanceClass" : "db.t2.micro",
     "Engine" : "sqlserver-ex",
     "MasterUsername" : "MyName",
     "MasterUserPassword" : "MyPassword",
     "DBSnapshotIdentifier" : "NameOfYourNewSnapshot"
 }
}

应该就是这样,当您运行堆栈时,它会从您的快照中删除并重新创建您的数据库,因此请务必注意停机时间。

文件:

http://docs.aws.amazon.com/powershell/latest/reference/Index.html
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-database-instance.html
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-database-instance.html#cfn-rds-dbinstance-dbsnapshotidentifier

于 2017-03-09T03:45:18.433 回答