RMAN相关

xxxx > rman target / catalog rman11g/rman11g@cat11g

Recovery Manager: Release 11.2.0.2.0 - Production on Wed Jun 18 22:24:31 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates.? All rights reserved.

connected to target database: SMSCP (DBID=1154030563)
connected to recovery catalog database

RMAN> resync catalog;

备份示例:
date;
log_file=/xxx/full_backup_${ORACLE_SID}_`date '+%Y%m%d_%H%M%S'`.log;export log_file
rman target / << EOF > ${log_file} 2>&1
sql 'alter system switch logfile';
run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate channel c5 type disk;
allocate channel c6 type disk;
allocate channel c7 type disk;
allocate channel c8 type disk;
BACKUP as compressed backupset full DATABASE FORMAT '/xxx/full_%T-%d-%u-%p' filesperset=10 plus archivelog SKIP INACCESSIBLE format '/xxx/arch_%T-%d-%u-%p.log';
backup as copy current controlfile format '/xxx/ctrl_%t-%s-%p.f';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
release channel c6;
release channel c7;
release channel c8;
}
EOF
echo "Backup finished at `date '+%Y%m%d_%H%M%S'`" >> ${log_file}
date;

恢复示例:
#RMAN> restore controlfile from '/xxx/ctrl_851797375-22-1.f';
#CATALOG START WITH '/xxxx/xxx/';

export log_file=/xxx/restore_${ORACLE_SID}_`date '+%Y%m%d_%H%M%S'`.log
rman target / << EOF > ${log_file} 2>&1
run
{
allocate channel c1 type disk ;
allocate channel c2 type disk ;
allocate channel c3 type disk ;
allocate channel c4 type disk ;
allocate channel c5 type disk ;
allocate channel c6 type disk ;
allocate channel c7 type disk ;
allocate channel c8 type disk ;
allocate channel c9 type disk ;
allocate channel c10 type disk ;
allocate channel c11 type disk ;
allocate channel c12 type disk ;
restore database;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5 ;
release channel c6 ;
release channel c7 ;
release channel c8 ;
release channel c9 ;
release channel c10;
release channel c11;
release channel c12;
}
EOF
echo "Restore finished at `date '+%Y%m%d_%H%M%S'`" >> ${log_file}

z3bi1030:fcrstg1 > cat restore0924.sh
export log_file=/xxx/restore_${ORACLE_SID}_`date '+%Y%m%d_%H%M%S'`.log
rman target / << EOF > ${log_file} 2>&1
run
{
allocate channel c1 type disk ;
allocate channel c2 type disk ;
allocate channel c3 type disk ;
allocate channel c4 type disk ;
set newname for datafile 1 to '+data_dg';
set newname for datafile 2 to '+data_dg';
set newname for datafile 3 to '+data_dg';
set newname for datafile 4 to '+data_dg';
set newname for datafile 5 to '+data_dg';
set newname for datafile 6 to '+data_dg';
set newname for datafile 7 to '+data_dg';
set newname for datafile 8 to '+data_dg';
set newname for datafile 9 to '+data_dg';
set newname for datafile 11 to '+data_dg';
set newname for datafile 12 to '+data_dg';
set newname for datafile 13 to '+data_dg';
set newname for datafile 14 to '+data_dg';
set newname for datafile 15 to '+data_dg';
set newname for datafile 16 to '+data_dg';
set newname for datafile 17 to '+data_dg';
set newname for datafile 18 to '+data_dg';
set newname for datafile 19 to '+data_dg';
set newname for datafile 21 to '+data_dg';
set newname for datafile 22 to '+data_dg';
set newname for datafile 23 to '+data_dg';
set newname for datafile 24 to '+data_dg';
set newname for datafile 25 to '+data_dg';
restore database;
switch datafile all;
recover database;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
EOF
echo "Restore finished at `date '+%Y%m%d_%H%M%S'`" >> ${log_file}
z3bi1030:fcrstg1 >
list incarnation of database;
reset database to incarnation ***;

-- 报错解决
RMAN-08512: waiting for snapshot controlfile enqueue

SELECT s.sid, username AS "User", program, module, action, logon_time
"Logon", l.*
FROM v$session s, v$enqueue_lock l
WHERE l.sid = s.sid and l.type = 'CF' AND l.id1 = 0 and l.id2 = 2;

增备与恢复:
1 从DG库取SCN
select to_char(min(checkpoint_change#)) from v$datafile_header; 9555036123902

2生产库备份。 --修改路径和SCN号-注意磁盘空间
rman target / <<EOF
run 
{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3  device type disk;
allocate channel c4  device type disk;
BACKUP as compressed backupset INCREMENTAL FROM SCN 9600357601469 DATABASE FORMAT '/xxx/standby_%U' tag 'FORSTANDBY';
backup current controlfile format '/xxx/stdctl.ctl';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
exit
EOF

3 恢复
(1) 拷贝备份到DG库
(2) DG停MRP进程并屏蔽重启RECOVERY的cron
(3) recover controlfile
rman target '/'
startup nomount;
restore controlfile from '/xxx/stdctl.ctl'; 
exit
(4) 注册备份信息
rman target '/'
catalog start with '/xxx/';   --注册备份信息
exit
(5) 恢复
rman target '/'<<EOF
RUN {
ALLOCATE CHANNEL ch00 TYPE disk; 
ALLOCATE CHANNEL ch01 TYPE disk; 
ALLOCATE CHANNEL ch02 TYPE disk; 
ALLOCATE CHANNEL ch03 TYPE disk; 
ALLOCATE CHANNEL ch04 TYPE disk; 
recover database noredo;
release channel ch00; 
release channel ch01; 
release channel ch02; 
release channel ch03; 
release channel ch04; 



exit;
EOF
(6) recover完成后shutdown
SQL> shutdown immediate

4、恢复DG同步
sqlplus '/ as sysdba'
startup nomount;
alter database mount standby database;
--alter database convert to physical standby;  
recover managed standby database parallel 16 disconnect;
alter database recover managed standby database disconnect from session parallel 16;
exit
观察下是否日志正常传输。
正常后恢复CRON

登录RMAN,连接catalog:
rman catalog username/password@catalog target /


查看已被备份的某段时间内的归档日志:
list backup of archivelog from time 'trunc(sysdate-1)+22/24' until time 'trunc(sysdate)+ 2/24';
list backup of archivelog from time 'trunc(sysdate-1)+22/24';





来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22818880/viewspace-2077094/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/22818880/viewspace-2077094/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值