Oracle dbms_backup_restore恢复数据库
2012-09-21 23:43
337 查看
Oracle Version:Oracle 10.2.0.5 64bit
OS:RHEL5.4 64bit
1.fullbackup
[oracle@Kin ~]$ rman target /
Recovery Manager: Release 10.2.0.5.0 - Production on Mon Sep 17 17:00:14 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: KIN (DBID=2123478169)
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS;
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 '/oracle/oracle10g/dbs/snapcf_KIN.f'; # default
RMAN> backup database format '/db/backup/full_%d_%T_%s';
Starting backup at 17-SEP-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=158 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/oradata/KIN/system01.dbf
input datafile fno=00002 name=/oradata/KIN/undotbs01.dbf
input datafile fno=00003 name=/oradata/KIN/sysaux01.dbf
input datafile fno=00005 name=/oradata/KIN/kin.dbf
channel ORA_DISK_1: starting piece 1 at 17-SEP-12
channel ORA_DISK_1: finished piece 1 at 17-SEP-12
piece handle=/db/backup/full_KIN_20120917_5 tag=TAG20120917T170520 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 17-SEP-12
channel ORA_DISK_1: finished piece 1 at 17-SEP-12
piece handle=/db/backup/full_KIN_20120917_6 tag=TAG20120917T170520 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:05
Finished backup at 17-SEP-12
2.archivelog backup
RMAN> backup format '/db/backup/arch_%d_%T_%s' archivelog all delete input;
Starting backup at 17-SEP-12
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=26 recid=16 stamp=794250422
input archive log thread=1 sequence=27 recid=17 stamp=794250423
input archive log thread=1 sequence=28 recid=18 stamp=794250427
input archive log thread=1 sequence=29 recid=19 stamp=794250508
channel ORA_DISK_1: starting piece 1 at 17-SEP-12
channel ORA_DISK_1: finished piece 1 at 17-SEP-12
piece handle=/db/backup/arch_KIN_20120917_7 tag=TAG20120917T170828 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/oradata/KIN/archive/KIN_1_26_790937753.arc recid=16 stamp=794250422
archive log filename=/oradata/KIN/archive/KIN_1_27_790937753.arc recid=17 stamp=794250423
archive log filename=/oradata/KIN/archive/KIN_1_28_790937753.arc recid=18 stamp=794250427
archive log filename=/oradata/KIN/archive/KIN_1_29_790937753.arc recid=19 stamp=794250508
Finished backup at 17-SEP-12
RMAN> list backup of controlfile;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Full 6.77M DISK 00:00:02 05-SEP-12
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: DBFULL
Piece Name: /db/backup/dbfullbackup_KIN_20120905_3
Control File Included: Ckp SCN: 471210 Ckp time: 05-SEP-12
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6 Full 6.80M DISK 00:00:03 17-SEP-12
BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20120917T170520
Piece Name: /db/backup/full_KIN_20120917_6
Control File Included: Ckp SCN: 476736 Ckp time: 17-SEP-12
3.Query the file location
[oracle@Kin backup]$ sqlplus '/as sysdba'
SQL*Plus: Release 10.2.0.5.0 - Production on Mon Sep 17 17:15:40 2012
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/oradata/KIN/system01.dbf
/oradata/KIN/undotbs01.dbf
/oradata/KIN/sysaux01.dbf
/oradata/KIN/kin.dbf
GROUP# STATUS TYPE MEMBER
IS_RECOVERY_DEST_FILE
------ ------ -------------------- ------------------------------ -------------------------
1 ONLINE
/oradata/KIN/redo01.log NO
2 ONLINE
/oradata/KIN/redo02.log NO
3 ONLINE
/oradata/KIN/redo03.log NO
SQL> select * from v$controlfile;
STATUS NAME
IS_RECOVERY_DEST_FILE BLOCK_SIZE FILE_SIZE_BLKS
---------- ------------------------------ ------------------------- ---------- --------------
/oradata/KIN/control01.ctl
NO 16384
430
/oradata/KIN/control02.ctl
NO 16384
430
/oradata/KIN/control03.ctl
NO 16384
430
4.Use dbms_backup_restore to restore Database
startup nomount;
Restore controlfile:
declare
devtype varchar2(256);
done boolean;
begin
devtype:=sys.dbms_backup_restore.deviceallocate(type=>'',ident=>'t1');
sys.dbms_backup_restore.restoresetdatafile;
sys.dbms_backup_restore.restorecontrolfileto(cfname=>'/oradata/KIN/control01.ctl');
sys.dbms_backup_restore.restorebackuppiece(done=>done,handle=>'/db/backup/full_KIN_20120917_6',params=>null);
sys.dbms_backup_restore.devicedeallocate;
end;
/
Restore datafile:
declare
devtype varchar2(256);
done boolean;
begin
devtype:=sys.dbms_backup_restore.deviceallocate(type=>'',ident=>'t1');
sys.dbms_backup_restore.restoresetdatafile;
sys.dbms_backup_restore.restoredatafileto(dfnumber=>01,toname=>'/oradata/KIN/system01.dbf');
sys.dbms_backup_restore.restoredatafileto(dfnumber=>02,toname=>'/oradata/KIN/undotbs01.dbf');
sys.dbms_backup_restore.restoredatafileto(dfnumber=>03,toname=>'/oradata/KIN/sysaux01.dbf');
sys.dbms_backup_restore.restoredatafileto(dfnumber=>05,toname=>'/oradata/KIN/kin.dbf');
sys.dbms_backup_restore.restorebackuppiece(done=>done,handle=>'/db/backup/full_KIN_20120917_5',params=>null);
sys.dbms_backup_restore.devicedeallocate;
end;
/
startup mount;
Restore archive:
mkdir archive
declare
devtype varchar2(256);
done boolean;
begin
devtype:=sys.dbms_backup_restore.deviceallocate(type=>'',ident=>'t1');
sys.dbms_backup_restore.restoresetarchivedlog(destination=>'/oradata/KIN/archive');
sys.dbms_backup_restore.restorearchivedlog(thread=>1,sequence=>26);
sys.dbms_backup_restore.restorearchivedlog(thread=>1,sequence=>27);
sys.dbms_backup_restore.restorearchivedlog(thread=>1,sequence=>28);
sys.dbms_backup_restore.restorearchivedlog(thread=>1,sequence=>29);
sys.dbms_backup_restore.restorebackuppiece(done=>done,handle=>'/db/backup/arch_KIN_20120917_7',params=>null);
sys.dbms_backup_restore.devicedeallocate;
end;
/
recover database using backup controlfile until cancel;
alter database open resetlogs;
OS:RHEL5.4 64bit
1.fullbackup
[oracle@Kin ~]$ rman target /
Recovery Manager: Release 10.2.0.5.0 - Production on Mon Sep 17 17:00:14 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: KIN (DBID=2123478169)
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS;
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 '/oracle/oracle10g/dbs/snapcf_KIN.f'; # default
RMAN> backup database format '/db/backup/full_%d_%T_%s';
Starting backup at 17-SEP-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=158 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/oradata/KIN/system01.dbf
input datafile fno=00002 name=/oradata/KIN/undotbs01.dbf
input datafile fno=00003 name=/oradata/KIN/sysaux01.dbf
input datafile fno=00005 name=/oradata/KIN/kin.dbf
channel ORA_DISK_1: starting piece 1 at 17-SEP-12
channel ORA_DISK_1: finished piece 1 at 17-SEP-12
piece handle=/db/backup/full_KIN_20120917_5 tag=TAG20120917T170520 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 17-SEP-12
channel ORA_DISK_1: finished piece 1 at 17-SEP-12
piece handle=/db/backup/full_KIN_20120917_6 tag=TAG20120917T170520 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:05
Finished backup at 17-SEP-12
2.archivelog backup
RMAN> backup format '/db/backup/arch_%d_%T_%s' archivelog all delete input;
Starting backup at 17-SEP-12
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=26 recid=16 stamp=794250422
input archive log thread=1 sequence=27 recid=17 stamp=794250423
input archive log thread=1 sequence=28 recid=18 stamp=794250427
input archive log thread=1 sequence=29 recid=19 stamp=794250508
channel ORA_DISK_1: starting piece 1 at 17-SEP-12
channel ORA_DISK_1: finished piece 1 at 17-SEP-12
piece handle=/db/backup/arch_KIN_20120917_7 tag=TAG20120917T170828 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/oradata/KIN/archive/KIN_1_26_790937753.arc recid=16 stamp=794250422
archive log filename=/oradata/KIN/archive/KIN_1_27_790937753.arc recid=17 stamp=794250423
archive log filename=/oradata/KIN/archive/KIN_1_28_790937753.arc recid=18 stamp=794250427
archive log filename=/oradata/KIN/archive/KIN_1_29_790937753.arc recid=19 stamp=794250508
Finished backup at 17-SEP-12
RMAN> list backup of controlfile;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Full 6.77M DISK 00:00:02 05-SEP-12
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: DBFULL
Piece Name: /db/backup/dbfullbackup_KIN_20120905_3
Control File Included: Ckp SCN: 471210 Ckp time: 05-SEP-12
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6 Full 6.80M DISK 00:00:03 17-SEP-12
BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20120917T170520
Piece Name: /db/backup/full_KIN_20120917_6
Control File Included: Ckp SCN: 476736 Ckp time: 17-SEP-12
3.Query the file location
[oracle@Kin backup]$ sqlplus '/as sysdba'
SQL*Plus: Release 10.2.0.5.0 - Production on Mon Sep 17 17:15:40 2012
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/oradata/KIN/system01.dbf
/oradata/KIN/undotbs01.dbf
/oradata/KIN/sysaux01.dbf
/oradata/KIN/kin.dbf
GROUP# STATUS TYPE MEMBER
IS_RECOVERY_DEST_FILE
------ ------ -------------------- ------------------------------ -------------------------
1 ONLINE
/oradata/KIN/redo01.log NO
2 ONLINE
/oradata/KIN/redo02.log NO
3 ONLINE
/oradata/KIN/redo03.log NO
SQL> select * from v$controlfile;
STATUS NAME
IS_RECOVERY_DEST_FILE BLOCK_SIZE FILE_SIZE_BLKS
---------- ------------------------------ ------------------------- ---------- --------------
/oradata/KIN/control01.ctl
NO 16384
430
/oradata/KIN/control02.ctl
NO 16384
430
/oradata/KIN/control03.ctl
NO 16384
430
4.Use dbms_backup_restore to restore Database
startup nomount;
Restore controlfile:
declare
devtype varchar2(256);
done boolean;
begin
devtype:=sys.dbms_backup_restore.deviceallocate(type=>'',ident=>'t1');
sys.dbms_backup_restore.restoresetdatafile;
sys.dbms_backup_restore.restorecontrolfileto(cfname=>'/oradata/KIN/control01.ctl');
sys.dbms_backup_restore.restorebackuppiece(done=>done,handle=>'/db/backup/full_KIN_20120917_6',params=>null);
sys.dbms_backup_restore.devicedeallocate;
end;
/
Restore datafile:
declare
devtype varchar2(256);
done boolean;
begin
devtype:=sys.dbms_backup_restore.deviceallocate(type=>'',ident=>'t1');
sys.dbms_backup_restore.restoresetdatafile;
sys.dbms_backup_restore.restoredatafileto(dfnumber=>01,toname=>'/oradata/KIN/system01.dbf');
sys.dbms_backup_restore.restoredatafileto(dfnumber=>02,toname=>'/oradata/KIN/undotbs01.dbf');
sys.dbms_backup_restore.restoredatafileto(dfnumber=>03,toname=>'/oradata/KIN/sysaux01.dbf');
sys.dbms_backup_restore.restoredatafileto(dfnumber=>05,toname=>'/oradata/KIN/kin.dbf');
sys.dbms_backup_restore.restorebackuppiece(done=>done,handle=>'/db/backup/full_KIN_20120917_5',params=>null);
sys.dbms_backup_restore.devicedeallocate;
end;
/
startup mount;
Restore archive:
mkdir archive
declare
devtype varchar2(256);
done boolean;
begin
devtype:=sys.dbms_backup_restore.deviceallocate(type=>'',ident=>'t1');
sys.dbms_backup_restore.restoresetarchivedlog(destination=>'/oradata/KIN/archive');
sys.dbms_backup_restore.restorearchivedlog(thread=>1,sequence=>26);
sys.dbms_backup_restore.restorearchivedlog(thread=>1,sequence=>27);
sys.dbms_backup_restore.restorearchivedlog(thread=>1,sequence=>28);
sys.dbms_backup_restore.restorearchivedlog(thread=>1,sequence=>29);
sys.dbms_backup_restore.restorebackuppiece(done=>done,handle=>'/db/backup/arch_KIN_20120917_7',params=>null);
sys.dbms_backup_restore.devicedeallocate;
end;
/
recover database using backup controlfile until cancel;
alter database open resetlogs;
相关文章推荐
- DB2的备份(backup)和恢复(RESTORE)数据库方法
- 利用dbms_backup_restore恢复数据库
- 利用dbms_backup_restore恢复数据库
- dbms_backup_restore恢复数据库
- 使用dbms_backup_restore包恢复数据库学习
- DB2的备份(backup)和恢复(RESTORE)数据库方法
- DB2的备份(backup)和恢复(RESTORE)数据库方法
- 利用dbms_backup_restore恢复数据库
- DB2的备份(backup)和恢复(RESTORE)数据库方法
- DB2的备份(backup)和恢复(RESTORE)数据库方法
- DB2的备份(backup)和恢复(RESTORE)数据库方法
- 手动备份(BACKUP)、恢复(RESTORE)数据库
- 数据库恢复报RMAN-06026,尝试dbms_backup_restore包进行恢复
- DB2的备份(backup)和恢复(RESTORE)数据库方法
- To restore the database on a new host-将数据库恢复至一个新的主机上
- shrink log和查询数据库 backup,restore,shrink 进度 和 还原历史 的sql (for sqlserver)re
- postgresql使用pg_dump、pg_restore备份及恢复数据库
- 应对RMAN-06026错误,使用dbms_backup_restore进行恢复
- RESTORE DATABASE is terminating abnormally. (Microsoft SQL Server, Error: 3154)同一台服务器上如何恢复两个数据库
- 数据库Backup/restore, 数据库同步, 数据库比较(Schema,Data)