Aliyun Linux to move Web content from system disk to data disk method

Source: Internet
Author: User
Tags disk usage aliyun
At the beginning of a look, thought difficult, after all, did not operate, and then walked a lie, feeling that it is the case.
Aliyun The IO performance difference between the system disk and the data disk
The tribe searched the Internet for a aliyun of the IO performance difference between the system disk and the data disk, as follows:
Aliyun system Disk (20G): Total transferred 901.56Mb (15.026mb/sec) 961.64 requests/sec executed
Aliyun data Disk (100G): Total transferred 550Mb (9.1664mb/sec) 586.65 requests/sec executed
Conclusion: The IO of the system disk is much faster than that of the data disk, and the data of reading and writing is not too big to suggest to put the system disk, if your website data is not large, then it is not recommended to replace it.
mount a data disk under Linux system
If you have previously purchased a system disk and have already mounted it, please disregard this step. The tribe here directly quotes Aliyun's official tutorials:
1. First, we install the Putty tool, and then log on to your server.
You cannot see the data disk until you have partitioned and formatted the data disk, and you can view it using the "fdisk-l" command by using the "df–h" command. The following figure:
If you execute the fdisk-l command, you find no/dev/xvdb indicating that your cloud service has no data disk.
2. Next, we need to partition the purchased data disk
Execute the "fdisk/dev/xvdb" command to partition the data disk;
According to the prompts, enter "n", "P" "1", two times carriage return, "Wq", the partition begins, will soon complete.
3. View the new partition
Using the "fdisk-l" command, you can see that the new partition XVDB1 has been built.
4. Format a new partition
Take ext3 as an example: Use the "MKFS.EXT3/DEV/XVDB1" command to format the new partition, depending on the size of the hard disk.
5. Add partition information
Write new partition information using the "Echo '/dev/xvdb1/mnt ext3 defaults 0 0 ' >>/etc/fstab" (without quotes) command.
Then use the "cat/etc/fstab" command to view that the following information indicates a write success.
Note: ubuntu12.04 does not support barrier, so the correct wording is: Echo '/dev/xvdb1/mnt ext3 barrier=0 0 0 ' >>/etc/fstab
If you need to mount the data disk to a separate folder, such as a separate Web page, you can modify the/mnt section of the above command.
Here the tribe needs to add, Aliyun official did not say, we only know we add the data disk, is loaded into the mnt this file.
6. Mount a new partition
Use the "mount-a" command to mount a new partition, and then use the "df-h" command to view it, with the following information stating that the mount is successful and you can start using the new partition.
The above tribe said, the default is to mount the data disk to the MNT directory, the Mount custom directory needs to create a directory, first into the root directory. The command is as follows:
CD/
Create a folder Xiedandan, I'm creating a Xiedandan folder that you can rename yourself to know on line. The order is as follows:
mkdir Xiedandan
ECS Linux system disk data transfer operation process
In general, we can first look at the system disk usage, the implementation of DF-H query space usage is close to 100%, the need to transfer data to the newly purchased data disk.
1, buy the data disk, create a good partition, in the system mount the data disk to the/mnt/shujupan directory.
2. Create a snapshot backup of the system disk so that the operation fails rollback.
3, for data security considerations, in order to ensure the smooth transfer, stop the running of the service program. Reference Example:
#/etc/init.d/nginx stop
#/etc/init.d/httpd stop
#/etc/init.d/mysqld stop
#/etc/init.d/php-fpm stop
#/etc/init.d/vsftpd stop
4, assume that the current system disk/mnt/www directory is the need for data transfer directory, through the MV command of the WWW directory to move all files to the data disk (XVDB1).
#mv/mnt/www/*/mnt/shujupan/
5, modify the Fstab file, specify the data disk mount directory, to achieve power-on from start.
#vi/etc/fstab, save the reboot after adding the following content:
/dev/xvdb1/mnt/www EXT4 Defaults 0 0
Note: The EXT4 is the file system type of the data disk, XVDB1 is the partition of the data disk, please adjust according to the actual situation.
6, after the reboot check the system of the program service is normal, test site, database, etc. can be normal connection access.
If there are no exceptions, the data migration succeeds. At this point in the system and program, access to the/MNT/WWW directory has not changed, but at this time the directory is located on the data disk, the implementation of DF-H system disk space usage returned to normal.
To this end, Aliyun ECS Linux to move the site content from the system disk to the data disk operation process completed.
LNMP change default MySQL data to data disk
If your use of the LNMP installation package, then we can also need to modify a few places,
1. Change Web site file directory
If you are using the LNMP installation package, the default virtual host configuration environment in the/usr/local/nginx/conf/vhost/directory, modify:
vi/usr/local/nginx/conf/vhost/domain name. conf
You can open the corresponding virtual host configuration, and then modify the Web site directory. Then execute:
New catalogue of CP-A old catalogue
Chown Www:www-r New Catalogue
2. Change MySQL data storage directory
The following new directory takes/storage/mysql/as an example, and then copies the database from the old directory to the new directory:
Cp-r/usr/local/mysql/var/*/storage/mysql/
3. Assign the new directory to the MySQL user group:
Chown Mysql:mysql-r/storage/mysql/
4. Modify the configuration file again:
Vi/etc/my.cnf
Find MySQL Data original directory/usr/local/mysql/var modified to:
DataDir =/storage/mysql
Innodb_data_home_dir =/storage/mysql
Innodb_log_group_home_dir =/storage/mysql
5. Start MySQL:
/etc/init.d/mysql start
To finish this.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.