oracle增量恢复dg备库,Oracle 12c 新特性 --- RMAN通过网络服务恢复DG主备库数据

https://www.cndba.cn/leo1990/article/2081

RESTORE operations can copy data files from one database to another (for example, a physical standby database to a primary database) over the network. Network-enabled restore also supports compression and multisection options.

The RESTORE operation reduces data file copy time from one database to another by reducing data transfer sizes and by better parallelizing restore workload for large data files across multiple channels.

恢复操作可以将数据文件从一个数据库复制到另一个数据库(例如,一个物理备用数据库到主数据库)。支持网络的恢复也支持压缩和多节选项。

还原操作通过减少数据传输大小,并通过多个通道的大型数据文件更好的并行化还原工作负载,将数据文件复制时间从一个数据库减少到另一个数据库。

RMAN can perform recovery by fetching an incremental backup, over the network, from a primary database and then applying this incremental backup to the physical standby database. RMAN is connected as TARGET to the physical standby database. The recovery process is optimized by restoring only the used data blocks in a data file. Use the FROM SERVICE clause to specify the service name of the primary database from which the incremental backup must be fetched.

To use multisection backup sets during the recovery process, specify the SECTION SIZE clause in the RECOVER command. To transfer the required files from the primary database as encrypted backup sets, use the SET ENCRYPTION command before the RESTORE command to specify the encryption algorithm used to create the backup sets.

To compress backup sets that are used to recover files over the network, use the USING COMPRESSED BACKUPSET. RMAN compresses backup sets when it creates them on the primary database and then transfers these backup sets to the target database.

RMAN可以通过在网络上从主数据库中获取增量备份,然后将增量备份应用到物理备用数据库来执行恢复。RMAN作为目标连接到物理备用数据库。通过只在数据文件中恢复使用的数据块来优化恢复过程。使用FROM SERVICE子句指定要获取增量备份的主数据库的服务名称。

要在恢复过程中使用多节备份集,请在恢复命令中指定SECTION SIZE子句。为了将需要的文件从主数据库传输为加密的备份集,在恢复命令之前使用SET加密命令来指定用于创建备份集的加密算法。

为了压缩用于在网络上恢复文件的备份集,使用压缩后的压缩包。RMAN在主数据库中创建它们时压缩备份集,然后将这些备份集传输到目标数据库。

Scenarios for Restoring and Recovering Files Over the Network

https://www.cndba.cn/leo1990/article/2081

https://www.cndba.cn/leo1990/article/2081https://www.cndba.cn/leo1990/article/2081

Recovering files by connecting, over the network, to physical standby database is useful in the following scenarios:

· You need to roll-forward a physical standby database to make it in-sync with the primary database.

After creating an incremental backup of the latest changes on the primary database, you can restore the physical standby database using the incremental backup.

· You want to restore lost data files, control files, or tablespaces on a primary database using the corresponding files on the physical standby database. You can also restore files on a physical standby database by using the primary database.

通过将网络连接到物理备用数据库,恢复文件在以下场景中非常有用:

您需要前滚一个物理备用数据库,使它与主数据库同步。

在对主数据库的最新更改创建增量备份之后,可以使用增量备份恢复物理备用数据库。

您希望在主数据库上使用物理备用数据库上的相应文件恢复丢失的数据文件、控制文件或表空间。您还可以通过使用主数据库恢复物理备用数据库上的文件。

实验

https://www.cndba.cn/leo1990/article/2081

1) 查询数据库状态正常

[[email protected] ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 12.2.0.1.0 Production on Tue Aug 8 15:51:12 2017

Copyright (c) 1982, 2016, Oracle. All rights reserved.

Connected to:

Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED

---------- ------------------------------ ---------- ----------

2 PDB$SEED READ ONLY NO

3 PDBCNDBA MOUNTED

2)破坏主库数据文件mv users01.dbf users01.dbf.bak 数据库文件 数据库open 报错

[[email protected] cndba]$ pwd

/u01/app/oracle/oradata/cndba

[[email protected] oradata]$ cd cndba/

[[email protected] cndba]$ ls

control01.ctl pdbcndba redo01.log redo03.log stdredo02.log stdredo04.log system01.dbf undotbs01.dbf

