Showing posts with label High Availability. Show all posts
Showing posts with label High Availability. Show all posts

May 26, 2017

Migrate EC2 Instances from one account to another (same region)




There are a lot of cases, which I encounter every now and then and do not find solutions easily and I have to refer to books that are available with me or on the Internet. One such scenario that I faced recently was that I had a development instance (in my aws account) and I had to create an instance for client and install/deploy all required packages/app etc (in his aws account). At that point I was wondering if there is some way to simply transfer the instance to other account (I was using my personal AWS account for development purposes and had to create/configure instance in client’s account).  Being lazy to the core I just didn't wanted to create an instance and do the rework. 

Lot of times I was regretting not asking client to provide infra for development purposes as well. A lot was going through my mind like “Why I didn’t used docker”, “ Why I didn’t note down all configuration steps”, “Should I write Ansible script to make it easier”. While I was thinking all this and searching web at the same time I came across several answers (on stackoverflow) where it was mentioned how snapshots can be used to create new instances etc.

At that point I decided to explore AWS Console a bit more deeply and decided to play around with it while referring to documentation as well and very soon I was able to migrate instance across accounts in same region.

I am sharing steps below in hope of helping others :
Pre-requisite :
-       You should be able to access the support section of destination account (more on this below).

Step 1: Log into source account and go to EC2.
Step 2: Select the instance that you want to migrate.



Step 3: Create an AMI and give it a name or description that its easier to understand. I named my AMI as devmigrate20may17.



Step 4: Click on Create Image and wait for snapshot to appear in Snapshots section in the same region.

Step 5: Select the snapshot and create image from it.


Step 6: Keep all the values as default and give a descriptive name.



Step 7: Once the Image is created, go to AMI section and select the newly created image.  In lower half note “Permissions” tab, click on that.







Step 8: You will notice that AMI’s are by default private. (Most will get excited at this point). Yes , we can edit and make it public.


Step 9: At this point we need account number of destination account, you can find account number in support section in top right corner copy that account number and paste it in the box. There are two options here to make AMI public i.e it will be visible to everybody and to make it visible to the account number we specify. We will go with the second option for obvious reasons.

Step 10: Log into destination account Go to Images -> AMI and select “Private Images” from drop down filter. Here you will see the AMI and from this AMI you can simply launch an instance.

I hope this post help people like me who needed to migrate instance from one account to another.

Do share your feedback and if you think its helpful, please share it with others as well.

Dec 1, 2016

Docker Cheatsheet - Handy Docker commands for everyday use.


Docker is a container management system that helps easily manage Linux Containers. It lets us create images in virtual environments on our laptop or development environments. The actions that we do on containers and its corresponding behaviour remains same when we run them in production environment.


Docker Commands :

$docker --help : It gives full list of all Docker commands.

$docker <COMMAND> --help : To get additional help pertaining for the given command.

$docker version : gives the information about docker installation.

Search Docker Images :

$docker search <search-term> for e.g docker search nginx

Pulling a Docker Image:

$docker pull tutum/ubuntu

List Docker Images :

$docker images

       

Remove Docker Image:

$docker rmi ubuntu:trusty

Run a Docker Image:

$docker run -i -t image_name:tag /bin/bash 
-i gives an interactive shell
-t will assign a pseudo-tty

Run Docker Image as Daemon
<pre>
$docker run -d image_name:tag for e.g. $docker run -d ubuntu:trusty
</pre>
View the running container/s:
$docker ps

Expose the Docker ports in Daemon mode
$docker run -d -p 8080:80 ubuntu:trusty (port 8080 of container is mapped to port 80 of host)

Check the logs of Docker Container
$docker logs container_id or name

Kill a Docker Container:
$docker kill container_id or name

Stop a Docker Container:
$docker stop container_id or name

Get the stats of Docker Container:
$docker stats container_name

$docker top container_name

Remove the container
$docker rm container_name

BUILDING A DOCKER IMAGE
$docker build --help 

$docker build -f path_to_Dockerfile -t REPOSITORY:TAG
REPOSITORY mostly username is used for Docker Hub and <TAG> is the container name.

Building with multiple config files

Create a new directory to hold config files and CD into that directory before executing the build command.

$docker build -t REPOSITORY:TAG


DATA VOLUMES

Mounting a single volume
$docker run -it -v /user/home ubuntu /bin/bash

Mounting multiple volumes 
$docker run -it -v /user/home -v /tmp ubuntu /bin/bash

Mounting local directory inside the Docker Container
$docker run -it -v /user/home:/data ubuntu /bin/bash

Mounting in Read Only mode
$docker run -it -v /user/home:/data:ro ubuntu /bin/bash

We can verify the mounts by issuing :
$docker inspect container_id

DATA VOLUMES CONTAINER










Sep 4, 2010

Build you own Highly Available Cluster with 'Wackamole' and 'Spread'

By :


Yair Amir
Ryan Caudy
Ashima Munjal
Theo Schlossnagle









This application works on a bunch of virtaul IPs and sees that all these IP remain available on a bunch of machines hosting these IP's. Constraint is that these bunch of machines should be on same LAN. If one machine goes down 'Wackamole' ensures that rest of the machines take over those IP's and all 20 IP remain visible to outer world at all times.

More to come....