Sei sulla pagina 1di 3

Part I: Introduction

Exercise 1- Sign-up in AWS

Sign up process consists of five steps:


1 Provide your login credentials.
2 Provide your contact information.
3 Provide your payment details.
4 Verify your identity.
5 Choose your support plan. (Select the Basic plan, which is free)

Exercise 2: To access a virtual server in AWS, you need a key pair consisting of a private key and a
public key. Create a key pair.

1 Open the AWS Management Console at https://console.aws.amazon.com.


2 Click Services in the navigation bar, find the EC2 service, and click it.
3 Your browser shows the EC2 Management Console.

Follow these steps to create a new key pair:


1 Click Key Pairs in the navigation bar under Network & Security.
2 Click the Create Key Pair button.
3 Name the Key Pair mykey.
In Linux, the only thing you need to do is change the access rights of mykey.pem so that only you can
read the file. To do so, run chmod 400 mykey.pem in the terminal. You’ll learn about how to use your
key when you need to log in to a virtual server for the first time in this book

Exercise 3: Create a billing alarm


If you exceed the Free Tier, an email is sent to you.
http://mng.bz/M7Sj

Part II: Install a WordPress insfraestructure


You’ll use four different AWS services to copy the old infrastructure to AWS:
■ Elastic Load Balancing (ELB)—AWS offers a load balancer as a service. The Elastic Load Balancer

(ELB) distributes traffic to a bunch of servers behind it. It’s highly available by default.
■ Elastic Compute Cloud (EC2)—A virtual server is provided by the Elastic Compute Cloud ( EC2) service.

You’ll use a Linux server with an optimized distribution called Amazon Linux to install Apache, PHP,
and WordPress. You aren’t limited to Amazon Linux; you could also choose Ubuntu, Debian, Red Hat, or
Windows.
Virtual servers can fail, so you need at least two of them. The load balancer will distribute the traffic
between them. In case of a server failure, the load balancer will stop sending traffic to the failed server,
and the remaining server will need to handle all the requests until the failed server is replaced.
■ Relational Database Service (RDS) for MySQL—WordPress relies on the popular MySQL database. AWS

provides MySQL as a Relational Database Service. You choose the database size (storage, CPU, RAM),
and RDS takes care of the rest (backups, updates). RDS can also provide a highly available MySQL
database by replication.
■ Security groups—Security groups are a fundamental service of AWS to control network traffic like a

firewall. Security groups can be attached to a lot of services like ELB, EC2, and RDS. With security
groups, you can configure your load balancer so that it only accepts requests on port 80 from the internet,
web servers only accept connections on port 80 from the load balancer, and MySQL only accepts
connections on port 3306 from the web servers. If you want to log in to your web servers via SSH, you
must also open port 22.

Exercise 1: Create a blogging infrastructure


1. Open the AWS Management Console at https://console.aws.amazon.com.
2. Click Services in the navigation bar
3. Click the CloudFormation service.
4. Click Create Stack to start the four-step wizard
5. Enter wordpress as the Name. For Source, select Specify an Amazon S3 Template URL, and copy
this URL: https://s3.amazonaws.com/awsinaction/chapter2/template.json.
6. Click Next to set the KeyName to mykey.
7. Click Next to create a tag for your infrastructure. A tag consists of a key-value pair and can be
used add information to all parts of your infrastructure. You can use tags to differentiate between
testing and production resources, add the cost center to easily track costs in your organization, or
mark resources that belong to a certain application if you host multiple applications in the same
AWS account.
8. Click Next. Finally, you’ll see a confirmation page.
9. Click Create. Your infrastructure will now be created.
10. Switch to the Outputs tab. There you’ll find the URL to your wordpress system; click it to visit
the system.

You can create all that with a few clicks. The following tasks are performed automatically in the
background:
(Attention: You have to follow the steps with number. These are the steps that you haven’t to do because
you have already done
Create a Basic Load Balancer
Creating 2 web servers:
– Installing Apache and PHP via yum install php, php-mysql, mysql, httpd
Creating two EC2 virtual servers
– Downloading and extracting the latest version of WordPress from http://
wordpress.org/latest.tar.gz
– Configuring WordPress to use the created RDS MySQL database
– Starting Apache
Create a RDBMS MySQL database
Create and attaching security groups

Your infrastructure consists of the following:


■ Web servers

■ Load balancer

■ MySQL database

Exercise 2: Create a new resource group:


1 Click on Resource Groups > Create a New Resouirce Group
Set Group Name to wordpress or whatever you like.
2 Add the tag system with the value wordpress.
3 Select the region N. Virginia.

Exercise 3: Inspect web servers


1 Select Instances under EC2 on the left to see your web servers. By clicking the arrow icon in the Go
column, you can easily jump to the details of a single web server.
You’re now looking at the details of your web server, also called an EC2 instance.
■ Instance type—Tells you about how powerful your instance is.

■ Public IP address—The IP address that’s reachable over the internet. You can use that IP address to

connect to the server via SSH.


■ Security groups—If you click View Rules, you’ll see the active firewall rules like the one that enabled

port 22 from all sources (0.0.0.0/0).


■ AMI ID—Remember that you used the Amazon Linux operating system ( OS). If you click the AMI ID,

you’ll see the version number of the OS, among others.


2 Select the Monitoring tab to see how your web server is utilized.
Knowing how your infrastructure is doing. AWS collects some metrics and shows them in the Monitoring
section. If the CPU is utilized more than 80%, you should add a third server to prevent page load times
from increasing.
Exercise 4: Inspect Load Balancers
1 Select Load Balancers under EC2 on the left to open the page.
2 By clicking the arrow icon in the Go column, you can easily jump to the details of the load balancer.
The most interesting part is how the load balancer forwards traffic to the web servers. The load balancer
accepts only HTTP connections to forward to one of the web servers that also listen on port 80. The load
balancer performs a health check on the virtual servers attached. Both virtual servers are working as
expected, so the load balancer routes traffic to them.
3 Here’s a Monitoring tab where you can find interesting metrics that you should watch in production. If
the traffic pattern changes suddenly, this indicates a potential problem with your system. You’ll also find
metrics indicating the number of HTTP errors, which will help you to monitor and debug your system.

Exercise 5: Inspect MySQL database


You can find your database in a resource group named wordpress. Select DB Instances under RDS at left.
By clicking the arrow icon in the Go column.

Exercise 6: Bill your service


1 Go to https://s3.amazonaws.com/awsinaction/chapter2/cost.html
2 Click on Estimate of Your Monthly Bill, and expand the Amazon EC2 Service and Amazon RDS
Service rows.
Everything is on-demand and usually billed by hours of usage or by gigabytes of usage. But what
influences usage for this infrastructure?
■ Traffic processed by the load balancer—Expect costs to go down in December and the summer when

people are on vacation and not looking at blogs.


■ Storage needed for the database—If your company increases the number of blogs, the database will

grow, so the cost of storage will increase.


■ Number of web servers needed—A single web server is billed by hours of usage. If two web servers

aren’t enough to handle all the traffic during the day, you may need a third server. In that case, you’ll
consume more hours of virtual servers.

Exercise 7: Delete your infraestructure


Go to the CloudFormation service in the Management Console and do the
following:
1 Select the Wordpress row.
2 Click Delete Stack

Potrebbero piacerti anche