2010年(61)
分类: Oracle
2010-01-26 11:11:08
归档日志对于介质恢复相当关键,其虽然不像控制文件那样一旦损坏则数据库马上崩溃,但重要性丝毫不减。只要拥有相应的归档日志文件,就能确保我们将数据库恢复到备份之后的任意时刻。在RMAN中备份归档日志有以下两种方式:
BACKUP ARCHIVELOG 命令的使用如下所示:
RMAN> BACKUP ARCHIVELOG ALL;
Starting backup at 29-MAR-09
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=27 recid=1 stamp=682798250
input archive log thread=1 sequence=28 recid=2 stamp=682798255
input archive log thread=1 sequence=29 recid=3 stamp=682805568
channel ORA_DISK_1: starting piece 1 at 29-MAR-09
channel ORA_DISK_1: finished piece 1 at 29-MAR-09
piece handle=F:\ORACLE\PRODUCT\10.2.0\DB_2\DATABASE\0NKB5IA0_1_1 tag=TAG20090329T201248 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
Finished backup at 29-MAR-09BACKUP ARCHIVELOG 命令比较灵活, ALL 是指备份当前所有可访问到的归档文件,你还可以通过 UNTIL 、 SCN 、 TIME 、 SEQUENCE 等参数灵活指定要备份的归档区间,这里不再一一演示,感兴趣的朋友可以自行尝试。
执行BACKUP命令时指定PLUS ARCHIVELOG子句,如下所示:
RMAN> BACKUP CURRENT CONTROLFILE PLUS ARCHIVELOG;
Starting backup at 29-MAR-09
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=27 recid=1 stamp=682798250
channel ORA_DISK_1: starting piece 1 at 29-MAR-09
channel ORA_DISK_1: finished piece 1 at 29-MAR-09
piece handle=F:\ORACLE\PRODUCT\10.2.0\DB_2\DATABASE\0KKB5B5B_1_1 tag=TAG20090329T181050 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 29-MAR-09
Starting backup at 29-MAR-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
channel ORA_DISK_1: starting piece 1 at 29-MAR-09
channel ORA_DISK_1: finished piece 1 at 29-MAR-09
piece handle=F:\ORACLE\PRODUCT\10.2.0\DB_2\DATABASE\0LKB5B5D_1_1 tag=TAG20090329T181053 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 29-MAR-09
Starting backup at 29-MAR-09
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=28 recid=2 stamp=682798255
channel ORA_DISK_1: starting piece 1 at 29-MAR-09
channel ORA_DISK_1: finished piece 1 at 29-MAR-09
piece handle=F:\ORACLE\PRODUCT\10.2.0\DB_2\DATABASE\0MKB5B5G_1_1 tag=TAG20090329T181055 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 29-MAR-09在备份控制文件之前首先对所有归档文件进行备份。
PLUS ARCHIVELOG 的方式与上种有什么区别呢?区别太明显了,BACKUP...PLUS ARCHIVELOG命令在备份过程中会依次执行下列步骤:
1 )运行ALTER SYSTEM ARCHIVE LOG CURRENT语句对当前 R edolog 进行归档。
2 )执行BACKUP ARCHIVELOG ALL命令备份所有已归档日志。
3 )执行BACKUP命令对指定项进行备份。
4 )再次运行ALTER SYSTEM ARCHIVE LOG CURRENT对当前 R edolog 归档。
5 )对新生成的尚未备份的归档文件进行备份。
在完成归档日志文件备份后,我们需要删除已备份过的归档文件(归档文件记录下了数据库进行的所有操作,如果您的数据库操作频繁而且量大,那归档文件的大小也是相当恐怖,备份后删除释放存储空间是相当有必要的)。RMAN提供了DELETE ALL INPUT参数,加在BACKUP命令后,则会在完成备份后自动删除归档目录中已备份的归档日志。
完成备份之后,可以通过下列命令查看已备份的归档日志片段: