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

How does Linux recover the data files deleted by the rm-rf command

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how Linux restores the data files deleted by the rm-rf command, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.

As long as the handle to the deleted file in the LINUX system is not closed, the corresponding copy of the file can be found in / proc//fd. Where refers to the process id that opened the file. Using this method, combined with the OS command, DM7 provides a recovery scheme for invalid files, which is demonstrated by an example below:

1. Create a tablespace cs and create two data files for it

SQL > create tablespace cs datafile'/ dm_home/dmdba/dmdbms/data/jydm/cs1.dbf' size 128 dmdba / dm_home/dmdba/dmdbms/data/jydm/cs1.dbf' size 128

Executed successfully

Used time: 00:00:21.941. Execute id is 90.

two。 Find out the Dameng server process ID

[root@cs1 jydm] # ps-ef | grep dmserver

Dmdba 2467 October 15-00:05:53 / dm_home/dmdba/dmdbms/bin/dmserver / dm_home/dmdba/dmdbms/data/jydm/dm.ini-noconsole

Root 18893 18058 0 21:45 pts/1 00:00:00 grep-color=auto dmserver

3. Displays a list of files opened by the Damon server process

[root@cs1 jydm] # ls / proc/2467/fd-l

Total dosage 0

Lr-x- 1 dmdba dinstall 64 October 15 12:23 0-> / dev/null

Lmurwx-1 dmdba dinstall 64 October 15 12:23 1-> / dm_home/dmdba/dmdbms/log/DmServicejydm.log

Lrwx- 1 dmdba dinstall 64 October 15 12:23 10-> / dm_home/dmdba/dmdbms/data/jydm/ROLL.DBF

Lrwx- 1 dmdba dinstall 64 October 15 12:23 11-> / dm_home/dmdba/dmdbms/data/jydm/MAIN.DBF

Lrwx- 1 dmdba dinstall 64 October 15 12:23 12-> / dm_home/dmdba/dmdbms/data/jydm/BOOKSHOP.DBF

Lrwx- 1 dmdba dinstall 64 October 15 12:23 13-> / dm_home/dmdba/dmdbms/data/jydm/DMHR.DBF

Lr-x- 1 dmdba dinstall 64 October 15 12:23 14-> pipe: [21853]

Lmurwx-1 dmdba dinstall 64 October 15 12:23 15-> pipe: [21853]

Lr-x- 1 dmdba dinstall 64 October 15 12:23 16-> pipe: [21854]

Lmurwx-1 dmdba dinstall 64 October 15 12:23 17-> pipe: [21854]

Lr-x- 1 dmdba dinstall 64 October 15 12:23 18-> pipe: [21855]

Lmurwx-1 dmdba dinstall 64 October 15 12:23 19-> pipe: [21855]

Lmurwx-1 dmdba dinstall 64 October 15 12:23 2-> / dm_home/dmdba/dmdbms/log/DmServicejydm.log

Lr-x- 1 dmdba dinstall 64 October 15 12:23 20-> pipe: [21856]

Lmurwx-1 dmdba dinstall 64 October 15 12:23 21-> pipe: [21856]

Lrwx- 1 dmdba dinstall 64 October 25 21:12 22-> socket: [297043807]

Lrwx- 1 dmdba dinstall 64 October 25 21:12 23-> / dm_home/dmdba/dmdbms/data/jydm/cs1.dbf

Lrwx- 1 dmdba dinstall 64 October 25 21:42 24-> / dm_home/dmdba/dmdbms/data/jydm/cs.dbf

Lrwx- 1 dmdba dinstall 64 October 15 12:23 3-> socket: [20041]

Lrwx- 1 dmdba dinstall 64 October 15 12:23 4-> socket: [20042]

Lrwx- 1 dmdba dinstall 64 October 15 12:23 5-> / dm_home/dmdba/dmdbms/data/jydm/SYSTEM.DBF

Lrwx- 1 dmdba dinstall 64 October 15 12:23 6-> / dm_home/dmdba/dmdbms/data/jydm/dminst.sys

Lrwx- 1 dmdba dinstall 64 October 15 12:23 7-> / dm_home/dmdba/dmdbms/data/jydm/TEMP.DBF

Lrwx- 1 dmdba dinstall 64 October 15 12:23 8-> / dm_home/dmdba/dmdbms/data/jydm/jydm01.log

Lrwx- 1 dmdba dinstall 64 October 15 12:23 9-> / dm_home/dmdba/dmdbms/data/jydm/jydm02.log

