AWS-CLI:将 RDS Aurora 数据库实例创建到从快照创建的现有集群中

Mar*_*fan 6 amazon-web-services amazon-aurora

根据我的研究,我发现使用 CLI 创建一个 Aurora 集群的唯一方法是从现有快照创建一个内部有实例的实例:

1) 从现有集群创建快照

2) 从快照启动集群

3) 将实例添加到集群中

因此,我使用最新的 AWS CLI 版本运行的命令如下(以及输出):

aws rds create-db-cluster-snapshot \
  --db-cluster-snapshot-identifier analytics-replica-db \
  --db-cluster-identifier prodcluster
Run Code Online (Sandbox Code Playgroud)

哪个输出

{
    "DBClusterSnapshot": {
        "Engine": "aurora",
        "SnapshotCreateTime": "2017-07-24T15:08:12.836Z",
        "VpcId": "vpc-ID",
        "DBClusterIdentifier": "cluster_name",
        "DBClusterSnapshotArn": "arn:aws:rds:eu-west-1:aws_account:cluster-snapshot:analytics-replica-db",
        "MasterUsername": "db_username",
        "LicenseModel": "aurora",
        "Status": "creating",
        "PercentProgress": 0,
        "DBClusterSnapshotIdentifier": "analytics-replica-db",
        "IAMDatabaseAuthenticationEnabled": false,
        "ClusterCreateTime": "2016-04-14T11:10:02.413Z",
        "StorageEncrypted": false,
        "AllocatedStorage": 1,
        "EngineVersion": "5.6.10a",
        "SnapshotType": "manual",
        "AvailabilityZones": [
            "eu-west-1a",
            "eu-west-1b",
            "eu-west-1c"
        ],
        "Port": 0
    }
}
Run Code Online (Sandbox Code Playgroud)

之后,我使用以下命令创建集群:

aws rds restore-db-cluster-from-snapshot \
  --db-cluster-identifier analytics-replica-cluster \
  --snapshot-identifier analytics-replica-db \
  --engine aurora \
  --port 3306 \
  --db-subnet-group-name this_is_a_subnet_group \
  --database-name this_is_the_database_name_equal_to_original_cluster_db \
  --vpc-security-group-ids this_is_a_random_security_group \
  --no-enable-iam-database-authentication
Run Code Online (Sandbox Code Playgroud)

哪个输出

{
    "DBCluster": {
        "MasterUsername": "this_is_the_same_username_as_the_one_on_original_db",
        "ReaderEndpoint": "this_is_the_new_RDS_endpoint_of_cluster",
        "ReadReplicaIdentifiers": [],
        "VpcSecurityGroups": [
            {
                "Status": "active",
                "VpcSecurityGroupId": "this_is_that_security_group"
            }
        ],
        "HostedZoneId": "Z29XKXDKYMONMX",
        "Status": "creating",
        "MultiAZ": false,
        "PreferredBackupWindow": "23:50-00:20",
        "DBSubnetGroup": "this_is_a_subnet_group",
        "AllocatedStorage": 1,
        "BackupRetentionPeriod": 10,
        "PreferredMaintenanceWindow": "fri:03:34-fri:04:04",
        "Engine": "aurora",
        "Endpoint": "this_is_the_new_RDS_endpoint_of_reader",
        "AssociatedRoles": [],
        "IAMDatabaseAuthenticationEnabled": false,
        "ClusterCreateTime": "2017-07-24T15:11:07.003Z",
        "EngineVersion": "5.6.10a",
        "DBClusterIdentifier": "analytics-replica-cluster",
        "DbClusterResourceId": "cluster-resource_id",
        "DBClusterMembers": [],
        "DBClusterArn": "arn:aws:rds:eu-west-1:aws_account:cluster:analytics-replica-cluster",
        "StorageEncrypted": false,
        "DatabaseName": "this_is_the_database_name_equal_to_original_cluster_db",
        "DBClusterParameterGroup": "default.aurora5.6",
        "AvailabilityZones": [
            "eu-west-1a",
            "eu-west-1b",
            "eu-west-1c"
        ],
        "Port": 3306
    }
}
Run Code Online (Sandbox Code Playgroud)

现在,我想做的就是运行这个

{
    "DBClusterSnapshot": {
        "Engine": "aurora",
        "SnapshotCreateTime": "2017-07-24T15:08:12.836Z",
        "VpcId": "vpc-ID",
        "DBClusterIdentifier": "cluster_name",
        "DBClusterSnapshotArn": "arn:aws:rds:eu-west-1:aws_account:cluster-snapshot:analytics-replica-db",
        "MasterUsername": "db_username",
        "LicenseModel": "aurora",
        "Status": "creating",
        "PercentProgress": 0,
        "DBClusterSnapshotIdentifier": "analytics-replica-db",
        "IAMDatabaseAuthenticationEnabled": false,
        "ClusterCreateTime": "2016-04-14T11:10:02.413Z",
        "StorageEncrypted": false,
        "AllocatedStorage": 1,
        "EngineVersion": "5.6.10a",
        "SnapshotType": "manual",
        "AvailabilityZones": [
            "eu-west-1a",
            "eu-west-1b",
            "eu-west-1c"
        ],
        "Port": 0
    }
}
Run Code Online (Sandbox Code Playgroud)

哪个输出

调用 CreateDBInstance 操作时发生错误 (InvalidParameterCombination):请求的数据库实例将是数据库集群的成员。设置数据库集群的数据库名称。

有人可以告诉我为什么讨厌我吗?

Chr*_*hez 3

对于面临同样问题的任何人,当您将新实例添加到 aurora 集群时,某些选项不可用。

这个错误一开始很棘手,但很容易理解。最后一部分Set database name for the DB Cluster.指出了真正的问题,大多数时候,您需要删除该属性。

An error occurred (InvalidParameterCombination) when calling the CreateDBInstance operation: The requested DB Instance will be a member of a DB Cluster. Set backup retention period for the DB Cluster.您需要删除的另一个示例--backup-retention-period