找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 120|回复: 0

[Cloud] [Cloud]_AWS上的测试环境如何自动开启

[复制链接]

10

主题

0

回帖

52

积分

注册会员

积分
52
发表于 2023-4-11 11:57:37 | 显示全部楼层 |阅读模式
背景:

AWS云上环境一般在需要测试的时候才会开启,而开启环境的步骤较多(服务启动有先后顺序)且开启时间长达半小时+,启动环境的过程需要专人做,且不方便在上班途中操作

解决办法:
我们需要一个配置环境自启脚本,一方面可以在上班路上手机开启环境,到公司后就能快速开展工作,另一方面不用专人操作,节约人力
ps:手机上可以下载aws的客户端,或者就直接网页访问aws控制台,简单开一台实例还是没有难度的

具体操作:
1.在AWS上找一台linux机器来运行自启脚本(该机器需要能识别aws脚本,可以找更新补丁的机器或代理机器,最好不要使用带基础服务的机器)
ps,安装aws插件的方法 https://docs.aws.amazon.com/cli/latest/userguide/install-linux.html
2.编写自启脚本,范例如下:
ps:instance-ids 需要替换成AWS实例的ids,需要启动哪些服务也可以自定义,等待时间也可自定义


#启动StorageGW
aws ec2 start-instances --instance-ids 'i-0441b0a3e2946b704'
#等待240秒,等待StorageGW启动完成
ping -i 1 -c 240 127.0.0.1 > null

#启动3个Foundation节点
aws ec2 start-instances --instance-ids 'i-08e1055ba3b38172b'
aws ec2 start-instances --instance-ids 'i-07f0f3980c9b054c0'
aws ec2 start-instances --instance-ids 'i-071c45ea62273e68c'
#等待180秒,等待Foundation节点启动完成
ping -i 1 -c 180 127.0.0.1 > null
#远程执行第1个Foundation节点上的sobeyhive_start_all.sh文件,启动节点上的服务
ssh root@10.30.80.102 "/usr/bin/sobeyhive_start_all.sh nocheck"
#等待180秒,等待节点服务启动完成
ping -i 1 -c 180 127.0.0.1 > null

#修改ECS集群中各服务的目标数量为0
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service hivecore-service --desired-count 0
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service hivepmp-service --desired-count 0
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service nebula-service --desired-count 0
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service cmserver-service --desired-count 0
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service cmweb-service --desired-count 0
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service cmproxy-service --desired-count 0
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service cmnotify-service --desired-count 0
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service jove-service --desired-count 0
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service actorfactory-service --desired-count 0
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service ingestmsg-service --desired-count 0
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service ingesttask-service --desired-count 0
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service ingestdb-service --desired-count 0
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service webingest-service --desired-count 0
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service apigateway-service --desired-count 0
#修改ECS集群的AutoScaling目标数量,让Container实例起来
aws autoscaling update-auto-scaling-group --auto-scaling-group-name hivecloudv12-CloudFormation-EcsInstanceAsg-1MJLC3LYF0J9F --max-size 5
aws autoscaling update-auto-scaling-group --auto-scaling-group-name hivecloudv12-CloudFormation-EcsInstanceAsg-1MJLC3LYF0J9F --desired-capacity 4
#等待120秒,让Container实例能够起来
ping -i 1 -c 120 127.0.0.1 > null

#修改ECS集群中hivecore和hivepmp的Service目标数量,准备启动
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service hivecore-service --desired-count 1
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service hivepmp-service --desired-count 1
#等待240秒,让hivecore和hivepmp先起来
ping -i 1 -c 240 127.0.0.1 > null
#修改ECS集群中其它Service目标数量,让其它Docker服务起来
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service nebula-service --desired-count 1
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service cmserver-service --desired-count 1
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service cmweb-service --desired-count 1
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service cmproxy-service --desired-count 1
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service cmnotify-service --desired-count 1
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service jove-service --desired-count 1
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service actorfactory-service --desired-count 1
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service ingestmsg-service --desired-count 1
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service ingesttask-service --desired-count 1
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service ingestdb-service --desired-count 1
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service webingest-service --desired-count 1
aws ecs update-service --cluster Hive_CloudV12_ECS_cluster --service apigateway-service --desired-count 1
#等待120秒,让其它docker服务起来
ping -i 1 -c 120 127.0.0.1 > null

#修改MediaEngine的AutoScaling目标数量,让MediaEngine实例起来
#aws autoscaling update-auto-scaling-group --auto-scaling-group-name hivecloudv12-AS-MediaEngine --desired-capacity 1
#修改CommonGW的AutoScaling目标数量,让CommonGW实例起来
#aws autoscaling update-auto-scaling-group --auto-scaling-group-name hivecloudv12-AS-CommonGW --desired-capacity 1
#修改Cloudia的AutoScaling目标数量,让Cloudia实例起来
#aws autoscaling update-auto-scaling-group --auto-scaling-group-name hivecloudv12-AS-Cloudia --desired-capacity 1
#修改Transform的AutoScaling目标数量,让Transform实例起来
#aws autoscaling update-auto-scaling-group --auto-scaling-group-name hivecloudv12-AS-Transform --desired-capacity 1

#启动MediaEngine-01
aws ec2 start-instances --instance-ids 'i-0defe5855bad71cce'
#启动Transform-01
aws ec2 start-instances --instance-ids 'i-04d8262a2bafa507a'
#启动Cloudia-01
aws ec2 start-instances --instance-ids 'i-03143c3a088ba156d'
#启动CommonGW-01
#aws ec2 start-instances --instance-ids 'i-0422e9938164b8794'
#启动AdobeServer-01
#aws ec2 start-instances --instance-ids 'i-0dae47e47417307ea'
#启动SDIIngestTransfer-01
#aws ec2 start-instances --instance-ids 'i-08c8ede7e3f1cad02'
#启动RTMPServer
#aws ec2 start-instances --instance-ids 'i-05a6ba4f67533e458'
#启动ProxyServer
aws ec2 start-instances --instance-ids 'i-0b923d5ee021fc9f3'
#启动Zeddis
aws ec2 start-instances --instance-ids 'i-025b24a1dae20ce3c'



3.将该sh脚本放到linux机器的路径下(比如根目录),并赋予权限
4.对该脚本添加开启自启
在etc/rc.local中添加命令
sh /start_tokyo_system.sh
5.启动时,只需在aws控制开启这一台linux机器,就可实现环境自启

注意:hive相关组件和服务 也需要加到自己机器的开机自启中,否则 环境自启脚本就算开启了实例,也不会自动开启服务的

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Sobey-IBG-BBS

GMT+8, 2025-12-6 13:47 , Processed in 0.019266 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表