setting up amazon ec2 server

40

Upload: tahsin-hasan

Post on 19-May-2015

2.175 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: Setting Up Amazon EC2 server
Page 2: Setting Up Amazon EC2 server

Who am I? Tahsin Hasan Sr. software Engineer, Tasawr Interactive. [email protected] Books - “Opencart 1.5 Template Design CookBook” and

“Joomla 1.6 Mobile Development Beginners Guide” with Packt Publishers UK.

Website – tahSin’s gaRage (http://newdailyblog.blogspot.com).

Page 3: Setting Up Amazon EC2 server

Some Misconceptions

EC2 is expensive – False.Only for large applications – False.Fully commercial – False.Instances are not preserved when shutdown –

False.EC2 requires a proprietary OS – False.

Page 4: Setting Up Amazon EC2 server

What is Amazon EC2?

“Amazon Elastic Compute Cloud(EC2) is a web service that provides resizable compute capacity in the cloud.”- Amazon EC2 home page.

Page 5: Setting Up Amazon EC2 server

Why Amazon EC2?

Create, launch and terminate as needed.Buy computing power by the hour.Buy bandwidth by the GB.Buy space by the GB/month.Add a firewall, load balancer, monitoring etc

with the click of a mouse.Rent virtual computers and peripherals.Get start with a pre-configured images.

Page 6: Setting Up Amazon EC2 server

EC2 Data Centers

Geographically dispersed-US West (North CA).US East (North VA).EU (Ireland).Asia pacific (Singapure).

Page 7: Setting Up Amazon EC2 server

Availability Zone

Page 8: Setting Up Amazon EC2 server

EC2 Instance Families

Standard – Small, Large, Extra Large.Micro. High-CPU – Medium, Extra Large. High-Memory – Extra Large, Double Extra

Large, Quadruple Extra Large.Cluster Compute.Cluster GPU.

Page 9: Setting Up Amazon EC2 server

Amazon EC2 Instance Types

Small – 1.7 GB memory, 160 GB storage.Large – 7.5 GB memory, 850 GB storage.Extra Large – 15 GB memory, 1690 GB storage.Micro – 613 MB memory.High-CPU Medium – 1.7 GB memory, 5 EC2

unit, 350 GB storage.High-CPU Extra Large – 7 GB memory, 20 EC2

unit, 1690 GB storage.

Page 10: Setting Up Amazon EC2 server

Amazon EC2 Instance Types

High-Memory Extra Large – 17.1 GB memory, 480 GB instance.

High-Memory Double Extra Large – 34. GB.High-Memory Quadruple Extra Large – 68.4.Cluster Compute – 23 GB memory, 33.5 EC2

unit, 1690 GB storage.Cluster GPU

Page 11: Setting Up Amazon EC2 server

Amazon EC2 Free Tier

Calculate each month usage for a year. 750 hours usage of micro instance and load

balancing.10 GB of Amazon Elastic Block Storage.15 GB bandwidth.

Page 12: Setting Up Amazon EC2 server

Getting Started with CLI

Setting the Java Home variable.export JAVA_HOME=<PATH>.Download .zip file from Amazon EC2 resource

center.export EC2_HOME=<path-to-tools>export PATH=$PATH:$EC2_HOME/bin

Page 13: Setting Up Amazon EC2 server

X.509 certificate

Create X.509 certificate.Create a directory named .ec2 in the home

dir.Download the PEM-encoded certificate and

private key file.

Page 14: Setting Up Amazon EC2 server

Import SSH Key Pair

Either by OpenSSH or AWS mgmt console.ec2-import-keypair phpXpert-keypair --public-

key-file mykey.ppk.https://ec2.amazonaws.com/?

Action=ImportKeyPair&KeyName=phpXpert-keypair &PublicKeyMaterial=base64_encode(public_key).

Page 15: Setting Up Amazon EC2 server

Generate SSH key with AWS

Create with Amazon mgmt console.“ec2-add-keypair phpXperts-keypair" returns

the private key.Save the private key in a file like “id_rsa-

phpXpert-keypair” and set file permission.https://ec2.amazonaws.com/ ?

Action=CreateKeyPair &KeyName=gsg-keypair &...auth parameters…

Page 16: Setting Up Amazon EC2 server

Tell Who You Are?

$export EC2_PRIVATE_KEY=~/.ec2/pk-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem

$export EC2_CERT=~/.ec2/cert-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem

$export EC2_URL=https://<service_endpoint>

Page 17: Setting Up Amazon EC2 server

Launch Instance

Page 18: Setting Up Amazon EC2 server

Launch an Instance: CLI $ec2-run-instances ami-3ac33653 -k gsg-keypair RESERVATION r-f25e6f9a 999988887777 default

INSTANCE i-85b435ee ami-3ac33653 pending gsg-keypair 0 m1.small 2010-03-30T08:01:36+0000 monitoring-disabled ebs us-east-1a aki-407d9529

$ec2-describe-instances i-85b435eeRESERVATION r-f25e6f9a 999988887777 defaultINSTANCE i-85b435ee ami-3ac33653 ec2-67-202-28-13.compute-1.amazonaws.com domU-12-31-39-00-78-93.compute-1.internal running gsg-keypair 0 m1.small 2010- 03-30T08:01:36+0000 us-east-1a aki-407d9529 monitoring-disabled 67.202.28.13 10.254.127.97 ebs BLOCKDEVICE /dev/sda1 vol-02a2a46b 2010-03-30T08:01:44.000Z

Page 19: Setting Up Amazon EC2 server

Launch an Instance: API

https://ec2.amazonaws.com/ ?Action=RunInstances &ImageId=ami-3ac33653 &MaxCount=1 &MinCount=1 &KeyName=gsg-keypair &Placement.AvailabilityZone=us-east-1a

https://ec2.amazonaws.com/ ?Action=DescribeInstances &InstanceId=i-2ba64342

Page 20: Setting Up Amazon EC2 server

Choose AMI

Page 21: Setting Up Amazon EC2 server

Community AMI

Alestic.com

Page 22: Setting Up Amazon EC2 server

Start/Stop Instances: API

https://ec2.amazonaws.com/ ?Action=StopInstances &InstanceId.1=i-10a64379 &...auth parameters...

https://ec2.amazonaws.com/ ?Action=StartInstances &InstanceId.1=i-10a64379 &...auth parameters...

Page 23: Setting Up Amazon EC2 server

Choosing Instance Types

Page 24: Setting Up Amazon EC2 server

Create a Key Pair

Page 25: Setting Up Amazon EC2 server

Create a Key Pair

Page 26: Setting Up Amazon EC2 server

Choose Security Group

Page 27: Setting Up Amazon EC2 server

Amazon EC2 Console

Page 28: Setting Up Amazon EC2 server

Public DNS

Page 29: Setting Up Amazon EC2 server

Connect to Instance

ec2-get-console-output instance_idssh -i id_rsa-gsg-keypair root@ec2-67-202-51-

223.compute-1.amazonaws.com

Page 30: Setting Up Amazon EC2 server

What about Security?

Page 31: Setting Up Amazon EC2 server

Security Groups

Page 32: Setting Up Amazon EC2 server

Security Group:CLI• $ec2-authorize default -p 22 -s your-local-system's-public-ip-ad

dress/32PERMISSION default ALLOWS tcp 22 22 FROM CIDR your- local-system's-public-ip-address/32

• $ec2-authorize default -p 3389 -s your-local-system's-public-ip-ad dress/32PERMISSION default ALLOWS tcp 3389 3389 FROM CIDR your-local-system's-public-ip-address/32

• $ec2-authorize default -p 80PERMISSION default ALLOWS tcp 80 80 FROM CIDR 0.0.0.0/0

Page 33: Setting Up Amazon EC2 server

Security Group: API https://ec2.amazonaws.com/ ?

Action=AuthorizeSecurityGroupIngress &GroupName=default &IpProtocol=tcp &FromPort=22&ToPort=22 &CidrIp=your-local-system's-public-ip-address/32

https://ec2.amazonaws.com/ ?Action=AuthorizeSecurityGroupIngress &GroupName=default &IpProtocol=tcp &FromPort=3389&ToPort=3389 &CidrIp=your-local-system's-public-ip-address/32

https://ec2.amazonaws.com/ ?Action=AuthorizeSecurityGroupIngress &GroupName=default &IpProtocol=tcp &FromPort=80 &ToPort=80 &CidrIp=0.0.0.0/0

Page 34: Setting Up Amazon EC2 server

What is Elastic IP?

Static IP address.Associated with your account, not instances.It propagate instantly throughout the web.

Page 35: Setting Up Amazon EC2 server

Elastic IP

Page 36: Setting Up Amazon EC2 server

Elastic IP

Page 37: Setting Up Amazon EC2 server

Terminate Instances

Page 38: Setting Up Amazon EC2 server

Start/Stop Instances with CLI

ec2-stop-instances i-10a64379 IMAGE i-10a64379 running stopping ec2-start-instances i-10a64379 IMAGE i-10a64379 stopped pending

Page 39: Setting Up Amazon EC2 server

Tools

Elasticfox – Firefox addons.AWS toolkit for Eclipse.

Page 40: Setting Up Amazon EC2 server

Questions?