Tuesday, May 19, 2020

Lab: Install and Configure the CloudWatch Logs Agent on a Running EC2 Linux Instance

Note: This blog is for you to make your life easier. 
Don't make your life complicated, just enjoy the blog. ^_^
Please pardon my simplicity of my own blog and look for the content. 



To make it more easier for you just click one photos, follow then scroll. ⏩

Enjoy reading! ^_^

Configure the Older CloudWatch Logs Agent on a Running EC2 Linux Instance

You can use the CloudWatch Logs agent installer on an existing EC2 instance to install and configure the CloudWatch Logs agent. After installation is complete, logs automatically flow from the instance to the log stream you create while installing the agent. The agent confirms that it has started and it stays running until you disable it.

Step 1: Configure Your IAM Role or User for CloudWatch Logs

From IAM choose roles by selecting the role name then attach policies and create policy. New browser will open then choose the JSON tab and type the following to JSON policy document.
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "logs:CreateLogGroup",
        "logs:CreateLogStream",
        "logs:PutLogEvents",
        "logs:DescribeLogStreams"
    ],
      "Resource": [
        "*"
    ]
  }
 ]



Then review policy, from the review policy page type Name and a Description.



Now, Create policy. After that close the summary and create policy. Now, close the browser and return to add permission page for your role then refresh and attach policy.



Creating a Role
In IAM from the left side panel select role tab then create new role.


From creating role window select AWS services and select EC2 and click permission.



From permission, select the policy you created then click tag.

From tag window, give a tag for the role.



Then review and put a name to your role.


You should now be able to see your role you created.





Attach IAM Role to a Instances

Attach the IAM role then add the details by selecting the role you created.





Step 2: Install and Configure CloudWatch Logs on an Existing Amazon EC2 Instance

The process for installing the CloudWatch Logs agent differs depending on whether your Amazon EC2 instance is running Amazon Linux, Ubuntu, CentOS, or Red Hat. Use the steps appropriate for the version of Linux on your instance.

Install the CloudWatch Agent and log-in to instances. Use your public IP address and putty to log to your Instances.

And type the commands:



Update Instances: sudo yum update -y
Install AWS Logs: sudo yum install -y awslogs
Start AWS Log Services: sudo systemctl start awslogsd
Check the Logservicese Status: sudo systemctl status awslogsd.service
Enable the Logservicese at each boot: sudo systemctl enable awslogsd.service


After that, check the CloudWatch Logs.
Go to CloudWatch then Management & Governance select CloudWatch, click logs & view it.
Lastly, click on the Path(/var/log/messages)



You should now see all the log file.



Problems Encountered:
None

Realisation:
The unified CloudWatch agent enables you to collect both logs and advanced metrics with one agent. It offers support across operating systems, including servers running Windows Server. This agent also provides better performance.

References:
AWS Site

Wednesday, May 13, 2020

Lab: Scale and Load Balance Your Architecture

Note: This blog is for you to make your life easier. 
Don't make your life complicated, just enjoy the blog. ^_^
Please pardon my simplicity of my own blog and look for the content. 



To make it more easier for you just click one photos, follow then scroll. ⏩

Enjoy reading! ^_^

Elastic Load Balancing automatically distributes incoming application traffic across multiple Amazon EC2 instances. It enables you to achieve fault tolerance in your applications by seamlessly providing the required amount of load balancing capacity needed to route application traffic.

Auto Scaling helps you maintain application availability and allows you to scale your Amazon EC2 capacity out or in automatically according to conditions you define. You can use Auto Scaling to help ensure that you are running your desired number of Amazon EC2 instances. Auto Scaling can also automatically increase the number of Amazon EC2 instances during demand spikes to maintain performance and decrease capacity during lulls to reduce costs. Auto Scaling is well suited to applications that have stable demand patterns or that experience hourly, daily, or weekly variability in usage.

First, Access your AWS Management Console.

Task 1: Create an AMI for Auto Scaling

In this task, you will create an AMI from the existing Web Server 1. This will save the contents of the boot disk so that new instances can be launched with identical content.

From Instances wait for the Status Checks for Web Server 1 then configure by clicking the Image & Create Image.

Task 2: Create a Load Balancer

In this task, you will create a load balancer that can balance traffic across multiple EC2 instances and Availability Zones.

From the Load Balancer, Create Load Balancer then configure the following:
  • Name: LabELB
  • VPC: Lab VPC (In the Availability Zones section)
  • Availability Zones: Select  both to see the available subnets.
  • Select Public Subnet 1 and Public Subnet 2
This configures the load balancer to operate across multiple Availability Zones.

From Configure Routing name it as "LabGroup" then Create.


Task 3: Create a Launch Configuration and an Auto Scaling Group

In this task, you will create a launch configuration for your Auto Scaling group. A launch configuration is a template that an Auto Scaling group uses to launch EC2 instances. When you create a launch configuration, you specify information for the instances such as the AMI, the instance type, a key pair, security group and disks.

From the left navigation Panel of AWS you will find the Launch Configurations and click the "Create launch configuration" and proceed. When you reach the configuration settings name it as:
  • Name: LabConfig
  • Monitoring: Select  Enable CloudWatch detailed monitoring
This allows Auto Scaling to react quickly to changing utilization.

And, 
  • Click Select an existing security group
  • Select  Web Security Group
  • Click Review

Then "create launch configuration."

