Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Sql server database error data recovery-database data recovery

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Server hardware equipment list

two。 Fault description

The server that needs data recovery is an R520 storage. A total of seven SAS hard drives form raid1 and raid5 disk arrays respectively. The main sql server database is stored in disk C. in the process of use, customers find that disk C is about to fill up, so they point the database path to disk D and generate an .ndf file on disk D.

After the customer continued to use it for about 10 days, the database failed, the connection failed, and the query could not be attached normally.

3. Backup data

Considering the security and reducibility of the data, it is necessary to back up all the source data before data recovery, in case the data cannot be recovered again for other reasons. Use the dd command or the winhex tool to mirror all disks into files.

4. Malfunction analysis

A) analyze the cause of the failure

Due to the insufficient capacity of the disk where the database files are located, the database can not continue to operate normally, resulting in logic errors.

(B) Analysis of RAID group structure

There are 7 300G hard drives on the client server, of which 2 do RAID 1 to install the operating system, and the other 5 do RAID 5 to store data.

Analyze the related structure of RAID 1 and RAID 5, reassemble the virtual RAID 1 and RAID 5, and view the data.

(C) Analysis of the original database files

Because the customer has made many database recovery attempts after the database failure, and each attempt is carried out in the source environment, the original database file is overwritten by changes and the disk space is overwritten many times. Cannot be repaired with the database file after the attempt to recover.

Ask the customer to know that when there is a database failure, the customer has backed up a point of the original fault database file.

5. Database repair

Copy the database file previously backed up by the customer from the virtual RAID 5 space and try to attach it to the database. The attachment fails. The error prompt is as follows:

Figure 1:

The error indicates that the primary database file and the secondary database file do not match. Look at the bottom of the .ndf file and find that there is almost no data in the .ndf file. Try to cancel the association between the .MDF file and the .ndf file and attach only the .MDF file.

After trying, it was found that an error also occurred when only .MDF files were attached, but the error prompt changed.

Figure 2:

The error indicates that the log file (.ldf) and the database file (.mdf) do not match.

After that, there is no database attachment to the database, and the attachment is successful. However, it is found that the database system table is damaged and cannot be used normally.

Figure 3:

An attempt was made to repair the system table in the database, but it could not be repaired because the system table was too damaged.

Database record extraction

Parsing database records in database files

Write the corresponding program to extract the database records from the database file

Obtain the table structure in the database according to the customer's previous database backup

Restructure the table structure and import the database records extracted side by side into the new table

6. Data verification

The extracted database records are verified by the customer, all the data is fully recovered, and the data recovery is successful.

7. Data recovery conclusion

In the process of using the database, it is necessary to allocate the disk space where the database files are located and clean up the garbage data in time to ensure the normal and safe operation of the database.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report