首页 > 代码库 > AWS标准扩容(三)

AWS标准扩容(三)

AWS扩容过程:

You can increase the storage space of an existing EBS volume without losing the data on the volume.

你能够不丢数据地增加现在EBS卷上的存储空间。

To do this, you migrate your data to a larger volume and then extend the file system on the volume to recognize the newly-available space. After you verify that your new volume is working properly, you can delete the old volume.要做到这一点,你迁移你的数据到一个更大的卷然后扩展卷上的文件系统来识别新的可用空间。在你验证新的卷工作正常后,你可以删除老的卷。

 

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.打开EC2Console

  2. In      the navigation pane, choose Instances and      then locate the instance with the volume that you want to expand. 找到导航窗格,选择“Instances”然后找到需要扩容的实例

  3. Make      a note of the instance ID and Availability Zone. You will specify this      information when you attach a new volume to the instance later in this      procedure.记录下实例的ID号和可用区域。当你附加一个新的磁盘到此实例的过程中你需要指定这些信息。

  4. Verify      that the instance Shutdown      Behavior is set to Stop and not Terminate.

    1. Choose the instance.

    2. From       the context-menu (right-click) choose Instance Settings, and then choose Change Shutdown Behavior.

    3. If       the Shutdown behavior is       set to Terminate,       choose Stop,       and then choose Apply.
                   If the
       Shutdown       behavior is already set to Stop, then choose Cancel.

 

核实是被stop而不是terminate.a.选择实例  b.右击选择“Instance settings”然后,选择“Change shutdown behavior. c.如果“shutdown behavior”将被设置为“Terminate,选择“Stop,然后选择“Apply;如果“shutdown behavior”已经被设置为“Stop,选择“Cancel.

 

 

5. Stop the instance. For more      information about how to stop an instance, see Stopping and Starting Your Instances.
           
Warning
           
When you stop an instance, the data on any      instance store volumes is erased. Therefore, if you have any data on      instance store volumes that you want to keep, be sure to back it up to persistent storage.

停止实例。如果有数据放在instance store,请备份到persistent storage.

6. Create a snapshot of the volume to expand.

    1. In the navigation pane, choose Volumes, and then locate the volume you want to expand.

    2. From       the context-menu (right-click) choose the volume that you want to       expand, and then choose Create Snapshot.

    3. Enter       information in the Name and Description fields,       and then choose Yes,       Create.

创建一个卷的snapshot用于扩展。右击需要做snapshot的磁盘创建snapshot,加入名字和描述。

7. Create a new volume from the snapshot.

    1. In the navigation pane, choose Snapshots.

    2. When       the status of the snapshot that you just created is set to completed, choose the snapshot, and       then from the context-menu (right-click) choose Create Volume.

    3. In       the Create Volume dialog       box, choose the desired volume type and enter the new volume size. You       must also set the Availability       Zone to match the instance       Availability Zone. Choose Yes, Create.
                   
      Important
                   
      If you do not set the Availability Zone to       match the instance then you will not be able to attach the new volume to       the instance.

创建新的卷对于这个snapshot.当 备份完毕后右击这个snapshot创建卷。输入卷的类型和大小。你必须把它放在可用区域。

 

8. Detach the old volume.

    1. In the navigation pane, choose Volumes, and then choose the old volume from the list. Make a note       of the device name in the Attachment Information field. You will specify this information when you attach a       new volume to the instance later in this procedure. The information       appears in the following format:
                   
      i-xxxxxxxxxxxxxxxxx (instance_name):device_name

    2. From       the context-menu (right-click) choose the old volume, and then choose Detach Volume.

    3. In       the Detach Volume dialog       box, choose Yes,       Detach. It may take several minutes for the       volume to detach.

分离老的卷。

  1. 找到老的卷,记下设备名称,在attachment      information你可以找到。当你附加一个新的卷在这个实例的时候你需要指定这个信息。

  2. 右击老的卷,然后选择detach      volume.

  3. 选择yes,detach.

 

9. Attach the newly expanded volume

    1. In the navigation pane, choose Volumes.

    2. From       the context-menu (right-click) choose the new volume, and then choose Attach Volume.

    3. Start       typing the name or ID of the instance in the Instance field,       and then choose the instance.

    4. Enter the same device name retrieved in Step       8.a, and then choose Yes,       Attach. It is important to attach       the new volume to the exact location you noted above (for example /dev/sda1).

 

附加新的扩展过的卷。

a.右击,选择attach volume.

b.输入实例的名字和Id在“instance”这个字段,选择实例。

c.输入设备名称,选择yes,attach.


 10.Restart the instance.

    1. In the navigation pane, choose Instances and then choose the instance you want to       restart.

    2. From       the context-menu (right-click) choose Instance State, and then choose Start.

    3. In       the Start Instances dialog       box, choose Yes,       Start. If the instance fails to start, and the volume being       expanded is a root volume, verify that you attached the expanded volume       using the same device name as the original volume, for example /dev/sda1.

 

 

重启实例,右击实例,选择instance state,然后选择start. 然后选择yes,start.

 

 

 

  1. 注意:

Note

After you are done resizing your volume, you should delete the snapshot you created in the procedure above to avoid incurring storage costs.

在你resize你的卷后,你应该删除刚刚创建的snapshot,避免招致存储花费。

 

 

11. Extending a Linux File System扩展文件系统:

For ext2ext3, and ext4 file systems, this command is resize2fs. For XFS file systems, this command is xfs_growfs.注意在使用xfs_growfs需要安装包:

sudo yum install xfsprogs

 

Then use the following command, substituting the mount point of the file system (XFS file systems must be mounted to resize them).注意下括号里面的内容:xfs文件系统必须挂载状态。

[ec2-user ~]$ sudo xfs_growfs -d /mnt

 

 

 

怎么查看文件系统的类型:

file -s /dev/xvd*

 

显示块设备:

lsblk command to list the block devices attached to your instance. The example below shows three volumes: /dev/xvda/dev/xvdb, and /dev/xvdf.

 

注意:

Note

If you receive an xfsctl failed: Cannot allocate memory error, you may need to update the Linux kernel on your instance. For more information, refer to your specific operating system documentation.

如果是收到一个:xfsctl faild:cannot 分配内存错误,你或许需要更新linux内核了。

 

 

 

 

 

 

 

 


本文出自 “Victor的奋斗历程” 博客,请务必保留此出处http://victor2016.blog.51cto.com/6768693/1880857

AWS标准扩容(三)