Focus on cloud service provider activities
Notes on website operation and maintenance

AliCloud ECS has websites to mount data disks and migrate data for WDCP/AMH and other environments

Generally, we purchase VPS hosts with the default hard disk benchmark, but with the increase of website data, we will need to upgrade and add data disk configurations later. For example, the default system disk of AliCloud ECS is 20GB, which basically meets the initial project requirements of most users. We may need to add attached disks in future project operations.

Because considering Alibaba Cloud ECS The user demand of the server is still quite large in China, so Lao Zuo was also real last week purchase A+20GB data disk, so that the authenticity can be ensured during the tutorial exercise. In previous blog posts, I have shared“ AliCloud ECS data disk mounting process "Article, this is for the newly launched server that does not install the website environment and website mount, so it doesn't matter even if we install it incorrectly.

However, today's article is different from the past, because we are not sure whether we need to add a data disk. The project is already in use, and there are not enough data disks. The operation of attaching and adding data disks is quite common among the possible needs, so it is necessary to practice such a tutorial.

Alibaba Cloud official website address: www

First, preparations before mounting

When operating any project, you need to have a plan and preparation. This article implements the Attach data disk We need to make the following preparations.

1. Purchase data disks. We need to add and purchase new data disks, which we can operate in the background and purchase data disks according to the needs of our project.

2. Back up data. We can manually back up the website data and database to other servers or package them and back them up locally to prevent accidents. At the same time, we can also use Alibaba Cloud's own snapshot backup, which can be backed up together with data and environment. If an error occurs, we can restore everything. Even if we are confident, we need to back up data.

3. Pause the website environment. If we use a panel or environment package, we can pause the website environment first after backing up the data, because data differences will occur during data transfer.

Second, view the current data disk

fdisk -l

 View the current data disk

Because Lao Zuo here only demonstrates the process of mounting, I only purchased 20GB of data disks. We can see that there are still 21GB unmounted through the command.

Third, partition data disk

fdisk /dev/xvdb

 Partitioned data disk

Operate n p 1 Enter Enter wq to save and exit.

Fourth, check whether the partition is completed

fdisk -l

 Check whether the partition is completed

When we check whether the partition is complete, we can see the figure above. If there is an additional line of/dev/xvdb1, it will be correct.

Fifth, format partition

mkfs.ext3 /dev/xvdb1

There is a write process to format the partition. Wait a little while.

 format partition

VI. Backup and migration of temporary data

1. Create a temporary directory for migrating data

mkdir /mnt/data

2. Temporary mounting

mount /dev/xvdb1 /mnt/data

3. Migrate data

mv / www /* /mnt/data

We need to migrate data to the mounted directory. Here, if we use the WDCP panel environment or other environments that use the www directory, we should write it like this. If the AMH panel or LNMP environment is the home directory, we need to migrate the files in the home directory. There is a little process in the migration process, and the migration time varies according to the size of the data.

4. Modify Startup Item

echo ' /dev/xvdb1 / www ext3 defaults 1  2' >> /etc/fstab

5. Restore Data

mv /mnt/data /www/

Finally, check for completeness

After restoring the data, we can check whether the website is normal. It is better to restart VPS or start Apache or Nginx to see whether the website is OK.

 AliCloud ECS has websites to mount data disks and migrate data for WDCP/AMH and other environments

We can see that the www directory is the directory where we are located and the directory where the disk is mounted. Because I only bought 20GB here, I can see 20GB. The system disk is also 20GB. Generally, we will buy more. If we have 20GB, we can buy 20GB again. Generally, it is really idle.

To sum up, Lao Zuo has used the existing environment and sites of AliCloud ECS to mount and migrate data, and can also ensure the normal operation of the website. Several problems to be noted are to check the drive letter of the data disk. Don't make mistakes. Everyone is different, but you need to check. The path to mount is determined according to our environment. For example, if we are an amh panel or an lnmp environment, it is the home directory. If we are a WDCP panel, it is the WWW directory. This cannot be mistaken.

Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( zero )
Do not reprint without permission: Lao Zuo's Notes » AliCloud ECS has websites to mount data disks and migrate data for WDCP/AMH and other environments

Scan the code to follow the official account

Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge