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 recover the Database Files deleted by rm by linux

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 rm deleted database files by linux". In daily operation, I believe that many people have doubts about how to restore rm deleted database files by linux. 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 about "how to restore rm deleted database files by linux". Next, please follow the editor to study!

1. First test rm for mistakenly deleting database files

[oracle@primary dbwdn] $ll

Total 2153164

-rw-r- 1 oracle dba 8536064 Nov 27 21:50 control01.ctl

-rw-r- 1 oracle dba 8536064 Nov 27 21:50 control02.ctl

-rw-r- 1 oracle dba 8536064 Nov 27 21:50 control03.ctl

-rw-r- 1 oracle dba 104865792 Nov 27 21:32 ggs01.dbf

-rw-r- 1 oracle dba 525344768 Nov 27 21:32 perfstat.dbf

-rw-r- 1 oracle dba 52429312 Nov 27 21:10 redo01.log

-rw-r- 1 oracle dba 52429312 Nov 27 21:49 redo02.log

-rw-r- 1 oracle dba 52429312 Nov 27 21:10 redo03.log

-rw-r- 1 oracle dba 10493952 Nov 27 21:32 shkz_data_01.dbf

-rw-r- 1 oracle dba 524296192 Nov 27 21:49 sysaux01.dbf

-rw-r- 1 oracle dba 524296192 Nov 27 21:49 system01.dbf

-rw-r- 1 oracle dba 209723392 Nov 18 10:54 temp01.dbf

-rw-r- 1 oracle dba 52436992 Nov 27 21:32 test01.dbf

-rw-r- 1 oracle dba 251666432 Nov 27 21:49 undotbs01.dbf

-rw-r- 1 oracle dba 26222592 Nov 27 21:32 users01.dbf

[oracle@primary dbwdn] $rm test01.dbf

two。 Find the database background process dbw0

Oracle 3493 10 21:10? 00:00:00 ora_dbw0_dbwdn

Process number 3493

3. Find the database file that was deleted by mistake

[oracle@primary dbwdn] $ll / proc/3493/fd

Total 0

Lr-x- 1 oracle oinstall 64 Nov 27 21:52 0-> / dev/null

Lr-x- 1 oracle oinstall 64 Nov 27 21:52 1-> / dev/null

Lr-x- 1 oracle oinstall 64 Nov 27 21:52 10-> / dev/zero

Lr-x- 1 oracle oinstall 64 Nov 27 21:52 11-> / dev/zero

Lr-x- 1 oracle oinstall 64 Nov 27 21:52 12-> / u01/app/oracle/product/10.2.0/db_1/rdbms/mesg/oraus.msb

Lrwx- 1 oracle oinstall 64 Nov 27 21:52 13-> / u01/app/oracle/product/10.2.0/db_1/dbs/hc_dbwdn.dat

Lrwx- 1 oracle oinstall 64 Nov 27 21:52 14-> / u01/app/oracle/product/10.2.0/db_1/dbs/lkDBWDN

Lrwx- 1 oracle oinstall 64 Nov 27 21:52 15-> / u01/app/oracle/oradata/dbwdn/control01.ctl

Lrwx- 1 oracle oinstall 64 Nov 27 21:52 16-> / u01/app/oracle/oradata/dbwdn/control02.ctl

Lrwx- 1 oracle oinstall 64 Nov 27 21:52 17-> / u01/app/oracle/oradata/dbwdn/control03.ctl

Lrwx- 1 oracle oinstall 64 Nov 27 21:52 18-> / u01/app/oracle/oradata/dbwdn/system01.dbf

Lrwx- 1 oracle oinstall 64 Nov 27 21:52 19-> / u01/app/oracle/oradata/dbwdn/undotbs01.dbf

Lr-x- 1 oracle oinstall 64 Nov 27 21:52 2-> / dev/null

Lrwx- 1 oracle oinstall 64 Nov 27 21:52 20-> / u01/app/oracle/oradata/dbwdn/sysaux01.dbf

Lrwx- 1 oracle oinstall 64 Nov 27 21:52 21-> / u01/app/oracle/oradata/dbwdn/users01.dbf

Lrwx- 1 oracle oinstall 64 Nov 27 21:52 22-> / u01/app/oracle/oradata/dbwdn/test01.dbf (deleted)

Lrwx- 1 oracle oinstall 64 Nov 27 21:52 23-> / u01/app/oracle/oradata/dbwdn/ggs01.dbf

