Showing posts with label Dataguard. Show all posts
Showing posts with label Dataguard. Show all posts

Monday, December 17, 2012

Impact of NOLOGGING on an Oracle Dataguard Standby


Impact of NOLOGGING on an Oracle Dataguard Standby


In below we will run few of the test cases NOLOGGING  option at dataguard environment.
Oracle recommended  for Dataguard Standby databases is to run "alter database force logging;" to make sure all database transactions on the primary database are logged which will be applied to the standby.

NOLOGGING is valid for the following operations :-

direct load (SQL*Loader)
direct load INSERT (using APPEND hint)
CREATE TABLE ... AS SELECT
CREATE INDEX
ALTER TABLE ... MOVE PARTITION
ALTER TABLE ... SPLIT PARTITION
ALTER INDEX ... SPLIT PARTITION
ALTER INDEX ... REBUILD
ALTER INDEX ... REBUILD PARTITION
INSERT, UPDATE, and DELETE on LOBs in NOCACHE NOLOGGING mode stored out of line

NOLOGGING  results indicate :-
1. significant reduction in redo (there will still be UNDO REDO generated)
2. logical corruption in the tables in the standby database which will stop select statements until the table data is reloaded (e.g drop and recreate)

##  At primary database ##
# check logging

select force_logging from v$database;
select tablespace_name from dba_tablespaces where logging = 'NOLOGGING';
select logging from user_tables where table_name = 'NOLOG';

SQL> truncate table nolog;
Table truncated.
SQL> alter database force logging;
Database altered.
SQL> alter tablespace users logging;
Tablespace altered.
SQL> alter table nolog logging;
Table altered.
SQL> set autotrace ON statistics
SQL> insert /*+ APPEND */
into nolog select 'this is a nologging NOLOG' from dual nologging; 2

1 row created.


Statistics
----------------------------------------------------------
165 recursive calls
7 db block gets
21 consistent gets
2 physical reads
8624 redo size
820 bytes sent via SQL*Net to client
780 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
6 sorts (memory)
0 sorts (disk)
1 rows processed

SQL> set autotrace off
SQL> select file#, unrecoverable_change#, to_char(unrecoverable_time,'hh:mi') from v$datafile where UNRECOVERABLE_CHANGE# > 0;

FILE# UNRECOVERABLE_CHANGE# TO_CH
---------- --------------------- -----
26 2.4329E+10 02:48

SQL> alter database no force logging;

Database altered.

SQL> alter tablespace users nologging;

Tablespace altered.

SQL> alter table nolog nologging;

Table altered.

SQL> truncate table nolog;

Table truncated.

SQL> set autotrace ON statistics
SQL> insert /*+ APPEND */
into nolog select 'this is a nologging nolog' from dual nologging; 2

1 row created.


Statistics
----------------------------------------------------------
3 recursive calls
7 db block gets
2 consistent gets
2 physical reads
448 redo size
820 bytes sent via SQL*Net to client
780 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
2 sorts (memory)
0 sorts (disk)
1 rows processed

SQL> select file#, unrecoverable_change#, to_char(unrecoverable_time,'hh:mi') from v$datafile where UNRECOVERABLE_CHANGE# > 0;

FILE# UNRECOVERABLE_CHANGE# TO_CH
---------- --------------------- -----
26 2.4329E+10 02:51



# On the Physical Standby ##

