Recovery Process of rm-rf misoperations

Source: Internet
Author: User

Recovery Process of rm-rf misoperations

Many DBAs must hate rm-rf. Maybe the database will be wiped out one day when they make a mistake, and then there will be no more ...... In case ...... Is it true that there is no medicine to save this unfortunate event? There are still solutions, maybe one day when you encounter it, you can save yourself. The premise of the Restoration Operation is that there is no available rman backup or cold database backup, that is, there is no backup.

1. log on to SQLPLUS and start the database
[Oracle @ ora10g ~] $ Sqlplus/as sysdba
 

SQL * Plus: Release 10.2.0.1.0-Production on Mon Aug 25 12:37:50 2014
 

Copyright (c) 1982,200 5, Oracle. All rights reserved.
 

Connected to an idle instance.
 

SQL> startup
ORACLE instance started.
 

Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 96470608 bytes
Database Buffers 184549376 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
 

-- View instance initialization status
SQL> select status from v $ instance;
 

STATUS
------------
OPEN
 

-- View Instance name
SQL> show parameter name;
 

NAME TYPE VALUE
-----------------------------------------------------------------------------
Db_file_name_convert string
Db_name string ora10g
Db_unique_name string ora10g
Global_names boolean FALSE
Instance_name string ora10g
Lock_name_space string
Log_file_name_convert string
Service_names string ora10g
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-Production
With the Partitioning, OLAP and Data Mining options
 


2. Simulate rm-rf misoperations
 


[Oracle @ ora10g ~] $ Cd/u01/app/oracle/oradata
[Oracle @ ora10g oradata] $ ll
Total 4
Drwxr-x --- 2 oracle oinstall 4096 Aug 25 ora10g
[Oracle @ ora10g oradata] $ pwd
/U01/app/oracle/oradata
[Oracle @ ora10g oradata] $ rm-rf ora10g
[Oracle @ ora10g oradata] $ exit
Logout
 

[Root @ ora10g ~] # Su-oracle
[Oracle @ ora10g ~] $ Sqlplus/as sysdba
 

SQL * Plus: Release 10.2.0.1.0-Production on Mon Aug 25 12:43:58 2014
 

Copyright (c) 1982,200 5, Oracle. All rights reserved.
 

 

Connected:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-Production
With the Partitioning, OLAP and Data Mining options
 

SQL> select count (*) from dba_objects;
Select count (*) from dba_objects
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
The ORA-01116: error in opening database file 1
ORA-01110: data file 1: '/u01/app/oracle/oradata/ora10g/system01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
 

 

SQL> select count (*) from dba_segments;
Select count (*) from dba_segments
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
The ORA-01116: error in opening database file 1
ORA-01110: data file 1: '/u01/app/oracle/oradata/ora10g/system01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
 

Because all data files are deleted, including system01.dbf, which is the container for storing the data dictionary, it is impossible to access the view in the data dictionary again, so an error will be reported here, file not found, fault occurs
 

-- View the alert. log file
[Root @ ora10g ~] # Tailf/u01/app/oracle/admin/ora10g/bdump/alert_ora10g.log
ARCH shutting down
ARC2: Archival stopped
Mon Aug 25 12:45:38 2014
Errors in file/u01/app/oracle/admin/ora10g/bdump/ora10g_j000_3037.trc:
ORA-12012: error on auto execute of job 1
ORA-01116: error in opening database file 2
ORA-01110: data file 2: '/u01/app/oracle/oradata/ora10g/undotbs01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
Mon Aug 25 12:46:43 2014
Errors in file/u01/app/oracle/admin/ora10g/bdump/ora10g_j000_3070.trc:
ORA-12012: error on auto execute of job 1
ORA-01116: error in opening database file 2
ORA-01110: data file 2: '/u01/app/oracle/oradata/ora10g/undotbs01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
 

-- View the dbwr process and determine the directory where the file handle needs to be restored
SQL>! Ps-ef | grep ora_dbw
Oracle 2912 1 0? 00:00:00 ora_dbw0_ora10g
Oracle 3078 3032 0 00:00:00 pts/3/bin/bash-c ps-ef | grep ora_dbw
Oracle 3080 3078 0 00:00:00 pts/3 grep ora_dbw
 

