Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1760197
  • 博文数量: 150
  • 博客积分: 660
  • 博客等级: 上士
  • 技术积分: 2480
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-08 11:39
文章分类

全部博文(150)

文章存档

2019年(4)

2018年(36)

2017年(53)

2016年(7)

2015年(3)

2014年(3)

2013年(27)

2012年(2)

2011年(1)

2006年(1)

2005年(13)

分类: Oracle

2005-12-15 14:06:22

rman 全备份自动执行脚本

rman 全备份自动执行脚本


1. 自动执行脚本定于凌晨4点执行

0 4 * * * /oracle/OraHome/bin/rman @/space/oracle_backup/backup.rman >>/space/oracle_backup/backup.log 2>&1

将标准输出和标准错误重定向到日志文件中

2. 自动全备份backup.rman内容
bash-2.05$ more backup.rman
connect target /                 
connect catalog rman/rman;
list backup;
report obsolete;
delete obsolete;
backup full tag testok format '/space/oracle_backup/%d.dbf.%T' database;

%d : 数据库名字
%T :yyyymmdd格式的日期


3. 删除错误的备份
此备份已经在os级别上被物理删除了,但是catalog还有信息,383为backup set号码。
RMAN> delete backupset 383 ;

using channel ORA_DISK_1

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
384     383     1   1   UNAVAILABLE DISK        /data/ora_backup/testok20050929.dbf

Do you really want to delete the above objects (enter YES or NO)? y
deleted backup piece
backup piece handle=/data/ora_backup/testok20050929.dbf recid=12 stamp=570278433
Deleted 1 objects


383:可以通过list backup命令看出来

4. 删除错误的归档日志
4.1 错误信息如下:
RMAN> delete obsolete;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=50 devtype=DISK
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           1061   06-DEC-05        
  Backup Piece       1062   06-DEC-05          /oracle/testok.dbf.20051206
Archive Log          424    29-SEP-05          /oracle/OraHome/dbs/arch1_56.dbf

Do you really want to delete the above objects (enter YES or NO)? y
deleted backup piece
backup piece handle=/oracle/testok.dbf.20051206 recid=20 stamp=576350873
Deleted 1 objects

RMAN-06207: WARNING: 1 objects could not be deleted for DISK channel(s) due
RMAN-06208:          to mismatched status.  Use CROSSCHECK command to fix status
List of Mismatched objects
==========================
  Object Type   Filename/Handle
--------------- ---------------------------------------------------
Archivelog      /oracle/OraHome/dbs/arch1_56.dbf

4.2 解决办法:

RMAN> CROSSCHECK archivelog 424;

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=50 devtype=DISK
validation failed for archived log
archive log filename=/oracle/OraHome/dbs/arch1_56.dbf recid=55 stamp=570319641
Crosschecked 1 objects
4.3 然后删除

RMAN> report obsolete;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Report of obsolete backups and copies
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Archive Log          424    29-SEP-05          /oracle/OraHome/dbs/arch1_56.dbf

RMAN> delete obsolete;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Archive Log          424    29-SEP-05          /oracle/OraHome/dbs/arch1_56.dbf

Do you really want to delete the above objects (enter YES or NO)? y
deleted archive log
archive log filename=/oracle/OraHome/dbs/arch1_56.dbf recid=55 stamp=570319641
Deleted 1 objects


5. 磁盘空间不足,删除归档日志时,查看当前的归档日志情况

sqlplus '/as sysdba'
archive log list ;

6. 关于操作系统之间的区别

   上例是在Solaris 9上 ,用oracle直接加到crontab里面就可正确执行,但是linux 上执行有问题,经过修改增加个脚本来调用这个全备份的脚本

内容如下:首先设置oracle用户的变量;然后全路径运行ran @backup.rman

阅读(6881) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~