Академический Документы
Профессиональный Документы
Культура Документы
things
you dont know about
Amazon Web Services
Simone Brunozzi
Sr. Technology Evangelist, AWS
@simon
1
AWS CLI
01
AWS CLI
02
Autoscaling
03
Hmm...
10
Autoscaling
Amazon
Amazon
Amazon
Amazon
Amazon
Etc.
S3
DynamoDB
ELB (Elastic Load Balancing)
Glacier
EB (Elastic Beanstalk)
11
EC2 Autoscaling
03
12
AutoScaling (AS):
Four main components
Get the AS Command Line Tools:
aws.amazon.com/developertools/2535
1) Launch config: AMI to be used
2) Autoscaling group: where/how to launch
3) Autoscaling policy: what should AS do?
4) Autoscaling trigger: what will activate AS
13
13
14
AutoScaling tools
14
15
Windows setup
FILE: ec2.bat
@echo off
set EC2_HOME=c:\ec2
set PATH=%PATH%;%EC2_HOME%\bin
set JAVA_HOME=C:\Program Files\Java\jre6
"%JAVA_HOME%\bin\java" -version
set JAVA_HOME=C:\Program Files (x86)\Java\jre6 (Windows 7)
set EC2_PRIVATE_KEY=c:\ec2\PrivateKey.pem
set EC2_CERT=c:\ec2\509Certificate.pem
set AWS_AUTO_SCALING_HOME=c:\ec2\AutoScaling
set AWS_CLOUDWATCH_HOME=c:\ec2\CloudWatch
set PATH=%PATH%;%AWS_AUTO_SCALING_HOME%\bin;%AWS_CLOUDWATCH_HOME%\bin
16
16
Linux setup
FILE: .bash_profile
export EC2_HOME=~/ec2
export PATH=$PATH:$EC2_HOME/bin
export EC2_PRIVATE_KEY=pk-[removed].pem
export EC2_CERT=cert-[removed].pem
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home/
export AWS_AUTO_SCALING_HOME=~/ec2/AutoScaling
export AWS_CLOUDWATCH_HOME=~/ec2/CloudWatch
export PATH=$PATH:$AWS_AUTO_SCALING_HOME/bin:$AWS_CLOUDWATCH_HOME/bin
17
17
Test if it works
% as-version
Amazon AutoScaling CLI version 1.0.61.3 (API 2011-01-01)
18
18
AutoScaling + ELB
(1, 2)
STEP 1: Create Launch Config
as-create-launch-config LC1 --image-id ami-31814f58 --instance-type m1.small
[--region us-east-1] --group SG
AutoScaling + ELB
Emergency break
Scale in EC2 instances to ZERO, if needed
as-update-auto-scaling-group ASG1 --min-size 0 --max-size 0
20
20
AutoScaling + ELB
(3)
STEP 3: Create Scaling Out Policy
as-put-scaling-policy SOut1 --auto-scaling-group ASG1 --adjustment=1 --type
ChangeInCapacity --cooldown 120
arn:aws:autoscaling:useast-1:132891460296:scalingPolicy:a4a80ac4-3e3e-46a7-9b4a-72d893803618:autoSca
lingGroupName/ASG1:policyName/SP1
21
21
AutoScaling + ELB
(4)
STEP 4: Create Metric Out Alarm
mon-put-metric-alarm MOutA1
--comparison-operator GreaterThanThreshold --
evaluation-periods 1 --metric-name CPUUtilization --namespace "AWS/EC2" -period 60 --statistic Average --threshold 70 --alarm-actions
arn:aws:autoscaling:useast-1:132891460296:scalingPolicy:a4a80ac4-3e3e-46a7-9b4a-72d893803618:autoSca
lingGroupName/ASG1:policyName/SOut1 --dimensions "AutoScalingGroupName=ASG1"
22
22
AutoScaling + ELB
(5)
STEP 5: Create Scaling In Policy
as-put-scaling-policy SInP1 --auto-scaling-group ASG1 --adjustment=-1 --type
ChangeInCapacity --cooldown 120
arn:aws:autoscaling:us-east-1:132891460296:scalingPolicy:5ddb0046-a571-417fb025-4268baf9d860:autoScalingGroupName/ASG1:policyName/SInP1
If you are using Windows, wrap the --adjustment parameter in quotation marks:
"--adjustment=-1".
23
23
AutoScaling + ELB
(6)
STEP 6: Create Metric In Alarm
mon-put-metric-alarm MInA1 --comparison-operator LessThanThreshold -evaluation-periods 1 --metric-name CPUUtilization --namespace "AWS/EC2" -period 60 --statistic Average --threshold 30 --alarm-actions
arn:aws:autoscaling:us-east-1:132891460296:scalingPolicy:5ddb0046-a571-417fb025-4268baf9d860:autoScalingGroupName/ASG1:policyName/SInP1 --dimensions
"AutoScalingGroupName=ASG1"
24
24
25
25
EC2 Autoscaling
03
26
27
EC2 metadata
04
28
29
30
VPC + Cloudformation
05
31
{
"AWSTemplateFormatVersion" : "2010-09-09",
!
"Description": "Creates a Multi-AZ VPC with subnets for a three tier architecture",
!
"Parameters" : {
!
!
"VpcCidr" : {
!
!
!
"Description" : "CIDR for the VPC",
!
!
!
"Type" : "String",
!
!
!
"MinLength": "9",
!
!
!
"MaxLength": "18",
!
!
!
"Default" : "10.0.0.0/16",
!
!
!
"AllowedPattern" : "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\
\d{1,2})",
!
!
!
"ConstraintDescription" : "must be a valid CIDR range of the form x.x.x.x/
x."
!
!
}
},
!
"Resources" : {
"VPC" : {
"Type" : "AWS::EC2::VPC",
"Properties" : {
"CidrBlock" : {"Ref" : "VpcCidr"},
"Tags" : [
{"Key" : "Application", "Value" : {"Ref" : "AWS::StackId"} }
]
}
}
!
}
}
32
{
"AWSTemplateFormatVersion" : "2010-09-09",
!
"Description": "Creates a Multi-AZ VPC with subnets for a three tier architecture",
!
"Parameters" : {
!
!
"VpcCidr" : {
!
!
!
"Description" : "CIDR for the VPC",
!
!
!
"Type" : "String",
!
!
!
"MinLength": "9",
!
!
!
"MaxLength": "18",
!
!
!
"Default" : "10.0.0.0/16",
!
!
!
"AllowedPattern" : "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\
\d{1,2})",
!
!
!
"ConstraintDescription" : "must be a valid CIDR range of the form x.x.x.x/
x."
!
!
}
},
!
"Resources" : {
"VPC" : {
"Type" : "AWS::EC2::VPC",
"Properties" : {
"CidrBlock" : {"Ref" : "VpcCidr"},
"Tags" : [
{"Key" : "Application", "Value" : {"Ref" : "AWS::StackId"} }
]
}
}
!
}
}
33
{
"AWSTemplateFormatVersion" : "2010-09-09",
!
"Description": "Creates a Multi-AZ VPC with subnets for a three tier architecture",
!
"Parameters" : {
!
!
"VpcCidr" : {
!
!
!
"Description" : "CIDR for the VPC",
!
!
!
"Type" : "String",
!
!
!
"MinLength": "9",
!
!
!
"MaxLength": "18",
!
!
!
"Default" : "10.0.0.0/16",
!
!
!
"AllowedPattern" : "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\
\d{1,2})",
!
!
!
"ConstraintDescription" : "must be a valid CIDR range of the form x.x.x.x/
x."
!
!
}
},
!
"Resources" : {
"VPC" : {
"Type" : "AWS::EC2::VPC",
"Properties" : {
"CidrBlock" : {"Ref" : "VpcCidr"},
"Tags" : [
{"Key" : "Application", "Value" : {"Ref" : "AWS::StackId"} }
]
}
}
!
}
}
34
{
"AWSTemplateFormatVersion" : "2010-09-09",
!
"Description": "Creates a Multi-AZ VPC with subnets for a three tier architecture",
!
"Parameters" : {
!
!
"VpcCidr" : {
!
!
!
"Description" : "CIDR for the VPC",
!
!
!
"Type" : "String",
!
!
!
"MinLength": "9",
!
!
!
"MaxLength": "18",
!
!
!
"Default" : "10.0.0.0/16",
!
!
!
"AllowedPattern" : "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\
\d{1,2})",
!
!
!
"ConstraintDescription" : "must be a valid CIDR range of the form x.x.x.x/
x."
!
!
}
},
!
"Resources" : {
"VPC" : {
"Type" : "AWS::EC2::VPC",
"Properties" : {
"CidrBlock" : {"Ref" : "VpcCidr"},
"Tags" : [
{"Key" : "Application", "Value" : {"Ref" : "AWS::StackId"} }
]
}
}
!
}
}
35
36
37
38
cfn-update-stack CustomerLittleNetwork
--template-file
stack_cfn_learn_001_vpc_step2.template
cfn-describe-stacks CustomerLittleNetwork
cfn-list-stack-resources CustomerLittleNetwork
39
{
"AWSTemplateFormatVersion" : "2010-09-09",
! "Description": "Creates a Multi-AZ VPC
with subnets for a three tier architecture",
!
!
"Parameters" : {
! "VpcCidr" : {
40
"Parameters" : {
! !
"VpcCidr" : {
! ! !
"Description" : "CIDR for the VPC",
! ! !
"Type" : "String",
! ! !
"MinLength": "9",
! ! !
"MaxLength": "18",
! ! !
"Default" : "10.0.0.0/16",
! ! !
"AllowedPattern" : "(\\d{1,3})\\.(\
\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
! ! !
"ConstraintDescription" : "must be a
valid CIDR range of the form x.x.x.x/x."
! !
},
41
! !
"PublicSubnetCidrA" : {
! ! !
"Description" : "Subnet for public
resources in the first AZ",
! ! !
"Type" : "String",
! ! !
"MinLength": "9",
! ! !
"MaxLength": "18",
! ! !
"Default" : "10.0.1.0/24",
! ! !
"AllowedPattern" : "(\\d{1,3})\\.(\
\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
! ! !
"ConstraintDescription" : "must be a
valid CIDR range of the form x.x.x.x/x."
! !
},
42
43
CloudFormer
06
CloudFormation
templates from an
existing deployment
44
45
Custom errors
07
46
47
48
49
08
What is ZFS?
ZFS is a file system + logical volume manager.
Features:
- protection against data corruption
- support for high storage capacities
- integration of filesystem and volume management
- snapshots and copy-on-write clones
- continuous integrity checking and automatic repair
- RAID-Z
- native NFSv4 ACLs.
OpenZFS is an Open Source implementation of it.
51
52
1) Linux
Linux AMI:
https://aws.amazon.com/amazon-linux-ami/
http://zfsonlinux.org/
53
2) OmniOS
54
3) FreeBSD
55
56
57
$ mount
/dev/xvda1 on / type ext4 (rw,noatime)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
test on /test type zfs (rw,xattr)
$ df -h
Filesystem
Size Used Avail Use% Mounted on
/dev/xvda1
7.9G 1.6G 6.3G 20% /
tmpfs
15G
0
15G
0% /dev/shm
test
196G
0 196G
0% /test
58
59
Learn more
http://pthree.org/2012/04/17/install-zfs-on-debiangnulinux/
60
Extra stuff
09
61
62
63
64
65
66
Thank
you!
67
things
you dont know about
Amazon Web Services
Simone Brunozzi
Sr. Technology Evangelist, AWS
@simon
68