During the first time, I was tried many ways to set a CNAME alias to set root domain, but it will not be worked until I started with R53 service.
Amazon instructed that we need to do something with commandline to connect load balancer to identify the apex hosted zone. For doing that I need to setup commandline ELB tool to do that. But it’s configurations are not like X.509 certificate based authentication which will not work with ELB.
ELB commandline using key based authentications. So that you may need Access key Identifier and Secret key.
You may get the amazon ELB commandline tools from here
a. Etract the zip file on C:ELB
b. Now you need to set 3 environment variables to work with ELB
Set the following
AWS_CREDENTIAL_FILE : C:ELBcredential.cfg
AWS_ELB_HOME : C:ELB
EC2_REGION : ap-southeast-1
Pls note that you should set the “EC2_REGION” to list out your loadbalencer created with respect to the region. Otherwise you will received an message ” No loadbalencer found” Here I choose the Asia as the most users accessing it from this continent.
You can also rename the file credential-templete file inside the EC2 tools you downloaded to “credential.cfg” and added the respective values for ‘AWSAccessKeyId‘ and ‘AWSSecretKey’
Now you all set and explore the command line power.
1. Show the loadbalencer your created for the mentioned region.
LOAD_BALANCER NAME DNS_NAME CANONICAL_HOSTED_ZONE_NAME
CANONICAL_HOSTED_ZONE_NAME_ID CREATED_TIME
LOAD_BALANCER mybalencer mybalencer-123456471.ap-southeast-1.elb.amazonaws.com mybalencer-123456471.ap-southeast-1.elb.
amazonaws.com ZNH9876DNDR38 2011-06-01T11:27:40.030Z
I do not wish to do everything from commandline as we can easily done it from the Amazon management console.
Now I’m going to interconnect my loadbalencer with my hosted R53 zone for my domain. So that any request to “mydomain.com” can able to serve by this loadebalencer.
C:ELBbin>elb-associate-route53-hosted-zone mybalencer –rr-name mydomain.com –hosted-zone-id Z2YWJJGD6DS –weight 100 -show-xml
Here,
mybalencer : my loadbalencer name
mydomain.com : my domain name
Z2YWJJGD6DS : You will get this is from the Route 53 interface. Each domain has unique id to identify itslef
-show-xml : This will help you to get the API response in return to identify the status of execution.
show-xml
<?xml version="1.0"?>
<ChangeResourceRecordSetsResponse xmlns="https://route53.amazonaws.com/doc/2011-05-05/"><ChangeInfo><Id>/change/CBE4J74135U2C</Id><St
tus>PENDING</Status><SubmittedAt>2011-06-01T11:49:04.333Z</SubmittedAt></ChangeInfo></ChangeResourceRecordSetsResponse>
You can see a domain host root record added in Route 53 apex hosted zone. From my experience even though the command was successful, But it will not worked as I expected. The hostalias ( A Alias) works like a charm in my case.
mydomain AAlias mybalencer-123456471.ap-southeast-1.elb.amazonaws.com
hi, nice articles. i want to know how the load balancer works in aws ?
if i have 1 main web server with web file , and i want other instance process web file in main instance, how i must do ? do I need NFS server installed in main instance ?
if not , how web files in main instance can processed by other instance ? i need this for load balancing .
Thx 🙂
You may need to setup NFS share on primary web server and common database server. NFS share would have full access from all other nodes.
note the following,
1.Source file syncronization : I use rsync with an option –exclude. This helps not logs and other cache folders not been copied among other servers.
2. NFS share :- It’s difficult to set firewall against on AWS security group to accept the NFS share only from the node servers. I do recommended VPC. This share should be mount automatically on every node restarts.
3. Use a common mysql server.