完整備份Oracle資料庫

來源:互聯網
上載者:User

修改備份檔案的有效時間(必須用spfile啟動資料庫)

SQL>   alter system set control_file_record_keep_time=30 scope=both;

System altered.

先啟動歸檔

SQL> startup mount

Oracle instance started.

Total System Global Area  314572800 bytes

Fixed Size                  1219136 bytes

Variable Size              96470464 bytes

Database Buffers          209715200 bytes

Redo Buffers                7168000 bytes

Database mounted.

SQL>  alter database archivelog;

 

Database altered.

 

[root@bw ~]# su - oracle

[oracle@bw ~]$ rman target /

 

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Apr 24 10:14:45 2011

 

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

 

connected to target database: BW (DBID=3011863310)

 

RMAN> show all;

 

using target database control file instead of recovery catalog

RMAN configuration parameters are:

CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

CONFIGURE BACKUP OPTIMIZATION OFF; # default

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default

CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE MAXSETSIZE TO UNLIMITED; # default

CONFIGURE ENCRYPTION FOR DATABASE OFF; # default

CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default

CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default

CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2/db_1/dbs/snapcf_bw.f'; # default

 

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

 

new RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters are successfully stored

[oracle@bw u01]$ rman target /

RMAN> run{

2> allocate channel d1 type disk;

3> allocate channel d2 type disk;

4>backup full database format '/u01/bak/bw20110430_%u.bak' tag=bwfull01;

5> release channel d1;

6> release channel d2;

7> }

斷行符號

 

開始恢複資料庫檔案

在/u01/oradata/bw下刪除dbf檔案 (沒有刪除控制檔案)

[oracle@bw bw]$ rm -rf *dbf

 

恢複

[oracle@bw u01]$ rman target /

RMAN> startup nomount;

RMAN> alter database mount;

RMAN> restore database;

RMAN> recover database;

 

Starting recover at 23-APR-11

using channel ORA_DISK_1

 

starting media recovery

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

 

Finished recover at 23-APR-11(表示還原成功)

如果控制檔案和資料檔案都刪除

[oracle@bw ~]$ cd /u01/oradata/bw/

[oracle@bw bw]$ ll

total 1005496

-rw-r-----  1 oracle oinstall 104865792 Apr 26 20:53 bw01.dbf

-rw-r-----  1 oracle oinstall 115351552 Apr 26 21:14 bwtbs01.dbf

-rw-r-----  1 oracle oinstall  17547264 Apr 26 21:14 control01.ctl(紅色部分都刪除)

-rw-r-----  1 oracle oinstall  17547264 Apr 26 21:14 control02.ctl

-rw-r-----  1 oracle oinstall  17547264 Apr 26 21:14 control03.ctl

-rw-r-----  1 oracle oinstall  20972032 Apr 26 21:14 redo1_1.dbf

-rw-r-----  1 oracle oinstall  20972032 Apr 26 20:36 redo2_1.dbf

-rw-r-----  1 oracle oinstall  20972032 Apr 26 20:48 redo3_1.dbf

-rw-r-----  1 oracle oinstall 314580992 Apr 26 21:14 sysaux01.dbf

-rw-r-----  1 oracle oinstall 314580992 Apr 26 21:14 system01.dbf

-rw-r-----  1 oracle oinstall 209723392 Apr 26 21:09 temp01.dbf

-rw-r-----  1 oracle oinstall  20972032 Apr 26 21:14 redo1_1.rdo

-rw-r-----  1 oracle oinstall  20972032 Apr 26 20:36 redo2_1.rdo

-rw-r-----  1 oracle oinstall  20972032 Apr 26 20:48 redo3_1.rdo

 [oracle@bw ~]$rm –rf*dbf

[oracle@bw ~]$rm –rf*ctl

[oracle@bw ~]$ll

-rw-r-----  1 oracle oinstall  20972032 Apr 26 21:14 redo1_1.rdo

-rw-r-----  1 oracle oinstall  20972032 Apr 26 20:36 redo2_1.rdo

-rw-r-----  1 oracle oinstall  20972032 Apr 26 20:48 redo3_1.rdo

 

[oracle@bw ~]$rman target /

 

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Apr 26 19:46:45 2011

 

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

 

connected to target database: bw (not mounted)

 

RMAN> startup nomount;

 

database is already started

[oracle@bw ~]$ cd $ORACLE_HOME/dbs

[oracle@bw dbs]$ ll

total 34452

-rw-r-----  1 oracle oinstall 17629184 Apr 26 19:37 c-3011863310-20110426-00

-rw-r--r--  1 oracle oinstall      849 Apr 22 13:38 db.sql

-rw-rw----  1 oracle oinstall     1544 Apr 22 13:37 hc_bw.dat

-rw-r--r--  1 oracle oinstall      960 Apr 22 13:36 initbw.ora

-rw-r-----  1 oracle oinstall    12920 May  3  2001 initdw.ora

-rw-r-----  1 oracle oinstall     8385 Sep 11  1998 init.ora

-rw-rw----  1 oracle oinstall       24 Apr 22 13:38 lkBW

-rw-r-----  1 oracle oinstall     1536 Apr 22 13:36 orapwbw

-rw-r-----  1 oracle oinstall 17547264 Apr 26 19:37 snapcf_bw.f

-rw-r-----  1 oracle oinstall     2560 Apr 26 19:28 spfilebw.ora

 

RMAN> set dbid=3011863310;

 

executing command: SET DBID

·

RMAN> restore controlfile from autobackup;

 

Starting restore at 26-APR-11

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=47 devtype=DISK

 

channel ORA_DISK_1: looking for autobackup on day: 20110426

channel ORA_DISK_1: autobackup found: c-3011863310-20110426-00

channel ORA_DISK_1: control file restore from autobackup complete

output filename=/u01/oradata/bw/control01.ctl

output filename=/u01/oradata/bw/control02.ctl

output filename=/u01/oradata/bw/control03.ctl

Finished restore at 26-APR-11

(控制檔案恢複成功)

開始恢複資料檔案

[oracle@bw u01]$ rman target /

RMAN> startup nomount;

RMAN> alter database mount;

RMAN> restore database;

RMAN> recover database;

Starting recover at 23-APR-11

using channel ORA_DISK_1

 

starting media recovery

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

 

Finished recover at 23-APR-11(表示還原成功)

[oracle@bw ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Apr 26 20:12:42 2011

 

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

 

Connected to an idle instance.

 

SQL> startup

ORACLE instance started.

 

Total System Global Area  314572800 bytes

Fixed Size                  1219136 bytes

Variable Size              96470464 bytes

Database Buffers          209715200 bytes

Redo Buffers                7168000 bytes

Database mounted.

ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

 

SQL> alter database open resetlogs;

 

Database altered.

 

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

 

Total System Global Area  314572800 bytes

Fixed Size                  1219136 bytes

Variable Size              96470464 bytes

Database Buffers          209715200 bytes

Redo Buffers                7168000 bytes

Database mounted.

Database opened.

SQL>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.