Disclaimer

Wednesday, 9 June 2021

18c :Automatic Correction of Non-logged Blocks at a Data Guard Standby Database


1) We all aware of, when a table has attribute set with nologging option , those redo      will be missed (although redo information there, the data will be missed) and        standby will not apply those changes, and this will problematic when you do a switchover or failover unless you use force logging mode.

2) To address this in 18c, we have three different logging modes to ensure nologged blocks are also captured and send to standby depends on requirement of performance and availability perspective.

3) Of course, we can use FORCE LOGGING at primary database to ensure all modifications are captured, however this has an performance impact where in which you are doing a bulk load and this has to be captured in redo logs may slow down your load process.

To overcome this, we have two new Logging modes available at primary database

Automatic Correction of Non-logged Blocks at a Data Guard Standby Database

Database nologging functionality has been extended to provide better support for use in an Oracle Active Data Guard environment without significantly increasing the amount of redo generated. 

There are two new nologging modes:

1) Standby Nologging for Data Availability

ALTER DATABASE SET STANDBY NOLOGGING FOR DATA AVAILABILITY;

This  mode causes the load operation to send the loaded data to each standby through its own connection to the standby. 

Means the data availability is critical so it has to delay the commit on primary side to ensure all non logged blocks also shipped and applied by MRP


This mode causes the load operation to send the loaded data to each standby through its own respective connection. 

The commit is delayed until all the standbys have applied the data as part of running managed recovery in an Active Data Guard environment

▪ Standby Nologging for Data Availability 

 dedicated connection to all standbys 

 commit delayed until changes are applied on all standbys


2) Standby Nologging for Load Performance

ALTER DATABASE SET STANDBY NOLOGGING FOR LOAD PERFORMANCE;


This mode  is similar to the above one except that the loading process can stop sending the data to the standbys if the network cannot keep up with the speed at which data is being loaded to the primary. 

Standby may miss the data but eventually it fetches the non logged blocks during recover process by MRP process.


With this mode loading process can stop sending the data to the standbys if the network cannot keep up with the speed at which data is being loaded to the primary. 

In this mode it is possible that the standbys may have missing data, but each standby automatically fetches the data from the primary as a normal part of running managed recovery in an Active Data Guard environment.


▪ Standby Nologging for Load Performance 

 all nologging data is directly sent to standby databases 

 if not possible due to network bottlenecks, nologging data transport will be stopped. 

Same situation as on primary for nologging operations.

 Datafile changes will be applied to Standby during normal managed recovery apply.


Commands to Enable an Appropriate Logging Mode
 
 FORCE LOGGING
 ALTER DATABASE FORCE LOGGING;

 STANDBY NOLOGGING FOR DATA AVAILABILITY
 ALTER DATABASE SET STANDBY NOLOGGING FOR DATA AVAILABILITY; 

 STANDBY NOLOGGING FOR LOAD PERFORMANCE
 ALTER DATABASE SET STANDBY NOLOGGING FOR LOAD PERFORMANCE;

Recovery Steps for Physical Standby Databases with conventional nonlogged operations
 
 SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL; 
 RMAN> RECOVER DATABASE NONLOGGED BLOCK;

If the presence of unrecoverable blocks is only found after a switchover, then you can use these same two steps, but the primary database must be just mounted ( not open) and, RMAN must be connected to the primary.




Tuesday, 1 June 2021

Restore Missing Datafile In Standby Database Oracle 12c

 

Restore Missing Datafile In Standby Database Oracle 12c

In oracle 12c, if datafile is missing is standby database, then it can be restored easily from primary database using RESTORE DATAFILE FROM SERVICE command. This is one of the new feature of dataguard 12c . 



DEMO:

PRIMDB – Primary database

STYDB – Standby database

 

Check status of primary and standby database:

--PRIMARY

 

SQL> select DB_UNIQUE_NAME,OPEN_MODE,DATABASE_ROLE from v$database;

 

DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE

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

PRIMDB READ WRITE PRIMARY

-- STANDBY

SQL> select name,OPEN_MODE,DATABASE_ROLE from v$database;

 

NAME OPEN_MODE DATABASE_ROLE

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

STYDB READ ONLY WITH APPLY PHYSICAL STANDBY

 