SQL> select * from nolog;
ERROR:
ORA-01578: ORACLE data block corrupted (file # 26, block # 42)
ORA-01110: data file 26:
'/u01/oradata/orcl/datafile/o1_mf_users_3vty8wdy_.dbf'
ORA-26040: Data block was loaded using the NOLOGGING option

SQL> analyze table nolog validate structure cascade;
analyze table nolog validate structure cascade
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 26, block # 31)
ORA-01110: data file 26:
'/u01/oradata/orcl/datafile/o1_mf_users_3vty8wdy_.dbf'
ORA-26040: Data block was loaded using the NOLOGGING option

!oerr ora 26040
26040, 00000, "Data block was loaded using the NOLOGGING option\n"
//* Cause: Trying to access data in block that was loaded without
//* redo generation using the NOLOGGING/UNRECOVERABLE option
//* Action: Drop the object containing the block. 

Tuesday, November 27, 2012

redo log generation per hour basis


Redo generation ratio/per hour 



SELECT day,A "00",B "01",C "02",D "03",E "04",F "05",G "06",H "07",I "08",J "09",K "10",
L "11",M "12",N "13",O "14",P "15",Q "16",R "17",S "18",T "19",U "20",V "21",W "22",X "23",
A+B+C+D+E+F+G+H+I+J+K+L+M+N+O+P+Q+R+S+T+U+V+W+X DAY_SUM FROM (
select to_char(first_time,'YYYY.MM.DD') day,
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'00',1,0)),'999') "A",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'01',1,0)),'999') "B",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'02',1,0)),'999') "C",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'03',1,0)),'999') "D",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'04',1,0)),'999') "E",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'05',1,0)),'999') "F",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'06',1,0)),'999') "G",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'07',1,0)),'999') "H",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'08',1,0)),'999') "I",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'09',1,0)),'999') "J",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'10',1,0)),'999') "K",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'11',1,0)),'999') "L",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'12',1,0)),'999') "M",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'13',1,0)),'999') "N",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'14',1,0)),'999') "O",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'15',1,0)),'999') "P",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'16',1,0)),'999') "Q",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'17',1,0)),'999') "R",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'18',1,0)),'999') "S",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'19',1,0)),'999') "T",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'20',1,0)),'999') "U",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'21',1,0)),'999') "V",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'22',1,0)),'999') "W",
to_char(sum(decode(substr(to_char(first_time,'DDMMYYYY:HH24:MI'),10,2),'23',1,0)),'999') "X"
from v$log_history
group by to_char(first_time,'YYYY.MM.DD')
order by to_char(first_time,'YYYY.MM.DD')) ;

Sunday, November 18, 2012

Redolog resizing at dataguard environment


 Steps 01: Stop/Shutdown standby database
===========================================

SQL> Alter database recover managed standby database cancel;
SQL> Shutdown immediate;

 Steps 02: delete redolog file and standby file using rm command in standby side
====================================================================================


Steps: 3. Drop online redologfiles in primary database
========================================================
SQL> alter system switch logfile;
SQL> alter system checkpoint;
SQL> alter database drop logfile group 1;

SQL> ALTER DATABASE ADD LOGFILE GROUP 1 ('/oradata1/redo1/redo01a.log',
'/oradata1/redo2/redo01b.log') SIZE 300M;

SQL> alter database drop logfile group 2;


SQL> ALTER DATABASE ADD LOGFILE GROUP 2 ('/oradata1/redo1/redo02a.log',
'/oradata1/redo2/redo02b.log') SIZE 300M;

SQL> alter database drop logfile group 3;


SQL> ALTER DATABASE ADD LOGFILE GROUP 3 ('/oradata1/redo1/redo03a.log',
'/oradata1/redo2/redo03b.log') SIZE 300M;

SQL> alter database drop logfile group 4;

SQL> ALTER DATABASE ADD LOGFILE GROUP 4 ('/oradata1/redo1/redo04a.log',
'/oradata1/redo2/redo04b.log') SIZE 300M;

==========================================================================================

Steps 04:  Drop standby logs in primary database and add standby logs in primary

SQL> ALTER DATABASE DROP STANDBY LOGFILE GROUP 5;

SQL> ALTER DATABASE DROP STANDBY LOGFILE GROUP 6;

SQL> ALTER DATABASE DROP STANDBY LOGFILE GROUP 7;

SQL> ALTER DATABASE DROP STANDBY LOGFILE GROUP 8;

SQL> ALTER DATABASE DROP STANDBY LOGFILE GROUP 9;


===========================================================================================

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 ('/oradata1/redo1/standbyredo05a.log',
'/oradata1/redo2/standbyredo05b.log') SIZE 300M;

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 ('/oradata1/redo1/standbyredo06a.log',
'/oradata1/redo2/standbyredo06b.log') SIZE 300M;

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 ('/oradata1/redo1/standbyredo07a.log',
'/oradata1/redo2/standbyredo07b.log') SIZE 300M;

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 8 ('/oradata1/redo1/standbyredo08a.log',
'/oradata1/redo2/standbyredo08b.log') SIZE 300M;

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 9 ('/oradata1/redo1/standbyredo09a.log',
'/oradata1/redo2/standbyredo09b.log') SIZE 300M;

Steps 05:  create standby controlfile- and move it on standby db side
===========================================================================================

SQL> alter database create standby controlfile as '/oradata1/standby01.ctl';

Move Control file to standby remote destination
============================
Steps 06: Startup standby database--
============================

SQL> startup nomount

SQL> alter database mount standby database;

SQL> alter database recover managed standby database disconnect from session

Steps 07:  Open read-only mode and real-time redo apply
========================================================
SQL> startup
SQL> alter database recover managed standby database disconnect using current logfile;