rm-rf 误操作的恢复过程

很多DBA一定对rm -rf深恶痛绝吧,没准哪天自己一个犯迷糊就把数据库给消灭了,然后,就没有然后了……那万一……真的发生了这样的不幸,是否真的就无药可救了吗?未必,还是有解决方法的,也许某天当你不幸遇到,就可以用来救自己了。这里做恢复操作的前提是没有可用的rman备份,或者数据库冷备份等,也就是说,没有任何备份。

一、登陆SQLPLUS,并启动数据库

[[email protected] ~]$ sqlplus / as sysdba

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

Copyright (c) 1982, 2005, 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.

--查看实例初始化状态

SQL> select status from v$instance;

STATUS

------------

OPEN

--查看实例名

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

二、模拟rm -rf误操作

[[email protected] ~]$ cd  /u01/app/oracle/oradata

[[email protected] oradata]$ ll

total 4

drwxr-x--- 2 oracle oinstall 4096 Aug 25 11:15 ora10g

[[email protected] oradata]$ pwd

/u01/app/oracle/oradata

[[email protected] oradata]$ rm -rf ora10g

[[email protected] oradata]$ exit

logout

[[email protected] ~]# su - oracle

[[email protected] ~]$ sqlplus / as sysdba

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

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

Connected to:

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

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

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

由于数据文件都被删除,其中包括system01.dbf,是存放数据字典的容器,想要再访问数据字典中得视图,当然是不可能的了,所以这里会报错,找不到文件,故障出现

--查看alert.log日志文件

[[email protected] ~]# 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

--查看dbwr进程,判断需要恢复文件句柄所在目录

SQL> !ps -ef|grep ora_dbw

oracle    2912     1  0 12:37 ?        00:00:00 ora_dbw0_ora10g

oracle    3078  3032  0 12:48 pts/3    00:00:00 /bin/bash -c ps -ef|grep ora_dbw

oracle    3080  3078  0 12:48 pts/3    00:00:00 grep ora_dbw

其实这个时候,所有oracle的进程都还在,都是以ora_开头的都是oracle的后台进程:

SQL> !ps -ef|grep ora_

oracle    2906     1  0 12:37 ?        00:00:00 ora_pmon_ora10g

oracle    2908     1  0 12:37 ?        00:00:00 ora_psp0_ora10g

oracle    2910     1  0 12:37 ?        00:00:00 ora_mman_ora10g

oracle    2912     1  0 12:37 ?        00:00:00 ora_dbw0_ora10g

oracle    2914     1  0 12:37 ?        00:00:00 ora_lgwr_ora10g

oracle    2916     1  0 12:37 ?        00:00:00 ora_ckpt_ora10g

oracle    2918     1  0 12:38 ?        00:00:01 ora_smon_ora10g

oracle    2920     1  0 12:38 ?        00:00:00 ora_reco_ora10g

oracle    2922     1  0 12:38 ?        00:00:00 ora_cjq0_ora10g

oracle    2924     1  0 12:38 ?        00:00:01 ora_mmon_ora10g

oracle    2926     1  0 12:38 ?        00:00:00 ora_mmnl_ora10g

oracle    2928     1  0 12:38 ?        00:00:00 ora_d000_ora10g

oracle    2930     1  0 12:38 ?        00:00:00 ora_s000_ora10g

oracle    2934     1  0 12:38 ?        00:00:00 ora_arc0_ora10g

oracle    2936     1  0 12:38 ?        00:00:00 ora_arc1_ora10g

oracle    2941     1  0 12:38 ?        00:00:00 ora_qmnc_ora10g

oracle    2943     1  0 12:38 ?        00:00:00 ora_q000_ora10g

oracle    2945     1  0 12:38 ?        00:00:00 ora_q001_ora10g

oracle    3077     1  0 12:48 ?        00:00:00 ora_j000_ora10g

oracle    3085  3032  0 12:49 pts/3    00:00:00 /bin/bash -c ps -ef|grep ora_

oracle    3087  3085  0 12:49 pts/3    00:00:00 /bin/bash -c ps -ef|grep ora_

由此可知,我们需要的被删除的文件句柄在/proc/2912/fd下

三、开始恢复误删除的文件

--恢复数据文件和控制文件

SQL> exit

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

With the Partitioning, OLAP and Data Mining options

[[email protected] ~]$ cd /proc/2912

[[email protected] 2912]$ ll

total 0

dr-xr-xr-x 2 oracle oinstall 0 Aug 25 12:51 attr

-r-------- 1 oracle oinstall 0 Aug 25 12:51 auxv

-r--r--r-- 1 oracle oinstall 0 Aug 25 12:48 cmdline

-rw-r--r-- 1 oracle oinstall 0 Aug 25 12:51 coredump_filter

-r--r--r-- 1 oracle oinstall 0 Aug 25 12:51 cpuset

lrwxrwxrwx 1 oracle oinstall 0 Aug 25 12:51 cwd -> /u01/app/oracle/product/10.2.0/db_1/dbs

-r-------- 1 oracle oinstall 0 Aug 25 12: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 12:51 fd

-r-------- 1 oracle oinstall 0 Aug 25 12:51 limits

-rw-r--r-- 1 oracle oinstall 0 Aug 25 12:51 loginuid

-r--r--r-- 1 oracle oinstall 0 Aug 25 12:37 maps

-rw------- 1 oracle oinstall 0 Aug 25 12:51 mem

-r--r--r-- 1 oracle oinstall 0 Aug 25 12:51 mounts

-r-------- 1 oracle oinstall 0 Aug 25 12:51 mountstats

-rw-r--r-- 1 oracle oinstall 0 Aug 25 12:51 oom_adj

-r--r--r-- 1 oracle oinstall 0 Aug 25 12:51 oom_score

lrwxrwxrwx 1 oracle oinstall 0 Aug 25 12:51 root -> /

-r--r--r-- 1 oracle oinstall 0 Aug 25 12:51 schedstat

