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 to restore the mistakenly deleted files in Linux/Unix

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces "how to restore mistakenly deleted files in Linux/Unix". In daily operation, I believe that many people have doubts about how to restore files mistakenly deleted in Linux/Unix. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to restore files deleted by mistake in Linux/Unix". Next, please follow the editor to study!

To roughly redemonstrate the recovery process under Linux, the recovery steps do not have much to do with the version of the database and will vary from operating system to operating system.

1. When you are in the database open, delete the data files in the users table space directly.

The code is as follows:

SQL > select name from v$datafile

NAME

/ app/oracle/oradata/ORCL/datafile/o1_mf_system_555wqbnk_.dbf

/ app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_555wqxgl_.dbf

/ app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_555wr5p6_.dbf

/ app/oracle/oradata/ORCL/datafile/o1_mf_users_555wrj4o_.dbf

SQL > host rm / app/oracle/oradata/ORCL/datafile/o1_mf_users_555wrj4o_.dbf

two。 Try to create a table in the users tablespace and start reporting an error.

The code is as follows:

SQL > create table t tablespace users as select * from dual

Create table t tablespace users as select * from dual

*

ERROR at line 1:

ORA-01116: error in opening database file 4

ORA-01110: data file 4:

'/ app/oracle/oradata/ORCL/datafile/o1_mf_users_555wrj4o_.dbf'

ORA-27041: unable to open file

Linux Error: 2: No such file or directory

Additional information: 3

Similar information can also be seen in the alarm log.

The code is as follows:

Mon Dec 19 21:48:17 CST 2011

Errors in file / app/oracle/admin/orcl/bdump/orcl_m000_3897.trc:

ORA-01116: error in opening database file 4

ORA-01110: datafile 4:'/ app/oracle/oradata/ORCL/datafile/o1_mf_users_555wrj4o_.dbf'

ORA-27041: unable to open file

Linux Error: 2: No such file or directory

Additional information: 3

3. Check the process PID of dbwr

The code is as follows:

$ps-ef | grep dbw0 | grep-v grep

Oracle 2879 1 0 21:38? 00:00:00 ora_dbw0_orcl

4. Dbwr opens the handle to all data files. It can be found in the proc directory that the directory name is the process PID,fd represents the file descriptor.

The code is as follows:

$cd / proc/2879/fd

$ls-l

Total 0

Lr-x- 1 oracle dba 64 Dec 19 21:50 0-> / dev/null

Lr-x- 1 oracle dba 64 Dec 19 21:50 1-> / dev/null

Lr-x- 1 oracle dba 64 Dec 19 21:50 10-> / dev/zero

Lr-x- 1 oracle dba 64 Dec 19 21:50 11-> / dev/zero

Lr-x- 1 oracle dba 64 Dec 19 21:50 12-> / app/oracle/product/10.2.0/db_1/rdbms/mesg/oraus.msb

Lrwx- 1 oracle dba 64 Dec 19 21:50 13-> / app/oracle/product/10.2.0/db_1/dbs/hc_orcl.dat

Lrwx- 1 oracle dba 64 Dec 19 21:50 14-> / app/oracle/product/10.2.0/db_1/dbs/lkORCL

Lrwx- 1 oracle dba 64 Dec 19 21:50 15-> / app/oracle/oradata/ORCL/controlfile/o1_mf_555wq3ng_.ctl

Lrwx- 1 oracle dba 64 Dec 19 21:50 16-> / app/oracle/oradata/ORCL/datafile/o1_mf_system_555wqbnk_.dbf

Lrwx- 1 oracle dba 64 Dec 19 21:50 17-> / app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_555wqxgl_.dbf

Lrwx- 1 oracle dba 64 Dec 19 21:50 18-> / app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_555wr5p6_.dbf

Lrwx- 1 oracle dba 64 Dec 19 21:50 19-> / app/oracle/oradata/ORCL/datafile/o1_mf_users_555wrj4o_.dbf (deleted)

Lr-x- 1 oracle dba 64 Dec 19 21:50 2-> / dev/null

Lrwx- 1 oracle dba 64 Dec 19 21:50 20-> / app/oracle/oradata/ORCL/datafile/o1_mf_temp_555wrbnz_.tmp

Lr-x- 1 oracle dba 64 Dec 19 21:50 21-> / app/oracle/product/10.2.0/db_1/rdbms/mesg/oraus.msb

Lr-x- 1 oracle dba 64 Dec 19 21:50 3-> / dev/null

Lr-x- 1 oracle dba 64 Dec 19 21:50 4-> / dev/null

Lmurwx-1 oracle dba 64 Dec 19 21:50 5-> / app/oracle/admin/orcl/udump/orcl_ora_2871.trc

Lmurwx-1 oracle dba 64 Dec 19 21:50 6-> / app/oracle/admin/orcl/bdump/alert_orcl.log

Lrwx- 1 oracle dba 64 Dec 19 21:50 7-> / app/oracle/product/10.2.0/db_1/dbs/lkinstorcl (deleted)

Lmurwx-1 oracle dba 64 Dec 19 21:50 8-> / app/oracle/admin/orcl/bdump/alert_orcl.log

Lrwx- 1 oracle dba 64 Dec 19 21:50 9-> / app/oracle/product/10.2.0/db_1/dbs/hc_orcl.dat

Note that the word "/ app/oracle/oradata/ORCL/datafile/o1_mf_users_555wrj4o_.dbf (deleted)" indicates that the file has been deleted. If it is a Solaris operating system, the ls command will not be displayed so clearly. In order to confirm which handle corresponds to which file in the Solaris system, you need to use the lsof program.

5. Directly cp the handle file name back to its original location.

The code is as follows:

Cp 19 / app/oracle/oradata/ORCL/datafile/o1_mf_users_555wrj4o_.dbf

6. Do the data file recover

The code is as follows:

SQL > alter database datafile 4 offline

Database altered.

SQL > recover datafile 4

Media recovery complete.

SQL > alter database datafile 4 online

Database altered.

Complete the data file recovery.

The principle of recovery is that in the Linux operating system, if a file is rm from the operating system level, the process that opened the file before still holds the corresponding file handle, the file it points to can still read and write, and the file descriptor of the file can be obtained from the / proc directory. However, it should be noted that if you close the database at this time, this handle will disappear, so there is no other way but to scan the disk for file recovery, so when there is a problem with the database, if you are not sure of the complexity of the situation, do not shut down the database casually. Restarting a database is often pointless or even fatal.

Of course, the customer's operating system is Solaris, and the files deleted by the customer also include current online redo log, so there are other more complex operations that are not described here.

At this point, the study on "how to restore mistakenly deleted files in Linux/Unix" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Servers

Wechat

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

12
Report