user2119488
user2119488

Reputation: 21

Autoscaling ec2 instance without loss of old data

Recently My Website shifted on Amazon.

  1. I create EC2 Instance. Install lamp and Setup CodeIgnitor in /var/www/http folder. the structure
  2. Codeignitor folder I have folder name 'UPLOAD'.this folder is used for uploaded images and files.

  3. I make AMI image from EC2 Instance.

  4. I have setup Auto scaling of Ec2 instances.

  5. When my old ec2 instance is failed then automatically new instance is created. But My all data from "UPLOAD" of folder on old ec2 instance has lost.

  6. I want to separate "UPLOAD" folder in codeignitor from ec2 instance. So whenever new instance is create it will get UPLOAD folder and its contents without loss.

I want to separate this upload folder. so when new instance is create then it will get this data. how to do this.
Thanks for Advance.

Note . I have used MYSQL on Amazon RDS.

Upvotes: 2

Views: 1893

Answers (2)

Talal MAZROUI
Talal MAZROUI

Reputation: 645

As said by Mike, you can use EBS, but you can also use Amazon Simple Storage Service (S3) to store your images.

This way, whenever an instance starts, it can access all the previously uploaded images from S3. Of course, this means that you must change your code for the upload, to use the AWS API and not the filesystem to store your images to S3.

Upvotes: 1

Mike Hogan
Mike Hogan

Reputation: 10613

You can use a shared Elastic Block Storage mounted directory.

If you manually configure your stack using the AWS Console, go to the EC2 Service in the console, then go to Elastic Block Storage -> Volumes -> Create Volume. And in your launch configuration you can bind to this storage device.

If you are using the command line tool as-create-launch-config to create your launch config, you need the argument

--block-device-mapping "key1=value1,key2=value2..."

If you are using Cloudformation to provision your stack, refer to this template for guidance.

This assumes Codeignitor can be configured to state where its UPLOAD directory is.

Upvotes: 1

Related Questions