标签:执行 集中 还原数据文件 one test stand exe 安全 complete
一、异机恢复,restore database,recover database
二、 duplicate target database for standby from active database;
三、 duplicate target database for standby
区别:
对主库的影响:
异机恢复,使用主库传输过来的备份,手工搭建物理DG,影响最小,安全系数最高,三种方式对比操作复杂 --手动挡
duplicate from active database 使用主库在线backup as copy 在线对主库数据文件进行操作系统拷贝备份,影响最大,安全系数最低,操作最简单 --自动驾驶
duplicate fro standby 使用主库传输的备份进行恢复,与异机恢复在于,当主备文件路径不同时,可以使用参数,自动转换,而异机恢复 RMAN SET指定 ,影响也小,安全--半自动
#根据恢复应用及参数调整做出说明:
1.1控制文件
#主库备份控制文件
RMAN> backup format ‘/u01/app/rman/control%U‘ current controlfile for standby;
#备库restore控制文件,从备份片中还原
RMAN> restore standby controlfile from ‘/picclife/app/rman/control1rsvlvau_1_1‘;
1.2日志文件目录修改 命令 ,执行修改--备库Mount状态下
# set linesize 200
set heading off
set feedback off
spool /home/oracle/rename.sql
select ‘alter database rename file ‘‘‘||member||‘‘‘ to ‘||‘‘‘/picclife/app/oracle/oradata/ENV/‘||substr(member,instr(member,‘/‘,‘-1‘)+1)||‘‘‘‘||‘;‘ from v$logfile;
spool off
1.3数据文件修改路径--两种情况:
date_file_1可以在数据库Mount状态直接alter database rename修改成功
data_file_2 rename不成功,,在RMANrestore 还原数据文件,set指定路径
1.3.1 data_file_1=>
#执行,输出修改sql,执行操作
select ‘alter database rename file ‘‘‘||name||‘‘‘ to ‘||‘‘‘/picclife/app/oracle/oradata/ENV/‘||substr(name,instr(name,‘/‘,‘-1‘)+1)||‘‘‘‘ ||‘;‘ from v$datafile;
1.3.2data_file_2=>
#如果上述操作:数据文件无法rename,则执行如下命令:输出SQL,不执行
>spool /home/oracle/newname.sql
select ‘set newname for datafile ‘||file#||‘ to "/picclife/app/oracle/oradata/ENV/‘||substr(name,instr(name,‘/‘,‘-1‘)+1)||‘";‘ from v$datafile;
1.4 restore搭建备库
#可以使用RMAN中的newname,临时性:将restore还原的路径,修改为指定
# switch datafile all; ---永久性的,直接修改控制文件中记录的数据文件目录
RMAN> 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 "/picclife/app/oracle/oradata/ENV/system01.dbf";
set newname for datafile 2 to "/picclife/app/oracle/oradata/ENV/sysaux01.dbf";
set newname for datafile 3 to "/picclife/app/oracle/oradata/ENV/undotbs01.dbf";
set newname for datafile 4 to "/picclife/app/oracle/oradata/ENV/users01.dbf";
set newname for datafile 5 to "/picclife/app/oracle/oradata/ENV/example01.dbf";
set newname for datafile 6 to "/picclife/app/oracle/oradata/ENV/test1";
set newname for datafile 7 to "/picclife/app/oracle/oradata/ENV/lin_tbs";
set newname for datafile 8 to "/picclife/app/oracle/oradata/ENV/undo_tb12.dbf";
set newname for datafile 9 to "/picclife/app/oracle/oradata/ENV/sink_tbs";
set newname for datafile 10 to "/picclife/app/oracle/oradata/ENV/index01.dbf";
set newname for datafile 11 to "/picclife/app/oracle/oradata/ENV/lmtbsb01.dbf";
set newname for datafile 12 to "/picclife/app/oracle/oradata/ENV/lmtbsb02.dbf";
set newname for datafile 13 to "/picclife/app/oracle/oradata/ENV/lmtbsb03.dbf";
set newname for datafile 14 to "/picclife/app/oracle/oradata/ENV/lmtbsb04.dbf";
set newname for datafile 15 to "/picclife/app/oracle/oradata/ENV/sm_a.dbf";
set newname for datafile 16 to "/picclife/app/oracle/oradata/ENV/bigts.big";
set newname for datafile 17 to "/picclife/app/oracle/oradata/ENV/rm_a.dbf";
set newname for datafile 18 to "/picclife/app/oracle/oradata/ENV/lmt.dbf";
set newname for datafile 19 to "/picclife/app/oracle/oradata/ENV/undo_tb14.db";
set newname for datafile 20 to "/picclife/app/oracle/oradata/ENV/compress.dbf";
set newname for datafile 21 to "/picclife/app/oracle/oradata/ENV/compressb.dbf";
set newname for datafile 22 to "/picclife/app/oracle/oradata/ENV/compressc.dbf";
set newname for datafile 23 to "/picclife/app/oracle/oradata/ENV/tbs_01.dbf";
set newname for datafile 24 to "/picclife/app/oracle/oradata/ENV/tbs_02.dbf";
set newname for datafile 25 to "/picclife/app/oracle/oradata/ENV/ceshi.dbf";
restore database;
switch datafile all;
release channel c4;
release channel c3;
release channel c2;
release channel c1;
}
2.1备库参数设置:
#主备直接,路径转换参数:前主库文件路径,后备库文件路径
db_file_name_convert
/u01/app/oracle/oradata/ENMO/,/picclife/app/oracle/oradata/dage/
log_file_name_convert
/u01/app/oracle/oradata/ENMO/,/picclife/app/oracle/oradata/dage/
2.2直接在主库begin backup表空间,as copy tablespace传输至备库,end backup
duplicate target database for standby from active database;
2.3RMAN日志截取:
#操作系统密码文件自动拷贝
contents of Memory Script:
{ backup as copy reuse
targetfile ‘/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwENMO‘ auxiliary format
‘/picclife/app/oracle/product/11.2.0/dbhome_1/dbs/orapwdage‘ ;}
#控制文件自动拷贝standby 至备库参数文件指定的控制文件名称及路径
contents of Memory Script:
{ backup as copy current controlfile for standby auxiliary format ‘/picclife/app/oracle/oradata/dage/control01.ctl‘;}
#生成控制文件启动脚本,执行将备库启动到Mount状态
contents of Memory Script:
{ sql clone ‘alter database mount standby database‘;}
executing Memory Script
sql statement: alter database mount standby database
#根据参数文件db_file_name_convent参数指定转换,set newname指定新的路径
contents of Memory Script:
set newname for tempfile 1 to
"/picclife/app/oracle/oradata/dage/temp001.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/picclife/app/oracle/oradata/dage/system01.dbf";
set newname for datafile 2 to
"/picclife/app/oracle/oradata/dage/sysaux01.dbf";
set newname for datafile 3 to
"/picclife/app/oracle/oradata/dage/undotbs01.dbf";
set newname for datafile 4 to
"/picclife/app/oracle/oradata/dage/users01.dbf";
set newname for datafile 5 to
"/picclife/app/oracle/oradata/dage/example01.dbf";
#对主库数据文件进行Backup as copy 操作系统拷贝备份,传输至备库指定路径
backup as copy reuse
datafile 1 auxiliary format
"/picclife/app/oracle/oradata/dage/system01.dbf" datafile
2 auxiliary format
"/picclife/app/oracle/oradata/dage/sysaux01.dbf" datafile
3 auxiliary format
"/picclife/app/oracle/oradata/dage/undotbs01.dbf" datafile
4 auxiliary format
"/picclife/app/oracle/oradata/dage/users01.dbf" datafile
5 auxiliary format
"/picclife/app/oracle/oradata/dage/example01.dbf" ;
sql ‘alter system archive log current‘;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /picclife/app/oracle/oradata/dage/temp001.dbf in control file
executing command: SET NEWNAME
#省略部分日志,重复
executing command: SET NEWNAME
Starting backup at 15-JAN-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/ENMO/undotbs01.dbf
output file name=/picclife/app/oracle/oradata/dage/undotbs01.dbf tag=TAG20180408T020947
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:46
#省略部分日志,重复
sql statement: alter system archive log current
#执行修改控制文件中数据文件的路径:提交修改
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=1 STAMP=965518459 file name=/picclife/app/oracle/oradata/dage/system01.dbf
datafile 2 switched to datafile copy
#省略部分日志,重复
3.1主库全备
run{ sql ‘alter system archive log current‘;
backup database format ‘/tmp/full/full_back_%U.bak‘;
backup format ‘/tmp/full/arch_%U.log‘ archivelog all delete input;
backup current controlfile for standby format=‘/tmp/full/contr_standby%U‘;}
3.2直接执行duplicate target database for standby报错:需要将主库的备份,传输至备库
#主库备份:且备份文件,备库能读取
$ scp full/* root@dage:/tmp/full
#修改权限:
# chown oracle.oinstall *
#再次执行 OK
$ rman target sys/oracle@enmo auxiliary sys/oracle@dage
duplicate target database for standby;
3.3日志
#使用备份的standby 控制文件
{restore clone standby controlfile;}
#从备份文件中提取备份信息
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /tmp/full/contr_standby2osvpprb_1_1
channel ORA_AUX_DISK_1: piece handle=/tmp/full/contr_standby2osvpprb_1_1 tag=TAG20180408T031347
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/picclife/app/oracle/oradata/dage/control01.ctl
Finished restore at 16-JAN-18
#启动到mount状态
{ sql clone ‘alter database mount standby database‘;}
executing Memory Script
sql statement: alter database mount standby database
#根据参数文件,自动set newname restore还原目录
contents of Memory Script:
{
set newname for tempfile 1 to
"/picclife/app/oracle/oradata/dage/temp001.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/picclife/app/oracle/oradata/dage/system01.dbf";
set newname for datafile 2 to
"/picclife/app/oracle/oradata/dage/sysaux01.dbf";
set newname for datafile 3 to
"/picclife/app/oracle/oradata/dage/undotbs01.dbf";
set newname for datafile 4 to
"/picclife/app/oracle/oradata/dage/users01.dbf";
set newname for datafile 5 to
"/picclife/app/oracle/oradata/dage/example01.dbf";
restore
clone database
;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /picclife/app/oracle/oradata/dage/temp001.dbf in control file
executing command: SET NEWNAME
#执行restore还原操作:从备份集中获取数据!!!
executing command: SET NEWNAME
Starting restore at 16-JAN-18
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /picclife/app/oracle/oradata/dage/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /picclife/app/oracle/oradata/dage/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /picclife/app/oracle/oradata/dage/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /picclife/app/oracle/oradata/dage/users01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to /picclife/app/oracle/oradata/dage/example01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /tmp/full/full_back_2lsvppp2_1_1.bak
#确认修改控制文件记录的数据文件目录及名称
contents of Memory Script:
{ switch clone datafile all;}
executing Memory Script
#还原操作完成
datafile 1 switched to datafile copy
input datafile copy RECID=2 STAMP=965685533 file name=/picclife/app/oracle/oradata/dage/system01.dbf
datafile 2 switched to datafile copy
*格式恶心。。。
标签:执行 集中 还原数据文件 one test stand exe 安全 complete
原文地址:https://www.cnblogs.com/lvcha001/p/9081600.html