System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

时间:2023-03-08 17:32:32

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

创建你的一个web server,然后将这个实例制成你的AMI,通过启动配置生成一个Auto Scaling组(包括scale-in/scale-out策略),配置一台Load Balancer指向你的Auto Scaling组

1. 创建你的AMI

1.1 获得密钥对名称,AMI ID,子网ID的信息

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

1.2 创建一个安全组

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

1.3 登陆到CommandHost实例

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

1.4.1 创建新的EC2实例

aws ec2 run-instances --key-name qwikLABS-L1042-414119 --instance-type t2.micro --image-id ami-df8767bf --user-data file://c:\temp\UserData.txt --security-group-ids sg-51de5f36 --subnet-id subnet-ec617c9b --associate-public-ip-address

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

1.4.2 监控该新建EC2实例状态

aws ec2 describe-instance-status --instance-id i-1849cec0

1.4.3 显示该实例的公共DNS名称

aws ec2 describe-instances --instance-id i-1849cec0 --query 'Reservations[0].Instances[0].NetworkInterfaces[0].Association.PublicDnsName'

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

1.4.4 使用PowerShell脚本测试web server

(new-object net.webclient).DownloadString('http://ec2-52-10-69-251.us-west-2.compute.amazonaws.com/stressapp/Default')

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

1.5 根据该实例来创建你的AMI

aws ec2 create-image --name WebServer --instance-id i-1849cec0

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

2. 创建Auto Scaling环境

2.1 创建一个load balancer

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

2.2 创建一个启动配置

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

2.3 创建一个Auto Scaling group

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

2.4 设置scale-out策略

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

2.5 设置scale-in策略

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

2.6 完成Auto Scaling group的创建

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

2.7 确认该Auto Scaling配置

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

在本地访问http://webserverloadbalancer-93038626.us-west-2.elb.amazonaws.com/stressapp/Default

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

点击Start Stress

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

在该Auto Scaling group的活动历史记录中发现scale-out策略生效,一台新实例被自动创建了

System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)