Amazon


Source: here.
Here we describe some notes on using amazon services such as EC2. 
Create an Amazon AWS account
Enable a Multi-Factor Authentication (e.g. by installing an app on your iPhone or Android)


Set the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to your Amazon EC2 access key ID and secret access key. These can be obtained from the AWS homepage by clicking Account > Security Credentials > Access Credentials:

$ export AWS_ACCESS_KEY_ID=<ACCESS_KEY_ID>
$ export AWS_SECRET_ACCESS_KEY=<SECRET_ACCESS_KEY>
 
Create an Amazon EC2 key pair for yourself. This can be done by logging into your Amazon Web Services account through the AWS console, selecting EC2 from the Services menu, selecting Key Pairs on the left sidebar, and creating and downloading a key:

Make sure that you set the permissions for the private key file to 600 (i.e. only you can read and write it) so that ssh will work (commands to do this are provided farther below).
 






How to(Steps)Getting Started in Cloud: Amazon EC2

Ok,

1) Create an account on aws.amazon.com, you will need a credit card to enter but you won't be charged that's for security purposes.
2) Hover your mouse over My Account / Console, click AWS Management Console. This will take you to https://console.aws.amazon.com/
3) Click on EC2, This will take you to https://console.aws.amazon.com/ec2/
4) On the left pane of the screen click on Key Pairs. Click Create Key Pair. Enter a name for your key click create. Your key -pair will be created and your private key will start downloading. Save it at a  safe place.
5) Get back to EC2 Console https://console.aws.amazon.com/ec2   Click on Launch Instance, this will take you to https://console.aws.amazon.com/ec2/home?region=us-west-2#startWizards=true  
6) Quick Launch Wizard > Choose a Launch Configuration, scroll down
and select the operating system of your choice. Here we select Microsoft Windows Server 2008 Base 32bits. Click Continue. You can take a look at it's details by clicking Edit Details, more description of details is here. quick note: Shut Down Behavior: Stop or Terminate: Look at the footnote:
7) Get back to EC2 Console https://console.aws.amazon.com/ec2  Click on Running Instances. You'll see your instance there. It takes a few minutes before a windows instance is ready to use, linux is usually immediately ready. Once it'ss ready it will change its status to 2/2 checks passed.
8) Right click on the instance, click Connect. Click Retrieve Password. Select the private key you just create above that downloaded to your computer to decrypt the password.  Click Decrypt Password. Save the Public DNS, Username and Password to access your instance.
Some thing like this:
Public DNS: ec2-54-214-174-102.us-west-2.compute.amazonaws.com
Username: Administrator
Password: abcdPasdkjvdvk@!2
DNS is the internet address of your server right now.
9) Click Download Shortcut File. Click Close.
Now you are ready to use your instance!
Run a software for remote desktop connection.

For example in ubuntu I use Applications>Internet>Remmina Remote Desktop Client.
In the menu: Connection>New. In the Server put the DNS, and respectively enter username and password, and click Connect. It will ask you to accept the certificate.
Please Wait for User Profile Service.
Or in windows you can use the default Remote Desktop Connection program. For this, if you could not connect directly

This is the end of the hello world cloud! Below is the screenshot of my little first cloud VM!
Now I'm in the cloud! Super EXCITED!





Source: Create Amazon AWS server Tutorial, shut down instanceGet WAMP running on EC2.

This will cost you 10 cents/hour. You don't want to leave it on forever. To stop, disconnect from instance, go to EC2 Console > Instances https://console.aws.amazon.com/ec2/home?region=us-west-2#s=Instances Right click on the virtual machine name (instance), click stop. You can restart it again. Alternatively you can terminate. Any data in there will be lost. And the machine will be gone forever. Either case, You'll notice that the status of the instance goes from running to shutting down.
Note: By default, Amazon EC2 deletes all Amazon EBS volumes that were attached when the instance launched. Amazon EBS volumes attached after instance launch persist. 




StopThe data on your EBS volume will remain after stopping while all information on the local (ephemeral) hard drive will be lost as usual.  The volume will continue to persist in its availability zone.  Standard charges for EBS volumes will apply. Root Device Type is:  EBS.  Terminate: your data will be lost no charges apply. Therefore, you should only stop an instance if you plan to start it again within a reasonable timeframe.  Otherwise, you might want to terminate an instance instead of stopping it for cost saving purposes.
The ability to stop an instance is only supported on instances that were launched using an EBS-based AMI where the root device data is stored on an attached EBS volume as an EBS boot partition instead of being stored on the local instance itself.  As a result, one of the key advantages of starting a stopped instance is that it should theoretically have a faster boot time.  When you start a stopped instance the EBS volume is simply attached to the newly provisioned instance.  Although, the AWS-id of the new virtual machine will be the same, it will have new IP Addresses, DNS Names, etc.  You shouldn't think of starting a stopped instance as simply restarting the same virtual machine that you just stopped as it will most likely be a completely different virtual machine that will be provisioned to you.
Once you terminate, the name of the instance will disappear from your Instance list after a couple of hours.

========================
To Save your Data:
Anything that is not stored on an ebs volume that is mounted to the instance will be lost. For instance, if you mount your ebs volume at /mystuff, then anything not in /mystuff will be lost. If you don't mount an ebs volume and save stuff on it, then I believe everything will be lost.

You can create an AMI from your current machine state, which will contain everything in your ephemeral storage. Then, when you launch a new instance based on that AMI it will contain everything as it is now.

To SSH
You can get a  linux machine using the same procedure. To ssh to the machine you need the private key (the key.pem file):
$ chmod 400 ./Downloads/my_private_key.pem        # Take some safety measures! Don't be DUMB
$ mv ./Downloads/my_private_key.pem ~/.ssh/
$ ssh -i ~/.ssh/my_private_key.pem root@ec2-54-244-74-27.us-west-2.compute.amazonaws.com     # the last argument is the name of the instance.

To have a permanent Storage
 Click on Elastic Block Store. You can create Volumes or snapshots of the current EC2 instances. Let's create a Volume:
Volume type Standard, Size 8GB, Select the machine zone your instance is located at (e.g. us-west-2a).

To check it out, create an instance: SUSE Linux Enterprise Server 11 (prevent against accidental termination) and connect to it.
$ cat /proc/partitions
major minor  #blocks  name

   8        1   10485760 sda1

Click on the ESB volume and right click Attach.
     
Linux Devices: /dev/sdf through /dev/sdp

Note: Newer linux kernels may rename your devices to /dev/xvdf through /dev/xvdp internally, even when the device name entered here (and shown in the details) is /dev/sdf through /dev/sdp.


$ cat /proc/partitions
major minor  #blocks  name

   8        1   10485760 sda1
   8       80    8388608 sdf

$ mkfs -t ext3 /dev/sdf   # format new partition, don't format if you have data on it ;)
$ mkdir /data
$ mount /dev/sdf /data
$ cd /data/
$ df  # check drives     # disk is readonly so far
$















Comments