how to configure amazon ec2 load balancer

19
How To Configure Amazon EC2 Load Balancer 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 i | Page

Upload: vcp-muthukrishna

Post on 06-Aug-2015

41 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: How to configure amazon ec2 load balancer

How To Configure Amazon EC2 Load Balancer

Table of ContentsOverview.....................................................................................................................................................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

i | P a g e

Page 2: How to configure amazon ec2 load balancer

How To Configure Amazon EC2 Load Balancer

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

ii | P a g e

Page 3: How to configure amazon ec2 load balancer

How To Configure Amazon EC2 Load Balancer

OverviewThe 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 ToAmazon EC2 Instance

Pre-requisitesA minimum of 2 EC2 instances have to be running. In this document we would be configuring Linux Operating System.

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

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

sudo yum update

Node #1 – OS Packages Update

1 | P a g e

Page 4: How to configure amazon ec2 load balancer

How To Configure Amazon EC2 Load Balancer

Node #2 – OS Packages Update

NTP ConfigurationNext 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

2 | P a g e

Page 5: How to configure amazon ec2 load balancer

How To Configure Amazon EC2 Load Balancer

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

Install – Web ServerAfter 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"

3 | P a g e

Page 6: How to configure amazon ec2 load balancer

How To Configure Amazon EC2 Load Balancer

Webserver – Index FileCreate 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>

4 | P a g e

Page 7: How to configure amazon ec2 load balancer

How To Configure Amazon EC2 Load Balancer

LoadBalancerThe 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).

5 | P a g e

Page 8: How to configure amazon ec2 load balancer

How To Configure Amazon EC2 Load Balancer

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.

6 | P a g e

Page 9: How to configure amazon ec2 load balancer

How To Configure Amazon EC2 Load Balancer

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.

7 | P a g e

Page 10: How to configure amazon ec2 load balancer

How To Configure Amazon EC2 Load Balancer

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.

8 | P a g e

Page 11: How to configure amazon ec2 load balancer

How To Configure Amazon EC2 Load Balancer

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.

9 | P a g e

Page 12: How to configure amazon ec2 load balancer

How To Configure Amazon EC2 Load Balancer

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.

10 | P a g e

Page 13: How to configure amazon ec2 load balancer

How To Configure Amazon EC2 Load Balancer

Create – Review

Review the loadbalancer and click on “Create” button.

Create – Creation Status – Progress

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

11 | P a g e

Page 14: How to configure amazon ec2 load balancer

How To Configure Amazon EC2 Load Balancer

Create – Creation Status – Successful

After configuring the loadbalancer, loadbalancer will be created.

LoadBalancer – DNS NameAfter 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.

12 | P a g e

Page 15: How to configure amazon ec2 load balancer

How To Configure Amazon EC2 Load Balancer

Load Balancer – Instance StatusFrom the load balancer choose the “effonelb”, click on the “Instances” to know the status of nodes.

s

Load Balancer – Availability ConfiguredFrom the load balancer choose the “effonelb”, click on the “Instances” to know the availability zones configured.

13 | P a g e

Page 16: How to configure amazon ec2 load balancer

How To Configure Amazon EC2 Load Balancer

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

14 | P a g e