When we want to connect to amazon server instance through linux terminal then you need to install ec2-api-tools for fedora. We given full detailed information.
How to install ec2-api-tools for fedora
For installing the ec2-api-tools in linux box follow the steps.
Permissions 0755 for ‘ec2-project.pem’ are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: ec2-project.pem
For solving the issue you need to change the key file permission to 700. For that use following command
[root@localhost EC2key]$ chmod 700 -R ec2-project.pem
[root@localhost EC2key]$ ssh -i ec2-project.pem root@ec2-59-16-79-85.compute-1.amazonaws.com
Last login: Mon Jan 10 01:08:27 2011 from 158.162.131.50
[root@domU-18-33-35-0B-D5-02 ~]#
Confused how to configure load balancer on Amazon. Here we given you detail instructions about How to configure haproxy load balancing on amazon EC2
Many people take amazon EC2 cloud hosting. Amazon does gives the load balancer for application load balancing. But Amazon load balancer is not that much good. Amazon load balancer is not working on hardware or software base. That balancer just sending request to server one by one. Many people confused how to configure load balancer on Amazon EC2.
Here I am going to give you detail instructions about setting up the HaProxy load balancer on Amazon EC2.
How to configure haproxy load balancing on amazon ec2
What is Haproxy?
AProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It is particularly suited for web sites crawling under very high loads while needing persistence or Layer7 processing. Supporting tens of thousands of connections is clearly realistic with todays hardware. Its mode of operation makes its integration into existing architectures very easy and riskless.
For Haproxy load balancing I recommend to create the micro instance first. Then login to micro instance and install haproxy on that machine. I taken the Centos 5.0 virgin os. Use following command for install the haproxy.
#yum install haproxy
Then Open the haproxy config file.
# vi /etc/haproxy.cfg
For detail configuration you should read the Haproxy config documentation.
Haproxy’s default load balancing style is roundrobin. Which is trusted and good. With this load balancing I am serving around two million pages daily. Means I am handling 6 to 7 million requests per day. I am not having any issues.
I used the three backend server for delivery of my application and one server for serving the static data which is having images and js and css and application files.
Here is my configuration file
global
maxconn 4096 # Total Max Connections. This is dependent on ulimit
daemon
nbproc 4 # Number of processing cores. Dual Dual-core Opteron is 4 cores for example.
#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
mode http
log global
option dontlognull
option httpclose
option httplog
option forwardfor
option redispatch
timeout connect 10000 # default 10 second time out if a backend is not found
timeout client 300000
timeout server 300000
maxconn 60000
retries 3
#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
#frontend main *:80
frontend http-in
bind :80
acl url_static path_beg -i /static /images /javascript /stylesheets
acl url_static path_end -i .jpg .gif .png .css .js
acl url_stats path_beg /haproxy-stats
use_backend be_stats if url_stats
use_backend static if url_static
default_backend app
#-------------------------------------------------
#back-end statistics section
#----------------------------------------------------------------
backend be_stats
stats uri /haproxy-stats
# stats show-node
#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
backend static
balance roundrobin
server static 10.211.164.138:80 check
#server static 10.211.185.111:80 check
#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
backend app
balance roundrobin
server app1 10.214.284.241:80 check
server app2 10.208.168.131:80 check
server app3 10.212.158.126:80 check
You can use the above code in haproxy.cfg file. You just need to change the IP address which are listed under backend static and backend app section. You just put your static server(amazon EC2 instance’s internal IP address).
You should use internal IP address of server because that will reduce the bandwidth uses of Amazon EC2 server. Do not use the public IP address for load balance because that will cost you.
Put application database and application files on all the server. Point your domain to your load balancer machine’s Public IP address.
Let say your application is running on following domain.
www.YOURDOMAIN.COM – point to Load balancer macine.
Open your all application and static server’s apache configuration file. put following entry in that file.
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName www.YOURDOMAIN.COM
# Other directives here
</VirtualHost>
after this just restart the apache server of all servers.
If you are having any issues or questions about setting up the haproxy on amazon EC2 server Please write to me.