After creating launch configuration, configure the following settings:
Group name: Lab Auto Scaling Group and group size of 2. Choose Lab VPC from Network and Ignore the message regarding "No public IP address."

Note: Review the details of your Auto Scaling group, then click Create Auto Scaling group. If you encounter an error Failed to create Auto Scaling group, then click Retry Failed Tasks.


Task 4: Verify that Load Balancing is Working

In this task, you will verify that Load Balancing is working correctly.

Proceed with the Lab Instance then from the Target Groups check the status of both instances and the transitions to Health state.


Copy the DNS name of the load balancer, making sure to omit "(A Record)".
It should look similar to: LabELB-1998580470.us-west-2.elb.amazonaws.com

Then open a new web browser tab then paste the DNS Name you just copied.



Task 5: Test Auto Scaling

You created an Auto Scaling group with a minimum of two instances and a maximum of six instances. Currently two instances are running because the minimum size is two and the group is currently not under any load. You will now increase the load to cause Auto Scaling to add additional instances.
From the left navigation pane click Alarms then configure the following:
  • On the Services  menu, click EC2.
  • In the left navigation pane, click Auto Scaling Groups and then click on Scaling Policies.
  • Click Actions⌄ and Edit.
  • Change the Target Value to 50.
  • Click Save.
  • On the Services  menu, click CloudWatch.
  • In the left navigation pane, click Alarms (not ALARM) and verify you see two alarms.

Two alarms will be displayed. These were created automatically by the Auto Scaling group. They will automatically keep the average CPU load close to 60% while also staying within the limitation of having two to six instances.
Beside the AWS logo you can see the Load Test. This will cause the application to generate high loads. The browser page will automatically refresh so that all instances in the Auto Scaling group will generate load. Do not close this tab.

From CloudWatch console, the AlarmLow alarm should change to OK and the AlarmHigh alarm status should change to ALARM. 


Task 6: Terminate Web Server 1

In this task, you will terminate Web Server 1. This instance was used to create the AMI used by your Auto Scaling group, but it is no longer needed.

 Terminated Successfully.





Problems Encountered:

NONE.




Lesson Learned:

Registering your Auto Scaling group with an Elastic Load Balancing load balancer helps you set up a load-balanced application. Elastic Load Balancing works with Amazon EC2 Auto Scaling to load balance incoming traffic across your healthy Amazon EC2 instances. This increases the scalability and availability of your application. You can enable Elastic Load Balancing within a single Availability Zone or multiple Availability Zones to increase the fault tolerance of your applications. 


References:

AWS Website.






Thursday, May 7, 2020

Lab: Build a Database Server

Note: This blog is for you to make your life easier. 
Don't make your life complicated, just enjoy the blog. ^_^
Please pardon my simplicity of my own blog and look for the content. 

To make it more easier for you just click one photos, follow then scroll. ⏩

Enjoy reading! ^_^


Build a Database Server

This lab is designed to reinforce the concept of leveraging an AWS-managed database instance for solving relational database needs.

Amazon Relational Database Service (Amazon RDS) makes it easy to set up, operate, and scale a relational database in the cloud. It provides cost-efficient and resizable capacity while managing time-consuming database administration tasks, which allows you to focus on your applications and business. Amazon RDS provides you with six familiar database engines to choose from: Amazon Aurora, Oracle, Microsoft SQL Server, PostgreSQL, MySQL and MariaDB.


Objectives
  • Launch an Amazon RDS DB instance with high availability.
  • Configure the DB instance to permit connections from your web server.
  • Open a web application and interact with your database.


First, Access your AWS Management Console.


Task 1: Create a Security Group for the RDS DB Instance


We will create a Security Group for RDS DB instance, go to AWS Management Console then Services, click VPC. Go to Create Security Group and add the following below. 


After creating, go to DB Security Group then Inbound Rules tab and Edit rules. You will be able to create MySQL Aurora.








Task 2: Create a DB Subnet Group



On the Services menu click RDS then Subnet groups. We will be creating DB Subnet Group as part of the requirements.





Task 3: Create an Amazon RDS DB Instance

Now, we will configure and launch a Multi-AZ Amazon RDS for MySQL database instance.

Amazon RDS Multi-AZ deployments provide enhanced availability and durability for Database (DB) instances, making them a natural fit for production database workloads. When you provision a Multi-AZ DB instance, Amazon RDS automatically creates a primary DB instance and synchronously replicates the data to a standby instance in a different Availability Zone (AZ).

From your current browser, go to Database then Create Database, this will enable you to create an Amazon RDS DB Instance.



Note that it will take approximately 4 minutes for the database to be available. This will be the deployment process is deploying a database in two different availability zones.



After creating database, click lab-db (the link itself). Then go to Modify, Connectivity & Security section and copy the endpoint field.




Task 4: Interact with Your Database


The last task is opening the web application running in web server and configuring it to use the database.

To copy the WebsServer IP address, click the Vocareum tab then Details & Show. Proceed with RDS link at the top of the page and configure.






Problems Encountered:

NONE.




Lesson Learned:

This lab we created is a DB instance in an isolated database environment running in the cloud. It is the basic building block of Amazon RDS. A DB instance can contain multiple user-created databases, and can be accessed using the same client tools and applications you might use to access a standalone database instance. DB instances are simple to create and modify with the Amazon AWS command line tools, Amazon RDS API operations, or the AWS Management Console.


References:

AWS Website.