Application Scenarios
This section applies to the data migration between different file systems in the same region and the same VPC.
Prerequisites
You already have two NFS protocol file systems and prepare an ECS under the same VPC network as the source file system. The two file systems are used as the source file system and the destination file system respectively. The source file system refers to the source file system containing service data, and the destination file system refers to the new file system to be put into use.
Making Preparations
l Register an account on the official website of eSurfing Cloud and complete the real-name authentication. For specific operations, see Registering an eSurfing Cloud Account.
l Log in to the official website page of eSurfing Cloud and find the Console. For specific operations, see eSurfing Cloud - Console.
l Create a file system and an ECS respectively. For specific operations, see Creating an SFS and Creating an ECS.
l For details about how to mount the file system to the ECS, see Using the ECSs to Mount a File System.
Procedure
Here are the key steps for migrating data between two file systems: Mount the file system > Migrate the existing data > Migrate the incremental data > Migrate the application. The specific operation steps are as follows:
1. Mount the file system to the cloud server.
Mount the file system to the cloud server. For the convenience of distinction, mount the source file system on the /mnt/src/ path and the destination file system on the /mnt/dst/ path.
2. Install the migration tool.
Run the following command to install the migration tools rsync and tmux. The rsync tool is used to copy data and the tmux tool is used to check the progress.
sudo yum install -y rsync tmux
3. Migrate existing data.
Run the following two commands in turn to synchronize existing data from the source file system to the destination file system.
tmux sudo rsync -avP /mnt/src/ /mnt/dst/
You can also use rsync to concurrently copy and migrate data. Run the following command:
threads=<Number of threads>; src=<Source path/>; dest=<Destination path/>; rsync -av -f"+ */" -f"- *" $src $dest && (cd $src && find . -type f | xargs -n1 -P$threads -I% rsync -av % $dest/% )
Note:
The source path in the rsync command must end with a slash (/). Otherwise, the source path does not match the destination path after the data is synchronized.
4. Migrate incremental data.
If applications that run on other cloud servers write data to the source file system during existing data migration, you must migrate the incremental data synchronously after the existing data is migrated.
a) Stop running applications: To avoid continuous writing of new data, you must stop the applications that use the source file system on all cloud server clients before synchronizing incremental data.
Note:
After you stop applications in the client, do not manually delete any data from the source file system. Otherwise, the stop may be lost in the next step.
We recommend that you perform this operation during off-peak hours. Run the fuser-mv <dir> command to find the processes that read and write the NFS file system.
b) Run the rsync command to synchronize the incremental data after the existing data migration begins to the destination file system.
rsync -avP --delete /mnt/src/ /mnt/dst/
5. Check the migration result.
After the migration is complete, run the following command to check whether the data stored in the source file system is consistent with the data stored in the destination file system.
rsync -rvn /mnt/src/ /mnt/dst/
If the data in the two file systems is consistent, the following information should be displayed without any file paths in between.
6. Switch applications to a new file system
If you need to switch the services on the source file system to the destination file system (i.e., the new file system) after the data migration is complete, unmount the source file system on all cloud server clients and then mount the new file system to the cloud server used by your services.
a) Run df-h in the cloud server used by the service and check the local mount path of the source file system mount. For parameter description, see Mounting an NFS File System to ECSs (Linux).
b) Select an appropriate method to stop the service process on the source file system according to the actual service.
c) Run the umount local mount path command to unmount the source file system directory.
d) Mount the new file system to the local mount path based on step 1). For the mount method, see Using the ECS to Mount a File System.
e) Start the service that accesses the file system and confirm that the read and write operations are normal.
Note:
The cloud server in this operation is only used as a transfer station for data migration, not for actual businesses. After the data migration and switching are completed on the new file system, the new file system should be mounted on the cloud server used by the actual service.