Lrwx- 1 oracle oinstall 64 Nov 27 21:52 24-> / u01/app/oracle/oradata/dbwdn/perfstat.dbf

Lrwx- 1 oracle oinstall 64 Nov 27 21:52 25-> / u01/app/oracle/oradata/dbwdn/shkz_data_01.dbf

Lrwx- 1 oracle oinstall 64 Nov 27 21:52 26-> / u01/app/oracle/oradata/dbwdn/temp01.dbf

Lr-x- 1 oracle oinstall 64 Nov 27 21:52 27-> / u01/app/oracle/product/10.2.0/db_1/rdbms/mesg/oraus.msb

Lr-x- 1 oracle oinstall 64 Nov 27 21:52 3-> / dev/null

Lr-x- 1 oracle oinstall 64 Nov 27 21:52 4-> / dev/null

Lmurwx-1 oracle oinstall 64 Nov 27 21:52 5-> / u01/app/oracle/admin/dbwdn/udump/dbwdn_ora_3485.trc

Ltel WX-1 oracle oinstall 64 Nov 27 21:52 6-> / u01/app/oracle/admin/dbwdn/bdump/alert_dbwdn.log

Lrwx- 1 oracle oinstall 64 Nov 27 21:52 7-> / u01/app/oracle/product/10.2.0/db_1/dbs/hc_dbwdn.dat

Lmurwx-1 oracle oinstall 64 Nov 27 21:52 8-> / u01/app/oracle/admin/dbwdn/bdump/alert_dbwdn.log

After erroneous deletion, the database is not restarted and the system is useless to restart.

4. Copy database files

[oracle@primary ~] $cp / proc/3493/fd/22 / u01/app/oracle/oradata/dbwdn/test01.dbf

[oracle@primary ~] $cd / u01/app/oracle/oradata/dbwdn

[oracle@primary dbwdn] $ls

Control01.ctl control03.ctl perfstat.dbf redo02.log shkz_data_01.dbf system01.dbf test01.dbf users01.dbf

Control02.ctl ggs01.dbf redo01.log redo03.log sysaux01.dbf temp01.dbf undotbs01.dbf

The database files are back.

5. Restore database files

[oracle@primary dbwdn] $sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.5.0-Production on Tue Nov 27 21:55:15 2012

Copyright (c) 1982, 2010, Oracle. All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0-Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL > alter database datafile 5 offline

Database altered.

SQL > recover datafile 5

Media recovery complete.

SQL > alter database datafile 5 online

Database altered.

SQL > shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL > startup

ORACLE instance started.

Total System Global Area 285212672 bytes

Fixed Size 1273276 bytes

Variable Size 130024004 bytes

Database Buffers 150994944 bytes

Redo Buffers 2920448 bytes

Database mounted.

Database opened.

SQL >

Successfully restore the database

Note: if the database can be recovered after restarting, test it:

[oracle@primary dbwdn] $rm users01.dbf [oracle@primary dbwdn] $ps-ef | grep dbw0

Oracle 3798 1 0 21:56? 00:00:00 ora_dbw0_dbwdn

Oracle 4147 3439 0 22:07 pts/1 00:00:00 grep dbw0

[oracle@primary dbwdn] $ll / proc/3798/fd

Total 0

Lr-x- 1 oracle oinstall 64 Nov 27 22:07 0-> / dev/null

Lr-x- 1 oracle oinstall 64 Nov 27 22:07 1-> / dev/null

Lr-x- 1 oracle oinstall 64 Nov 27 22:07 10-> / dev/zero

Lr-x- 1 oracle oinstall 64 Nov 27 22:07 11-> / dev/zero

Lr-x- 1 oracle oinstall 64 Nov 27 22:07 12-> / u01/app/oracle/product/10.2.0/db_1/rdbms/mesg/oraus.msb

Lrwx- 1 oracle oinstall 64 Nov 27 22:07 13-> / u01/app/oracle/product/10.2.0/db_1/dbs/hc_dbwdn.dat

Lrwx- 1 oracle oinstall 64 Nov 27 22:07 14-> / u01/app/oracle/product/10.2.0/db_1/dbs/lkDBWDN

Lrwx- 1 oracle oinstall 64 Nov 27 22:07 15-> / u01/app/oracle/oradata/dbwdn/control01.ctl