-r-------- 1 oracle oinstall 0 Aug 25 12:51 smaps

-r--r--r-- 1 oracle oinstall 0 Aug 25 12:37 stat

-r--r--r-- 1 oracle oinstall 0 Aug 25 12:51 statm

-r--r--r-- 1 oracle oinstall 0 Aug 25 12:48 status

dr-xr-xr-x 3 oracle oinstall 0 Aug 25 12:51 task

-r--r--r-- 1 oracle oinstall 0 Aug 25 12:51 wchan

[[email protected] 2912]$ cd fd

[[email protected] fd]$ ls -ltr

total 0

lr-x------ 1 oracle oinstall 64 Aug 25 12:51 0 -> /dev/null

l-wx------ 1 oracle oinstall 64 Aug 25 12:51 6 -> /u01/app/oracle/admin/ora10g/bdump/alert_ora10g.log

l-wx------ 1 oracle oinstall 64 Aug 25 12:51 5 -> /u01/app/oracle/admin/ora10g/udump/ora10g_ora_2904.trc

lr-x------ 1 oracle oinstall 64 Aug 25 12:51 4 -> /dev/null

lr-x------ 1 oracle oinstall 64 Aug 25 12:51 3 -> /dev/null

lr-x------ 1 oracle oinstall 64 Aug 25 12:51 2 -> /dev/null

