Oracle DataGuard物理备库的数据模式

本文详细介绍了 Oracle DataGuard 中的数据保护模式,包括最大限度保护数据、最大性能和数据0丢失三种模式及其修改方式,提供了从性能到数据保护级别的转换过程,并强调了不同模式下的条件与操作。

在DataGuard中数据保护模式要按照需求来设置


在所有的配置中都是用性能换数据的安全,要么就是用数据的安全级别来换性能。


1.数据的保护模式

第一种:最大限度保护数据

Maximum availability: This protection mode provides the highest level of data protection that is possible without compromising the availability of a primary database. With Oracle Data Guard, transactions do not commit until all redo data needed to recover those transactions has either been received in memory or written to the standby redo log (depending upon configuration) on at least one synchronized standby database. If the primary database cannot write its redo stream to at least one synchronized standby database, it operates as if it were in maximum performance mode to preserve primary database availability until it is again able to write its redo stream to a synchronized standby database.

This protection mode ensures zero data loss except in the case of certain double faults, such as failure of a primary database after failure of the standby database.

--先将log写入到内存或者一个备库归档,然后执行事务,除了双方同时故障的意外。


第二种:最大性能

Maximum performance: This is the default protection mode. It provides the highest level of data protection that is possible without affecting the performance of a primary database. This is accomplished by allowing transactions to commit as soon as all redo data generated by those transactions has been written to the online log. Redo data is also written to one or more standby databases, but this is done asynchronously with respect to transaction commitment, so primary database performance is unaffected by delays in writing redo data to the standby database(s).

This protection mode offers slightly less data protection than maximum availability mode and has minimal impact on primary database performance.

--默认的保护方式,先将事务执行,然后记录到log,然后同步到备库,对主库iude影响非常小

第三种:数据0丢失

Maximum protection: This protection mode ensures that no data loss will occur if the primary database fails. To provide this level of protection, the redo data needed to recover a transaction must be written to both the online redo log and to the standby redo log on at least one synchronized standby database before the transaction commits. To ensure that data loss cannot occur, the primary database will shut down, rather than continue processing transactions, if it cannot write its redo stream to at least one synchronized standby database.

--当事务提交后,将log先提交到备库,关闭主库其他的事务,然后执行事务,完毕后执行下一个事务


2.修改方式(数据保护由主库参数操控)

注意:在主库操作

按数据包户程度排序

maximize protection <  maximize availability < maximize performance

SQL> select protection_mode,protection_level from v$database;

PROTECTION_MODE 					     PROTECTION_LEVEL
------------------------------------------------------------ ------------------------------------------------------------
MAXIMUM PERFORMANCE					     MAXIMUM PERFORMANCE

SQL> alter database set standby database to maximize availability;

数据库已更改。

SQL> select protection_mode,protection_level from v$database;

PROTECTION_MODE                          PROTECTION_LEVEL
------------------------------------------------------------ ------------------------------------------------------------
MAXIMUM AVAILABILITY                         RESYNCHRONIZATION                //没生效

更改成availability模式的条件:

Maximum protection/AVAILABILITY模式必须满足以下条件

Redo Archival Process: LGWR

Network Tranmission mode: SYNC            //注意

Disk Write Option: AFFIRM

Standby Redo Logs: Yes

standby database type: Physical Only

SQL> show parameter  set log_archive_dest;

NAME				     TYPE			       VALUE
------------------------------------ --------------------------------- ------------------------------
awr_snapshot_time_offset	     integer			       0
plscope_settings		     string			       IDENTIFIERS:NONE
SQL> show parameter  log_archive_dest;   

NAME				     TYPE			       VALUE
------------------------------------ --------------------------------- ------------------------------
log_archive_dest		     string
log_archive_dest_1		     string			       location=/oracle/archive_log v
								       alid_for=(all_logfiles,all_rol
								       es) db_unique_name=TEST_M
log_archive_dest_2		     string			       service=TESTS reopen=120 lgwr
								       async valid_for=(online_logfil   //此处是async
								       es,primary_role) db_unique_nam
								       e=TEST_S

修改之:

SQL> alter system set log_archive_dest_2='service=TESTS reopen=120 lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=TEST_S';

系统已更改。

SQL> select protection_mode,protection_level from v$database;

PROTECTION_MODE                          PROTECTION_LEVEL
------------------------------------------------------------ ------------------------------------------------------------
MAXIMUM AVAILABILITY                         MAXIMUM AVAILABILITY     //已生效

注意:在以前的某些版本中如果数据保护级别从高到底,则主库必须在mount状态下

一下内容摘自Dave大师博客

SQL> startup mount;

ORACLE instance started.

Total System Global Area  167772160 bytes

Fixed Size                  1218316 bytes

Variable Size              79694068 bytes

Database Buffers           83886080 bytes

Redo Buffers                2973696 bytes

Database mounted.

SQL> alter database set standby database to maximize availability;

Database altered.

SQL> alter database open;

Database altered.

SQL> select protection_mode,protection_level from v$database;

PROTECTION_MODE      PROTECTION_LEVEL

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

MAXIMUM AVAILABILITY MAXIMUM AVAILABILITY

修改到最大保护模式:

SQL> alter database set standby database to maximize protection; //在availability模式下提高到protection模式下,不许要修改参数

数据库已更改。

SQL> select protection_mode,protection_level from v$database;

PROTECTION_MODE 					     PROTECTION_LEVEL
------------------------------------------------------------ ------------------------------------------------------------
MAXIMUM PROTECTION					     MAXIMUM PROTECTION

当备库在数据的最大保护模式下,备库是不允许被先down的如下:

备库操作

SQL> select protection_mode,protection_level from v$database;

PROTECTION_MODE 					     PROTECTION_LEVEL
------------------------------------------------------------ ------------------------------------------------------------
MAXIMUM PROTECTION					     MAXIMUM PROTECTION

SQL> shutdown immediate
ORA-01154: ????????????, ??, ?????
SQL> host oerr ORA 01154
01154, 00000, "database busy. Open, close, mount, and dismount not allowed now"
// *Cause: Some operation is in progress that expects the opened/mounted state
//	   of this instance to remain the same.
// *Action: Wait for the operation to complete then retry. If attempting to
//	   do a shutdown, SHUTDOWN ABORT will work.  If this is a shutdown
//         of a standby database that is operating in NO DATA LOSS mode, you
//         must shutdown the primary database first.
--必须先down掉主库

#################

迷途小运维原创

作者:john

转载请注明出处

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值