rman 恢複---歸檔丟失and資料檔案損壞

來源:互聯網
上載者:User

在歸檔日誌有丟失的情況下並且資料檔案損壞,恢複資料庫。
 
用rman恢複,歸檔有丟失,恢複到指定的sequence
1、在資料庫open的情況下,做一些操作,確定這些操作所在的歸檔記錄檔

SQL> select group#,sequence#,members,status from v$log;
    GROUP#  SEQUENCE#    MEMBERS STATUS
---------- ---------- ---------- ----------------
         1         10          1 ACTIVE
         2         11          1 CURRENT
         3          9          1 ACTIVE
SQL> show user;
USER is "HAOZG"
SQL> create table test11(name varchar2(10),age number);
Table created.
SQL> insert into test11 values('haozg',28);
1 row created.
SQL> commit;
Commit complete.
SQL> /
Commit complete.
SQL> insert into test11 values('zhangf',29);
1 row created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
SQL> select group#,sequence#,members,status from v$log;
    GROUP#  SEQUENCE#    MEMBERS STATUS
---------- ---------- ---------- ----------------
         1         10          1 ACTIVE
         2         11          1 ACTIVE
         3         12          1 CURRENT
上面做的操作儲存在sequence是11的歸檔記錄檔中。
2、做全庫備份
RMAN> run{
 allocate channel c1 type disk maxpiecesize=500m;
 backup current controlfile format '+dgasm/backup/haozg/ctl_%d_%s';
 backup full database format '+dgasm/backup/haozg/db_%d_%s_%p_%t';
 sql 'alter system archive log current';
 release channel c1;
 }2> 3> 4> 5> 6> 7>
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=44 device type=DISK
Starting backup at 01-JUL-12
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
channel c1: starting piece 1 at 01-JUL-12
channel c1: finished piece 1 at 01-JUL-12
piece handle=+DGASM/backup/haozg/ctl_ora11_41 tag=TAG20120701T101120 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:03
Finished backup at 01-JUL-12
Starting backup at 01-JUL-12
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DGASM/ora11/datafile/system.257.785186755
input datafile file number=00002 name=+DGASM/ora11/datafile/sysaux.258.785186845
input datafile file number=00003 name=+DGASM/ora11/datafile/undotbs1.259.785186901
input datafile file number=00004 name=+DGASM/ora11/datafile/users.272.787470817
channel c1: starting piece 1 at 01-JUL-12
channel c1: finished piece 1 at 01-JUL-12
piece handle=+DGASM/backup/haozg/db_ora11_42_1_787486286 tag=TAG20120701T101126 comment=NONE
channel c1: starting piece 2 at 01-JUL-12
channel c1: finished piece 2 at 01-JUL-12
piece handle=+DGASM/backup/haozg/db_ora11_42_2_787486286 tag=TAG20120701T101126 comment=NONE
channel c1: backup set complete, elapsed time: 00:02:00
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel c1: starting piece 1 at 01-JUL-12
channel c1: finished piece 1 at 01-JUL-12
piece handle=+DGASM/backup/haozg/db_ora11_43_1_787486406 tag=TAG20120701T101126 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 01-JUL-12
sql statement: alter system archive log current
released channel: c1
RMAN>
3、然再做操作,確定所在的歸檔檔案
SQL> select group#,sequence#,members,status from v$log;
    GROUP#  SEQUENCE#    MEMBERS STATUS
---------- ---------- ---------- ----------------
         1         13          1 CURRENT
         2         11          1 INACTIVE
         3         12          1 ACTIVE
SQL> create table test22(name varchar2(10),age number);
Table created.
SQL> insert into test22 values('guany',30);
1 row created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
SQL> select group#,sequence#,members,status from v$log;
    GROUP#  SEQUENCE#    MEMBERS STATUS
---------- ---------- ---------- ----------------
         1         13          1 ACTIVE
         2         14          1 CURRENT
         3         12          1 ACTIVE
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> select group#,sequence#,members,status from v$log;
    GROUP#  SEQUENCE#    MEMBERS STATUS
---------- ---------- ---------- ----------------
         1         16          1 CURRENT
         2         14          1 ACTIVE
         3         15          1 ACTIVE
上面的操作在sequence是13 的歸檔記錄檔中
4、到資料庫的歸檔目錄下刪除sequence 是13的歸檔記錄檔
[Oracle@ www.bkjia.com archivelog]$ ls -al
total 9904
drwxr-xr-x  2 oracle oinstall     4096 Jul  1 10:16 .
drwxrwxr-x 12 oracle oinstall     4096 Jun 18 17:04 ..
-rw-r-----  1 oracle oinstall     2560 Jul  1 10:03 1_10_787471195.dbf
-rw-r-----  1 oracle oinstall    20992 Jul  1 10:08 1_11_787471195.dbf
-rw-r-----  1 oracle oinstall 10061312 Jul  1 10:13 1_12_787471195.dbf
-rw-r-----  1 oracle oinstall    18944 Jul  1 10:16 1_13_787471195.dbf
-rw-r-----  1 oracle oinstall     2560 Jul  1 10:03 1_9_787471195.dbf
[oracle@ www.bkjia.com archivelog]$ mv 1_13_787471195.dbf ../
[oracle@ www.bkjia.com archivelog]$ ls
1_10_787471195.dbf  1_11_787471195.dbf  1_12_787471195.dbf  1_9_787471195.dbf
[oracle@ www.bkjia.com archivelog]$ ls -al
total 10168
drwxr-xr-x  2 oracle oinstall     4096 Jul  1 10:20 .
drwxrwxr-x 12 oracle oinstall     4096 Jul  1 10:19 ..
-rw-r-----  1 oracle oinstall     2560 Jul  1 10:03 1_10_787471195.dbf
-rw-r-----  1 oracle oinstall    20992 Jul  1 10:08 1_11_787471195.dbf
-rw-r-----  1 oracle oinstall 10061312 Jul  1 10:13 1_12_787471195.dbf
-rw-r-----  1 oracle oinstall   282624 Jul  1 10:20 1_14_787471195.dbf
-rw-r-----  1 oracle oinstall     3072 Jul  1 10:20 1_15_787471195.dbf
-rw-r-----  1 oracle oinstall     2560 Jul  1 10:03 1_9_787471195.dbf

  • 1
  • 2
  • 下一頁

相關文章

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.