安装并配置阿里云CLI
本文以Mac-os为例,其他系统安装可参考阿里云CLI。
首先为阿里云CLI创建一个RAM用户来获取AK,详细操作请参考创建RAM用户。
安装阿里云CLI。
br0 | j g S l X h ew install aliyun-cli | * P T [
配置CLa Y a n M kI。
aliyun configure
验证9 d 4 W 9CLI可用,若可用,可在终端看到输出当前支持的多个地域。
aliyun ecs DescribeR/ Q C 5 oegions
通过CLI执行滚动升级
需模板名称和参数。
- 通过更新镜像滚动升级。
命令如下:
aliyun oos StartExm ! #ecution --TemplateName A4 K # 8 } R x # 6CS-ESS-RollingUpdateByReplaceSystemDiskInSC z ycalingGroup --Parameters '{
"i5 ! { F k e 9 tnvokeTypeS e &": "invoke",
"imageId": "centos_7_8_amd_x64_20G_alibase_20200806.vhd",
"sourceImaget 0 * ` CId": "centos_8_2_x64_20G_alibase_20200717.vhd",
"OOSAssumeRol- q & } W , ? U Ie": "",
"exitProces/ - : t b 2s": [],4 W } V + 8 @
"scalin) n U NgConfigurationId": "asc-bp14e7lqyl66ca4rp4rb",
"enterProcess": [
"ScaleIn9 R j ( R I",
"ScaleOut",
"HealthCheck",
"AlarmNotification",
"ScheduledAction"
],- g q j 8
"scalingGroupId": "asg-bp1cjeuvlt1e1i1t",
"batchNumber": 2,
"batchPauseOption": "AutomI , [ 1 N t f B catic"
}'
- 通过脚本执行滚动升级。
aliyun oos StartExecution --TemplateName ACS-ESS-RollingUpdateByRunComma{ / ^ndInSx ( McalingGroup --Parameters '{
"invokeType": "invoke",
"commandType": "RunShellS$ & 4 L F ( S ycript",
"OOSAssumeRole": "",
"exitProcess": [],
"invokeScript": "df -h\nifconfig",
"rollbackScript": "df -h\nifconfig",
"e) D j , ~ j t ( Wnterk 2 4 hProc- Q ess": [
"ScaleIn",
"ScaleOut",
"HealthChecL p sk",
"AlarmNotification",
"ScheduledAction"
],
"scat q f P o $ E WlingGroupId": "asg-bp1cjeuv& e O h 5lt1e1i1t",
"batche m 0Number": 2,
"1 y ~ h $ + 6batchPauseOption": "Automatic"
}'
3.通过安装OOS软件包滚动升级。
aliyun oos StartExecution --Template[ ? NName ACS-ESS-RollingUpdateByConfigureOOSPackage --Paramet+ a 4 ers '{
"invokeType": "r O . ?invoke",
"1 ) b a OOSAssumeRole": "",
"exitProcess": [],
"action"L V u: "install",
"enterProcess":s b M ^ 3 [
"ScaleIn",
"ScaleOut",
"HeaW E A , Q H 6lthCheck",
"AlarmNotification",
"ScheduledAction"
],
"packageVersion": "v4",
"packageName": "wordpress",
"scalingGroupId": "asg-bp1cjeuvlt1e1i1t",
"batchNumber": 2,
"batchPauseOption": "Automatic"
}'