control02.ctl pdbseed redo02.log stdredo01.log stdredo03.log sysaux01.dbf temp01.dbf users01.dbf

[[email protected] cndba]$ mv users01.dbf users01.dbf.bak

[[email protected] cndba]$ ls

control01.ctl pdbcndba redo01.log redo03.log stdredo02.log stdredo04.log system01.dbf undotbs01.dbf

control02.ctl pdbseed redo02.log stdredo01.log stdredo03.log sysaux01.dbf temp01.dbf users01.dbf.bak

SQL> shutdown immediate

ORA-03113: end-of-file on communication channel

Process ID: 3461

Session ID: 1 Serial number: 19734

SQL> conn /as sysdba

Connected to an idle instance.

SQL> startup mount

ORACLE instance started.

Total System Global Area 1593835520 bytes

Fixed Size 8793256 bytes

Variable Size 1023411032 bytes

Database Buffers 553648128 bytes

Redo Buffers 7983104 bytes

Database mounted.

SQL> alter database open;

alter database open

*

ERROR at line 1:

ORA-01157: cannot identify/lock data file 7 - see DBWR trace file

ORA-01110: data file 7: '/u01/app/oracle/oradata/cndba/users01.dbf'

3)用具有SYSBACKUP特权的用户连接到主数据库。

[[email protected] cndba]$ rman target /

Recovery Manager: Release 12.2.0.1.0 - Production on Tue Aug 8 15:03:18 2017

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

connected to target database: CNDBA (DBID=215561032, not open)

4)指定备份集必须使用AES128加密算法进行加密

RMAN> SET ENCRYPTION ALGORITHM 'AES128';

executing command: SET encryption

using target database control file instead of recovery catalog

5)检查tnsname.ora 文件是否配置了备库的服务并且可用

确保物理备用数据库中tnsname.ora文件包含一个与主数据库相对应的条目。还要确保在主服务器和物理备用数据库上的密码文件是相同的。

[[email protected] admin]$ cat tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/db_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

CNDBA =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.75)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = cndba)

)

)

PDBCNDBA_P =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.74)(PORT = 1521))

(CONNECT_DATA =

(SERVICE_NAME = cndba)

)

)

PDBCNDBA_S =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.75)(PORT = 1521))

(CONNECT_DATA =

(SERVICE_NAME = cndba)

)

)

6) 使用物理备用数据库上的数据文件恢复主数据库上的数据文件。下面的命令创建多节备份集来执行恢复操作。

RMAN> run{

RESTORE DATAFILE '/u01/app/oracle/oradata/cndba/users01.dbf'

FROM SERVICE pdbcndba_s

SECTION SIZE 120M;

}

Starting restore at 08-AUG-17

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=43 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: using network backup set from service pdbcndba_s

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/cndba/users01.dbf

channel ORA_DISK_1: restoring section 1 of 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

Finished restore at 08-AUG-17

--如果不recover 数据文件 数据库open 报错

SQL> alter database open;

alter database open

*

ERROR at line 1:

ORA-01113: file 7 needs media recovery

ORA-01110: data file 7: '/u01/app/oracle/oradata/cndba/users01.dbf'

7) RECOVER DATAFILE

RMAN> RECOVER DATAFILE '/u01/app/oracle/oradata/cndba/users01.dbf';

Starting recover at 08-AUG-17

using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 30 is already on disk as file /u01/archive/1_30_951098251.dbf

archived log for thread 1 with sequence 31 is already on disk as file /u01/archive/1_31_951098251.dbf

archived log for thread 1 with sequence 32 is already on disk as file /u01/archive/1_32_951098251.dbf

archived log file name=/u01/archive/1_30_951098251.dbf thread=1 sequence=30

media recovery complete, elapsed time: 00:00:00

Finished recover at 08-AUG-17

8)验证数据库启动正常

SQL> alter database open;

Database altered.

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED

---------- ------------------------------ ---------- ----------

2 PDB$SEED READ ONLY NO

3 PDBCNDBA MOUNTED

https://www.cndba.cn/leo1990/article/2081

参考链接:

版权声明:本文为博主原创文章,未经博主允许不得转载。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值