English 中文(简体)
1. 重述
原标题:Restoring a volume from a snapshot
  • 时间:2011-03-11 20:02:43
  •  标签:
  • amazon-ec2

我要说的是,我有一个包含欧洲统计局卷的非洲工业部长会议。

我也看到了一个幻灯。

我想“恢复”欧洲统计局的卷,以了解情况。

What s the best process to do this?

最佳回答

我不知道你可以恢复所附卷的某种方式,但这样做的办法是从头版中提出一卷,然后打上原件并附上新卷。

问题回答

如果你有一个连续的EC2号案例,而且你想把它恢复到先前的黑体中被俘的国家,那么,你需要停止这种说法,删除其目前的数量,从头版中产生新的数量,把新卷的篇幅加在你身上,重新开始你的工作。 此外,在规定新卷的可用区和该卷的贴切/重标时的装置名称周围还有两条微妙之处。

逻辑可能比较容易看出,你是否从指挥线,而不是从AWS网调取。

The following bash script is notable for production use, as it lacks any mis-eck and it only use sleep rather than Poll to ensure AWS directs have contributed. 但它确实成功地执行了所有这些步骤:

#!/bin/bash

set -e

# IN PARAMS
INSTANCE_ID=<YOUR_INSTANCE_ID_HERE>
SNAPSHOT_ID=<YOUR_SNAPSHOT_ID_HERE>
# OUT PARAMS
VOLUME_ID=

# begin execution

echo "Gathering information about the instance"
DEVICE_NAME=`ec2-describe-instance-attribute ${INSTANCE_ID} --block-device-mapping | awk  {print $2} `
OLD_VOLUME_ID=`ec2-describe-instance-attribute ${INSTANCE_ID} --block-device-mapping | awk  {print $3} `
echo "Found instance ${INSTANCE_ID} has volume ${OLD_VOLUME_ID} on device ${DEVICE_NAME}"

echo "Creating new volume from snapshot"
AVAILABILITY_ZONE=`ec2-describe-availability-zones --filter state=available | head -n 1 | awk  {print $2} `
VOLUME_ID=`ec2-create-volume --availability-zone ${AVAILABILITY_ZONE} --snapshot ${SNAPSHOT_ID} | awk  {print $2} `
echo "Created new volume: ${VOLUME_ID}"

sleep 20

echo "Stopping the instance"
ec2-stop-instances $INSTANCE_ID

sleep 20

echo "Detaching current volume"
ec2-detach-volume $OLD_VOLUME_ID --instance $INSTANCE_ID --device $DEVICE_NAME

sleep 20

echo "Attaching new volume"
ec2-attach-volume $VOLUME_ID  --instance $INSTANCE_ID --device $DEVICE_NAME

sleep 20

echo "Starting the instance"
ec2-start-instances $INSTANCE_ID

我已触及到“algal”提供的文字,以使用 a子和投票,而不是睡觉。 还将研究特定数量的最新概况。

#!/bin/bash

set -e

# IN PARAMS
RECOVERY_INSTANCE_ID=
SNAPSHOT_VOLUME_ID=

echo "Gathering information about the instance"
BLOCK_DEVICE_MAPPING=`aws ec2 describe-instance-attribute --instance-id ${RECOVERY_INSTANCE_ID} --attribute blockDeviceMapping`
DEVICE_NAME=`echo ${BLOCK_DEVICE_MAPPING} | jq  .BlockDeviceMappings[0].DeviceName  | tr -d  " `
OLD_VOLUME_ID=`echo ${BLOCK_DEVICE_MAPPING} | jq  .BlockDeviceMappings[0].Ebs.VolumeId  | tr -d  " `
AVAILABILITY_ZONE=`aws ec2 describe-instances --filters "Name=instance-id,Values= ${RECOVERY_INSTANCE_ID} " | jq  .Reservations[0].Instances[0].Placement.AvailabilityZone  | tr -d  " `
LATEST_SNAPSHOT_ID=`aws ec2 describe-snapshots --filter "Name=volume-id,Values= ${SNAPSHOT_VOLUME_ID} " | jq  .[]|max_by(.StartTime)|.SnapshotId  | tr -d  " `
echo "Found instance ${RECOVERY_INSTANCE_ID} in ${AVAILABILITY_ZONE} has volume ${OLD_VOLUME_ID} on device ${DEVICE_NAME}"

