标签:open fast 覆盖 selected format finish home 记录 select
先在备库上找出控制文件的路径,通过和主库一样,不过为了以防万一,还是check为好。
SQL> select name from v$controlfile;
NAME -------------------------------------------------------------------------------- /Oracle/app/oracle/oradata/powerdes/control01.ctl /oracle/app/oracle/fast_recovery/powerdes/control02.ctl
SQL> |
在主库上备份当前的控制文件,记得生成的备份文件要在执行全备之前生成,而且命令行也是带for standby字样的backup current controlfile for standby format‘/home/oracle/ctlfile.bak‘才行,也可以手动提前生成。
RMAN> backup current controlfile for standby format ‘/home/oracle/ctlfile.bak‘;
Starting backup at 2016-11-23 21:20:41 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set including standby control file in backup set channel ORA_DISK_1: starting piece 1 at 2016-11-23 21:20:42 channel ORA_DISK_1: finished piece 1 at 2016-11-23 21:20:43 piece handle=/home/oracle/ctlfile.bak tag=TAG20161123T212041 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2016-11-23 21:20:43
RMAN> |
然后等备份任务结束后,在主库上,将备份前生成的控制文件、最近的一份备份文件到备库的相同目录:
scp /oracle/app/oracle/oradata/powerdes/control01.ctl 192.168.3.112:/home/oracle/ scp -r /data/backup/data/2016-11-23 192.168.3.112:/home/oracle/
|
获取备库的tns:(我的是earth_m2)
cat $ORACLE_HOME/network/admin/tnsnames.ora
earth_m2 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.3.112)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = powerdes) ) ) |
(1)查看主库备库SID名字是否统一,这个很重要
# 备库: [oracle@t1_dbm1_3_112 data]$ echo $ORACLE_SID powerdes [oracle@t1_dbm1_3_112 data]$
# 主库: [oracle@t1_dbm1_3_111 ~]$ echo $ORACLE_SID powerdes [oracle@t1_dbm1_3_111 ~]$
|
(2)查看主库备份传输密码是否一致:
# 备库: [oracle@t1_dbm1_3_112 dbs]$ cd $ORACLE_HOME/dbs [oracle@t1_dbm1_3_112 dbs]$ strings orapwpowerdes ]\[Z ORACLE Remote Password file INTERNAL 89F7167638478F13 0Cv# B6E56CBCA47429E2 [oracle@t1_dbm1_3_112 dbs]$
# 主库: [oracle@t1_dbm1_3_111 ~]$ cd $ORACLE_HOME/dbs [oracle@t1_dbm1_3_111 dbs]$ strings orapwpowerdes ]\[Z ORACLE Remote Password file INTERNAL 89F7167638478F13 0Cv# B6E56CBCA47429E2 [oracle@t1_dbm1_3_111 dbs]$ |
在备库上,直接copy覆盖控制文件
cp /home/oracle/ctlfile.bak /oracle/app/oracle/oradata/powerdes/control01.ctl cp /home/oracle/ctlfile.bak /oracle/app/oracle/fast_recovery/powerdes/control02.ctl |
然后启动到nomount状态
SQL> startup nomount ORACLE instance started.
Total System Global Area 8551575552 bytes Fixed Size 2270360 bytes Variable Size 7247760232 bytes Database Buffers 1291845632 bytes Redo Buffers 9699328 bytes SQL> |
在主库上,使用rman登录远程备库earth_m2
[oracle@t1_dbm1_3_111 ~]$ rlwrap rman target / auxiliary sys/04181123@earth_m2
Recovery Manager: Release 11.2.0.4.0 - Production on Wed Nov 23 20:05:54 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: POWERDES (DBID=3481287162) connected to auxiliary database: POWERDES (not mounted)
RMAN>
|
在rman命令行里面执行恢复命令:
run {
allocate auxiliary channel c1 devicetype disk;
allocate auxiliary channel c2 devicetype disk;
duplicate target database for standbynofilenamecheck dorecover;
release channel c1;
release channel c2;
}
#nofilenamecheck:必须指定NOFILENAMECHECK参数,避免覆盖primary数据库的当前的数据文件。另外主从路径一致,不需要执行文件路径以及check了
#release :这是关闭 前两行开启的通道
执行过程比较漫长,屏幕滚动信息比较多,这里不贴出来了,省略过……
执行命令后,需要很长时间,需要等待,因为需要写入文件到备库的数据文件目录里面,找个时候,在备库的alert log后台有如下记录日志,表明正在写数据文件:
Full restore complete of datafile 4 /oracle/app/oracle/oradata/powerdes/users01.dbf. Elapsed time: 0:00:00 checkpoint is 32945676 last deallocation scn is 3 Wed Nov 23 20:14:42 2016 Full restore complete of datafile 3 /oracle/app/oracle/oradata/powerdes/undotbs01.dbf. Elapsed time: 0:00:05 checkpoint is 32945676 last deallocation scn is 32897307 Undo Optimization current scn is 32934775 Wed Nov 23 20:15:50 2016 Full restore complete of datafile 5 /oracle/app/oracle/oradata/powerdes/example01.dbf. Elapsed time: 0:01:18 checkpoint is 32945676 last deallocation scn is 32806636 ………… |
最后rman命令行里面duplicate命令执行完,窗口界面上有如下报错信息:
Signalling error 1152 for datafile 1! Errors in file /oracle/app/oracle/diag/rdbms/earth_m2/powerdes/trace/powerdes_pr00_4069.trc: ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below ORA-01152: file 1 was not restored from a sufficiently old backup ORA-01110: data file 1: ‘/oracle/app/oracle/oradata/powerdes/system01.dbf‘ ORA-1547 signalled during: alter database recover cancel... ^C |
有报错没有关系,接下来直接开始应用日志,启动归档日志传输,通过应用归档日志来保证主备数据的一致性:
# 先开始启动传输开始应用日志 SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
SQL># 实时观察应用日志状态 SQL> select sequence#,applied from v$archived_log order by sequence# asc; …… SEQUENCE# APPLIED ---------- --------- 2334 YES 2335 YES
2301 rows selected.
SQL> # 等观察应用日志结束后,退出日志传输 SQL> alter database recover managed standby database cancel;
Database altered.
SQL> # 将备库从mount启动到open状态 SQL> alter database open;
Database altered.
SQL> # 查看备库状态,就会变成READ ONLY SQL> select database_role,open_mode from v$database;
DATABASE_ROLE OPEN_MODE ---------------- -------------------- PHYSICAL STANDBY READ ONLY
SQL> # 然后再次启动日志应用 SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
SQL> # 查看open_mode,有了READ ONLY WITH APPLY字样,OK SQL> select database_role,open_mode from v$database;
DATABASE_ROLE OPEN_MODE ---------------- -------------------- PHYSICAL STANDBY READ ONLY WITH APPLY
SQL> |
至此,Data Guard备库修复完成,如果遇到了ORA-01152问题,不需要慌张,可以试试应用日志来恢复数据。
ORACLE 11g 用Duplicate恢复Data Guard 备库详细过程
标签:open fast 覆盖 selected format finish home 记录 select
原文地址:http://www.cnblogs.com/andy6/p/6099985.html