1. 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
2. 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
3. How To Configure Amazon EC2 Load Balancer
1 | P a g e
Overview
The purpose of thisdocumentis to configure AmazonAWSLoadBalancer with2 nodes(instance).Inthis
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
Loginwiththe public IP address and update the operating system packages. Run the below command.
sudo yum update
Node #1 – OS Packages Update
4. How To Configure Amazon EC2 Load Balancer
2 | P a g e
Node #2 – OS Packages Update
NTP Configuration
Nextstepisto ensure NTPis configuredandTime serverisenabledtoverifyrunthe below commandon
both nodes.
cat /etc/ntp.conf | grep ^server
5. 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"
6. 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>
7. 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).
8. 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 zonesif
you need configure for higher availability.
9. 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 configuringhttpdservice,we needto ensure thatport 80 is openfrom the security
groups.
10. 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.
11. 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
Inthissectionyouneedconfigureloadbalancerparameters,suchasResponseTimeout,intervalandother
parameters.
12. How To Configure Amazon EC2 Load Balancer
10 | P a g e
Create – Configure Health Check - Advanced
Nextstepwouldbe addthe EC2 instancesintothe loadbalancer.Clickonthe nodes thathasto be part of
the load balancer.
Create – Add Tag
Next step would be add tag to the loadbalancer.
13. 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.
14. 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.
15. 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.
16. 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”.