Lrwx- 1 oracle oinstall 64 Nov 27 22:07 16-> / u01/app/oracle/oradata/dbwdn/control02.ctl

Lrwx- 1 oracle oinstall 64 Nov 27 22:07 17-> / u01/app/oracle/oradata/dbwdn/control03.ctl

Lrwx- 1 oracle oinstall 64 Nov 27 22:07 18-> / u01/app/oracle/oradata/dbwdn/system01.dbf

Lrwx- 1 oracle oinstall 64 Nov 27 22:07 19-> / u01/app/oracle/oradata/dbwdn/undotbs01.dbf

Lr-x- 1 oracle oinstall 64 Nov 27 22:07 2-> / dev/null

Lrwx- 1 oracle oinstall 64 Nov 27 22:07 20-> / u01/app/oracle/oradata/dbwdn/sysaux01.dbf

Lrwx- 1 oracle oinstall 64 Nov 27 22:07 21-> / u01/app/oracle/oradata/dbwdn/users01.dbf (deleted) lrwx- 1 oracle oinstall 64 Nov 27 22:07 22-> / u01/app/oracle/oradata/dbwdn/test01.dbf

Lrwx- 1 oracle oinstall 64 Nov 27 22:07 23-> / u01/app/oracle/oradata/dbwdn/ggs01.dbf

Lrwx- 1 oracle oinstall 64 Nov 27 22:07 24-> / u01/app/oracle/oradata/dbwdn/perfstat.dbf

Lrwx- 1 oracle oinstall 64 Nov 27 22:07 25-> / u01/app/oracle/oradata/dbwdn/shkz_data_01.dbf

The database has not been restarted, the data file can still be restored, if I restart the database, can I still see this data file?

[oracle@primary dbwdn] $sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.5.0-Production on Tue Nov 27 22:08:01 2012

Copyright (c) 1982, 2010, Oracle. All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0-Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL > shutdown immediate

ORA-01116: error in opening database file 4

ORA-01110: data file 4:'/ u01 * app *

ORA-27041: unable to open file

Linux Error: 2: No such file or directory

Additional information: 3

SQL > shutdown abort;ORACLE instance shut down.

SQL > exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0-Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@primary dbwdn] $sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.5.0-Production on Tue Nov 27 22:08:19 2012

Copyright (c) 1982, 2010, Oracle. All Rights Reserved.

Connected to an idle instance.

SQL > startup

ORACLE instance started.

Total System Global Area 285212672 bytes

Fixed Size 1273276 bytes

Variable Size 130024004 bytes

Database Buffers 150994944 bytes

Redo Buffers 2920448 bytes

Database mounted.

ORA-01157: cannot identify/lock data file 4-see DBWR trace file

ORA-01110: data file 4:'/ u01 * app *

SQL > exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0-Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@primary dbwdn] $ll / proc/3798/fd

Ls: / proc/3798/fd: No such file or directory

[oracle@primary dbwdn] $ps-ef | grep dbw0

Oracle 4160 1 0 22:08? 00:00:00 ora_dbw0_dbwdn

Oracle 4193 3439 0 22:09 pts/1 00:00:00 grep dbw0

[oracle@primary dbwdn] $ll / proc/4160/fd

Total 0

Lr-x- 1 oracle oinstall 64 Nov 27 22:09 0-> / dev/null

Lr-x- 1 oracle oinstall 64 Nov 27 22:09 1-> / dev/null

Lr-x- 1 oracle oinstall 64 Nov 27 22:09 10-> / dev/zero

Lr-x- 1 oracle oinstall 64 Nov 27 22:09 11-> / dev/zero

Lr-x- 1 oracle oinstall 64 Nov 27 22:09 12-> / u01/app/oracle/product/10.2.0/db_1/rdbms/mesg/oraus.msb

Lrwx- 1 oracle oinstall 64 Nov 27 22:09 13-> / u01/app/oracle/product/10.2.0/db_1/dbs/hc_dbwdn.dat

Lrwx- 1 oracle oinstall 64 Nov 27 22:09 14-> / u01/app/oracle/product/10.2.0/db_1/dbs/lkDBWDN

Lrwx- 1 oracle oinstall 64 Nov 27 22:09 15-> / u01/app/oracle/oradata/dbwdn/control01.ctl

Lrwx- 1 oracle oinstall 64 Nov 27 22:09 16-> / u01/app/oracle/oradata/dbwdn/control02.ctl

