how to configure amazon ec2 load balancer

16
How To Configure Amazon EC2 Load Balancer i | Page Table of Contents Overview ....................................................................................................................................................... 1 Applies To...................................................................................................................................................... 1 Pre-requisites ................................................................................................................................................ 1 Launch Instance ............................................................................................................................................ 1 System Update .............................................................................................................................................. 1 Node #1 – OS Packages Update ............................................................................................................ 1 Node #2 – OS Packages Update ............................................................................................................ 2 NTP Configuration ......................................................................................................................................... 2 System Date Time ......................................................................................................................................... 3 Install – Web Server ...................................................................................................................................... 3 Webserver – Index File ................................................................................................................................. 4 Add Node #1 – Content......................................................................................................................... 4 Add Node #2 – Content......................................................................................................................... 4 LoadBalancer................................................................................................................................................. 5 Load Balancer – Create LoadBalancer ...................................................................................................... 5 Load Balancer – Definition ........................................................................................................................ 5 Define LoadBalancer Name................................................................................................................... 5 Create – Internal LoadBalancer ............................................................................................................ 6 Create – Enable advanced VPC Configuration – Select Subnets ........................................................... 6 Create – Enable advanced VPC Configuration – Selected Subnets....................................................... 7 Verify – Security Group ......................................................................................................................... 7 Create – Assign Security Group............................................................................................................. 8 Create – Configure Security Settings .................................................................................................... 8 Create – Configure Health Check .......................................................................................................... 9 Create – Configure Health Check - Advanced ....................................................................................... 9 Create – Configure Health Check - Advanced ..................................................................................... 10 Create – Add Tag ................................................................................................................................. 10 Create – Review .................................................................................................................................. 11 Create – Creation Status – Progress ................................................................................................... 11

Upload: vcp-muthukrishna

Post on 06-Aug-2015

544 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: How To Configure Amazon EC2 Load Balancer

How To Configure Amazon EC2 Load Balancer

i | P a g e

Table of Contents

Overview ....................................................................................................................................................... 1

Applies To ...................................................................................................................................................... 1

Pre-requisites ................................................................................................................................................ 1

Launch Instance ............................................................................................................................................ 1

System Update .............................................................................................................................................. 1

Node #1 – OS Packages Update ............................................................................................................ 1

Node #2 – OS Packages Update ............................................................................................................ 2

NTP Configuration ......................................................................................................................................... 2

System Date Time ......................................................................................................................................... 3

Install – Web Server ...................................................................................................................................... 3

Webserver – Index File ................................................................................................................................. 4

Add Node #1 – Content ......................................................................................................................... 4

Add Node #2 – Content ......................................................................................................................... 4

LoadBalancer ................................................................................................................................................. 5

Load Balancer – Create LoadBalancer ...................................................................................................... 5

Load Balancer – Definition ........................................................................................................................ 5

Define LoadBalancer Name ................................................................................................................... 5

Create – Internal LoadBalancer ............................................................................................................ 6

Create – Enable advanced VPC Configuration – Select Subnets ........................................................... 6

Create – Enable advanced VPC Configuration – Selected Subnets ....................................................... 7

Verify – Security Group ......................................................................................................................... 7

Create – Assign Security Group ............................................................................................................. 8

Create – Configure Security Settings .................................................................................................... 8

Create – Configure Health Check .......................................................................................................... 9

Create – Configure Health Check - Advanced ....................................................................................... 9

Create – Configure Health Check - Advanced ..................................................................................... 10

Create – Add Tag ................................................................................................................................. 10

Create – Review .................................................................................................................................. 11

Create – Creation Status – Progress ................................................................................................... 11

Page 2: How To Configure Amazon EC2 Load Balancer

How To Configure Amazon EC2 Load Balancer

ii | P a g e

Create – Creation Status – Successful ................................................................................................. 12

LoadBalancer – DNS Name ......................................................................................................................... 12

LoadBalancer – Test – First Request ....................................................................................................... 12

LoadBalancer – Test – Second Request .................................................................................................. 12

Load Balancer – Instance Status ................................................................................................................. 13

Load Balancer – Availability Configured ..................................................................................................... 13

Load Balancer – Remove Subnet ................................................................................................................ 14

Page 3: How To Configure Amazon EC2 Load Balancer

How To Configure Amazon EC2 Load Balancer

1 | P a g e

Overview

The purpose of this document is to configure Amazon AWS LoadBalancer with 2 nodes (instance). In this

guide we will install apahce2 webserver on both the nodes to test the availability. The main purpose of

loadbalancer is service high availability.

Applies To

Amazon EC2 Instance

Pre-requisites

A minimum of 2 EC2 instances have to be running. In this document we would be configuring Linux

Operating System.

Launch Instance

Launch 2 instances of a Linux Operating System and start the instance.

System Update

Login with the public IP address and update the operating system packages. Run the below command.

sudo yum update

Node #1 – OS Packages Update

Page 4: How To Configure Amazon EC2 Load Balancer

How To Configure Amazon EC2 Load Balancer

2 | P a g e

Node #2 – OS Packages Update

NTP Configuration