Lets remove one file from standby database:[STYDB]:

 

SQL> select file_name from dba_data_files;
 
FILE_NAME
--------------------------------------------------------------------------------
/archive/PRIMDB/PRIMDB/system01.dbf
/archive/PRIMDB/PRIMDB/sysaux01.dbf
/archive/PRIMDB/PRIMDB/undotbs01.dbf
/archive/PRIMDB/PRIMDB/users01.dbf
 
mv /archive/PRIMDB/PRIMDB/users01.dbf /archive/PRIMDB/PRIMDB/users01.dbf_bkp
 
 
-- Try to query any table
 
SQL> select file_name from dba_data_files;
select file_name from dba_data_files
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: '/archive/PRIMDB/PRIMDB/users01.dbf'
ORA-27041: unable to open file
SVR4 Error: 2: No such file or directory
Additional information: 3
 

CHECK FROM RMAN: 

RMAN> list failure;
 
using target database control file instead of recovery catalog
Database Role: PHYSICAL STANDBY
 
List of Database Failures
=========================
 
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
322 CRITICAL OPEN 18-OCT-16 One or more non-system datafiles are missing
 


SOLUTION:

Now follow below steps to restore the datafile from primary:

NOTE : All activities need to be done on standby database


1. CANCEL THE RECOVERY( STANDBY)
SQL> recover managed standby database cancel;
Media recovery complete.
 

2 . START STANDBY IN MOUNT STAGE( IF IN READ-ONLY MODE):
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
 
Total System Global Area 1.3935E+10 bytes
Fixed Size 6002112 bytes
Variable Size 4630514240 bytes
Database Buffers 9193914368 bytes
Redo Buffers 104153088 bytes
Database mounted.
 

3. RESTORE THE DATAFILE ( STANDBY)

Now connect to RMAN in standby and use restore command.

 

SYNTAX – RESTORE DATAFILE < FILE_ID> FROM SERVICE < PRIMARY DB SERVICE NAME >



rman target /
 
Recovery Manager: Release 12.1.0.1.0 - Production on Tue Oct 18 18:04:15 2016
 
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
 
connected to target database: STYDB (DBID=599956155, not open)
 
RMAN> restore datafile 4 from service PRIMDB;
 
Starting restore at 18-OCT-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=705 device type=DISK
 
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: using network backup set from service PRIMDB
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00004 to /archive/PRIMDB/PRIMDB/users01.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 18-OCT-16
 

4. START THE RECOVERY ( STANDBY)
SQL> recover managed standby database using current logfile disconnect from session;
Media recovery complete.
 

5. CANCEL RECOVERY AND START DATABASE IN READ ONLY:
SQL> recover managed standby database cancel;
Media recovery complete.
SQL> shutdown immediate;
ORA-01109: database not open
 
 
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
 
Total System Global Area 1.3935E+10 bytes
Fixed Size 6002112 bytes
Variable Size 4630514240 bytes
Database Buffers 9193914368 bytes
Redo Buffers 104153088 bytes
Database mounted.
Database opened.
 

6 . START THE RECOVERY AGAIN:

 

SQL> recover managed standby database using current logfile disconnect from session;
Media recovery complete.
 


Now all datafiles are online :

 

SQL> select file_name from dba_data_files;
 
FILE_NAME
--------------------------------------------------------------------------------
/archive/PRIMDB/PRIMDB/system01.dbf
/archive/PRIMDB/PRIMDB/sysaux01.dbf
/archive/PRIMDB/PRIMDB/undotbs01.dbf
/archive/PRIMDB/PRIMDB/users01.dbf

 

 

 

Thursday, 22 April 2021

New Features in Oracle Database 19c

 

New Features in Oracle Database 19c


General

  • Multi-model partitioning with Hybrid partitioning allowing some partitions in the database and some as external partitions even in hdfs
  • New ALTER SYSTEM statement clause FLUSH PASSWORDFILE_METADATA_CACHE
  • Clear flashback logs periodically
  • Flush Metadata Cache for Passwords
  • Hybrid Partitioned Tables – to integrate internal partitions and external partitions into a single partition table. partitions to reside in both Oracle Database segments and in external files and sources
  • Passwords removed from schema accounts (default accounts)