4. Delete a data file in the tablespace cs

[root@cs1 jydm] # rm-rf cs.dbf

5. The tablespace failure file is checked manually by calling the system procedure SP_FILE_SYS_CHECK ().

SQL > call SP_FILE_SYS_CHECK ()

DMSQL executed successfully

Used time: 0.690 (ms). Execute id is 93.

6. Create a test table cs in the tablespace cs, the command execution error shows that the cs.dbf file in the tablespace cs has been deleted.

SQL > create table cs (cs_id number) tablespace cs

Create table cs (cs_id number) tablespace cs

[- 3430]: tablespace [CS] file [/ dm_home/dmdba/dmdbms/data/jydm/cs.dbf] has been deleted.

Used time: 31.462 (ms). Execute id is 0.

7. Call the system procedure SP_TABLESPACE_PREPARE_RECOVER (tablespace_name) to prepare for recovery

SQL > call SP_TABLESPACE_PREPARE_RECOVER ('CS')

DMSQL executed successfully

Used time: 16.121 (ms). Execute id is 95.

8. By displaying a list of files opened by the Damon server process, you can see that the cs.dbf file is marked deleted.

[root@cs1 jydm] # ls / proc/2467/fd-l

Total dosage 0

Lr-x- 1 dmdba dinstall 64 October 15 12:23 0-> / dev/null

Lmurwx-1 dmdba dinstall 64 October 15 12:23 1-> / dm_home/dmdba/dmdbms/log/DmServicejydm.log

Lrwx- 1 dmdba dinstall 64 October 15 12:23 10-> / dm_home/dmdba/dmdbms/data/jydm/ROLL.DBF

Lrwx- 1 dmdba dinstall 64 October 15 12:23 11-> / dm_home/dmdba/dmdbms/data/jydm/MAIN.DBF

Lrwx- 1 dmdba dinstall 64 October 15 12:23 12-> / dm_home/dmdba/dmdbms/data/jydm/BOOKSHOP.DBF

Lrwx- 1 dmdba dinstall 64 October 15 12:23 13-> / dm_home/dmdba/dmdbms/data/jydm/DMHR.DBF

Lr-x- 1 dmdba dinstall 64 October 15 12:23 14-> pipe: [21853]

Lmurwx-1 dmdba dinstall 64 October 15 12:23 15-> pipe: [21853]

Lr-x- 1 dmdba dinstall 64 October 15 12:23 16-> pipe: [21854]

Lmurwx-1 dmdba dinstall 64 October 15 12:23 17-> pipe: [21854]

Lr-x- 1 dmdba dinstall 64 October 15 12:23 18-> pipe: [21855]

Lmurwx-1 dmdba dinstall 64 October 15 12:23 19-> pipe: [21855]

Lmurwx-1 dmdba dinstall 64 October 15 12:23 2-> / dm_home/dmdba/dmdbms/log/DmServicejydm.log

Lr-x- 1 dmdba dinstall 64 October 15 12:23 20-> pipe: [21856]

Lmurwx-1 dmdba dinstall 64 October 15 12:23 21-> pipe: [21856]

Lrwx- 1 dmdba dinstall 64 October 25 21:12 22-> socket: [297043807]

Lrwx- 1 dmdba dinstall 64 October 25 21:12 23-> / dm_home/dmdba/dmdbms/data/jydm/cs1.dbf

Lrwx- 1 dmdba dinstall 64 October 25 21:42 24-> / dm_home/dmdba/dmdbms/data/jydm/cs.dbf (deleted)

Lrwx- 1 dmdba dinstall 64 October 15 12:23 3-> socket: [20041]

Lrwx- 1 dmdba dinstall 64 October 15 12:23 4-> socket: [20042]

Lrwx- 1 dmdba dinstall 64 October 15 12:23 5-> / dm_home/dmdba/dmdbms/data/jydm/SYSTEM.DBF

Lrwx- 1 dmdba dinstall 64 October 15 12:23 6-> / dm_home/dmdba/dmdbms/data/jydm/dminst.sys

Lrwx- 1 dmdba dinstall 64 October 15 12:23 7-> / dm_home/dmdba/dmdbms/data/jydm/TEMP.DBF

Lrwx- 1 dmdba dinstall 64 October 15 12:23 8-> / dm_home/dmdba/dmdbms/data/jydm/jydm01.log

Lrwx- 1 dmdba dinstall 64 October 15 12:23 9-> / dm_home/dmdba/dmdbms/data/jydm/jydm02.log