echo "Creating new volume from snapshot ${LATEST_SNAPSHOT_ID}"
NEW_VOLUME_ID=`aws ec2 create-volume --region eu-west-1 --availability-zone ${AVAILABILITY_ZONE} --snapshot-id ${LATEST_SNAPSHOT_ID} | jq  .VolumeId  | tr -d  " `
echo "Created new volume ${NEW_VOLUME_ID}"

aws ec2 wait volume-available --volume-ids $NEW_VOLUME_ID

echo "Stopping the instance"
aws ec2 stop-instances --instance-ids $RECOVERY_INSTANCE_ID

aws ec2 wait instance-stopped --instance-ids $RECOVERY_INSTANCE_ID

echo "Detaching current volume"
aws ec2 detach-volume --volume-id $OLD_VOLUME_ID --instance-id $RECOVERY_INSTANCE_ID

aws ec2 wait volume-available --volume-ids $OLD_VOLUME_ID

echo "Attaching new volume"
aws ec2 attach-volume --volume-id $NEW_VOLUME_ID --instance-id $RECOVERY_INSTANCE_ID --device $DEVICE_NAME

aws ec2 wait volume-in-use --volume-ids $NEW_VOLUME_ID

echo "Starting the instance"
aws ec2 start-instances --instance-ids $RECOVERY_INSTANCE_ID

如果您愿意继续遵守这一规定或贡献:

https://github.com/karimtabet/ebs_snapshot_recovery

1. 用从小体中产生的新卷取代对一例的附加量:

  1. Create a volume from the snapshot in the same availability zone the instance is in (right click on snapshot and click "create volume from snapshot")
  2. Best to stop the instance to avoid any application from crashing. Wait until instance is stopped.
  3. Write down the exact device name of the original volume (it is written in the AWS console under instances view or volumes view)
  4. Detach the old volume, delete it afterwards if you don t need it.
  5. Attach the newly created volume (from the snapshot) to the instance with the same device name.
  6. Start the instance again

从头版中提取一卷,以装在现有的EC2机器上,并复印其档案。

检查EC2机器。

  1. Pick an instance. EC2 tab | INSTANCES | Instances.
  2. Make a note of the EC2 machine’s availability zone.

编制一卷。

  1. Find the snapshot you want to copy files from and tick the box. ELASTIC BLOCK STORE | Snapshots
  2. Click the Create Volume button and fill in the fields. o The Size must be bigger than the snapshot size (free micro-instances get an 8GB volume). o The Availability Zone must be the same as the EC2 machine’s. o The Snapshot is already selected, more or less like snap12345678 - my description.
  3. Click the Yes, Create button. A new line appears in the Volumes table. ELASTIC BLOCK STORE | Volumes

附上该卷。

  1. Click the Attach Volume button and fill in the fields.
  2. The Volume value is already there.
  3. Pick your machine name i-12345678 (running) from the drop-down list of Instances.
  4. The Devices field shows the first available device name, like /dev/sdf. Does anyone bother changing this value?
  5. Click the Yes, Create button. A new device magically appears on the EC2 machine.
  6. Close the AWS console.




相关问题
SimpleDB vs Tokyo Cabinet

Has anybody compared SimpleDB and Tokyo Cabinet for performance and scalability? I m coding my project against SimpleDB at the moment and considering benchmarking TC, be nice if somebody had already ...

How to make visual studio 2008 deploy to ftp in ACTIVE mode?

I m using Amazon EC2 services and would like to publish my WCF application to this server using the visual studio 2008. Instead of opening so many ports on the amazon firewall, I ll use the ftp ACTIVE ...

Passenger and Rails on Scalr.net

I m having an issue with Passenger and Rails working together on my Scalr application server. I have Rails 2.3.5 installed and Passenger 2.2.7. I am running ruby 1.8.6 (patchlevel 111). Previous ...

Many users, many cpus, no delays. Good for cloud?

I wish to set up a CPU-intensive time-important query service for users on the internet. A usage scenario is described below. Is cloud computing the right way to go for such an implementation? If so, ...

Homemade cheap and cheerful clustering with MySQL+EC2?

I ve got a Java web service backed by MySQL + EC2 + EBS. For data integrity I ve looked into DRBD, MySQL cluster etc. but wonder if there isn t a simpler solution. I don t need high availability (can ...

What s a good way to collect logs from Amazon EC2 instances?

My app is hosted on an Amazon EC2 cluster. Each instance writes events to log files. I need to collect (and data mine) over these logs at the end of each day. What s a recommended way to collect these ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Need some help choosing between Amazon EC2 and VPS [closed]

At my company we are looking at hosting a blog and a CMS . We are still in the process of building the product and havent made it live yet. We are looking at some hosting options. We need to have ...

热门标签