rman SBT_TAPE NFS disk 模拟NBU带库 FRA
-----------------rman 将本地磁盘变成磁带-----------------------------------
##RAC 本地 /nfs----两个备份策略 cluster=n
run {
allocate channel ch00 device type 'SBT_TAPE'
PARMS="SBT_LIBRARY=oracle.disksbt,
ENV=(BACKUP_DIR=/nfs)";
backup recovery area ; }
run {
allocate channel ch00 device type 'SBT_TAPE'
PARMS="SBT_LIBRARY=oracle.disksbt,
ENV=(BACKUP_DIR=/nfs)";
restore datafile 3 ; }
run {
allocate channel ch00 device type 'SBT_TAPE'
PARMS="SBT_LIBRARY=oracle.disksbt,
ENV=(BACKUP_DIR=/nfs)";
delete obsolete device type sbt;
}
run {
allocate channel ch00 device type 'SBT_TAPE'
PARMS="SBT_LIBRARY=oracle.disksbt,
ENV=(BACKUP_DIR=/nfs)";
restore database;
recover database;
}
------------------------磁盘磁带两个策略
To maintain two disctinct retention policies for disk and tape backups.
Decide which device needs the longest recovery window - typically this will be TAPE.
Configure the default retention policy to your longest recovery window egt 60 days.
RMAN>CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 60 DAYS;
This ensures that if 'delete obsolete' is run without any further specification, your highest retention policy is always observed.
The daily housekeeping routine will then delete obsolete tape backups using the default, and delete obsolete disk backups using an explicit recovery window overriding the default.
For example, if tapes are to be kept 28 days but disk backups are kept for just 7 days:
RMAN>DELETE OBSOLETE DEVICE TYPE TAPE;
RMAN>DELETE OBSOLETE RECOVERY WINDOW OF 7 DAYS DEVICE TYPE DISK ;
RMAN> backup archivelog all delete input;
all, or until time 'sysdate -7'
RMAN> run {
backup archivelog all;
delete archivelog until time 'sysdate -1' like '/u01/archives/TEST/%';
delete archivelog until time 'sysdate -5' like '/u02/archives/TEST/%';
}
RMAN> run {
allocate channel c1 type 'sbt_tape';
set archivelog destination to '+FRA/TEST/ARCHIVELOG/2010_08_13';
restore archivelog
from time "to_date('13/08/2010-00:00:00','dd/mm/yyyy-hh24:mi:ss')"
until time "to_date('14/08/2010-00:00:00','dd/mm/yyyy-hh24:mi:ss')";
}
SQL>Select file_type, percent_space_used as used,percent_space_reclaimable as reclaimable,
number_of_files as "number" from v$recovery_area_usage;
SQL> select name, space_limit as Total_size ,space_used as Used,
SPACE_RECLAIMABLE as reclaimable ,NUMBER_OF_FILES as "number"
from V$RECOVERY_FILE_DEST;
CROSSCHECK FOREIGN ARCHIVELOG ALL;
DELETE EXPIRED FOREIGN ARCHIVELOG ALL;
backup as compressed backupset database plus archivelog ;
Delete obsolete device type disk;
crosscheck archivelog all
You have a number of choices on how to resolve a full Fast Recovery Area when no files are eligible for deletion:
1. Make more disk space available and increase DB_RECOVERY_FILE_DEST_SIZE
SQL> alter system set db_recovery_file_dest_size=xG SCOPE=BOTH; -- (larger amount)
2. Move backups from the fast recovery area to tertiary storage such as tape.
RMAN>BACKUP RECOVERY AREA;
Note : Flashback logs cannot be backed up outside the recovery area and so are not backed up by BACKUP RECOVERY AREA.
3. Run DELETE for any files that have been removed with an operating system utility. If you use host operating system commands to delete files, then the database will not be aware of the resulting free space.
RMAN>CROSSCHECK BACKUP;
RMAN>CROSSCHECK ARCHIVELOG ALL;
RMAN>Delete expired backup;
RMAN>Delete expired archivelog all;
RMAN>Delete force obsolete;
4. Make sure that your guaranteed restore points are necessary. If not, delete them
SQL>Drop restore point <restore_point_name>;
5. If flashback logs are enable then make sure you have enough space for all the flashback logs. If its not required then you can turn off flashback.
SQL>Alter database FLASHBACK OFF;
6. Review your backup retention policy and if required change the RMAN RETENTION POLICY
RMAN>CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
Exceptions :
- If RMAN is not part of backup strategy and archivelogs are going to FRA then manual intervention required for deletion of archivelogs. Periodically purse old archivelogs
for example
RMAN>Delete archivelog all completed before 'SYSDATE-7';
- By default RMAN backup goes to FRA. While taking RMAN backup if backup location explicitly specified to fast recovery area location then those backup pieces are not considered as part of FRA for auto management.
- For Archivelogs backup to FRA use USE_DB_RECOVERY_FILE_DEST rather than giving explicit path of FRA
SQL> alter system set log_archive_dest_10='LOCATION=USE_DB_RECOVERY_FILE_DEST' scope=both;
------------------------archive log 备份
RMAN> backup as compressed backupset archivelog all;
Starting backup at 02-DEC-23
current log archived
Finished Control File and SPFILE Autobackup at 02-DEC-23
RMAN> delete noprompt force archivelog all backed up 1 times to device type sbt;
没有可以删除的,因为只是备份到了disk
RMAN> run {
2> allocate channel ch00 device type 'SBT_TAPE'
3> PARMS="SBT_LIBRARY=oracle.disksbt,
4> ENV=(BACKUP_DIR=/nfs)";
5> backup recovery area ; }
released channel: ORA_DISK_1
allocated channel: ch00
channel ch00: SID=813 instance=cdb2 device type=SBT_TAPE
channel ch00: WARNING: Oracle Test Disk API
Starting backup at 02-DEC-23
specification does not match any datafile copy in the repository
skipping backup set key 82; already backed up 1 time(s)
channel ch00: starting archived log backup set
channel ch00: specifying archived log(s) in backup set
input archived log thread=2 sequence=39 RECID=407 STAMP=1154562772
input archived log thread=2 sequence=40 RECID=408 STAMP=1154562774
input archived log thread=2 sequence=41 RECID=409 STAMP=1154562778
input archived log thread=2 sequence=42 RECID=410 STAMP=1154562781
input archived log thread=2 sequence=43 RECID=411 STAMP=1154562795
channel ch00: starting piece 1 at 02-DEC-23
channel ch00: finished piece 1 at 02-DEC-23
piece handle=5f2d2eoi_175_1_1 tag=TAG20231202T235354 comment=API Version 2.0,MMS Version 8.1.3.0
RMAN> delete noprompt force archivelog all backed up 1 times to device type sbt;
Deleted 5 objects
删除了archivelog 但是磁盘和SBT都有一个备份
RMAN> alter system switch logfile;
Statement processed
RMAN> run {
2> allocate channel ch00 device type 'SBT_TAPE'
3> PARMS="SBT_LIBRARY=oracle.disksbt,
4> ENV=(BACKUP_DIR=/nfs)";
5> backup recovery area ; }
released channel: ORA_DISK_1
allocated channel: ch00
channel ch00: SID=813 instance=cdb2 device type=SBT_TAPE
channel ch00: WARNING: Oracle Test Disk API
Starting backup at 02-DEC-23
specification does not match any datafile copy in the repository
skipping backup set key 99; already backed up 1 time(s)
channel ch00: starting archived log backup set
channel ch00: specifying archived log(s) in backup set
input archived log thread=2 sequence=44 RECID=412 STAMP=1154562880
input archived log thread=2 sequence=45 RECID=413 STAMP=1154562882
input archived log thread=2 sequence=46 RECID=414 STAMP=1154562887
channel ch00: starting piece 1 at 02-DEC-23
channel ch00: finished piece 1 at 02-DEC-23
piece handle=5j2d2eqt_179_1_1 tag=TAG20231202T235509 comment=API Version 2.0,MMS Version 8.1.3.0
channel ch00: backup set complete, elapsed time: 00:00:01
Finished backup at 02-DEC-23
Starting Control File and SPFILE Autobackup at 02-DEC-23
piece handle=c-2265125454-20231202-22 comment=API Version 2.0,MMS Version 8.1.3.0
Finished Control File and SPFILE Autobackup at 02-DEC-23
released channel: ch00
RMAN> delete noprompt force archivelog all backed up 1 times to device type sbt;
Deleted 3 objects
只是备份FRA,Archivelog也是FRA一部分,SBT上有一个备份,DISK上没有备份,删了就没了
RMAN> delete noprompt force archivelog all;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=813 instance=cdb2 device type=DISK
specification does not match any archived log in the repository
本地和FRA都没了,删不了。。。。。。。
RMAN> alter system switch logfile;
RMAN> run {
2> allocate channel ch00 device type 'SBT_TAPE'
3> PARMS="SBT_LIBRARY=oracle.disksbt,
4> ENV=(BACKUP_DIR=/nfs)";
5> backup recovery area ; }
RMAN> delete noprompt force archivelog all backed up 1 times to device type disk;
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=813 instance=cdb2 device type=DISK
-----disk 确实没有备份,删除策略不生效
RMAN> backup recovery area; --------------backup fra 到disk 不行
RMAN> backup recovery area device type disk;
Starting backup at 02-DEC-23
using channel ORA_DISK_1
specification does not match any datafile copy in the repository
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 12/02/2023 23:56:56
RMAN-06603: TO DESTINATION option must be specified with RECOVERY AREA, RECOVERY FILES or DB_RECOVERY_FILE_DEST on disk device
RMAN-01007: at line 1 column 22 file: standard input
RMAN> delete noprompt force archivelog all backed up 1 times to device type disk;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=813 instance=cdb2 device type=DISK
---备份到本地可以删除也可以本地恢复
RMAN> backup archivelog all;
Finished Control File and SPFILE Autobackup at 02-DEC-23
RMAN> delete noprompt force archivelog all backed up 1 times to device type disk;
Deleted 5 objects
RMAN> restore archivelog from sequence 47 thread 2;
Starting restore at 02-DEC-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=47
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=48
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=49
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=50
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=51
channel ORA_DISK_1: reading from backup piece +DATA1/CDB/BACKUPSET/2023_12_02/annnf0_tag20231202t235747_0.318.1154516267
channel ORA_DISK_1: piece handle=+DATA1/CDB/BACKUPSET/2023_12_02/annnf0_tag20231202t235747_0.318.1154516267 tag=TAG20231202T235747
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 02-DEC-23
RMAN>