lr-x------ 1 oracle oinstall 64 Aug 25 12:51 1 -> /dev/null

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 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 12:51 7 -> /u01/app/oracle/product/10.2.0/db_1/dbs/lkinstora10g (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 23 -> /u01/app/oracle/oradata/ora10g/temp01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 22 -> /u01/app/oracle/oradata/ora10g/example01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 21 -> /u01/app/oracle/oradata/ora10g/users01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 20 -> /u01/app/oracle/oradata/ora10g/sysaux01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 19 -> /u01/app/oracle/oradata/ora10g/undotbs01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 18 -> /u01/app/oracle/oradata/ora10g/system01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 17 -> /u01/app/oracle/oradata/ora10g/control03.ctl (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 16 -> /u01/app/oracle/oradata/ora10g/control02.ctl (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 15 -> /u01/app/oracle/oradata/ora10g/control01.ctl (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 14 -> /u01/app/oracle/product/10.2.0/db_1/dbs/lkORA10G

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 13 -> /u01/app/oracle/product/10.2.0/db_1/dbs/hc_ora10g.dat

lr-x------ 1 oracle oinstall 64 Aug 25 12:51 12 -> /dev/zero

lr-x------ 1 oracle oinstall 64 Aug 25 12:51 11 -> /dev/zero

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 10 -> /u01/app/oracle/admin/ora10g/adump/ora_2904.aud

[[email protected] fd]$

分析:可以看句柄7,15-23的文件末尾被标记(deleted),这是由刚才的rm -rf操作所导致的,误删除后只要Oracle数据库未重启,进程就不会停止,那么就可以通过/proc/#oracle进程号/fd目录中的文件句柄号,来对这些被delete的文件进行恢复,方法就是cp文件句柄到原路径,注意一点这里如果不是在fd目录,那就要用绝对路径来指定文件句柄,如果删除文件后就,又对数据库进行了关闭操作,那就无解了

--手动创建ora10g实例名命名的目录并cp句柄到具体路径

[[email protected] fd]$ mkdir /u01/app/oracle/oradata/ora10g/

[[email protected] fd]$ cp 7 /u01/app/oracle/product/10.2.0/db_1/dbs/lkinstora10g

[[email protected] fd]$ cp 23 /u01/app/oracle/oradata/ora10g/temp01.dbf

[[email protected] fd]$ cp 22 /u01/app/oracle/oradata/ora10g/example01.dbf

[[email protected] fd]$ cp 21 /u01/app/oracle/oradata/ora10g/users01.dbf

[[email protected] fd]$ cp 20 /u01/app/oracle/oradata/ora10g/sysaux01.dbf

[[email protected] fd]$ cp 19 /u01/app/oracle/oradata/ora10g/undotbs01.dbf

[[email protected] fd]$ cp 18 /u01/app/oracle/oradata/ora10g/system01.dbf

[[email protected] fd]$ cp 17 /u01/app/oracle/oradata/ora10g/control03.ctl

[[email protected] fd]$ cp 16 /u01/app/oracle/oradata/ora10g/control02.ctl

[[email protected] fd]$ cp 15 /u01/app/oracle/oradata/ora10g/control01.ctl

注意,这里一定要注意权限问题,要用oracle用户去cp,如果用root去cp出来的文件,oracle进程是没有权限操作的,当然,你也可以在用root恢复完后,再chown一下:

[[email protected] fd]# chown oracle.oinstall /u01/app/oracle -R

但是一定要注意,必须等全部数据文件恢复后才可以做chown操作,因为一旦执行了该操作,原来的ora_进程会停止!!!你再也无法恢复丢失的数据了!!!这也是为什么推荐用oralce用户来cp的原因

[[email protected] fd]# ps -ef | grep ora_dbw

oracle    3470     1  0 13:50 ?        00:00:02 ora_dbw0_ora10g

root      4012  3825  0 15:15 pts/3    00:00:00 grep ora_dbw

[[email protected] fd]# chown oracle.oinstall /u01/ -R

[[email protected] fd]# cd /proc/3470

-bash: cd: /proc/3470: No such file or directory

[[email protected] fd]# ps -ef | grep ora_dbw

root      4026  3825  0 15:18 pts/3    00:00:00 grep ora_dbw

[[email protected] fd]# ps -ef | grep ora_

root      4036  3825  0 15:22 pts/3    00:00:00 grep ora_

[[email protected] fd]#

--再次查看fd目录下得文件状态

[[email protected] fd]$ ls -ltr

total 0

lr-x------ 1 oracle oinstall 64 Aug 25 12:51 0 -> /dev/null

l-wx------ 1 oracle oinstall 64 Aug 25 12:51 6 -> /u01/app/oracle/admin/ora10g/bdump/alert_ora10g.log

l-wx------ 1 oracle oinstall 64 Aug 25 12:51 5 -> /u01/app/oracle/admin/ora10g/udump/ora10g_ora_2904.trc

lr-x------ 1 oracle oinstall 64 Aug 25 12:51 4 -> /dev/null

lr-x------ 1 oracle oinstall 64 Aug 25 12:51 3 -> /dev/null

lr-x------ 1 oracle oinstall 64 Aug 25 12:51 2 -> /dev/null

lr-x------ 1 oracle oinstall 64 Aug 25 12:51 1 -> /dev/null

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 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 12:51 7 -> /u01/app/oracle/product/10.2.0/db_1/dbs/lkinstora10g (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 23 -> /u01/app/oracle/oradata/ora10g/temp01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 22 -> /u01/app/oracle/oradata/ora10g/example01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 21 -> /u01/app/oracle/oradata/ora10g/users01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 20 -> /u01/app/oracle/oradata/ora10g/sysaux01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 19 -> /u01/app/oracle/oradata/ora10g/undotbs01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 18 -> /u01/app/oracle/oradata/ora10g/system01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 17 -> /u01/app/oracle/oradata/ora10g/control03.ctl (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 16 -> /u01/app/oracle/oradata/ora10g/control02.ctl (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 15 -> /u01/app/oracle/oradata/ora10g/control01.ctl (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 14 -> /u01/app/oracle/product/10.2.0/db_1/dbs/lkORA10G

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 13 -> /u01/app/oracle/product/10.2.0/db_1/dbs/hc_ora10g.dat

lr-x------ 1 oracle oinstall 64 Aug 25 12:51 12 -> /dev/zero

lr-x------ 1 oracle oinstall 64 Aug 25 12:51 11 -> /dev/zero

lrwx------ 1 oracle oinstall 64 Aug 25 12:51 10 -> /u01/app/oracle/admin/ora10g/adump/ora_2904.aud

对文件进行恢复以后,直接查询fd目录下的文件状态,依然可以看到是(deleted)的,但是没关系,实际上文件已经恢复成功了

--开启另一个session查看文件是否已经恢复

[[email protected] ~]# su - oracle

[[email protected] ~]$ cd /u01/app/oracle/oradata/ora10g

[[email protected] ora10g]$ ll

total 914656

-rw-r----- 1 oracle oinstall   7061504 Aug 25 13:03 control01.ctl

-rw-r----- 1 oracle oinstall   7061504 Aug 25 13:03 control02.ctl

-rw-r----- 1 oracle oinstall   7061504 Aug 25 13:03 control03.ctl

-rw-r----- 1 oracle oinstall 104865792 Aug 25 13:00 example01.dbf

-rw-r----- 1 oracle oinstall 251666432 Aug 25 13:01 sysaux01.dbf

-rw-r----- 1 oracle oinstall 503324672 Aug 25 13:02 system01.dbf

-rw-r----- 1 oracle oinstall  20979712 Aug 25 12:59 temp01.dbf

-rw-r----- 1 oracle oinstall  31465472 Aug 25 13:01 undotbs01.dbf

-rw-r----- 1 oracle oinstall   5251072 Aug 25 13:00 users01.dbf

[[email protected] ora10g]$ pwd

/u01/app/oracle/oradata/ora10g

[[email protected] ora10g]$

--恢复在线日志文件

[[email protected] fd]$ ps -ef | grep ora_lgwr

oracle    2914     1  0 12:37 ?        00:00:01 ora_lgwr_ora10g

oracle    3255  2999  0 13:09 pts/2    00:00:00 grep ora_lgwr

[[email protected] fd]$ cd /proc/2914/fd

[[email protected] fd]$ ls -ltr

total 0

lr-x------ 1 oracle oinstall 64 Aug 25 13:09 0 -> /dev/null

l-wx------ 1 oracle oinstall 64 Aug 25 13:09 5 -> /u01/app/oracle/admin/ora10g/udump/ora10g_ora_2904.trc

lr-x------ 1 oracle oinstall 64 Aug 25 13:09 4 -> /dev/null

lr-x------ 1 oracle oinstall 64 Aug 25 13:09 3 -> /dev/null

l-wx------ 1 oracle oinstall 64 Aug 25 13:09 2 -> /u01/app/oracle/admin/ora10g/bdump/ora10g_lgwr_2914.trc

lr-x------ 1 oracle oinstall 64 Aug 25 13:09 1 -> /dev/null

lrwx------ 1 oracle oinstall 64 Aug 25 13:09 9 -> /u01/app/oracle/product/10.2.0/db_1/dbs/hc_ora10g.dat

l-wx------ 1 oracle oinstall 64 Aug 25 13:09 8 -> /u01/app/oracle/admin/ora10g/bdump/alert_ora10g.log

lrwx------ 1 oracle oinstall 64 Aug 25 13:09 7 -> /u01/app/oracle/product/10.2.0/db_1/dbs/lkinstora10g (deleted)

l-wx------ 1 oracle oinstall 64 Aug 25 13:09 6 -> /u01/app/oracle/admin/ora10g/bdump/alert_ora10g.log

lrwx------ 1 oracle oinstall 64 Aug 25 13:09 26 -> /u01/app/oracle/oradata/ora10g/temp01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 13:09 25 -> /u01/app/oracle/oradata/ora10g/example01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 13:09 24 -> /u01/app/oracle/oradata/ora10g/users01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 13:09 23 -> /u01/app/oracle/oradata/ora10g/sysaux01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 13:09 22 -> /u01/app/oracle/oradata/ora10g/undotbs01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 13:09 21 -> /u01/app/oracle/oradata/ora10g/system01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 13:09 20 -> /u01/app/oracle/oradata/ora10g/redo03.log (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 13:09 19 -> /u01/app/oracle/oradata/ora10g/redo02.log (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 13:09 18 -> /u01/app/oracle/oradata/ora10g/redo01.log (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 13:09 17 -> /u01/app/oracle/oradata/ora10g/control03.ctl (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 13:09 16 -> /u01/app/oracle/oradata/ora10g/control02.ctl (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 13:09 15 -> /u01/app/oracle/oradata/ora10g/control01.ctl (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 13:09 14 -> /u01/app/oracle/product/10.2.0/db_1/dbs/lkORA10G

lrwx------ 1 oracle oinstall 64 Aug 25 13:09 13 -> /u01/app/oracle/product/10.2.0/db_1/dbs/hc_ora10g.dat

lr-x------ 1 oracle oinstall 64 Aug 25 13:09 12 -> /dev/zero

lr-x------ 1 oracle oinstall 64 Aug 25 13:09 11 -> /dev/zero

lrwx------ 1 oracle oinstall 64 Aug 25 13:09 10 -> /u01/app/oracle/admin/ora10g/adump/ora_2904.aud

[[email protected] fd]$

可以看到,根据ora_lgwr进程找到的/proc/2914/fd目录下,也有刚才恢复过得数据文件句柄,但句柄的编号,和刚才在/proc/2912/fd下面是不一致的,这也就说明,这些进程在运行的时候,各自有各自的文件句柄编号,互不影响,由于刚才已经对数据文件和控制文件进行了恢复,此时,只需要再对online redo logfile进行恢复即可

--开始恢复online redo logfile

[[email protected] fd]$ cp 20 /u01/app/oracle/oradata/ora10g/redo03.log

[[email protected] fd]$ cp 19 /u01/app/oracle/oradata/ora10g/redo02.log

[[email protected] fd]$ cp 18 /u01/app/oracle/oradata/ora10g/redo01.log

--在另一个session中查看online redo log是否已经恢复

[[email protected] ora10g]$ ll

total 1068436

-rw-r----- 1 oracle oinstall   7061504 Aug 25 13:03 control01.ctl

-rw-r----- 1 oracle oinstall   7061504 Aug 25 13:03 control02.ctl

-rw-r----- 1 oracle oinstall   7061504 Aug 25 13:03 control03.ctl

-rw-r----- 1 oracle oinstall 104865792 Aug 25 13:00 example01.dbf

-rw-r----- 1 oracle oinstall  52429312 Aug 25 13:12 redo01.log

-rw-r----- 1 oracle oinstall  52429312 Aug 25 13:12 redo02.log

-rw-r----- 1 oracle oinstall  52429312 Aug 25 13:12 redo03.log

-rw-r----- 1 oracle oinstall 251666432 Aug 25 13:01 sysaux01.dbf

-rw-r----- 1 oracle oinstall 503324672 Aug 25 13:02 system01.dbf

-rw-r----- 1 oracle oinstall  20979712 Aug 25 12:59 temp01.dbf

-rw-r----- 1 oracle oinstall  31465472 Aug 25 13:01 undotbs01.dbf

-rw-r----- 1 oracle oinstall   5251072 Aug 25 13:00 users01.dbf

[[email protected] ora10g]$

--重新登录数据库,进行dml操作

[[email protected] fd]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Aug 25 13:14:25 2014

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

Connected to:

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;

COUNT(*)

----------

50314

此时数据库可以正常dml了,但是关闭后再开启数据库,会报600错误:

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

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.

ORA-00600: internal error code, arguments: [kcratr1_lastbwr], [], [], [], [],

[], [], []

--查看alert.log

Mon Aug 25 13:19:16 2014

ALTER DATABASE   MOUNT

Mon Aug 25 13:19:20 2014

Setting recovery target incarnation to 2

Mon Aug 25 13:19:21 2014

Successful mount of redo thread 1, with mount id 4175423764

Mon Aug 25 13:19:21 2014

Database mounted in Exclusive Mode

Completed: ALTER DATABASE   MOUNT

Mon Aug 25 13:19:21 2014

ALTER DATABASE OPEN

Mon Aug 25 13:19:21 2014

Beginning crash recovery of 1 threads

Mon Aug 25 13:19:21 2014

Started redo scan

Mon Aug 25 13:19:21 2014

Errors in file /u01/app/oracle/admin/ora10g/udump/ora10g_ora_3320.trc:

ORA-00600: internal error code, arguments: [kcratr1_lastbwr], [], [], [], [], [], [], []

Mon Aug 25 13:19:22 2014

Aborting crash recovery due to error 600--终止实例恢复

根据Metalink note ID: [393984.1]文档的说明,出现该问题的原因是oracle不能执行实例恢复,手工完成介质恢复后即可以打开

SQL> shutdown immediate

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

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.

SQL> recover database

Media recovery complete.

SQL> alter database open;

Database altered.

SQL> select count(*) from dba_objects;

COUNT(*)

----------

50314

SQL>

--再次验证数据文件

SQL> !ps -ef | grep ora_

oracle    3464     1  0 13:50 ?        00:00:00 ora_pmon_ora10g

oracle    3466     1  0 13:50 ?        00:00:00 ora_psp0_ora10g

oracle    3468     1  0 13:50 ?        00:00:00 ora_mman_ora10g

oracle    3470     1  0 13:50 ?        00:00:00 ora_dbw0_ora10g

oracle    3472     1  0 13:50 ?        00:00:00 ora_lgwr_ora10g

oracle    3474     1  0 13:50 ?        00:00:01 ora_ckpt_ora10g

oracle    3476     1  0 13:50 ?        00:00:01 ora_smon_ora10g

oracle    3478     1  0 13:50 ?        00:00:00 ora_reco_ora10g

oracle    3480     1  0 13:50 ?        00:00:01 ora_cjq0_ora10g

oracle    3482     1  0 13:50 ?        00:00:01 ora_mmon_ora10g

oracle    3484     1  0 13:50 ?        00:00:00 ora_mmnl_ora10g

oracle    3486     1  0 13:50 ?        00:00:00 ora_d000_ora10g

oracle    3488     1  0 13:50 ?        00:00:00 ora_s000_ora10g

oracle    3493     1  0 13:50 ?        00:00:00 ora_arc0_ora10g

oracle    3495     1  0 13:50 ?        00:00:00 ora_arc1_ora10g

oracle    3499     1  0 13:51 ?        00:00:00 ora_qmnc_ora10g

oracle    3513     1  0 13:51 ?        00:00:00 ora_q000_ora10g

oracle    3515     1  0 13:51 ?        00:00:00 ora_q001_ora10g

oracle    3565     1  0 14:04 ?        00:00:00 ora_j000_ora10g

oracle    3568  3278  0 14:04 pts/5    00:00:00 /bin/bash -c ps -ef | grep ora_

SQL> !ls -ltr /proc/3472/fd

total 0

lrwx------ 1 oracle oinstall 64 Aug 25 14:04 9 -> /u01/app/oracle/product/10.2.0/db_1/dbs/hc_ora10g.dat

l-wx------ 1 oracle oinstall 64 Aug 25 14:04 8 -> /u01/app/oracle/admin/ora10g/bdump/alert_ora10g.log

lrwx------ 1 oracle oinstall 64 Aug 25 14:04 7 -> /u01/app/oracle/product/10.2.0/db_1/dbs/lkinstora10g (deleted)

l-wx------ 1 oracle oinstall 64 Aug 25 14:04 6 -> /u01/app/oracle/admin/ora10g/bdump/alert_ora10g.log

l-wx------ 1 oracle oinstall 64 Aug 25 14:04 5 -> /u01/app/oracle/admin/ora10g/udump/ora10g_ora_3462.trc

lr-x------ 1 oracle oinstall 64 Aug 25 14:04 4 -> /dev/null

lr-x------ 1 oracle oinstall 64 Aug 25 14:04 3 -> /dev/null

l-wx------ 1 oracle oinstall 64 Aug 25 14:04 2 -> /u01/app/oracle/admin/ora10g/bdump/ora10g_lgwr_3472.trc

lrwx------ 1 oracle oinstall 64 Aug 25 14:04 13 -> /u01/app/oracle/product/10.2.0/db_1/dbs/hc_ora10g.dat

lr-x------ 1 oracle oinstall 64 Aug 25 14:04 12 -> /dev/zero

lr-x------ 1 oracle oinstall 64 Aug 25 14:04 11 -> /dev/zero

lrwx------ 1 oracle oinstall 64 Aug 25 14:04 10 -> /u01/app/oracle/admin/ora10g/adump/ora_3462.aud

lr-x------ 1 oracle oinstall 64 Aug 25 14:04 1 -> /dev/null

lr-x------ 1 oracle oinstall 64 Aug 25 14:04 0 -> /dev/null

lrwx------ 1 oracle oinstall 64 Aug 25 14:04 26 -> /u01/app/oracle/oradata/ora10g/temp01.dbf

lrwx------ 1 oracle oinstall 64 Aug 25 14:04 25 -> /u01/app/oracle/oradata/ora10g/example01.dbf

lrwx------ 1 oracle oinstall 64 Aug 25 14:04 24 -> /u01/app/oracle/oradata/ora10g/users01.dbf

lrwx------ 1 oracle oinstall 64 Aug 25 14:04 23 -> /u01/app/oracle/oradata/ora10g/sysaux01.dbf

lrwx------ 1 oracle oinstall 64 Aug 25 14:04 22 -> /u01/app/oracle/oradata/ora10g/undotbs01.dbf

lrwx------ 1 oracle oinstall 64 Aug 25 14:04 21 -> /u01/app/oracle/oradata/ora10g/system01.dbf

lrwx------ 1 oracle oinstall 64 Aug 25 14:04 20 -> /u01/app/oracle/oradata/ora10g/redo03.log

lrwx------ 1 oracle oinstall 64 Aug 25 14:04 19 -> /u01/app/oracle/oradata/ora10g/redo02.log

lrwx------ 1 oracle oinstall 64 Aug 25 14:04 18 -> /u01/app/oracle/oradata/ora10g/redo01.log

lrwx------ 1 oracle oinstall 64 Aug 25 14:04 17 -> /u01/app/oracle/oradata/ora10g/control03.ctl

lrwx------ 1 oracle oinstall 64 Aug 25 14:04 16 -> /u01/app/oracle/oradata/ora10g/control02.ctl

lrwx------ 1 oracle oinstall 64 Aug 25 14:04 15 -> /u01/app/oracle/oradata/ora10g/control01.ctl

lrwx------ 1 oracle oinstall 64 Aug 25 14:04 14 -> /u01/app/oracle/product/10.2.0/db_1/dbs/lkORA10G

SQL>

此时数据文件都已经正常了,每次启动数据库实例后,进程都会再/proc下生成一个相应的以进程号命名的目录,存放操作中涉及到的文件句柄,此时lgwr进程对应的目录已经变为3472,而原来的2914目录已经不存在了

--------------------------------------------------------------------------------------

第2次测试(创建完表并插入2条数据后,不提交,直接删除/u01/app/oracle/oradata/ora10g/下的全部文件)

[[email protected] fd]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Aug 25 15:57:57 2014

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

Connected to:

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;

COUNT(*)

----------

50314

SQL> create user aaron8219 identified by oracle;

User created.

SQL> grant dba to aaron8219;

Grant succeeded.

SQL> conn aaron8219/oracle

Connected.

SQL> create table test1(int number);

Table created.

SQL> select count(*) from dba_objects;

COUNT(*)

----------

50315

SQL> insert into test1 values(1);

1 row created.

SQL> insert into test1 values(2);

1 row created.

SQL> select * from test1;

INT

----------

1

2

SQL> select group#,status,members from v$log;

GROUP# STATUS              MEMBERS

---------- ---------------- ----------

1 CURRENT                   1

2 UNUSED                    1

3 INACTIVE                  1

SQL> exit

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

With the Partitioning, OLAP and Data Mining options

[[email protected] fd]$ cd /u01/app/oracle/oradata

[[email protected] oradata]$ cd ora10g

[[email protected] ora10g]$ ll

total 1068440

-rw-r----- 1 oracle oinstall   7061504 Aug 25 16:01 control01.ctl

-rw-r----- 1 oracle oinstall   7061504 Aug 25 16:01 control02.ctl

-rw-r----- 1 oracle oinstall   7061504 Aug 25 16:01 control03.ctl

-rw-r----- 1 oracle oinstall 104865792 Aug 25 15:52 example01.dbf

-rw-r----- 1 oracle oinstall  52429312 Aug 25 16:01 redo01.log

-rw-r----- 1 oracle oinstall  52429312 Aug 25 15:52 redo02.log

-rw-r----- 1 oracle oinstall  52429312 Aug 25 15:52 redo03.log

-rw-r----- 1 oracle oinstall 251666432 Aug 25 16:01 sysaux01.dbf

-rw-r----- 1 oracle oinstall 503324672 Aug 25 15:57 system01.dbf

-rw-r----- 1 oracle oinstall  20979712 Aug 25 15:50 temp01.dbf

-rw-r----- 1 oracle oinstall  31465472 Aug 25 15:57 undotbs01.dbf

-rw-r----- 1 oracle oinstall   5251072 Aug 25 15:52 users01.dbf

[oracle[email protected] ora10g]$ rm -rf *.*

[[email protected] ora10g]$ ll

total 0

[[email protected] ora10g]$ ps -ef | grep ora_lgwr

oracle    4566     1  0 15:52 ?        00:00:01 ora_lgwr_ora10g

oracle    6784  2999  0 16:02 pts/2    00:00:00 grep ora_lgwr

[[email protected] ora10g]$ cd /proc/4566/fd

[[email protected] fd]$ ll

total 0

lr-x------ 1 oracle oinstall 64 Aug 25 16:02 0 -> /dev/null

lr-x------ 1 oracle oinstall 64 Aug 25 16:02 1 -> /dev/null

lrwx------ 1 oracle oinstall 64 Aug 25 16:02 10 -> /u01/app/oracle/admin/ora10g/adump/ora_4556.aud

l-wx------ 1 oracle oinstall 64 Aug 25 16:02 11 -> /u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/dbca/ora10g/mkplug_v3_ora10g.log

lr-x------ 1 oracle oinstall 64 Aug 25 16:02 12 -> /dev/zero

lr-x------ 1 oracle oinstall 64 Aug 25 16:02 13 -> /dev/zero

lrwx------ 1 oracle oinstall 64 Aug 25 16:02 14 -> /u01/app/oracle/product/10.2.0/db_1/dbs/hc_ora10g.dat

lrwx------ 1 oracle oinstall 64 Aug 25 16:02 15 -> /u01/app/oracle/product/10.2.0/db_1/dbs/lkORA10G

lrwx------ 1 oracle oinstall 64 Aug 25 16:02 16 -> /u01/app/oracle/oradata/ora10g/control01.ctl (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 16:02 17 -> /u01/app/oracle/oradata/ora10g/control02.ctl (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 16:02 18 -> /u01/app/oracle/oradata/ora10g/control03.ctl (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 16:02 19 -> /u01/app/oracle/oradata/ora10g/redo01.log (deleted)

l-wx------ 1 oracle oinstall 64 Aug 25 16:02 2 -> /u01/app/oracle/admin/ora10g/bdump/ora10g_lgwr_4566.trc

lrwx------ 1 oracle oinstall 64 Aug 25 16:02 20 -> /u01/app/oracle/oradata/ora10g/redo02.log (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 16:02 21 -> /u01/app/oracle/oradata/ora10g/redo03.log (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 16:02 22 -> /u01/app/oracle/oradata/ora10g/system01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 16:02 23 -> /u01/app/oracle/oradata/ora10g/undotbs01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 16:02 24 -> /u01/app/oracle/oradata/ora10g/sysaux01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 16:02 25 -> /u01/app/oracle/oradata/ora10g/users01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 16:02 26 -> /u01/app/oracle/oradata/ora10g/example01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Aug 25 16:02 27 -> /u01/app/oracle/oradata/ora10g/temp01.dbf (deleted)

lr-x------ 1 oracle oinstall 64 Aug 25 16:02 3 -> /dev/null

lr-x------ 1 oracle oinstall 64 Aug 25 16:02 4 -> /dev/null

l-wx------ 1 oracle oinstall 64 Aug 25 16:02 5 -> /u01/app/oracle/admin/ora10g/udump/ora10g_ora_4556.trc

l-wx------ 1 oracle oinstall 64 Aug 25 16:02 6 -> /u01/app/oracle/admin/ora10g/bdump/alert_ora10g.log

lrwx------ 1 oracle oinstall 64 Aug 25 16:02 7 -> /u01/app/oracle/product/10.2.0/db_1/dbs/lkinstora10g (deleted)

l-wx------ 1 oracle oinstall 64 Aug 25 16:02 8 -> /u01/app/oracle/admin/ora10g/bdump/alert_ora10g.log

lrwx------ 1 oracle oinstall 64 Aug 25 16:02 9 -> /u01/app/oracle/product/10.2.0/db_1/dbs/hc_ora10g.dat

[[email protected] fd]$ cp 7 /u01/app/oracle/product/10.2.0/db_1/dbs/lkinstora10g

[[email protected] fd]$ cp 16 /u01/app/oracle/oradata/ora10g/control01.ctl

[[email protected] fd]$ cp 17 /u01/app/oracle/oradata/ora10g/control02.ctl

[[email protected] fd]$ cp 18 /u01/app/oracle/oradata/ora10g/control03.ctl

[[email protected] fd]$ cp 19 /u01/app/oracle/oradata/ora10g/redo01.log

[[email protected] fd]$ cp 20 /u01/app/oracle/oradata/ora10g/redo02.log

[[email protected] fd]$ cp 21 /u01/app/oracle/oradata/ora10g/redo03.log

[[email protected] fd]$ cp 22 /u01/app/oracle/oradata/ora10g/system01.dbf

[[email protected]g fd]$ cp 23 /u01/app/oracle/oradata/ora10g/undotbs01.dbf

[[email protected] fd]$ cp 24 /u01/app/oracle/oradata/ora10g/sysaux01.dbf

[[email protected] fd]$ cp 25 /u01/app/oracle/oradata/ora10g/users01.dbf

[[email protected] fd]$ cp 26 /u01/app/oracle/oradata/ora10g/example01.dbf

[[email protected] fd]$ cp 27 /u01/app/oracle/oradata/ora10g/temp01.dbf

[[email protected] fd]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Aug 25 16:10:03 2014

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

Connected to:

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;

COUNT(*)

----------

50315

SQL> select * from aaron8219.test1;

INT

----------

1

2

SQL> select group#,status,members from v$log;

GROUP# STATUS              MEMBERS

---------- ---------------- ----------

1 CURRENT                   1

2 UNUSED                    1

3 INACTIVE                  1

SQL> archive log list

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     1

Next log sequence to archive   2

Current log sequence           2

SQL> alter system switch logfile;

System altered.

SQL> archive log list

ORA-03113: end-of-file on communication channel

切换一次日志后,实例被终止,可以从alert.log中看到:

[[email protected] oradata]# tailf /u01/app/oracle/admin/ora10g/bdump/alert_ora10g.log

...

Mon Aug 25 16:13:05 2014

Thread 1 advanced to log sequence 3

Current log# 2 seq# 3 mem# 0: /u01/app/oracle/oradata/ora10g/redo02.log

Mon Aug 25 16:13:05 2014

Errors in file /u01/app/oracle/admin/ora10g/bdump/ora10g_arc0_4586.trc:

ORA-00322: Message 322 not found; No message file for product=RDBMS, facility=ORA; arguments: [1] [1]

ORA-00312: Message 312 not found; No message file for product=RDBMS, facility=ORA; arguments: [1] [1] [/u01/app/oracle/oradata/ora10g/redo01.log]

Mon Aug 25 16:13:05 2014

Errors in file /u01/app/oracle/admin/ora10g/bdump/ora10g_arc0_4586.trc:

ORA-00322: Message 322 not found; No message file for product=RDBMS, facility=ORA; arguments: [1] [1]

ORA-00312: Message 312 not found; No message file for product=RDBMS, facility=ORA; arguments: [1] [1] [/u01/app/oracle/oradata/ora10g/redo01.log]

Mon Aug 25 16:13:05 2014

ARC0: Failed to archive thread 1 sequence 2 (0)

ARCH: Archival stopped, error occurred. Will continue retrying

Mon Aug 25 16:13:05 2014

ORACLE Instance ora10g - Archival Error

Mon Aug 25 16:13:05 2014

ORA-16038: Message 16038 not found; No message file for product=RDBMS, facility=ORA; arguments: [1] [2]

ORA-00312: Message 312 not found; No message file for product=RDBMS, facility=ORA; arguments: [1] [1] [/u01/app/oracle/oradata/ora10g/redo01.log]

Mon Aug 25 16:13:05 2014

Errors in file /u01/app/oracle/admin/ora10g/bdump/ora10g_arc0_4586.trc:

ORA-16038: Message 16038 not found; No message file for product=RDBMS, facility=ORA; arguments: [1] [2]

ORA-00312: Message 312 not found; No message file for product=RDBMS, facility=ORA; arguments: [1] [1] [/u01/app/oracle/oradata/ora10g/redo01.log]

Mon Aug 25 16:13:08 2014

********************* ATTENTION: ********************

The controlfile header block returned by the OS

has a sequence number that is too old.

The controlfile might be corrupted.

PLEASE DO NOT ATTEMPT TO START UP THE INSTANCE

without following the steps below.

RE-STARTING THE INSTANCE CAN CAUSE SERIOUS DAMAGE

TO THE DATABASE, if the controlfile is truly corrupted.

In order to re-start the instance safely,

please do the following:

(1) Save all copies of the controlfile for later

analysis and contact your OS vendor and Oracle support.

(2) Mount the instance and issue:

ALTER DATABASE BACKUP CONTROLFILE TO TRACE;

(3) Unmount the instance.

(4) Use the script in the trace file to

RE-CREATE THE CONTROLFILE and open the database.

*****************************************************

Instance terminated by USER, pid = 6994

--关闭实例,重新启动

SQL> shutdown immediate

ORA-24324: service handle not initialized

ORA-01041: internal error. hostdef extension doesn‘t exist

SQL> exit

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

With the Partitioning, OLAP and Data Mining options

[[email protected] fd]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Aug 25 16:17:05 2014

Copyright (c) 1982, 2005, 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              92276304 bytes

Database Buffers          188743680 bytes

Redo Buffers                2973696 bytes

Database mounted.

Database opened.

SQL> select * from aaron8219.test1;

INT

----------

1

2

SQL>

可以看到,这次未提交的数据并没有丢失,insert的2条数据已经被写入数据文件中,而且又恢复出来了

总结:

当我们进行Linux操作系统命令rm的时候,切忌不可随意加-rf参数,就算一定要用,也要确定再三后才能执行,否则对于数据库而言,可以说是灾难性的。这里只是测试了一下删除/u01/app/oracle/oradata/下的全部文件,试想一下,如果你当初执行的是rm -rf /u01呢?可能情况就要更加复杂一点了,恢复需要的步骤也就更多了。

由于是在数据库open状态下直接进行了破坏性操作,对于还来不及写入online redo logfile的那部分操作,是会丢失的,(但在我的第2次测试中,并没有丢失未提交数据,原因还有待研究),因为我们通过文件句柄号恢复出来的日志文件中,并不一定包含数据库的最新变更,即便如此,对于rm -rf误操作的恢复,还是有一定意义的,至少可以在你没有任何备份的情况下,多提供了一根救命稻草来拯救你的数据库,再次强调一下,rm -rf后,千万不要着急地关闭数据库重启!!!否则就等着哭吧!!!

时间: 2024-11-05 17:29:56

rm-rf 误操作的恢复过程的相关文章

mysql权限的误操作的恢复

mysql权限的误操作的恢复 原因:由于误操作,我把repl用户授予了所有权限,但删除了数据库中的其他用户及权限,因此repl用户虽然具有操作所有数据库的权限,但没有grant权限,所以若想授予其他用户权限,来管理数据库,出现这种状况就酷毙了,没有授予权限怎麽办? 误操作过程: mysql >grant all on *.* to 'repl'@'192.168.1.%' identified by '123456'; mysql> flush privileges; 授予完以后,我把其他的所

Linux对rm的误操作预防

rm -rf /*    这个要命的操作,让我们轻易不敢用rm这个命令.虽然rm后,数据可以恢复,但是,rm后,rm的目标所在的区,一定不能写入内容了,但是我们无法保证一定不会写入内容.比如紧急状态下,人为的紧张或者其他的日志之类的持续的导入或者数据的同步之类的情况.(当然,那种传说中rpm能敲成rm的也是奇才.) 那么我们不如让rm实现mv aaa /root/.local/share/Trash的效果,让rm的目标转移到trash中,一旦发现rm了错误的目标,可以及时的从trash中还原.实

rm -rf误删文件的恢复(extundelete工具的使用)

实战:extundelete恢复数据的过程 在数据被误删除后,第一时间要做的是卸载被删除数据所在的磁盘或磁盘分区,如果是系统根分区的数据遭到误删除,就需要将系统进入单用户,并且将根分区以只读模式挂载.这样做的原因很简单,因为将文件删除后,仅仅是将文件的inode结点中的扇区指针清零,实际文件还存储在磁盘上,如果磁盘以读写模式挂载,这些已删除的文件的数据块就可能被操作系统重新分配出去,在这些数据块被新的数据覆盖后,这些数据就真的丢失了,恢复工具也回力无天.所以,以只读模式挂载磁盘可以尽量降低数据块

SCPPO:SQL误操作如何恢复?

[前言] 今天研究项目中自己有疑惑的一块儿内容应该是这个系统的核心-数据从上传的Access中解析出来(ETL的贡献)经过一系列的存储过程将数据放到数据库表中(每天凌晨都会定时的执行这一系列操作)这只是今天的引子,不具体深入的讲解下去,小编会在接下来的博文中更加深入的为大家分享: 在分析这块儿的时候无意在服务器上发现一款软件-ApexSQL Log:之前没接触过出于好奇就去网上查了一下它是干嘛用的,这一查不要紧,又燃起了自己新的兴趣,仿佛一切的一切上天冥冥之中自有安排!为何这么说?小编下面为大家

记一次rm的误操作

记录一次我在linux下的瓜皮操作吧,这次是乱用rm -rf 导致. 起因是我用vim编辑配置文件后,wq后面接了~然后回车,这样保存后,该路劲下多了一个~文件.一开始我觉得是以~创建了一个文件而已,没多想就直接rm -rf  ~了,当时没什么事,接着再次编辑文档保存退出时发现,会提示E138: Can't write viminfo file /root/.viminfo!,然后想着进入root的家目录看看,发现此时root家目录已经不存在了,顿时恍然大悟. 百度了下,发现不止我遇到过这种问题

SQLServer 2008以上误操作数据库恢复方法——日志尾部备份

问题: 经常看到有人误删数据,或者误操作,特别是update和delete的时候没有加where,然后就喊爹喊娘了.人非圣贤孰能无过,做错可以理解,但不能纵容,这个以后再说,现在先来解决问题. 遇到这种情况,一般都是没有做备份,不然也不会来发问了.首先要冷静,否则会有更大的灾难.直到你放弃. 解决方法: 对于这类问题,主要是找回误操作之前的数据,在2008之前,有个很出名的工具Log Exploer,听说还挺好用的,这个网上大把教程,这里就不多说了.但是唯一遗憾的是,不支持2008及更高版本,这

logminer挖掘归档日志,针对DDL误操作的恢复

日志挖掘,未开启补充日志功能,利用归档对DDL操作进行恢复:        Oracle   的日志文件中,对于表等用户对象(Object),并不是保存名字,而是保存一个ID号.建立字典文件的目的就是使logminer在分析时可以将Object   ID翻译成我们所熟悉的对象名.       建立字典文件之前,先要确保数据库的初始化参数   UTL_FILE_DIR   已经正确地设置.通过命令可以查看是否有字典文件:show parameters utl_file_dir; [email pr

【转】SQLServer 2008以上误操作数据库恢复方法——日志尾部备份

4号,公司的生产数据表被全部删除,目前没有找到原因,由于刚接触SQL不久,所以短时间内不会还原,也不敢动被原服务器,于是就将原服务器停掉,拷贝出里面的PPD数据库文件,留作备份:近几天在自己的电脑上尝试修复,一直没有成功,细读了一下<SQL2005技术内幕——存储引擎>了解到删除列.删除表这些操作不会直接对每一行数据进行操作,而是直接改变他们的物理指向地址的ID,专业术语我也不是很清楚,我的理解是这样的,有时间再弄清楚,不过这足以让我明白被删除的表还是存在mdf文件中,其改变的便宜地址记录在日

git操作——git pull 撤销误操作,恢复本地代码

需求 开发的代码还未commit到git本地仓库,就从git远程仓库上pull了代码,导致开发的代码直接被冲掉,需要退回到上一个版本代码. 操作 进入到项目git本地仓库文件夹下 打开cmd窗口,执行命令:git reflog 找到需要回退的版本,执行命令:git reset --hard [email protected]{n} 如执行:git reset --hard 61a942c 原文地址:https://www.cnblogs.com/zuiyue_jing/p/11123654.ht