MySQL Disaster-recovery

Source: Internet
Author: User
Tags mysql view

Http://www.admin5.com/article/20140523/546473.shtml



If. MyD file lost or mistakenly deleted, there is no backup, there is no binary log, there is no library, then what?



Case: Disaster Recovery

Recover data without backup, no logs, no standby, and data files are deleted


Recovery ideas


Deleting a file in the system does not really erase the data in the store, but simply indicates that the corresponding block block can be reassigned, so the data is still in the normal way, just not reading

Therefore, if the data can be read in a non-normal way, in a lot of new files saved, then the data is restored back,



MySQL Configuration

In order to simulate data deletion by mistake, and to recover data using EXT3GREP, the following environment is required to prepare

1, create a separate partition.

2. Copy MSYQL data to this partition

3. Mount the new partition to the MySQL data file directory


Reason? Ext3grep cannot operate a mounted partition, so MySQL data should be on a separate partition so that it is easy to mount and unload



To view the file system using Ext3grep:


Ext3grep can help us read the underlying data through the file system.

--ls--inode can view information for a specified file or directory

EXT3GREP/DEV/SDB1--ls--inode 2


Recovering files using Ext3grep

Using the--restore-inode parameter combination, we can restore the specified file

EXT3GREP/DEV/SDB1--restore-inode 12354


Links to the tools used in this article:


1.ext3grep:https://code.google.com/p/ext3grep/

Ext3grep relies on e2fsprogs-devel and e2fsprogs-lib packages, so they need to be installed before they can be compiled Ext3grep

Tar xvf ext3grep-0.10.2.tar.gz-c/home

CD xt3grep-0.10.2

./configure

Make

Mkae install.


If it is a EXT4 file system, use the following tool to use the same method as Ext3

EXTUNDELETE/DEV/SDB1--inde 2

EXTUNDELETE/DEV/SDB1--restore-inode 57146

Extundelete


The simulation cases are as follows:


>drop table T2;

/etc/init.d/mysqld stop

Mount view MySQL data in that partition

Ll-id/usr/local/mysql View the inode for MySQL

2 drwxr-xr-x 3 root root 4096 Jan 16:52 MySQL

Umount//var/lib/mysql

EXT3GREP/DEV/SDB1--ls--inode 2

EXT3GREP/DEV/SDB1--ls--inode 48961 (db1 the inode of a specific library)

Next, restore to an empty directory based on the Inode

Cd/root/test

EXT3GREP/DEV/SDB1--restore-inode 48961

MV test/restore-files/inode.48691 Test/restore-files/t2. MYD

MV test/restore-files/inode.48692 Test/restore-files/t2. MYI

MV test/restore-files/inode.48693 TEST/RESTORE-FILES/T2.FRM

Mount/dev/sdb2/var/lib/mysql

CP t2.*/USR/LOCAL/MYSQL/DATA/DB1

Chow-r Mysql.mysql. * (pwd =/VAR/LIB/MYSQL/DB1)

/etc/mysqld start

Finally, check that the data is complete,


This article is from the "Crazy_sir" blog, make sure to keep this source http://douya.blog.51cto.com/6173221/1604049

MySQL Disaster-recovery

Related Article

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.