EzDevInfo.com

amazon-ec2 interview questions

Top amazon-ec2 frequently asked interview questions

Change key pair for ec2 instance

How do I change the key pair for my ec2 instance in AWS management console? I can stop the instance, I can create new key pair, but I don't see any link to modify the instance's key pair.


Source: (StackOverflow)

How to safely upgrade an Amazon EC2 instance from t1.micro to large? [closed]

I have an Amazon EC2 micro instance (t1.micro). I want to upgrade this instance to large. This is our production environment, so what is the best and risk-free way to do this?

Is there any step by step guide to do this?


Source: (StackOverflow)

Advertisements

Add Keypair to existing EC2 instance

I was given AWS Console access to an account with 2 instances running that I cannot shut down (in production). I would however like to gain SSH access to these instances, is it possible to create a new Keypair and apply it to the instances so I can SSH in? Obtaining the exisiting pem file for the keypair the instances were created under is currently not an option.

If this isn't possible is there some other way I can get into the instances?


Source: (StackOverflow)

Benefits of EBS vs. instance-store (and vice-versa)

I'm unclear as to what benefits I get from EBS vs. instance-store for my instances on Amazon EC2. If anything, it seems that EBS is way more useful (stop, start, persist + better speed) at relatively little difference in cost...? Also, is there any metric as to whether more people are using EBS now that it's available, considering it is still relatively new?


Source: (StackOverflow)

Where is my httpd.conf file located apache [closed]

I am new to Apache and I wanted to ask, where is my httpd.conf file located? I am running a server from the amazon ec2 (elastic compute cloud) and I can't find my apache config. Can someone please tell me where it is located? Thanks!


Source: (StackOverflow)

EC2 instance has no public DNS

A guy I work with gave me the EC2 credentials to log onto his EC2 console. I was not the one who set it up. Some of the instances show a public dns name and others have a blank public DNS. I want to be able to connect to the instances that have a blank public DNS. I have not been able to figure out why these show up as blank.


Source: (StackOverflow)

Trying to SSH into an Amazon Ec2 instance - permission error

This is probably a stupidly simple question to some :)

I've created a new linux instance on Amazon EC2, and as part of that downloaded the .pem file to allow me to SSH in.

When I tried to ssh with:

ssh -i myfile.pem <public dns>

I got:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'amazonec2.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: amazonec2.pem
Permission denied (publickey).

Following this post I tried to chmod +600 the pem file, but now when I ssh I just get:

Permission denied (publickey).

What school-boy error am I making here? The .pem file is in my home folder (in osx). It's permissions look like this:

-rw-------@   1 mattroberts  staff    1696 19 Nov 11:20 amazonec2.pem

Source: (StackOverflow)

mongodb, replicates and error: { "$err" : "not master and slaveOk=false", "code" : 13435 }

I tried mongo replica sets for the first time.

I am using ubuntu on ec2 and I booted up three instances. I used the private IP address of each of the instances. I picked on as the primary and below is the code.

mongo --host Private IP Address
rs.initiate()
rs.add(“Private IP Address”)
rs.addArb(“Private IP Address”)

All at this point is fine. When I go to the http://ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com:28017/_replSet site I see that I have a primary, seconday, and arbitor.

Ok, now for a test.

On the primary create a database in this is the code:

use tt
db.tt.save( { a : 123 } )

on the secondary, I then do this and get the below error:

db.tt.find()
error: { "$err" : "not master and slaveOk=false", "code" : 13435 }

I am very new to mongodb and replicates but I thought that if I do something in one, it goes to the other. So, if I add a record in one, what do I have to do to replicate across machines?


Source: (StackOverflow)

On EC2: sudo node command not found, but node without sudo is ok

I have just installed nodejs on a new EC2 micro instance.

I installed it normally, ./configure -> make -> sudo make install.

Problem: When I run "node" under ec2-user, it runs perfectly. When I run "sudo node", it fails.

I found out that node is in:

[ec2-user@XXXX ~]$ whereis node
node: /usr/local/bin/node /usr/local/lib/node

and the current path is

[ec2-user@XXXX ~]$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/opt/aws/bin:/home/ec2-user/bin

but, the sudo path is

[root@ip-10-112-222-32 ~]# echo $PATH
/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin:/root/bin

then I tried to edit the root PATH to include the paths to node, so "node" runs when I'm logged in as root - but it still won't work when I log in as ec2-user and run "sudo node".

I need this to install npm properfly. Any idea on how to include the node path while running "sudo node"?


Source: (StackOverflow)

Do on-demand Mac OS X cloud services exist, comparable to Amazon's EC2 on-demand instances? [closed]

Amazon's EC2 service offers a variety of Linux and Windows OS choices, but I haven't found a service offering a similar "rent by the hour" service for a remote Mac OS X virtual machine. Does such a service exist? (iCloud looks to be just a data storage service, rather than a service allowing remote login, etc.)

Such a virtual machine service would be very useful for testing software in a reproducible, "neutral" location.


