Friday 22 March 2019

Amazon EC2 Instance

How to get started with Amazon EC2
Setting up with Amazon EC2
  • Sign up with AWS
Note -  If you previously signed in to the AWS Management Console using AWS account root user credentials, choose Sign in to a different account. If you previously signed in to the console using IAM credentials, choose Sign-in using root account credentials. Then choose to Create a new AWS account.
To create an AWS account - Open https://aws.amazon.com/ and then choose to create an AWS account.
  • Create an IAM user
To create an IAM user for yourself and add the user to an Administrators group
  1. Use your AWS account email address and password to sign in as the AWS account root user to the IAM console at https://console.aws.amazon.com/iam/.
  2. In the navigation pane of the console, choose Users, and then choose Add user.
  3. For User name, type Administrator
  4. elect the checkbox next to AWS Management Console access, select Custom password, and then type the new user's password in the text box. You can optionally select Require password reset to force the user to create a new password the next time the user signs in.
  5. Choose Next: Permissions.
  6. On the Set permissions page, choose to Add user to group.
  7. Choose Create group.
  8. In the Create group dialog box, for Group name type Administrators.
  9. For Filter policies, select the check box for AWS managed - job function.
  10. In the policy list, select the check box for AdministratorAccess. Then choose Create group.
  11. Back in the list of groups, select the check box for your new group. Choose Refresh if necessary to see the group in the list.
  12. Choose Next: Tags to add metadata to the user by attaching tags as key-value pairs.
  13. Choose Next: Review to see the list of group memberships to be added to the new user. When you are ready to proceed, choose to Create user.
To sign in as this new IAM user 

  • Create a key pair
To create a key pair

  1. Sign in to AWS using the URL that you created in the previous section.
  2. From the AWS dashboard, choose EC2 to open the Amazon EC2 console.
  3. From the navigation bar, select a region for the key pair. You can select any region that's available to you, regardless of your location. However, key pairs are specific to a region; for example, if you see plan to launch an instance in the US East (Ohio) Region, you must create a key pair for the instance in the US East (Ohio) Region.
  4. In the navigation pane, under NETWORK & SECURITY, choose Key Pairs.
  5. Choose Create Key Pair.
  6. Enter a name for the new key pair in the Key pair name field of the Create Key Pairdialog box, and then choose Create. Use a name that is easy for you to remember, such as your IAM user name, followed by -key-pair, plus the region name. For example, me-key-pair-useast2.
  7. If you will use an SSH client on a Mac or Linux computer to connect to your Linux instance, use the following command to set the permissions of your private key file so that only you can read it.
chmod 400 your_user_name-key-pair-region_name.pem
  • Create a Virtual Private Cloud
Amazon VPC enables you to launch AWS resources into a virtual network that you've defined, known as a virtual private cloud (VPC). The newer EC2 instance types require that you launch your instances in a VPC. If you have a default VPC, you can skip this section and move to the next task, Create a Security Group. To determine whether you have a default VPC, open the Amazon EC2 console and look for Default VPC under Account Attributes on the dashboard.
  • Create a Security Group
To create a security group with the least privilege
  1. Choose Security Groups in the navigation pane.
  2. Choose Security Groups in the navigation pane.
  3. Enter a name for the new security group and a description. Use a name that is easy for you to remember, such as your IAM user name, followed by _SG_, plus the region name. For example, me_SG_uswest2.
  4. In the VPC list, select your VPC. If you have a default VPC, it's the one that is marked with an asterisk (*).
  5. On the Inbound tab, create the following rules (choose Add Rule for each new rule), and then choose Create:
    • Choose HTTP from the Type list, and make sure that Source is set to Anywhere (0.0.0.0/0).
    • Choose HTTPS from the Type list, and make sure that Source is set to Anywhere (0.0.0.0/0).
    • Choose SSH from the Type list. In the Source box, choose My IP to automatically populate the field with the public IPv4 address of your local computer. Alternatively, choose Custom and specify the public IPv4 address of your computer or network in CIDR notation. To specify an individual IP address in CIDR notation, add the routing suffix /32, for example, 203.0.113.25/32. If your company allocates addresses from a range, specify the entire range, such as 203.0.113.0/24.
Getting Started with Amazon EC2 Linux Instances

Friday 1 March 2019

Monitoring with Ganglia

Prerequisites
Installing LAMP server

Before starting, you will need to install LAMP on the server. You can install it by running the following command:

user@host:$ sudo apt-get install -y apache2
user@host:$ service apache2 status
OR
Go to http://localhost or http://server-ipA page saying your Apache server is running properly should show up.

user@host:$ sudo apt-get install -y php7.0 libapache2-mod-php7.0 php7.0-cli php7.0-common php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-zip
user@host:$ php -v
OR
Go to http://localhost/info.php or http://server-ip/info.php. If php is running in your server, you will receive the following message in your web browser.

Installing Ganglia Server

user@host:$ sudo apt-get install ganglia-monitor rrdtool gmetad ganglia-webfrontend

During installation, you will be asked to restart Apache. Select yes. Depending on your system, you may be asked twice. Select yes again.


Configure Ganglia Master Node
Now you need to copy the ganglia webfrontend apache configuration to correct location using the following command

user@host:$ sudo cp /etc/ganglia-webfrontend/apache.conf /etc/apache2/sites-enabled/ganglia.conf

Now you need to edit the ganglia meta daemon configuration file using the following command

user@host:$ sudo gedit /etc/ganglia/gmetad.conf

change the following
data_source "my cluster" localhost
to
data_source "mach cluster" localhost

Need to edit the master node configuration file using the following command

user@host:$ sudo gedit /etc/ganglia/gmond.conf

change the following

/* If a cluster attribute is specified, then all gmond hosts are wrapped inside 
 * of a <CLUSTER> tag.  If you do not specify a cluster tag, then all <HOSTS> will 
 * NOT be wrapped inside of a <CLUSTER> tag. */ 
cluster { 
  name = "unspecified" 
  owner = "unspecified" 
  latlong = "unspecified" 
  url = "unspecified" 

to

/* If a cluster attribute is specified, then all gmond hosts are wrapped inside 
 * of a <CLUSTER> tag.  If you do not specify a cluster tag, then all <HOSTS> will 
 * NOT be wrapped inside of a <CLUSTER> tag. */ 
cluster { 
  name = "mach cluster" 
  owner = "unspecified" 
  latlong = "unspecified" 
  url = "unspecified" 

/* Feel free to specify as many udp_send_channels as you like.  Gmond 
   used to only support having a single channel */ 
udp_send_channel { 
  mcast_join = 239.2.11.71 
  port = 8649 
  ttl = 1 

to

/* Feel free to specify as many udp_send_channels as you like.  Gmond 
   used to only support having a single channel */ 
udp_send_channel { 
  # mcast_join = 239.2.11.71 
  host = localhost
  port = 8649 
  ttl = 1 

/* You can specify as many udp_recv_channels as you like as well. */ 
udp_recv_channel { 
  mcast_join = 239.2.11.71 
  port = 8649 
  bind = 239.2.11.71 

to

/* You can specify as many udp_recv_channels as you like as well. */ 
udp_recv_channel { 
  # mcast_join = 239.2.11.71 
  port = 8649 
  # bind = 239.2.11.71 

Save and exit the file

Restart Ganglia-monitor, Gmetad and Apache.

user@host:$ sudo systemctl start ganglia-monitor
user@host:$ sudo systemctl start gmetad
user@host:$ sudo systemctl restart apache2

Web Interface

Ganglia should now be set up and accessible at http://localhost/ganglia.