In fact, at this time, all oracle processes are still there. All processes starting with ora _ are oracle background processes:
SQL>! Ps-ef | grep ora _
Oracle 2906 1 0? 00:00:00 ora_pmon_ora10g
Oracle 2908 1 0? 00:00:00 ora_psp0_ora10g
Oracle 2910 1 0? 00:00:00 ora_mman_ora10g
Oracle 2912 1 0? 00:00:00 ora_dbw0_ora10g
Oracle 2914 1 0? 00:00:00 ora_lgwr_ora10g
Oracle 2916 1 0? 00:00:00 ora_ckpt_ora10g
Oracle 2918 1 0? 00:00:01 ora_smon_ora10g
Oracle 2920 1 0? 00:00:00 ora_reco_ora10g
Oracle 2922 1 0? 00:00:00 ora_cjq0_ora10g
Oracle 2924 1 0? 00:00:01 ora_mmon_ora10g
Oracle 2926 1 0? 00:00:00 ora_mmnl_ora10g
Oracle 2928 1 0? 00:00:00 ora_d000_ora10g
Oracle 2930 1 0? 00:00:00 ora_s000_ora10g
Oracle 2934 1 0? 00:00:00 ora_arc0_ora10g
Oracle 2936 1 0? 00:00:00 ora_arcw.ora10g
Oracle 2941 1 0? 00:00:00 ora_qmnc_ora10g
Oracle 2943 1 0? 00:00:00 ora_q000_ora10g
Oracle 2945 1 0? 00:00:00 ora_q0020.ora10g
Oracle 3077 1 0? 00:00:00 ora_j000_ora10g
Oracle 3085 3032 0 00:00:00 pts/3/bin/bash-c ps-ef | grep ora _
Oracle 3087 3085 0 00:00:00 pts/3/bin/bash-c ps-ef | grep ora _
 

We can see that the file handle to be deleted is under/proc/2912/fd.
 

3. Start to restore objects accidentally deleted
 

