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 connection failure, unable to attach query)

2025-01-17 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 7 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 takes into account the security and reducibility of the data, so it is necessary to back up all the source data before data recovery, in case the data cannot be restored again due to other reasons. Use the dd command or the winhex tool to mirror all disks into files.

4. Fault analysis (a) Analysis of the cause of the failure due to insufficient disk capacity of the database files, the database can not continue to operate normally, resulting in logic errors

(B) analyze 7 300G hard drives on the client server of RAID group structure, of which 2 hard drives are used as RAID 1 to install the operating system, and the other 5 hard drives are used as 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 file because the customer made many database recovery attempts after the database failure, and each attempt was made in the source environment, the original database file was overwritten and the disk space was overwritten many times, so that the database file after the attempted recovery could not be repaired.

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 copies the database files previously backed up by the customer from the virtual RAID 5 space and attempts to attach them 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. The data verification is carried out by the customer to verify the extracted database records, all the data is fully restored, and the data recovery is successful.

7. Conclusion in the process of using the database, it is necessary to allocate the disk space of the database files reasonably 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