9.准备RMAN恢复工作(db2)
创建相应的目录,复制备库控制文件到相应的位置
[oracle@db2 ~]$ mkdir -p /opt/oracle/admin/tpy100/adump
[oracle@db2 ~]$ mkdir -p /opt/oracle/oradata/tpy100
[oracle@db2 ~]$ mkdir -p /opt/oracle/flash_recovery_area/tpy100
[oracle@db2 ~]$ cp /opt/oracle/dbackup/standby.ctl /opt/oracle/oradata/tpy100/control01.ctl
[oracle@db2 ~]$ cp /opt/oracle/dbackup/standby.ctl /opt/oracle/flash_recovery_area/tpy100/control02.ctl
[oracle@db2 ~]$ lsnrctl start
#启动监听
10.生成备库参数文件(db2)
SQL> shutdown immediate;
SQL> startup nomount pfile='/tmp/tpy100.pfile'
SQL> create spfile from pfile='/tmp/tpy100.pfile';
SQL> alter database mount;
11.恢复数据库(db2)
RMAN> restore database;
12.启动备库(db2)
SQL > alter database open read only;
#在这里启动的时候如果出现
ERROR at line 1:
ORA-10458: standby database requires recovery
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/opt/oracle/oradata/tpy100/system01.dbf'
先使用shutdown immediate关闭后再重新启动
SQL > alter database recover managed standby database using current logfile disconnect from session;
如果需要重启备库,则需要按如下命令进行重启
SQL> startup;
SQL> alter database recover managed standby database using current logfile disconnect from session;
注意:刚重启完你会发现主库的数据还没过来,但是过段时间就过来了,在生产环境中我们需要快速处理这个问题,以便减少宕机时间。
关闭完备库后,在主库查看
SQL> select dest_name,status,error from v$archive_dest;
DEST_NAME STATUS ERROR
------------------------------ --------
LOG_ARCHIVE_DEST_1 VALID
LOG_ARCHIVE_DEST_2 ERROR ORA-03113: end-of-file on communication channel
可以看到LOG_ARCHIVE_DEST_2是错误的,这个是因为没有连接到备库的归档路径,默认情况下Dataguard会每300秒自动连接,这边为了快读处理
解决办法:在主库执行
SQL> alter system set log_archive_dest_state_2= enable;
再查询,如果依然是如此则需要检查备库的网络及监听
测试有如下语句:
SQL> select sequence#,applied from v$archived_log;
SQL> select process,status from v$managed_standby;
SQL> select sequence# from v$log_history;
基于同一主机配置 Oracle 11g Data Guard
Oracle Data Guard (RAC+DG) 归档删除策略及脚本
Oracle 11g Data Guard Error 16143 Heartbeat failed to connect to standby 处理方法