Use cold backup in a real environment
In the previous article (cold backup for MySQL backup and recovery), we mentioned cold backup. However, there is a problem. The data files we store are stored on the current local disk. If this disk fails, the data we store will not be lost, so that backup data will not suffer a loss, work hard. Therefore, in the real environment, we need to prepare several more disks and then build an LVM on these disks to mount the MySQL data directory to the LVM. In this way, the data is not stored on the current disk, to ensure data security.
II
3. Use Cold Standby simulation in real environment
The first step is to plan the disk in advance. Here we will simulate and add two disks.
Step 2: partition the disk
[Root @ serv01 ~] # Fdisk/dev/sdb
[Root @ serv01 ~] # Fdisk/dev/sdc
[Root @ serv01 ~] # Ll/dev/sd [bc] 1
Brw-rw ----. 1 root disk 8, 17 Sep 10 18:06/dev/sdb1
Brw-rw ----. 1 root disk 8, 33 Sep 10 18:09/dev/sdc1
Step 3: Install lvm2 in yum
[root@serv01 ~]# yum install lvm2 -y
Step 4: create a physical volume
[Root @ serv01 ~] # Pvcreate/dev/sdb1/dev/sdc1
Physical volume "/dev/sdb1" successfully created
Physical volume "/dev/sdc1" successfully created
Step 5: Create a volume group
[root@serv01 ~]# vgcreate data /dev/sdb1 /dev/sdc1 Volume group "data" successfully created
Step 6: Create a logical volume
[root@serv01 ~]# lvcreate -L 2G -n mydata data Logical volume "mydata" created
Step 7 format the disk
[root@serv01 ~]# mkfs.ext4 /dev/data/mydata mke2fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks131072 inodes, 524288 blocks26214 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=53687091216 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912Writing inode tables: done Creating journal (16384 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 28 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.
For more details, please continue to read the highlights on the next page:
Implementation of MySQL backup and recovery
MySQL backup: mylvmbackup introduction and use
Using mysqldump in Linux to back up a MySQL database as an SQL File
Use mysqldump in Linux to regularly back up MySQL Databases
Disk management-LVM