Oracle 12c|RMAN (FROM SERVICE)

在12cR1开始,RMAN提供了一个from service的子句让备库可以通过网络来执行recover和restore命令。

在以下情况下可以使用这个新特性呢

  • 当备库出现GAP,而主库丢失归档需要做增量备份的时候

  • 当备库丢失数据文件、控制文件以及表空间的需要restore的时候

1、检查备库 GAP 的情况

备库状态:

SQL> select * from v$archive_gap;

   THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#     CON_ID
---------- ------------- -------------- ----------
         1            21             21          1

SQL>  select current_scn from v$database;

CURRENT_SCN
-----------
    1808808

 

主库scn :
 

SQL>  select current_scn from v$database;

CURRENT_SCN
-----------
    1810297

 

2、备库通过from service子句进行增量恢复

将备库启动到nomount 状态,重建控制文件

RMAN> restore standby controlfile from service orclst;

Starting restore at 09-SEP-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=36 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: using network backup set from service orclst
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/home/oracle/app/oracle/oradata/ORCL/controlfile/o1_mf_gq1mg6l6_.ctl
Finished restore at 09-SEP-19

 

3、为防止在GAP期间有新增的数据文件 ,可以在主库查询断档之后主库新增的数据文件(若没有新增数据文件,这步可以跳过)

SQL> select FILE#,to_char(CREATION_TIME,'yyyy-mm-dd hh24:mi:ss') CREATION_TIME,STATUS,LAST_TIME,name from v$datafile where CREATION_CHANGE#>1808808;

no rows selected

SQL> /

     FILE# CREATION_TIME       STATUS  LAST_TIME
---------- ------------------- ------- ------------
NAME
------------------------------
         2 2019-09-09 02:50:53 ONLINE
/home/oracle/app/oracle/oradat
a/ORCLST/datafile/user01.dbf

 

通过from service恢复命令将新增的数据文件通过网络在备库恢复。

如果这里不用 set newname 指定 文件的目录及名称,那么文件名字和存放的目录会和主库一样。

RMAN> run
2> {
3> SET NEWNAME FOR DATABASE TO '/home/oracle/app/oracle/oradata/ORCL/datafile/%f_%U';
4> RESTORE DATAFILE 2 FROM SERVICE orclst;
5> }

executing command: SET NEWNAME

Starting restore at 09-SEP-19
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: using network backup set from service orclst
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00002 to /home/oracle/app/oracle/oradata/ORCL/datafile/2_data_D-ORCL_TS-USERS_FNO-2
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 09-SEP-19

4、将数据文件注册到控制文件:

RMAN>  catalog start with '/home/oracle/app/oracle/oradata/ORCL/datafile/';

searching for all files that match the pattern /home/oracle/app/oracle/oradata/ORCL/datafile/

List of Files Unknown to the Database
=====================================
File Name: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_system_gq1mcdxb_.dbf
File Name: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_gq1mdjd5_.dbf
File Name: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_gq1mf9p5_.dbf
File Name: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_users_gq1mfbw6_.dbf
File Name: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_temp_gq1mgfj6_.tmp

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...

 

5、至此,可以进行增量恢复了 ,在from service句式中还是可以使用常规备份时候使用的参数

  • SECTION SIZE (在传输时使用并发备份集传输)

  • USING COMPRESSED BACKUPSET (在传输时使用压缩,减轻网络压力)

RMAN>  recover database from service orclst noredo SECTION SIZE 1G USING COMPRESSED BACKUPSET;

Starting recover at 09-SEP-19
using channel ORA_DISK_1
skipping datafile 2; already restored to SCN 1820457
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service orclst
destination for restore of datafile 00001: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_system_gq1mcdxb_.dbf
channel ORA_DISK_1: restoring section 1 of 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service orclst
destination for restore of datafile 00003: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_gq1mdjd5_.dbf
channel ORA_DISK_1: restoring section 1 of 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service orclst
destination for restore of datafile 00004: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_gq1mf9p5_.dbf
channel ORA_DISK_1: restoring section 1 of 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service orclst
destination for restore of datafile 00007: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_users_gq1mfbw6_.dbf
channel ORA_DISK_1: restoring section 1 of 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

Finished recover at 09-SEP-19

RMAN> 

至此,恢复过程已经完成

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

huangliang0703

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值