Next step is to ensure NTP is configured and Time server is enabled to verify run the below command on

both nodes.

cat /etc/ntp.conf | grep ^server

Page 5: How To Configure Amazon EC2 Load Balancer

How To Configure Amazon EC2 Load Balancer

3 | P a g e

System Date Time

Next step is to ensure date and Time on both nodes are in sync and are set to same timezone (UTC).

Install – Web Server

After updating operating system “install web server”, to install the webserver group run the below

command on both the nodes (instances).

yum groupinstall -y "Web Server"

Page 6: How To Configure Amazon EC2 Load Balancer

How To Configure Amazon EC2 Load Balancer

4 | P a g e

Webserver – Index File

Create a new “index.html” file in “/var/www/html” directory to create run the below command, run on

both the nodes.

cd /var/www/html

touch index.html

chmod 755 index.html

Add Node #1 – Content

Edit the “index.html” and a line to be displayed upon request from the browser.

<HTML>

<BODY>

<H1> This is message is from node ...... <i> One </i>

</BODY>

</HTML>

Add Node #2 – Content

Edit the “index.html” and a line to be displayed upon request from the browser.

<HTML>

<BODY>

<H1> This is message is from node ...... <i> Two </i>

</BODY>

</HTML>

Page 7: How To Configure Amazon EC2 Load Balancer

How To Configure Amazon EC2 Load Balancer

5 | P a g e

LoadBalancer

The purpose of load balancer is to ensure service is

Load Balancer – Create LoadBalancer

Navigate to “Network & Security Load Balancers” and click on “Create Load Balancer” button.

Load Balancer – Definition

Define LoadBalancer Name

In this step you need to define the loadbalancer name and Create LB inside (which inside network).

Page 8: How To Configure Amazon EC2 Load Balancer

How To Configure Amazon EC2 Load Balancer

6 | P a g e

Create – Internal LoadBalancer

This option is to enable the loadbalancer only within the internal network. Ideally we configure load

balancer to the internet facing ones. Hence we would not choose the option.

Create – Enable advanced VPC Configuration – Select Subnets

This option is to enable the loadbalancer available to other availability zones and choose other zones if

you need configure for higher availability.

Page 9: How To Configure Amazon EC2 Load Balancer

How To Configure Amazon EC2 Load Balancer

7 | P a g e

Create – Enable advanced VPC Configuration – Selected Subnets

Choose the availability zones from different subnets, if needed for higher availability.

Verify – Security Group

In this guide, we are configuring httpd service, we need to ensure that port 80 is open from the security

groups.

Page 10: How To Configure Amazon EC2 Load Balancer

How To Configure Amazon EC2 Load Balancer

8 | P a g e

Create – Assign Security Group

Choose existing security groups or create new security group, if you opt to choose create new security

group ensure Port “80” rule is added.

Create – Configure Security Settings

In this guide we are configuring simple Load balancer without security feature. In order to configure

security you could configure HTTPS or SSL protocol for secured connections.

Page 11: How To Configure Amazon EC2 Load Balancer

How To Configure Amazon EC2 Load Balancer

9 | P a g e

Create – Configure Health Check

Type of protocol “HTTP” and on port “80” and file “/index.html” that would be verified.

Create – Configure Health Check - Advanced

In this section you need configure load balancer parameters, such as Response Timeout, interval and other

parameters.

Page 12: How To Configure Amazon EC2 Load Balancer

How To Configure Amazon EC2 Load Balancer

10 | P a g e

Create – Configure Health Check - Advanced

Next step would be add the EC2 instances into the loadbalancer. Click on the nodes that has to be part of

the load balancer.

Create – Add Tag

Next step would be add tag to the loadbalancer.

Page 13: How To Configure Amazon EC2 Load Balancer

How To Configure Amazon EC2 Load Balancer

11 | P a g e

Create – Review

Review the loadbalancer and click on “Create” button.

Create – Creation Status – Progress

Upon clicking “Create” button; Loadbalancer creation progress is displayed.

Page 14: How To Configure Amazon EC2 Load Balancer

How To Configure Amazon EC2 Load Balancer

12 | P a g e

Create – Creation Status – Successful

After configuring the loadbalancer, loadbalancer will be created.

LoadBalancer – DNS Name

After creating loadbalancer successfully, DNS Name will be associated.

LoadBalancer – Test – First Request

Launch the DNS Name from the browser; the request is fetched from node One.

LoadBalancer – Test – Second Request

Launch the DNS Name from the browser; the request is fetched from node Two.

Page 15: How To Configure Amazon EC2 Load Balancer

How To Configure Amazon EC2 Load Balancer

13 | P a g e

Load Balancer – Instance Status

From the load balancer choose the “effonelb”, click on the “Instances” to know the status of nodes.

s

Load Balancer – Availability Configured

From the load balancer choose the “effonelb”, click on the “Instances” to know the availability zones

configured.

Page 16: How To Configure Amazon EC2 Load Balancer

How To Configure Amazon EC2 Load Balancer

14 | P a g e

Load Balancer – Remove Subnet

To remove zone(s) from the configured availability zones, click on “Remove from Load Balancer”.