AWS使用快照创建实例启动失败

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AWS使用快照创建实例启动失败相关的知识,希望对你有一定的参考价值。

参考技术A  因业务需求,需要将A集群复制一份到B集群,当做预生产环境使用。但是在AWS使用快照的方式创建EC2实例的时候无法正常启动,通过获取AWS EC2截图能够看到已经到了登录界面。

 在发现问题后尝试使用 SSM 登录,但是却无法登录进系统内部。后再停止实例运行,然后在运行实例,依然无法启动。
为了排查是 VPC 的问题,还是实例镜像的问题。使用另外一台服务器的镜像启动,但是依然无效。最后在待实例进入 running 状态后,依次选择 Actions 、 Instance Settings 、 Get System Log 通过获取系统日志发现了一些问题。

在 /usr/bin/cloud-init 中修改 #!/usr/bin/python 为 #!/usr/bin/python2.7 然后手动创建快照。在用创建的快照从新启动一台新的实例来。

为了能够更好的解决这个问题。后来通过实际测试, centos7 系统中默认使用的 python 版本为 python2.7 ,我们通过使用 yum 安装,是不会覆盖掉系统的python版本。

所以建议,系统中同时存在两个 python 版本,您使用 yum 安装 python3 这样不会覆盖系统的 python 版本,在您不想使用系统 python2.7.x 而使用 python3 时,您直接在相应应用指明使用python的版本即可。
如果将 Centos7 中系统默认的 python 版本修改为 python3 时,这个可能会遇到各种各样的问题。
不过 python2.7 已经停止维护了,如果不想使用 python2.7 ,目前可能只能通过升级系统的方式来解决这个问题, centos8 和 redhat8 系统默认使用的 python 版本都是 python3
文章原文
https://cnsre.cn/posts/210311132723

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

【中文标题】AWS-CLI:在从快照创建的现有集群中创建 RDS Aurora 数据库实例【英文标题】:AWS-CLI : Create RDS Aurora DB instance into existing cluster created from snapshot 【发布时间】:2017-12-30 06:30:39 【问题描述】:

根据我的研究,我发现使用 CLI 从现有快照创建包含实例的 Aurora 集群的唯一方法是按照以下步骤操作:

1) 从现有集群创建快照

2) 从快照启动集群

3) 将实例添加到集群中

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

aws rds create-db-cluster-snapshot \
  --db-cluster-snapshot-identifier analytics-replica-db \
  --db-cluster-identifier prodcluster

哪个输出


    "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
    

之后,我使用这个创建集群:

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

哪个输出


    "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
    

现在,我只想运行这个

aws rds create-db-instance \
  --db-name this_is_the_database_name_equal_to_original_cluster_db \
  --db-instance-identifier analytics-replica-instance \
  --db-instance-class "db.r3.large" \
  --publicly-accessible \
  --no-enable-iam-database-authentication \
  --db-cluster-identifier analytics-replica-cluster \
  --engine aurora

哪个输出

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

有人能告诉我它为什么讨厌我吗?

【问题讨论】:

不要传递--db-name,因为这是在集群上设置的,而不是在实例上。 “请求的数据库实例将是数据库集群的成员。[您只能]为数据库集群[而不是实例]设置[该]数据库名称。” 谢谢!稍后在集群上没有 --db-name 的情况下再试一次 你是对的!我对错误消息的理解很差。非常感谢您的帮助!!! 【参考方案1】:

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

这个错误一开始很棘手,但很容易理解。最后一部分,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

【讨论】:

以上是关于AWS使用快照创建实例启动失败的主要内容,如果未能解决你的问题,请参考以下文章

启动 AWS EC2 实例时如何使用 bash 脚本运行 postgres?

AWS ec2 - 从快照添加的卷的磁盘uuid

如何创建和应用初始快照

"锁定文件失败 打不开磁盘或它所依赖的某个快照磁盘。模块启动失败。未能启动虚拟机"--解决方法

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

[AWS][安全] 监控登录 Console 失败