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.要做到這一點,你遷移你的資料到一個更大的卷然後擴充卷上的檔案系統來識别新的可用空間。在你驗證新的卷工作正常後,你可以删除老的卷。
In the navigation pane, choose Instances and then locate the instance with the volume that you want to expand. 找到導航窗格,選擇“Instances”然後找到需要擴容的執行個體
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号和可用區域。當你附加一個新的磁盤到此執行個體的過程中你需要指定這些資訊。
Verify that the instance Shutdown Behavior is set to Stop and not Terminate.
Choose the instance.
From the context-menu (right-click) choose Instance Settings, and then choose Change Shutdown Behavior.
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”.
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.
In the navigation pane, choose Volumes, and then locate the volume you want to expand.
From the context-menu (right-click) choose the volume that you want to expand, and then choose Create Snapshot.
Enter information in the Name and Description fields, and then choose Yes, Create.
建立一個卷的snapshot用于擴充。右擊需要做snapshot的磁盤建立snapshot,加入名字和描述。
7. Create a new volume from the snapshot.
In the navigation pane, choose Snapshots.
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.
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.
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
From the context-menu (right-click) choose the old volume, and then choose Detach Volume.
In the Detach Volume dialog box, choose Yes, Detach. It may take several minutes for the volume to detach.
分離老的卷。
找到老的卷,記下裝置名稱,在attachment information你可以找到。當你附加一個新的卷在這個執行個體的時候你需要指定這個資訊。
右擊老的卷,然後選擇detach volume.
選擇yes,detach.
9. Attach the newly expanded volume
In the navigation pane, choose Volumes.
From the context-menu (right-click) choose the new volume, and then choose Attach Volume.
Start typing the name or ID of the instance in the Instance field, and then choose the instance.
附加新的擴充過的卷。
a.右擊,選擇attach volume.
b.輸入執行個體的名字和Id在“instance”這個字段,選擇執行個體。
c.輸入裝置名稱,選擇yes,attach.
10.Restart the instance.
In the navigation pane, choose Instances and then choose the instance you want to restart.
From the context-menu (right-click) choose Instance State, and then choose Start.
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.
注意:
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 ext2, ext3, 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.
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核心了。
本文轉自chenzudao51CTO部落格,原文連結:http://blog.51cto.com/victor2016/1880857 ,如需轉載請自行聯系原作者