Automatic Indexing

  • Automatic Indexing is one of the great feature included in 19c .It automates index management tasks, such as creating, rebuilding, and dropping indexes in an Oracle Database based on changes in the application workload.
  • This feature improves database performance by managing indexes automatically in an Oracle Database.
  • Oracle has provided new package DBMS_AUTO_INDEX for this

SQL Quarantine

  • SQL statements that are terminated by Oracle Database Resource Manager due to their excessive consumption of CPU and I/O resources are automatically quarantined.
  • The execution plans associated with the terminated SQL statements are quarantined to prevent them from being executed again.
  • This feature protects an Oracle Database from performance degradation by preventing execution of SQL statements that excessively consume CPU and I/O resources.

Pluggable Databases

  • ADDM Analysis at PDB Level
  • Ability to Create a PDB by Cloning a Remote PDB Using DBCA in Silent
  • Mode Ability to relocate a PDB to another CDB Using DBCA in Silent Mode
  • Creation Duplicate of an Oracle Database, CreateDuplicateDB command, in DBCA Silent Mode

Data Pump

  • Oracle Data Pump Allows Tablespaces to Stay Read-Only During TTS Import
  • Oracle Data Pump Test Mode for Transportable Tablespaces (TTS)
  • Oracle Data Pump Support for Resource Usage Limitations – new parameter MAX_DATAPUMP_PARALLEL_PER_JOB
  • Oracle Data Pump Loads Partitioned Table Data One Operation – GROUP_PARTITION_TABLE_DATA, a new value for the Import DATA_OPTIONS command line parameter
  • Oracle Data Pump Import Supports More Object Store Credentials
  • Oracle Data Pump Ability to Exclude ENCRYPTION Clause on Import – new transform parameter OMIT_ENCRYPTION_CLAUSE
  • Oracle Data Pump Prevents Inadvertent Use of Protected Roles – new ENABLE_SECURE_ROLES parameter is available

 

 

Performance

  • SQL Statement Diagnosability with SQL Advisor repair and SQL Test case for procedures
  • Realtime statistics for DML Operations – Oracle Database 19c introduces real-time statistics, which extend online support to conventional DML statements
  • Workload Capture and Replay in a PDB
  • Statistics Collection on custom frequency automatically – From 19c onwards, High-frequency automatic optimizer statistics collection complements the standard statistics collection job
  • Automatic Database Diagnostic Monitor (ADDM) Support for Pluggable Databases (PDBs)
  • Automatic Indexing – Manage Auto Indexes with Advisory task like Monitor, Capture, Identify, Verify, Decide – to enable auto index mode is below, we have options “Implement”, “Report-Only”, “OFF”.

Data Guard

  • DML redirect to standby/ADG for read-mostly applications
  • Propagate Restore Points from Primary to Standby site
  • Re-creation of broker configuration
  • Simplified Data-guard broker parameter configurations
  • Re-creation of broker configuration
  • Finer Granularity Supplemental Logging for logical standby databases
  • Flashback Standby Database when Primary Database is Flashed Back – Oracle 19c onwards, DBA can put the standby database in MOUNT mode without managed recovery and then flashback primary database; the standby will also be reverted, thus keeping it in sync with the primary
  • Oracle Data Guard Multi-Instance Redo Apply Works with the In-Memory Column Store
  • Finer Granularity Supplemental Logging for logical standby databases

New init parameters

  • DATA_GUARD_MAX_IO_TIME
  • DATA_GUARD_MAX_LONGIO_TIME
  • MAX_DATAPUMP_JOBS_PER_PDB
  • aws_pdb_autoflush_enabled (TRUE or FALSE)
  • ADG_REDIRECT_DML (TRUE or FALSE)

New tables/views

  • dba_sql_quarantine
  • V$SQL_TESTCASES
  • dba_auto_index_config
  • DBA_REGISTRY_BACKPORTS

New packages

  • dbms_auto_index_internal
  • dbms_auto_index
  • DBMS_SQLQ


SQL Queries for Goldengate Replications

  set linesize 200 set pagesize 100 set trimspool on column table_owner format a25 heading 'TABLE_OWNER' column tabl...