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 accidentally deleted data files by rm under linux

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

Share

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

Editor to share with you how to restore accidentally deleted data files by rm under linux, I believe most people do not know much about it, so share this article for your reference. I hope you will gain a lot after reading this article. Let's learn about it together.

Restore data files that were accidentally deleted by rm

one。 Analog data file deletion

[oracle@node1 ~] $sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Sat Dec 31 22:00:52 2011

Copyright (c) 1982, 2011, Oracle. All rights reserved.

-- Database version

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0-64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining

Oracle Database Vault and Real Application Testing options

-- all data files

SQL > select name from v$datafile

NAME

/ opt/oracle/oradata/ora11g/system01.dbf

/ opt/oracle/oradata/ora11g/sysaux01.dbf

/ opt/oracle/oradata/ora11g/undotbs01.dbf

/ opt/oracle/oradata/ora11g/users01.dbf

/ opt/oracle/oradata/ora11g/example01.dbf

-- delete example01.dbf data files

SQL >! rm / opt/oracle/oradata/ora11g/example01.dbf

SQL >! ls-l / opt/oracle/oradata/ora11g/example01.dbf

Ls: / opt/oracle/oradata/ora11g/example01.dbf: there is no such file or directory

Failed to create the table because the data file was deleted

SQL > create table t_xifenfei tablespace example

2 as select * from dba_tables

As select * from dba_tables

*

ERROR at line 2:

ORA-01116: error in opening database file 5

ORA-01110: data file 5:'/ opt/oracle/oradata/ora11g/example01.dbf'

ORA-27041: unable to open file

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

two。 Retrieve the data file

-- find the dbw process spid

[oracle@node1 ~] $ps-ef | grep dbw | grep-v grep

Oracle 18387 1 0 Dec22? 00:00:12 ora_dbw0_ora11g

-- View all file handles to the process

[oracle@node1 ~] $ll / proc/18387/fd

Total 0

Lr-x- 1 oracle oinstall 64 12-31 22:03 0-> / dev/null

Lmurwx-1 oracle oinstall 64 12-31 22:03 1-> / dev/null

Lr-x- 1 oracle oinstall 64 12-31 22:03 10-> / dev/zero

Lr-x- 1 oracle oinstall 64 12-31 22:03 11-> / dev/zero

Lr-x- 1 oracle oinstall 64 12-31 22:03 12-> / opt/oracle/product/11.2.0/db_1/rdbms/mesg/orazhs.msb

Lrwx- 1 oracle oinstall 64 12-31 22:03 13-> / opt/oracle/product/11.2.0/db_1/dbs/hc_ora11g.dat

Lr-x- 1 oracle oinstall 64 12-31 22:03 14-> / proc/18387/fd

Lr-x- 1 oracle oinstall 64 12-31 22:03 15-> / dev/zero

Lr-x- 1 oracle oinstall 64 12-31 22:03 16-> / opt/oracle/product/11.2.0/db_1/rdbms/mesg/oraus.msb

Lrwx- 1 oracle oinstall 64 12-31 22:03 17-> / opt/oracle/product/11.2.0/db_1/dbs/hc_ora11g.dat

Lrwx- 1 oracle oinstall 64 12-31 22:03 18-> / opt/oracle/product/11.2.0/db_1/dbs/lkORA11G

Lr-x- 1 oracle oinstall 64 12-31 22:03 19-> / opt/oracle/product/11.2.0/db_1/rdbms/mesg/orazhs.msb

Lmurwx-1 oracle oinstall 64 12-31 22:03 2-> / dev/null

Lr-x- 1 oracle oinstall 64 12-31 22:03 20-> / opt/oracle/product/11.2.0/db_1/rdbms/mesg/oraus.msb

Lrwx- 1 oracle oinstall 64 12-31 22:03 21-> socket: [441562]

Lrwx- 1 oracle oinstall 64 12-31 22:03 256-> / opt/oracle/oradata/ora11g/control01.ctl

Lrwx- 1 oracle oinstall 64 12-31 22:03 257-> / opt/oracle/oradata/ora11g/system01.dbf

Lrwx- 1 oracle oinstall 64 12-31 22:03 258-> / opt/oracle/oradata/ora11g/sysaux01.dbf

Lrwx- 1 oracle oinstall 64 12-31 22:03 259-> / opt/oracle/oradata/ora11g/undotbs01.dbf

Lrwx- 1 oracle oinstall 64 12-31 22:03 260-> / opt/oracle/oradata/ora11g/users01.dbf

Lrwx- 1 oracle oinstall 64 12-31 22:03 261-> / opt/oracle/oradata/ora11g/example01.dbf (deleted)

Lrwx- 1 oracle oinstall 64 12-31 22:03 262-> / opt/oracle/oradata/ora11g/temp01.dbf

Lr-x- 1 oracle oinstall 64 12-31 22:03 3-> / dev/null

Lr-x- 1 oracle oinstall 64 12-31 22:03 4-> / dev/null

Lrwx- 1 oracle oinstall 64 12-31 22:03 5-> / opt/oracle/product/11.2.0/db_1/dbs/hc_ora11g.dat

Lr-x- 1 oracle oinstall 64 12-31 22:03 6-> / dev/null

Lr-x- 1 oracle oinstall 64 12-31 22:03 7-> / dev/null

Lr-x- 1 oracle oinstall 64 12-31 22:03 8-> / dev/null

Lr-x- 1 oracle oinstall 64 12-31 22:03 9-> / dev/null

-- restore data files through handles [deleted data files will be marked (deleted)]

[oracle@node1 ~] $cp / proc/18387/fd/261 / opt/oracle/oradata/ora11g/example01.dbf

-- confirm that the data file has been restored successfully

[oracle@node1 ~] $ll / opt/oracle/oradata/ora11g/example01.dbf

-rw-r- 1 oracle oinstall 362422272 12-31 22:05 / opt/oracle/oradata/ora11g/example01.dbf

three。 Data file online

SQL > alter database datafile 5 offline

Database altered.

SQL > recover datafile 5

Media recovery complete.

SQL > alter database datafile 5 online

Database altered.

SQL > create table t_xifenfei tablespace example

2 as select * from dba_tables

Table created.

four。 Supplementary explanation

When you accidentally delete a data file using the os command, do not restart the database or operating system hurriedly. You can retrieve the data file through the handle related to the dbwn process.

The above is all the contents of the article "how to restore data files accidentally deleted by rm under linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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