My cloud experience Amazon web services

June 8, 2017 | Autor: Umesh Poudel | Categoría: Computer Networks, Cloud Computing and Virtualization
Share Embed


Descripción

My cloud experience Amazon web services

Preview: The intent of this paper is to share my experience on Amazon web services (AWS) and its cloud based offerings. This paper also summarizes the difficulties I came across in building a cloud based web servers, how I overcame it and finally accomplished my goal. Initial plan: Task 1: Build a webserver in Red Hat Enterprise Linux instance AWS resources used: EC2 instance and elastic block storage Sub-tasks: i.

Create and connect to Linux instance

ii.

Install Apache web server

iii.

Install PHP

iv.

Install mysql server for database

v.

Install WordPress and customize my website

Task 2: Build a webserver in windows Server 2012 with SQL Express AWS resources used: EC2 instance and elastic block storage Sub-tasks: i. Create and connect to Windows instance ii. Install IIS web server iii. Install WordPress and customize my site. Task 3: Associate Elastic IPs to instances AWS resource used: Elastic IP addresses Task 4: Configure Amazon S3 AWS resource used: Simple Storage Service Task 5: Create an Elastic Load Balancer and add both webservers to the load balancer AWS resource used: Elastic Load Balancer Task 6: Configure the CloudWatch for alarms and metrics to monitor the performance of instances and ELB AWS resource used: CloudWatch and SNS Task 7: Register the domain name and map the AWS public dns to my personal domain name.

My cloud experience Amazon web services

Building the solution: Task 1: Build a webserver in Red Hat enterprise Linux instance i) Create and connect to Linux instance The very first step was to create an instance; so I logged into the AWS console using my free tier account. I chose RHEL 7.0-hvm as my AMI and t2.micro as my instance type. Further, I configured the EBS volume with default size-10 GB and type-general purpose SSD which is just enough to run my webserver .After tagging my instance name as Poudel.Umesh_RHEL7, I configured the security group as below: I opened the tcp ports for mysql, ssh, http and https services respectively to access my instance. I then created public-private key pair using the wizard. Screenshot: security group configuration I downloaded the unique private key to my computer. Then I was ready to connect my instance from my windows machine. I have used putty before and with the help of the documentation1, I set the parameters required for ssh connection as shown below. Note: Putty doesn’t recognize the AWS private key file .pem and hence we have to convert the .pem file to putty key format .ppk before making a connection. I used the putty key generator to convert the .pem file to putty compatible .ppk file. Putty key generator is the free tool that comes with the full installer version of Putty.

1

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html

My cloud experience Amazon web services

Screenshot: putty configuration Finally I was connected to my RHEL instance:

Screenshot: RHEL instance connected from windows PC ii) Install and test Apache web server:

My cloud experience Amazon web services

At first I ran the command: sudo su so that I have the root access to perform all required operations in this server. Next I installed the apache web server and started the service: Yum install httpd Service httpd start

Screenshot: Apache web server test page iii) Install and test PHP I ran the commands below to install and start php service in my server. Yum install php php-mysql Service httpd restart

Screenshot: php test page

My cloud experience Amazon web services

Note: To run the test pages, I copied my AWS instance public dns and pasted in the browser. iv) Download and install mysql for database service At first, I downloaded the latest mysql community release using wget command: wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm Then I installed the mysql server and ran the service using the command below: Yum install mysql-server Service mysqld start Next I created mysql root user, database and password using the AWS guide.2 I named my database name ‘yusite’, user as ‘root’ and then secured the database using the command below: mysql_secure_Installation v) Download and install WordPress I used wget again to download the latest WordPress installation package: wget https://wordpress.org/latest.tar.gz I unzipped the file using the following command: tar -xzf latest.tar.gz Next step was to copy the sample WordPress file wp-config-sample.php to wpconfig.php and move it to apache document root /var/www/html/yusite. I modified the wp-config.php file using the vi editor as below: define (‘DB_NAME’, ‘mywordpress-db’); define (‘DB_USER’, ‘mywordpress’); define (‘DB_PASSWORD’, ‘******’); define (‘DB_HOST’, ‘localhost’); My linux server was ready as I was able to log into the WordPress successfully using public dns of my RHEL instance. Next I wanted to try and learn how to host the same website in the windows server 2012 and configure it as my second web server for failover. Task 2: Build a webserver in windows Server 2012 with SQL Express i) Create and connect to Windows server instance

2

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hosting-wordpress.html

My cloud experience Amazon web services

I went back to the AWS management console and launched Windows Server2012 with SQL express. I selected the t2.micro instance again to be in free tier zone and configured the EBS volume of size 30 GB with general purpose SSD type. I configured the ports to accept RDP, MS-SQL, HTTP, HTTPS connections. Then I noticed that I can use the same private key- uPoudel_key_s14.pem that was saved before in my PC to securely connect to my Windows instance. I was then asked to download the rdp file and generate password.

Screenshot: windows rdp password Using the rdp file and decrypted password, I was able to connect to my windows instance in no time.

Screenshot: windows server 2012 r2 instance

My cloud experience Amazon web services

ii) Install IIS and WordPress for Windows server Then I installed IIS-windows web server from server manager and installed the WordPress using Microsoft web platform installer.3After installing WordPress I was able to login and customize my WordPress site. Task 3: Associate Elastic IPs to instances In knew that my web servers need to have static IP addresses so as to map the domain with these IP addresses to access it from outside. I decided to use the elastic IP service from AWS but was not quite sure if these addresses were free tier eligible.