Update 1: Just to be clear, I'm referring to services similar to EC2's on-demand or spot instances, where the machine (or virtual machine) is rented per hour, rather than typical web hosting services that involve a monthly subscription. As @Erik has pointed out, there are several good options for that route. As my searches for queries for OS X hosting with terms like "per hour" or "hourly rates" are turning up very little (basically, just labor fees for hourly repairs), I am inclined to believe that this doesn't exist for some reason. If it did, it seems reasonable that such a firm would advertise for precisely these queries.

Update 2: I see that this question is getting a lot of views over time. If someone encounters a change in the situation, i.e. that there is a provider of such services, please post and I will accept that answer instead.


Source: (StackOverflow)

Setting up FTP on Amazon Cloud Server

I am trying to set up FTP on Amazon Cloud Server, but without luck... I search over net and there is no concrete steps how to do it...

Since there is no steps on web, can someone help me finding it or write it here?

I usually use dedicated server or shared hosting, but I am not that good with those Cloud servers...

I found those commands to run:

$ yum install vsftpd
$ ec2-authorize default -p 20-21
$ ec2-authorize default -p 1024-1048
$ vi /etc/vsftpd/vsftpd.conf
#<em>---Add following lines at the end of file---</em>
    pasv_enable=YES
    pasv_min_port=1024
    pasv_max_port=1048
    pasv_address=<Public IP of your instance>
$ /etc/init.d/vsftpd restart

But I don't know where to write them...

Help?


Source: (StackOverflow)

How to convert Linux cron jobs to "the Amazon way"?

For better or worse, we have migrated our whole LAMP web application from dedicated machines to the cloud (Amazon EC2 machines). It's going great so far but the way we do crons is sub-optimal. I have a Amazon-specific question about how to best manage cron jobs in the cloud using "the Amazon way".

The problem: We have multiple webservers, and need to run crons for batch jobs such as creating RSS feeds, triggering emails, many different things actually. BUT the cron jobs need to only run on one machine because they often write to the database so would duplicate the results if run on multiple machines.

So far, we designated one of the webservers as the "master-webserver" and it has a few "special" tasks that the other webservers don't have. The trade-off for cloud computing is reliability - we don't want a "master-webserver" because it's a single point of failure. We want them to all be identical and to be able to upscale and downscale without remembering not to take the master-webserver out of the cluster.

How can we redesign our application to convert Linux cron jobs into transitory work items that don't have a single point of failure?

My ideas so far:

  • Have a machine dedicated to only running crons. This would be a little more manageable but would still be a single-point-of-failure, and would waste some money having an extra instance.
  • Some jobs could conceivably be moved from Linux crons to MySQL Events however I'm not a big fan of this idea as I don't want to put application logic into the database layer.
  • Perhaps we can run all crons on all machines but change our cron scripts so they all start with a bit of logic that implements a locking mechanism so only one server actually takes action and the others just skip. I'm not a fan of this idea as it sounds potentially buggy and I would prefer to use a Amazon best-practice rather than rolling our own.
  • I'm imagining a situation where jobs are scheduled somewhere, added to a queue and then the webservers could each be a worker, that can say "hey, I'll take this one". Amazon Simple Workflow Service sounds exactly this kind of thing but I don't currently know much about it so any specifics would be helpful. It seems kind of heavy-weight for something as simple as a cron? Is it the right service or is there a more suitable Amazon service?

Update: Since asking the question I have watched the Amazon Simple Workflow Service webinar on YouTube and noticed at 34:40 (http://www.youtube.com/watch?v=lBUQiek8Jqk#t=34m40s) I caught a glimpse of a slide mentioning cron jobs as a sample application. In their documentation page, "AWS Flow Framework samples for Amazon SWF", Amazon say they have sample code for crons:

... > Cron jobs In this sample, a long running workflow periodically executes an activity. The ability to continue executions as new executions so that an execution can run for very extended periods of time is demonstrated. ...

I downloaded the AWS SDK for Java (http://aws.amazon.com/sdkforjava/) and sure enough buried within a ridiculous layers of folders there is some java code (aws-java-sdk-1.3.6/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow).

The problem is, if I'm honest, this doesn't really help as it's not something I can easily digest with my skillset. The same sample is missing from the PHP SDK and there doesn't seem to be a tutorial that walks though the process. So basically, I'm still hunting for advice or tips.


Source: (StackOverflow)

I bought a domain and I want to apply it on my Amazon Ec2 instance? [closed]

I have an Amazon EC2 instance with public DNS: ec2-123......amazon.com

How do I change the public domain from ec2-123......amazon.com to mydomain.com?


Source: (StackOverflow)

When to use Amazon Cloudfront or S3

Are there use cases that lend themselves better to Amazon cloudfront over s3 or the other way around? I'm trying to understand the difference between the 2 through examples.


Source: (StackOverflow)

What are the respective advantages/limitations of Amazon RDS vs. EC2 with MySQL?

I realize a couple of basic differences between the two, i.e.

  1. EC2 is going to be cheaper

  2. RDS I wouldn't have to do maintenance

Other than those two, are there any advantages to running my database from RDS as opposed to a separate EC2 server acting as a MySQL server. Assuming similar instance sizes, are both going to run into the same limitations in terms of being able to handle a load?

To give you a little bit more info about my use, I've got a database, nothing too big or anything (biggest table 1 million rows), just high SELECT volume.


Source: (StackOverflow)