-- Restore data files and Control Files
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-Production
With the Partitioning, OLAP and Data Mining options
[Oracle @ ora10g ~] $ Cd/proc/2912.
[Oracle @ ora10g 2912] $ ll
Total 0
Dr-xr-x 2 oracle oinstall 0 Aug 25 :51 attr
-R -------- 1 oracle oinstall 0 Aug 25 12:51 auxv
-R -- 1 oracle oinstall 0 Aug 25 cmd48 using line
-Rw-r -- 1 oracle oinstall 0 Aug 25 :51 coredump_filter
-R -- 1 oracle oinstall 0 Aug 25 cpu51 cpuset
Lrwxrwxrwx 1 oracle oinstall 0 Aug 25 :51 cwd->/u01/app/oracle/product/10.2.0/db_1/dbs
-R -------- 1 oracle oinstall 0 Aug 25 :51 environ
Lrwxrwxrwx 1 oracle oinstall 0 Aug 25 12:51 exe->/u01/app/oracle/product/10.2.0/db_1/bin/oracle
Dr-x ------ 2 oracle oinstall 0 Aug 25 :51 fd
-R -------- 1 oracle oinstall 0 Aug 25 12:51 limits
-Rw-r -- 1 oracle oinstall 0 Aug 25 12:51 loginuid
-R -- 1 oracle oinstall 0 Aug 25 12:37 maps
-Rw ------- 1 oracle oinstall 0 Aug 25 :51 mem
-R -- 1 oracle oinstall 0 Aug 25 12:51 mounts
-R -------- 1 oracle oinstall 0 Aug 25 12:51 mountstats
-Rw-r -- 1 oracle oinstall 0 Aug 25 :51 oom_adj
-R -- 1 oracle oinstall 0 Aug 25 :51 oom_score
Lrwxrwxrwx 1 oracle oinstall 0 Aug 25 :51 root->/
-R -- 1 oracle oinstall 0 Aug 25 :51 schedstat
-R -------- 1 oracle oinstall 0 Aug 25 :51 smaps
-R -- 1 oracle oinstall 0 Aug 25 :37 stat
-R -- 1 oracle oinstall 0 Aug 25 12:51 statm
-R -- 1 oracle oinstall 0 Aug 25 12:48 status
Dr-xr-x 3 oracle oinstall 0 Aug 25 12:51 task
-R -- 1 oracle oinstall 0 Aug 25 12:51 wchan
[Oracle @ ora10g 2912] $ cd fd
[Oracle @ ora10g fd] $ ls-ltr
Total 0
Lr-x ------ 1 oracle oinstall 64 Aug 25 0->/dev/null
L-wx ------ 1 oracle oinstall 64 Aug 25 6->/u01/app/oracle/admin/ora10g/bdump/alert_ora10g.log
L-wx ------ 1 oracle oinstall 64 Aug 25 :51 5->/u01/app/oracle/admin/ora10g/udump/ora10g_ora_2904.trc
Lr-x ------ 1 oracle oinstall 64 Aug 25 4->/dev/null
Lr-x ------ 1 oracle oinstall 64 Aug 25 :51 3->/dev/null
Lr-x ------ 1 oracle oinstall 64 Aug 25 :51 2->/dev/null
Lr-x ------ 1 oracle oinstall 64 Aug 25 :51 1->/dev/null
Lrwx ------ 1 oracle oinstall 64 Aug 25 9->/u01/app/oracle/product/10.2.0/db_1/dbs/hc_ora10g.dat
L-wx ------ 1 oracle oinstall 64 Aug 25 12:51 8->/u01/app/oracle/admin/ora10g/bdump/alert_ora10g.log
Lrwx ------ 1 oracle oinstall 64 Aug 25 7->/u01/app/oracle/product/10.2.0/db_1/dbs/lkinstora10g (deleted)
Lrwx ------ 1 oracle oinstall 64 Aug 25->/u01/app/oracle/oradata/ora10g/temp01.dbf (deleted)
Lrwx ------ 1 oracle oinstall 64 Aug 25 22->/u01/app/oracle/oradata/ora10g/example01.dbf (deleted)
Lrwx ------ 1 oracle oinstall 64 Aug 25 21->/u01/app/oracle/oradata/ora10g/users01.dbf (deleted)
Lrwx ------ 1 oracle oinstall 64 Aug 25 :51 20->/u01/app/oracle/oradata/ora10g/sysaux01.dbf (deleted)
Lrwx ------ 1 oracle oinstall 64 Aug 25 :51 19->/u01/app/oracle/oradata/ora10g/undotbs01.dbf (deleted)
Lrwx ------ 1 oracle oinstall 64 Aug 25 18->/u01/app/oracle/oradata/ora10g/system01.dbf (deleted)
Lrwx ------ 1 oracle oinstall 64 Aug 25 17->/u01/app/oracle/oradata/ora10g/control03.ctl (deleted)
Lrwx ------ 1 oracle oinstall 64 Aug 25 16->/u01/app/oracle/oradata/ora10g/control02.ctl (deleted)
Lrwx ------ 1 oracle oinstall 64 Aug 25 15->/u01/app/oracle/oradata/ora10g/control01.ctl (deleted)
Lrwx ------ 1 oracle oinstall 64 Aug 25 :51 14->/u01/app/oracle/product/10.2.0/db_1/dbs/lkORA10G
Lrwx ------ 1 oracle oinstall 64 Aug 25 13->/u01/app/oracle/product/10.2.0/db_1/dbs/hc_ora10g.dat
Lr-x ------ 1 oracle oinstall 64 Aug 25 :51 12->/dev/zero
Lr-x ------ 1 oracle oinstall 64 Aug 25 11->/dev/zero
Lrwx ------ 1 oracle oinstall 64 Aug 25 10->/u01/app/oracle/admin/ora10g/adump/ora_2904.aud
[Oracle @ ora10g fd] $

 

Analysis: it can be seen that the file at the end of the handle 7, 15-23 is marked (deleted). This is caused by the rm-rf operation. If the Oracle database is not restarted after deletion, the process will not stop, so you can restore the deleted files by using the file handle number in the/proc/# oracle process number/fd directory, the method is to use the cp file handle to the original path. Note that if it is not in the fd directory, you must use the absolute path to specify the file handle. If the file is deleted, and shut down the database, so there is no solution.

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.