In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to retrieve the database file under Linux after being deleted by mistake". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to retrieve the database file under Linux after being deleted by mistake.
How to know and retrieve the database files under the Linux platform after being deleted by mistake
We know that on windows platform, once a file is opened in the program, it cannot be deleted, so there is no case of mistakenly deleting data files, as shown in the following figure:
However, in the LINUX operating system, the files opened by the process can still be deleted, so there is a risk that DM7 data files may be mistakenly deleted. And, by default, if the data file is deleted, the database will not return any error information, which virtually increases the risk of data loss. Therefore, this article focuses on two aspects:
1. After the tablespace file is deleted by mistake, how to make the database feedback in time.
two。 How to recover the data after the tablespace file is deleted by mistake.
1. How to make the database feedback after the tablespace file is deleted by mistake
1.1 first build a test table.
Create table test (id int)
Insert into test values (1)
Delete the data file MAIN.DBF, and then query the test table and find that everything is normal and the database does not report any errors.
1.3.There are two ways to set the relevant settings so that the database can detect that the file has been deleted: call the system procedure SP_FILE_SYS_CHECK () to check manually, and the database will be invalidated after restarting; set the parameter FIL_CHECK_INTERVAL greater than 0 (unit is s), if you make it permanent, you need to add the parameters to the dm.ini file.
Sp_set_para_value (1) FILLICKECKINTERVALLITY, 3
1.4 after the setting is successful, query the test table again, that is, an error is reported: the file [/ opt/dmdbms/data/DAMENG/MAIN.DBF] in the table space [MAIN] has been deleted
After the above settings, if the data file is deleted, we can know in time, let's talk about how to restore the data.
2. How to restore the data after the tablespace file is deleted by mistake
Online recovery:
2.1 online recovery, this method is only applicable to deleted user data files (take MAIN.DBF as an example):
First, call the following system procedure to prepare for the recovery:
Call SP_TABLESPACE_PREPARE_RECOVER ('MAIN')
2.2 execute ps ef | grepdms at the server terminal, and the pid for obtaining database services is 12130
Next, use the ls command to view the copy of the deleted file: ls / proc/12130/fd l, as shown in the following figure. After the MAIN.DBF file, there is a delete, indicating that it has been deleted.
2.4 just copy the above MAIN.DBF file to the original data file path:
Cp / proc/12130/fd/11 / opt/dmdbms/data/DAMENG/MAIN.DBF
2.5 after the replication is successful, execute the following statement to complete the recovery of the tablespace failure file.
Call SP_TABLESPACE_RECOVER ('MAIN')
2.6 query the test table again, it can be executed normally and get the correct data.
Why is online recovery only suitable for recovering deleted user data files? because when ROLL.DBF, TEMP.DBF or SYSTEM.DBF files are deleted, once the database detects that any of them are gone, it will hang up directly, so there is no chance to recover online at all. At this point, you can only use backup files and archive files to restore, and because the database is an abnormal exit, some redo logs have not yet been written into the archive, resulting in incomplete archiving and cannot be restored to the state before the database abnormal exit. Therefore, archive repair is required before a restore (archive repair scans online log files, rewrites REDO logs that have been written to the online log file but have not been written to the archive log file, as detailed in the manual DM7_Backup_And_Recovery.pdf).
Offline recovery:
When restoring with backup, it is also divided into the following two situations according to the type of file being deleted:
If the ROLL.DBF or TEMP.DBF is deleted, the database can be fully restored through the following procedure.
1. Archive repair: repair archivelog database'/ opt/dmdbms/data/DAMENG/dm.ini'
two。 Restore with backup and archiving:
. / dmrestore ini_path=/opt/dmdbms/data/TEST/dm.ini file=/opt/dmdbms/data/TEST/bak/test.bak archive_dir=/opt/dmdbms/data/TEST/arch/
2.1 if the SYSTEM.DBF file is deleted, the database cannot be fully restored.
After the SYSTEM.DBF is deleted, the archive cannot be repaired, so some data is lost.
2.2 after SYSTEM.DBF is deleted, it cannot be restored directly on the original library, and a new library must be initialized.
Thank you for your reading, the above is the content of "how to retrieve the database file under Linux after being deleted by mistake". After the study of this article, I believe you have a deeper understanding of how to retrieve the database file under Linux after being deleted by mistake. The specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.