9. Use the operating system's cp command to copy the file (cs.dbf) to its original location

[root@cs1 jydm] # cp / proc/2467/fd/24 / dm_home/dmdba/dmdbms/data/jydm/cs.dbf

[root@cs1 jydm] # ls-lrt

The total dosage is 1365112

Drwxr-xr-x 2 dmdba dinstall 6 July 23 22:12 bak

-rw-r-r-- 1 dmdba dinstall 479 July 23 22:12 sqllog.ini

-rw-r-r-- 1 dmdba dinstall 633 July 23 22:13 dm_service.prikey

Drwxr-xr-x 2 dmdba dinstall 6 July 23 22:14 HMAIN

-rw-r-r-- 1 dmdba dinstall 908 July 2322: 14 dminit20180723221249.log

-rw-r-r-- 1 dmdba dinstall 890 July 23 22:14 dmarch_example.ini

-rw-r-r-- 1 dmdba dinstall 23 July 1966 22:14 dmdcr_cfg_example.ini

-rw-r-r-- 1 dmdba dinstall 631 July 23 22:14 dmdcr_example.ini

-rw-r-r-- 1 dmdba dinstall 2070 July 23 22:14 dmmal_example.ini

-rw-r-r-- 1 dmdba dinstall 1537 July 23 22:14 dminit_example.ini

-rw-r-r-- 1 dmdba dinstall 1277 July 23 22:14 dmmonitor_example.ini

-rw-r-r-- 1 dmdba dinstall 1679 July 23 22:14 dmtimer_example.ini

-rw-r-r-- 1 dmdba dinstall 288 July 23 22:14 dmmpp_example.ini

-rw-r-r-- 1 dmdba dinstall 1241 July 23 22:14 dmwatch_example.ini

-rw-r-r-- 1 dmdba dinstall 2146 July 23 22:14 dmwatcher_example.ini

-rw-r-r-- 1 dmdba dinstall 522 July 23 22:14 dmwmon_example.ini

-rw-r-r-- 1 dmdba dinstall 636 July 23 22:14 sqllog_example.ini

Drwxr-xr-x 2 dmdba dinstall 6 July 23 22:14 trace

-rw-r-r-- 1 dmdba dinstall 12 July 23 22:14 rep_conflict.log

-rw-r-r-- 1 dmdba dinstall 157286400 July 23 22:16 BOOKSHOP.DBF

-rw-r-r-- 1 dmdba dinstall 134217728 July 23 22:16 DMHR.DBF

-rw-r-r-- 1 dmdba dinstall 40859 August 20 15:20 dm.ini

-rw-r-r-- 1 dmdba dinstall 10485760 October 15 12:21 TEMP.DBF

-rw-r-r-- 1 dmdba dinstall 268435456 October 15 12:21 jydm02.log

-rw-r-r-- 1 dmdba dinstall 134217728 October 25 21:24 MAIN.DBF

-rw-r-r-- 1 dmdba dinstall 134217728 October 25 21:43 cs1.dbf

-rw-r-r-- 1 dmdba dinstall 7168 October 25 21:43 dm.ctl

Drwxr-xr-x 2 dmdba dinstall 4096 October 25 21:43 ctl_bak

-rw-r-r-- 1 dmdba dinstall 134217728 October 25 21:43 ROLL.DBF

-rw-r-r-- 1 dmdba dinstall 22020096 October 25 21:59 SYSTEM.DBF

-rw-r-r-- 1 dmdba dinstall 268435456 October 25 21:59 jydm01.log

-rw-r-r-- 1 root root 134217728 October 25 21:59 cs.dbf

-rw-r-r-- 1 dmdba dinstall 220 October 25 21:59 dminst.sys

10. After the replication is successful, the system procedure SP_TABLESPACE_RECOVER (ts_name) is called to complete the recovery of the tablespace failure files. Note that to ensure that the data files are repaired correctly, you need to ensure that the data files are copied after the SP_TABLESPACE_PREPARE_RECOVER.

SQL > call SP_TABLESPACE_RECOVER ('CS')

DMSQL executed successfully

Used time: 46.532 (ms). Execute id is 96.

11. Once again, the cs command to create a test table in the tablespace cs was successfully executed.

SQL > create table cs (cs_id number) tablespace cs

Executed successfully

Used time: 36.913 (ms). Execute id is 97.

Thank you for reading this article carefully. I hope the article "Linux how to recover the data files deleted by the rm-rf command" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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