当我尝试使用 AWS CloudFormation 升级我的 Amazon Relational Database Service(Amazon RDS)集群的引擎版本时,出现以下错误:“The following parameters are not defined for the specified group: xxx, xxx.(未为指定的组定义以下参数:xxx, xxx。)”
简短描述
当您升级使用自定义参数组的 Amazon RDS 数据库集群或实例时,如果更新,则会收到错误消息
例如,在以下模板中,将 DBInstance 资源中的 EngineVersion 属性从 5.7.37 更新为 8.0.28 会导致堆栈更新失败。当您在 DBParameterGroup 资源中将 Family 属性从 MySQL5.7 更新为 MySQL8.0 时,堆栈更新也会失败。
Parameters:
DBName:
Default: MyDatabase
Description: The database name
Type: String
DBUser:
NoEcho: 'true'
Description: The database admin account username
Type: String
DBPassword:
NoEcho: 'true'
Description: The database admin account password
Type: String
Resources:
MyDB:
Type: 'AWS::RDS::DBInstance'
Properties:
DBName: !Ref DBName
AllocatedStorage: '5'
DBInstanceClass: db.t2.small
Engine: MySQL
EngineVersion: 5.7.37
MasterUsername: !Ref DBUser
MasterUserPassword: !Ref DBPassword
DBParameterGroupName: !Ref MyRDSParamGroup
AllowMajorVersionUpgrade: true
MyRDSParamGroup:
Type: 'AWS::RDS::DBParameterGroup'
Properties:
Family: MySQL5.7
Description: CloudFormation Sample Database Parameter Group
Parameters:
autocommit: '1'
general_log: '1'
old_passwords: '0'
**注意:**还有其他可能导致此错误消息的场景。以下“解决方法”部分中的步骤仅适用于上述场景。
解决方法
以下几组步骤是解决错误**“The following parameters are not defined for the specified group: xxx, xxx.(未为指定的组定义以下参数:xxx, xxx。)”**的两种方法
**注意:**将参数组应用于数据库实例可能会启动实例重启。在重启期间,数据库中断。
- 使用新的 Family 值将新的 ParameterGroup 资源添加到堆栈模板中,并将旧的 ParameterGroup 资源保留在模板中。
- 在 AWS::RDS::DBCluster 或 AWS::RDS::DBInstance 中引用新的 ParameterGroup 资源,然后将 EngineVersion 属性更新为新版本。
**注意:**如果您正在执行主要版本升级,则必须将 AllowMajorVersionUpgrade 属性设置为 true。
- 使用更新的模板更新堆栈。
- 更新堆栈后,从堆栈模板中移除之前的 ParameterGroup 资源。
-或者-
- 更改 ParameterGroup 资源的 LogicalResourceID。
- 在 AWS::RDS::DBCluster 或 AWS::RDS::DBInstance 中引用新的 LogicalResourceID。