Screenshot: elastic IP association Next day I got my answer. I got charged $0.07 and that is because AWS charges $0.005/hr per elastic IP not attached to running instance. So in case I stopped my instance for any reason, I get charged otherwise it is free to use. I decided to continue with elastic IP for this project as the charge was very minimal and I would require fixed IP addresses to map my instances with domain name in future. Task 4: Configure Amazon Simple Storage Service (S3) Next I wanted to create storage in the AWS to store my files and images required for my website. From the AWS console, I selected S3 and created a bucket named umeshpbucket. Then I uploaded all image files that I wanted to use in my 3

http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/EC2Win_CreateWordPressBlog.htmlhttp://d ocs.aws.amazon.com/AWSEC2/latest/WindowsGuide/EC2Win_CreateWordPressBlog.html

My cloud experience Amazon web services

website. I right clicked on the uploaded image file to make it public and got an error stating “the following objects were not made public due to errors”. I gave a try with few other images but got the same error message.

Screenshot: S3 error message After going through few forums based on google search, I came to know that it was a permission issue and I had to use the EC2 instance to do the same. So I connected to my Windows 2012 server, accessed my bucket and made the uploaded images public after which I was able to import my S3 contents to the WordPress site successfully.

Screenshot: importing image file from Amazon S3 to WordPress Task 5: Create an Elastic Load Balancer and add both webservers to the load balancer My next important task was to create a load balancer and add both my linux sand windows servers to load balance the incoming web traffic across my servers. I knew the concept was somewhat similar to windows network load balancing

My cloud experience Amazon web services

(NLB) cluster, where 2 or more servers in a cluster distribute the load automatically. This concept is also used for redundancy where if one of the servers fails; the traffic is rerouted to healthy servers.4From the EC2 dashboard, under network and security, I selected load balancers and clicked on create load balancer tab. I named my load balancer PoudelUmeshLB and added both servers to load balancer. After changing the default ping path to root ‘/’ from ‘/index.html’, I left the security group as default and made sure that my instances were running on the same VPC as my load balancer. I renamed the default VPC to MYVPC and noted the VPC id.

Screenshot: my default VPC id One of the important steps in this task was to configure ports for listening incoming requests. The default was set to port 80 for HTTP requests. I decided to stick with only http for listeners and completed setup of my load balancer. After a while, I made note of the public DNS from the description tab. I wanted to make sure both of my instances are healthy and running. I clicked on the instances tab and noticed that only one of the servers was in service. My linux server was out of service saying “instance has failed at least the unhealthy threshold number of health checks consecutively”.

Screenshot: Linux instance out of service in my load balancer After researching in google for a bit, I found out that the linux based application server listen on tcp port 8000 by default. 5 I quickly added the listeners for tcp port 8000 from the listeners tab and waited for load balancer to update the status and within few minutes, my linux server was in service too

Screenshot: my healthy instances Load Balancer

4

https://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/SvcIntro.html

5

http://support.rightscale.com

My cloud experience Amazon web services

Next I wanted to verify if I could reach my WordPress site using the public dns of my load balancer. I copied the ELB dns name and pasted in the browser’s address bar but didn’t get any response. I tried it with multiple browsers but got the same error “cannot resolve the dns”. I was bit worried because I spent a lot of time in this task and I didn’t want let it go in vain. I had a strong feeling that I was very close as both of my instances were healthy and in service. I then decided to go through the security configuration of my load balancer again and checked the inbound and outbound rules. I noticed that my inbound rule was set to accept all tcp or udp traffic from default source with random value. I changed the source to ‘anywhere’ (0.0.0.0/0)from default value and saved the changes.

Screenshot: ELB inbound security setting I now tried again to reach my site using the LB public dns and Voilà –I was straight into the site

Screenshot: my site accessed using my load balancer DNS Task 6: Configure the CloudWatch alarms and metrics to monitor performance of AWS resources Next I decided to try one of the most popular services from AWS. I configured CloudWatch to monitor the performance of my instances and ELB and created

My cloud experience Amazon web services

alarms to push notifications to my email using Amazon simple notification service. I set 3 alarms: a) To notify me if the CPU utilization of my instances is greater than 60 % for 5 minutes or more. b) To notify me if the minimum number of unhealthy instances in my ELB is >=1 c) To notify me if estimated charges of AWS resources is >=0.50 Next I verified the alarms and metric from the CloudWatch dashboard under services.

Screenshot: CloudWatch alarms and metric Task 7: Register the domain and map the webservers’ IP to my domain name

Screenshot: adding A records and CNAME from godaddy.com

My cloud experience Amazon web services

Both of my webservers were up and running hosting the WordPress site and were easily accessible by AWS public dns. I wanted to use the personalized domain, making easier to access my site from internet. I got my own domain named iamumesh.com for my WordPress site. I used the tool provided by my domain registrar to create an A record of my new domain and pointed it to my instances respectively. I then created the CNAME to create an alias for my ELB. Next I logged into the WordPress site and changed the WordPress URL and site URL to reflect the changes.6

Screenshot: change WordPress and Site URLs in WordPress settings Finally, I was able to access my WordPress site using my own domain name: www.iamumesh.com/yusite Summary: After playing around with multiple services and going through a series of documentation, I was finally able to host my own site using fully load balanced web servers. Each of the AWS services I used for this project was under free tier zone. For a beginner like me, the free tier offered enough room to learn and play around with some of the best cloud based services offered by Amazon.

Lihat lebih banyak...

Comentarios

Copyright © 2017 DATOSPDF Inc.