希望你顺利
现在我有一个正在运行的EC2实例并且我已经托管了一些网络应用程序,我的实例存储空间是20 GB,所以我问我是否可以为其中一个分配固定存储空间正在运行的应用程序?
提前致谢。
答案 0 :(得分:0)
为实例选择EBS存储时,您有多种选择。
但要更改实例类型,您需要创建快照并从snapshot恢复卷。您还需要考虑更改支持EBS优化的实例类型,这会为EBS通信创建专用网络通道,并且不受实例的网络流量影响。
您还可以在控制台中修改EBS卷
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/console-modify.html
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSPerformance.html
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html
答案 1 :(得分:0)
创建实例时,您可能已分配空间,该空间会自动创建弹性块存储卷并将其附加到EC2实例。
您可以创建其他卷并将它们附加(然后映射)到您的EC2实例。或者,您可以创建快照,并创建具有不同大小的新卷并切换附加的卷。
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html
修改强> 由于同一实例上有多个虚拟主机,因此您可以创建其他卷并将其映射到实例中。然后,您可以将虚拟主机目录设置为新映射的文件夹。但是,这两者的细节都超出了这个问题的范围。
所以TL; DR;是的,这是可能的。
答案 2 :(得分:0)
以下是准确的步骤,假设您使用基于centos的系统。
<强>参考强>:
Making an Amazon EBS Volume Available for Use
What happens when you 'mount over' an existing folder with contents?
# EBS device name
ebs_location=/dev/xvdb
# Lets say you application is in /etc/apps/
mount_folder=/etc/apps
temp_mount_folder="/mnt/temp-mount"
#Configure EBS volume and Create a temp mount point
mkfs -t ext4 $ebs_location
mkdir ${temp_mount_folder}
mount ${ebs_location} ${temp_mount_folder}
#Copy all the files from /etc/apps to the temp location
cp -ax ${mount_folder}/* ${temp_mount_folder}
#Umount the temp location
umount "${ebs_location}"
#rename the /etc/apps/ to /etc/apps.old
mv "${mount_folder}" "${mount_folder}.old"
mkdir "${mount_folder}"
#update fstab file to mount EBS on system startup
echo "UUID=${disk_uuid} ${mount_folder} ext4 defaults,relatime,nofail 0 0" >> /etc/fstab
#mount the EBS volume on /etc/apps
mount ${ebs_location} ${mount_folder}
rm -r ${temp_mount_folder}