通过阿里云CLI执行ESS滚动升级

安装并配置阿里云CLI
本文以Mac-os为例,其他系统安装可参考阿里云CLI
1.首先为阿里云CLI创建一个RAM用户来获取AK,详细操作请参考创建RAM用户

2.为创建的RAM用户授权:

  1. 云账号登录RAM控制台
  2. 在左侧导航栏的人员管理菜单下,单击用户
  3. 用户登录名称/显示名称列表下,找到目标RAM用户。
  4. 单击添加权限,被授权主体会自动填入。
  5. 在左侧权限策略名称列表下,单击AliyunECSFullAccess, AliyunESSFullAccess, AliyunOOSFullAccess, AliyunOSSFullAccess
  6. 单击确定
  7. 单击完成

3.安装阿里云CLI。

brew install aliyun-cli

4.配置CLI。

aliyun configure

通过阿里云CLI执行ESS滚动升级

5.验证CLI可用,若可用,可在终端看到输出当前支持的多个地域。

aliyun ecs DescribeRegions

通过CLI执行滚动升级
1.通过更新镜像滚动升级。
通过阿里云CLI执行ESS滚动升级
模板参数说明请查看ACS-ESS-RollingUpdateByReplaceSystemDiskInScalingGroup模板详情
执行命令如下:

aliyun oos StartExecution --TemplateName ACS-ESS-RollingUpdateByReplaceSystemDiskInScalingGroup --Parameters '{
                "invokeType": "invoke",
                "imageId": "centos_7_8_amd_x64_20G_alibase_20200806.vhd",
                "sourceImageId": "centos_8_2_x64_20G_alibase_20200717.vhd",
                "OOSAssumeRole": "",
                "exitProcess": [],
                "scalingConfigurationId": "asc-bp14e7lqyl66ca4rp4rb",
                "enterProcess": [
                    "ScaleIn",
                    "ScaleOut",
                    "HealthCheck",
                    "AlarmNotification",
                    "ScheduledAction"
                ],
                "scalingGroupId": "asg-bp1cjeuvlt1e1i1t",
                "batchNumber": 2,
                "batchPauseOption": "Automatic"
            }'

回滚命令如下:

aliyun oos StartExecution --TemplateName ACS-ESS-RollingUpdateByReplaceSystemDiskInScalingGroup --Parameters '{
                "invokeType": "rollback",
                "sourceImageId": "centos_8_2_x64_20G_alibase_20200717.vhd",
                "OOSAssumeRole": "",
                "scalingConfigurationId": "asc-bp14e7lqyl66ca4rp4rb",
                "scalingGroupId": "asg-bp1cjeuvlt1e1i1t",
                "sourceExecutionId": "exec-6801252e615c4067a2ef",
                "batchNumber": 2,
                "batchPauseOption": "Automatic"
            }'

2.通过脚本执行滚动升级。
通过阿里云CLI执行ESS滚动升级
模板参数说明请查看ACS-ESS-RollingUpdateByRunCommandInScalingGroup模板详情
执行命令如下:

aliyun oos StartExecution --TemplateName ACS-ESS-RollingUpdateByRunCommandInScalingGroup --Parameters '{
                "invokeType": "invoke",
                "commandType": "RunShellScript",
                "OOSAssumeRole": "",
                "exitProcess": [],
                "invokeScript": "df -h\nifconfig",
                "rollbackScript": "df -h\nifconfig",
                "enterProcess": [
                    "ScaleIn",
                    "ScaleOut",
                    "HealthCheck",
                    "AlarmNotification",
                    "ScheduledAction"
                ],
                "scalingGroupId": "asg-bp1cjeuvlt1e1i1t",
                "batchNumber": 2,
                "batchPauseOption": "Automatic"
            }'

回滚命令如下:

aliyun oos StartExecution --TemplateName ACS-ESS-RollingUpdateByRunCommandInScalingGroup --Parameters '{
                "invokeType": "rollback",
                "commandType": "RunShellScript",
                "OOSAssumeRole": "",
                "rollbackScript": "df -h\nifconfig",
                "scalingGroupId": "asg-bp1cjeuvlt1e1i1t",
                "sourceExecutionId": "exec-f577d2a639f24f4e9c0a",
                "batchNumber": 2,
                "batchPauseOption": "Automatic"
            }'

3.通过安装OOS软件包滚动升级。
通过阿里云CLI执行ESS滚动升级
模板参数说明请查看ACS-ESS-RollingUpdateByConfigureOOSPackage模板详情
执行命令如下:

aliyun oos StartExecution --TemplateName ACS-ESS-RollingUpdateByConfigureOOSPackage --Parameters '{
                "invokeType": "invoke",
                "OOSAssumeRole": "",
                "exitProcess": [],
                "action": "install",
                "enterProcess": [
                    "ScaleIn",
                    "ScaleOut",
                    "HealthCheck",
                    "AlarmNotification",
                    "ScheduledAction"
                ],
                "packageVersion": "v4",
                "packageName": "wordpress",
                "scalingGroupId": "asg-bp1cjeuvlt1e1i1t",
                "batchNumber": 2,
                "batchPauseOption": "Automatic"
            }'

回滚命令如下:

aliyun oos StartExecution --TemplateName ACS-ESS-RollingUpdateByConfigureOOSPackage --Parameters '{
                "invokeType": "rollback",
                "OOSAssumeRole": "",
                "packageVersion": "v3",
                "packageName": "wordpress",
                "scalingGroupId": "asg-bp1cjeuvlt1e1i1t",
                "sourceExecutionId": "exec-b1a293da254042f492f6",
                "batchNumber": 2,
                "batchPauseOption": "Automatic"
            }'
上一篇:教程 | 一文读懂自学机器学习的误区和陷阱(附学习资料)


下一篇:SQL Server 2012 创建数据库快照