Lrwx- 1 oracle oinstall 64 Nov 27 22:09 17-> / u01/app/oracle/oradata/dbwdn/control03.ctl

Lmurwx-1 oracle oinstall 64 Nov 27 22:09 2-> / u01/app/oracle/admin/dbwdn/bdump/dbwdn_dbw0_4160.trc

Lr-x- 1 oracle oinstall 64 Nov 27 22:09 3-> / dev/null

Lr-x- 1 oracle oinstall 64 Nov 27 22:09 4-> / dev/null

Lmurwx-1 oracle oinstall 64 Nov 27 22:09 5-> / u01/app/oracle/admin/dbwdn/udump/dbwdn_ora_4152.trc

Ltel WX-1 oracle oinstall 64 Nov 27 22:09 6-> / u01/app/oracle/admin/dbwdn/bdump/alert_dbwdn.log

Lrwx- 1 oracle oinstall 64 Nov 27 22:09 7-> / u01/app/oracle/product/10.2.0/db_1/dbs/hc_dbwdn.dat

Lmurwx-1 oracle oinstall 64 Nov 27 22:09 8-> / u01/app/oracle/admin/dbwdn/bdump/alert_dbwdn.log

Lrwx- 1 oracle oinstall 64 Nov 27 22:09 9-> / u01/app/oracle/product/10.2.0/db_1/dbs/lkinstdbwdn (deleted)

[oracle@primary dbwdn] $

There's no way to recover.

Note that it should be noted that after rm mistakenly deletes files, do not panic, stabilize your mind, do not restart the database, do not restart the system.

AIX system, I haven't tested it.

Use the backup set to restore the above database files:

[oracle@primary dbwdn] $rman target /

Recovery Manager: Release 10.2.0.5.0-Production on Tue Nov 27 22:13:45 2012

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

Connected to target database (not started)

RMAN > startup nomount

Oracle instance started

Total System Global Area 285212672 bytes

Fixed Size 1273276 bytes

Variable Size 130024004 bytes

Database Buffers 150994944 bytes

Redo Buffers 2920448 bytes

RMAN > alter database mount

Using target database control file instead of recovery catalog

Database mounted

RMAN > run

2 > {

3 > allocate channel T1 type to disk

RMAN-00571: =

RMAN-00569: = ERROR MESSAGE STACK FOLLOWS =

RMAN-00571: =

RMAN-00558: error encountered while parsing input commands

RMAN-01009: syntax error: found "to": expecting one of: "double-quoted-string, disk, equal, identifier, single-quoted-string"

RMAN-01007: at line 3 column 26 file: standard input

RMAN > run

2 > {

3 > allocate channel T1 device type disk

4 > restore datafile 4

5 > recover datafile 4

6 > release channel T1

7 >}

Allocated channel: t1

Channel t1: sid=156 devtype=DISK

Starting restore at 27-NOV-2012 22:16:26

Channel t1: starting datafile backupset restore

Channel T1: specifying datafile (s) to restore from backup set

Restoring datafile 00004 to / u01/app/oracle/oradata/dbwdn/users01.dbf

Channel t1: reading from backup piece / u01/bak/03nrctnp_1_1.bak

Channel t1: restored backup piece 1

Piece handle=/u01/bak/03nrctnp_1_1.bak tag=TAG20121127T213241

Channel t1: restore complete, elapsed time: 00:00:04

Finished restore at 27-NOV-2012 22:16:30

Starting recover at 27-NOV-2012 22:16:30

Starting media recovery

Media recovery complete, elapsed time: 00:00:01

Finished recover at 27-NOV-2012 22:16:31

Released channel: t1

RMAN > alter database open

Database opened

RMAN >

Data recovery under Windows (recovery method after emptying the Recycle Bin):

Steps:

1. Click start-run, and then enter regedit (Open Registry)

2. Expand in turn: HEKEY--LOCAL--MACHIME/SOFTWARE/microsoft/WINDOWS/ CURRENTVERSION/EXPLORER/DESKTOP/NAMESPACE, click "New" outside the left margin.

Select "primary key" and name it "645FFO40--5081--101B--9F08--00AA002F954E"

Then set the key value of the default primary key on the right to Recycle Bin, and then exit the registry. Just OK.

Restart the computer.

As long as the machine has not run disk consolidation. The system is intact. The files can be recovered at any time.

At this point, the study on "how to restore the database files mistakenly deleted by rm by linux" 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