Monday, October 22, 2012

Exadata Upgrade / Upgrade GI to 11.2.0.3

Few days back we did upgrade from 11.2.0.2 to 11.2.0.3 on Exadata x2 half rack.

This was direct upgrade from 11.2.0.2 to 11.2.0.3 with Bundle Patch 7  /  patch 13992240

Some High level steps. 
  • Oracle Grid Infrastructure 11.2.0.3 Installation (Dont run rootupgrade.sh at the end)
  • Install BP7 on New Grid home.
  • Run rootupgrade.sh (Outage Time)
  • 11.2.0.3 database software Installation. 
  • Install BP7 on New Oracle home
  • Upgrade database to 11.2.0.3 (Outage Time)

Attached is Detail Upgrade Document on Google docs.



Let me know if you any difficulties viewing above Document on jonyjt@gmail.com



Wednesday, October 17, 2012

OGG-01496 Failed to open target trail file



My Datapump was abending after start, because It was looking for MISSING remote trailfile at perticular RBA , that trailfile was deleted.

If you want to reposition extract please visit. Re-position Extract at particular RBA

here is from source side.

GGSCI (RACD1.localdomain.com) 6> INFO RMTTRAIL *

       Extract Trail: ./dirdat/DE
             Extract: RACDE
               Seqno: 1
                 RBA: 1049
           File Size: 10M

       Extract Trail: ./dirdat/DP
             Extract: RACDP
               Seqno: 0
                 RBA: 4499
           File Size: 10M

some output from ggserr.log

2012-10-17 19:47:58  INFO    OGG-00975  Oracle GoldenGate Manager for Oracle, mgr.prm:  EXTRACT RACDP starting.
2012-10-17 19:47:58  INFO    OGG-00992  Oracle GoldenGate Capture for Oracle, racdp.prm:  EXTRACT RACDP starting.
2012-10-17 19:47:59  INFO    OGG-00993  Oracle GoldenGate Capture for Oracle, racdp.prm:  EXTRACT RACDP started.
2012-10-17 19:48:04  INFO    OGG-01226  Oracle GoldenGate Capture for Oracle, racdp.prm:  Socket buffer size set to 27985 (flush size 27985).
--This is the error....
2012-10-17 19:48:04  ERROR   OGG-01496  Oracle GoldenGate Capture for Oracle, racdp.prm:  Failed to open target trail file ./dirdat/DP000000, at RBA 4499.
2012-10-17 19:48:04  ERROR   OGG-01668  Oracle GoldenGate Capture for Oracle, racdp.prm:  PROCESS ABENDING.

I had trailfile missing on Target side, which DATAPUMP was looking for.

TEST:/u00/app/gghome/dirdat :TEST$ll
total 12
-rw-rw-rw-  1 oracle oinstall 1167 Aug  2 09:49 XP000000
drwxr-xr-x 14 oracle oinstall 4096 Oct 17 16:10 ..
drwxrwxr-x  2 oracle oinstall 4096 Oct 17 16:52 .

So i did this below on Source side and start datapump successfully.

GGSCI (RACD1.localdomain.com) 11> ALTER EXTRACT RACDP ETROLLOVER

2012-10-17 19:54:30  INFO    OGG-01520  Rollover performed.  For each affected output trail of Version 10 or higher format, after starting the source extract, issue ALTER EXTSEQNO for that trail's reader (either pump EXTRACT or REPLICAT) to move the reader's scan to the new trail file;  it will not happen automatically.
EXTRACT altered.


GGSCI (RACD1.localdomain.com) 12> INFO RMTTRAIL *

       Extract Trail: ./dirdat/DE
             Extract: RACDE
               Seqno: 1
                 RBA: 1049
           File Size: 10M

       Extract Trail: ./dirdat/DP
             Extract: RACDP
               Seqno: 1
                 RBA: 0
           File Size: 10M



GGSCI (RACD1.localdomain.com) 13> START RACDP

Sending START request to MANAGER ...
EXTRACT RACDP starting


GGSCI (RACD1.localdomain.com) 14> info all

Program     Status      Group       Lag           Time Since Chkpt

MANAGER     RUNNING
EXTRACT     RUNNING     RACDE       00:00:00      00:00:01
EXTRACT     RUNNING     RACDP       00:00:00      00:00:02


2012-10-17 19:55:20  INFO    OGG-00975  Oracle GoldenGate Manager for Oracle, mgr.prm:  EXTRACT RACDP starting.
2012-10-17 19:55:20  INFO    OGG-00992  Oracle GoldenGate Capture for Oracle, racdp.prm:  EXTRACT RACDP starting.
2012-10-17 19:55:31  INFO    OGG-00993  Oracle GoldenGate Capture for Oracle, racdp.prm:  EXTRACT RACDP started.
2012-10-17 19:55:39  INFO    OGG-01226  Oracle GoldenGate Capture for Oracle, racdp.prm:  Socket buffer size set to 27985 (flush size 27985).
2012-10-17 19:55:40  INFO    OGG-01052  Oracle GoldenGate Capture for Oracle, racdp.prm:  No recovery is required for target file ./dirdat/DP000001, at RBA 0 (file not opened).
2012-10-17 19:55:40  INFO    OGG-01478  Oracle GoldenGate Capture for Oracle, racdp.prm:  Output file ./dirdat/DP is using format RELEASE 10.4/11.1.

Monday, October 1, 2012

Change Data guard Protection Mode


There are 3 ways of shipping redo data to a physical standby:

LGWR SYNC = Max Availability & Max Protection
LGWR ASYNC = Max Performance
ARCH


Maximum Protection = This protection level uses a synchronous replication process to ensure that no data loss will occur if the primary database fails. It also enforces rules that prevent multiple failure events from causing data loss. This protection level will never allow a primary database to acknowledge commit success for an unprotected transaction.To provide this level of protection, the redo data that is needed to recover each transaction must be written to both the local online redo log and to the standby redo log on at least one standby database before Oracle can acknowledge commit success to the application. To ensure that data loss cannot occur, the primary database will shut down if a fault prevents it from writing its redo stream to the standby redo log of at least one standby database.


Maximum Availability = This protection level uses a synchronous replication process that provides zero data loss protection without compromising the availability of the primary database. Like Maximum Protection, commit success is not acknowledged to the application until the redo that is needed to recover that transaction is written to the local online redo log and to the standby redo log of at least one standby database. Unlike Maximum Protection, however, the primary database does not shut down if a fault prevents it from writing its redo stream to a remote standby redo log. The primary database will stall for a maximum of net_timout seconds (user configurable) before proceeding, in order to maintain availability of the primary database. Data Guard automatically resynchronizes primary and standby databases when the connection is restored. Data loss is possible if a second failure occurs before the resynchronization process is complete.

Maximum performance = This protection mode (the default) is an asynchronous replication process that provides the highest level of data protection that is possible without affecting the performance of the primary database. This is accomplished by acknowledging commit success as soon as the redo data that is needed to recover that transaction is written to the local online redo log without waiting for confirmation by the standby that the data is protected. The redo data stream of the primary database is transmitted to the standby database directly from the Oracle in-memory log buffer as quickly as it is generated. .

The default is Maximum Performance.

SYNC | ASYNC = Specifies whether the redo data is to be received at the destination before the transaction is committed. ASYNC is default.

AFFIRM | NOAFFIRM = Control whether the redo destination acknowledges received redo data. NOAFFIRM is the default for ASYNC if not specified. AFFIRM is the default for SYNC for if not specified.

NET_TIMEOUT = Specifies the time in seconds that the primary database log writer will wait for a response from the Log Network Service (LNS) before terminating the connection and marking the standby (destination) as failed. The default value is 30 seconds.

REOPEN = Specifies the time in seconds that the log writer should wait before attempting to access a previously failed standby (destination). The default is 300 seconds.

Use LGWR SYNC if you use either Maximum Protection OR Maximum Availability.
so here LGWR is directly connected with RFS,henc there will be no LNS process.

On the primary database, query the RECOVERY_MODE column in the V$ARCHIVE_DEST_STATUS view, which displays the standby database's operation as MANAGED_RECOVERY for Redo Apply and MANAGED REAL TIME APPLY for real-time apply.


By default standby is running in MAXIMUM PERORMANCE Mode,

SQL> alter system set log_archive_dest_2='SERVICE=STDBY LGWR ASYNC COMPRESSION=ENABLE REOPEN=15 NET_TIMEOUT=30 MAX_FAILURE=10 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=STDBY

SQL> select PROTECTION_MODE,PROTECTION_LEVEL FROM V$DATABASE;

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


============Change to MAXIMUM AVAILABILITY========================

STDBY-> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

System altered.

--On Primary Change Log shipping attributes. 

PROD-> alter system set log_archive_dest_2='SERVICE=STDBY SYNC AFFIRM NET_TIMEOUT=100 REOPEN=300 DB_UNIQUE_NAME=STDBY VALID_FOR=(ALL_LOGFILES,PRIMARY_ROLE)' scope = both;

System altered.

--On Primary Change Mode.
PROD-> alter database set standby database to maximize availability;

Database altered.

---Start Recovery Process on STANDBY. 
STDBY-> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

STDBY-> select PROTECTION_MODE,PROTECTION_LEVEL FROM V$DATABASE;

PROTECTION_MODE      PROTECTION_LEVEL
-------------------- --------------------
MAXIMUM AVAILABILITY MAXIMUM AVAILABILITY


--In Primary database Alertlog.

ALTER SYSTEM SET log_archive_dest_2='SERVICE=STDBY SYNC AFFIRM NET_TIMEOUT=100 REOPEN=300 DB_UNIQUE_NAME=STDBY VALID_FOR=(ALL_LOGFILES,PRIMARY_ROLE)' SCOPE=BOTH;
Wed Aug 15 06:35:30 2012
Destination LOG_ARCHIVE_DEST_2 is UNSYNCHRONIZED
******************************************************************
LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2
******************************************************************
LGWR: Standby redo logfile selected to archive thread 1 sequence 19
LGWR: Standby redo logfile selected for thread 1 sequence 19 for destination LOG_ARCHIVE_DEST_2
Thread 1 advanced to log sequence 19 (LGWR switch)
  Current log# 1 seq# 19 mem# 0: /u01/test/redo/redo01.log
Wed Aug 15 06:35:30 2012
Archived Log entry 24 added for thread 1 sequence 18 ID 0xbacde77 dest 1:
Wed Aug 15 06:35:48 2012
Destination LOG_ARCHIVE_DEST_2 is SYNCHRONIZED
LGWR: Standby redo logfile selected to archive thread 1 sequence 20
LGWR: Standby redo logfile selected for thread 1 sequence 20 for destination LOG_ARCHIVE_DEST_2
Thread 1 advanced to log sequence 20 (LGWR switch)
  Current log# 2 seq# 20 mem# 0: /u01/test/redo/redo02.log
Wed Aug 15 06:35:49 2012
Archived Log entry 26 added for thread 1 sequence 19 ID 0xbacde77 dest 1:
Wed Aug 15 06:36:29 2012
alter database set standby database to maximize availability
Completed: alter database set standby database to maximize availability

========================Change it to MAXIMUM PROTECTION ==============================

STDBY->select PROTECTION_MODE,PROTECTION_LEVEL FROM V$DATABASE;

PROTECTION_MODE      PROTECTION_LEVEL
-------------------- --------------------
MAXIMUM AVAILABILITY MAXIMUM AVAILABILITY

Elapsed: 00:00:00.05

PROD-> select PROTECTION_MODE,PROTECTION_LEVEL FROM V$DATABASE;

PROTECTION_MODE      PROTECTION_LEVEL
-------------------- --------------------
MAXIMUM AVAILABILITY MAXIMUM AVAILABILITY

----STOP RECOVERY PROCESS ON STANDBY. 
STDBY->ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

Database altered.

Elapsed: 00:00:00.22

--On Primary Change Mode.
PROD-> ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PROTECTION;

Database altered.

PROD-> select PROTECTION_MODE,PROTECTION_LEVEL FROM V$DATABASE;

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

---Start Recovery Process on STANDBY.  
STDBY->ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

Database altered.

Elapsed: 00:00:06.07
STDBY->select PROTECTION_MODE,PROTECTION_LEVEL FROM V$DATABASE;

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

Elapsed: 00:00:00.00

--In Standby database Alertlog.

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL
Mon Oct 01 13:29:59 2012
MRP0: Background Media Recovery cancelled with status 16037
Errors in file /u00/app/oracle/diag/rdbms/stdby/STDBY/trace/STDBY_mrp0_3240.trc:
ORA-16037: user requested cancel of managed recovery operation
Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
Recovered data files to a consistent state at change 1054907
Errors in file /u00/app/oracle/diag/rdbms/stdby/STDBY/trace/STDBY_mrp0_3240.trc:
ORA-16037: user requested cancel of managed recovery operation
MRP0: Background Media Recovery process shutdown (STDBY)
Waiting for MRP0 pid 3240 to terminate
Managed Standby Recovery Canceled (STDBY)
Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL
Mon Oct 01 13:34:39 2012
Changing standby controlfile to MAXIMUM PROTECTION mode
Mon Oct 01 13:34:39 2012
Archived Log entry 23 added for thread 1 sequence 30 ID 0xbacde77 dest 1:
RFS[1]: Selected log 4 for thread 1 sequence 31 dbid 195900002 branch 784012804
Mon Oct 01 13:34:59 2012
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION
Attempt to start background Managed Standby Recovery process (STDBY)
Mon Oct 01 13:34:59 2012
MRP0 started with pid=28, OS id=3256
MRP0: Background Managed Standby Recovery process started (STDBY)
Serial Media Recovery started
Managed Standby Recovery starting Real Time Apply
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Media Recovery Log /u01/stdby/archive/1_30_784012804.dbf
Media Recovery Waiting for thread 1 sequence 31 (in transit)
Recovery of Online Redo Log: Thread 1 Group 4 Seq 31 Reading mem 0
  Mem# 0: /u01/stdby/redoredo04.log
Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION
Mon Oct 01 13:45:08 2012
Standby controlfile consistent with primary
RFS[1]: Selected log 5 for thread 1 sequence 32 dbid 195900002 branch 784012804
Mon Oct 01 13:45:10 2012
Archived Log entry 24 added for thread 1 sequence 31 ID 0xbacde77 dest 1:
Mon Oct 01 13:45:11 2012
Media Recovery Waiting for thread 1 sequence 32 (in transit)
Recovery of Online Redo Log: Thread 1 Group 5 Seq 32 Reading mem 0
  Mem# 0: /u01/stdby/redoredo05.log
  

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

Saturday, September 29, 2012

Duplicate for standby from active database / Rman Duplicate for standby


steps to create STANDBY database.

--Put Primary db into logging mode.
--Modify standby side listener.
--Set init parameter on Primary db.
--Create DUMMY init.ora for standby db.
--Copy primary db password file on standby side.
--Create standby redo log (SRL) on primary side.
--start standby db in NOMOUNT mode, test connection from both side.
--RMAN duplicate target database for standby from active database
--start recovery process.

Also visit ...How to change Data guard Protection Mode.


*--Put Primary db into logging mode.

ALTER DATABASE ENABLE FORCE LOGGING;


*--Modify standby side listener & reload it.

Add below part into SID_LIST

(SID_DESC =
      (GLOBAL_DB_NAME=STDBY)
      (SID_NAME = STDBY)
      (ORACLE_HOME = /u00/app/oracle/product/11.2.0/db_1)
     )

--Standby side Listner.ora

TEST:/u00/app/oracle/product/11.2.0/db_1/network/admin :TEST$cat listener.ora

SID_LIST_LISTENER_TEST =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u00/app/oracle/product/11.2.0/db_1)
      (PROGRAM = extproc)
    )
   (SID_DESC =
      (GLOBAL_DB_NAME=TEST)
      (SID_NAME = TEST)
      (ORACLE_HOME = /u00/app/oracle/product/11.2.0/db_1)
     )
---Edit below part 
   (SID_DESC =
      (GLOBAL_DB_NAME=STDBY)
      (SID_NAME = STDBY)
      (ORACLE_HOME = /u00/app/oracle/product/11.2.0/db_1)
     )
  )
-----
LISTENER_TEST =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.101 )(PORT = 1524))
    )
  )


--Now reload listener.

TEST:/u00/app/oracle/product/11.2.0/db_1/dbs :STDBY$lsnrctl reload LISTENER_TEST

LSNRCTL for Linux: Version 11.2.0.1.0 - Production
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
The command completed successfully
TEST:/u00/app/oracle/product/11.2.0/db_1/dbs :STDBY$lsnrctl status LISTENER_TEST

LSNRCTL for Linux: Version 11.2.0.1.0 - Production 
Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_TEST
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u00/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u00/app/oracle/diag/tnslsnr/TEST/listener_test/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.101)(PORT=1524)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "STDBY" has 1 instance(s).
  Instance "STDBY", status UNKNOWN, has 1 handler(s) for this service...
Service "TEST" has 1 instance(s).
  Instance "TEST", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully


--primary side Listener.ora

SID_LIST_LISTENER_PROD =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u00/app/oracle/product/11.2.0/db_1)
      (PROGRAM = extproc)
    )
   (SID_DESC =
      (GLOBAL_DB_NAME=PROD)
      (SID_NAME = PROD)
      (ORACLE_HOME = /u00/app/oracle/product/11.2.0/db_1)
     )
  )

LISTENER_PROD =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.102 )(PORT = 1525))
    )
  )



--tnsnames.ora on Both side. 

TEST_INST=(description=(address=(protocol=tcp)(host= 192.168.100.101 )(port=1524))(connect_data=(SERVER=DEDICATED)(SID=TEST)))
TEST_SERV=(description=(address=(protocol=tcp)(host= 192.168.100.101 )(port=1524))(connect_data=(SERVER=DEDICATED)(service_name=TEST)))
PROD_INST=(description=(address=(protocol=tcp)(host= 192.168.100.102 )(port=1525))(connect_data=(SERVER=DEDICATED)(SID=PROD)))
PROD_SERV=(description=(address=(protocol=tcp)(host= 192.168.100.102 )(port=1525))(connect_data=(SERVER=DEDICATED)(service_name=PROD)))


*--Set init parameter on Primary db.

--primary is running on SPFILE. 

SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u00/app/oracle/product/11.2.0/db_1/dbs/spfilePROD.ora
                                                  

--below are parameter on primary. 
DB_NAME=PROD
DB_UNIQUE_NAME=PROD

--SET BELOW PARAMTER ON PRIMARY. 

ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(PROD,STDBY)' SCOPE=BOTH;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=/u01/test/archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=PROD' SCOPE=BOTH;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=STDBY LGWR ASYNC COMPRESSION=ENABLE REOPEN=15 NET_TIMEOUT=30 MAX_FAILURE=10 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=STDBY' SCOPE=BOTH;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_1=ENABLE SCOPE=BOTH;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE SCOPE=BOTH;
ALTER SYSTEM SET REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE SCOPE=BOTH;
ALTER SYSTEM SET LOG_ARCHIVE_FORMAT=%t_%s_%r.dbf SCOPE=BOTH;
ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=30 SCOPE=BOTH;
ALTER SYSTEM SET FAL_SERVER=STDBY SCOPE=BOTH;
ALTER SYSTEM SET FAL_CLIENT=PROD SCOPE=BOTH;
ALTER SYSTEM SET DB_FILE_NAME_CONVERT='PROD','STDBY'
ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO SCOPE=BOTH;

---ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='/u01/test/redo','/u01/stdby/redo' scope=both; --- CANT CHANGE ON FLY. 


*--Create DUMMY init.ora for standby db.

TEST:/u00/app/oracle/product/11.2.0/db_1/dbs :STDBY$cat initSTDBY.ora
DB_NAME=NOTREAL


*----Copy primary db password file on standby side.

PROD:/u00/app/oracle/product/11.2.0/db_1/dbs :PROD$scp orapwPROD oracle@192.168.100.101:/u00/app/oracle/product/11.2.0/db_1/dbs


*--Create standby redo log (SRL) on primary side.

ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 '/u01/test/redo/redo04.log' size 10m ;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 '/u01/test/redo/redo05.log' size 10m ;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 '/u01/test/redo/redo06.log' size 10m ;


*--start standby db in NOMOUNT mode, test connection from both side.

TEST:/u00/app/oracle/product/11.2.0/db_1/dbs :STDBY$sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sat Sep 29 16:07:01 2012

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

Connected to an idle instance.

@STDBY->startup nomount;
ORACLE instance started.

Total System Global Area            367439872 bytes
Fixed Size                            2213456 bytes
Variable Size                       318769584 bytes
Database Buffers                     41943040 bytes
Redo Buffers                          4513792 bytes


--Test connections. You should be able to start/stop standby db from Primary side.

PROD:/u00/app/oracle/product/11.2.0/db_1/network/admin :PROD$tnsping STDBY
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production 
Copyright (c) 1997, 2009, Oracle.  All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (description=(address=(protocol=tcp)(host= 192.168.100.101)(port=1524))(connect_data=(SERVER=DEDICATED)(service_name=STDBY)))
OK (0 msec)

--Lets startup and stop standby from Primary side. 
 
PROD:/u00/app/oracle/product/11.2.0/db_1/network/admin :PROD$sqlplus sys/system@STDBY as sysdba

SQL*Plus: Release 11.2.0.1.0 Production 
Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shutdown immediate;
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> STARTUP NOMOUNT;
ORACLE instance started.

Total System Global Area  367439872 bytes
Fixed Size                  2213456 bytes
Variable Size             318769584 bytes
Database Buffers           41943040 bytes
Redo Buffers                4513792 bytes
SQL>


*--RMAN duplicate target database for standby from active database (full output is at end of the post)

RMAN will be invoked from Primary as below.

PROD:/u00/app/oracle/product/11.2.0/db_1/dbs :PROD$rman target  sys/system@PROD_SERV AUXILIARY sys/system@STDBY

Recovery Manager: Release 11.2.0.1.0 - Production on 
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PROD (DBID=195900002)
connected to auxiliary database: NOTREAL (not mounted)

RMAN> run{
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate channel prmy3 type disk;
allocate auxiliary channel stby1 type disk;
duplicate target database for standby from active database
spfile
parameter_value_convert='PROD','STDBY','/u01/test/','/u01/stdby/'
set db_file_name_convert='/u01/test/','/u01/stdby/'
set log_file_name_convert='/u01/test/redo/','/u01/stdby/redo'
set 'db_unique_name'='STDBY'
nofilenamecheck;
}


--start recovery process on standby side by applying Real-time redo.

@STDBY->ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

--you can also check output from alert log on standby side. 

STDBY:/u00/app/oracle/diag/rdbms/stdby/STDBY/trace :STDBY$tail -f alert_STDBY.log
--------
Primary database is in MAXIMUM PERFORMANCE mode
Tue Aug 14 14:44:27 2012
RFS[3]: Assigned to RFS process 6688
RFS[3]: Identified database type as 'physical standby': Client is ARCH pid 3141
RFS[2]: Selected log 4 for thread 1 sequence 9 dbid 195900002 branch 784012804
RFS[3]: Opened log for thread 1 sequence 8 dbid 195900002 branch 784012804
Archived Log entry 1 added for thread 1 sequence 8 rlc 784012804 ID 0xbacde77 dest 2:
RFS[2]: Selected log 5 for thread 1 sequence 10 dbid 195900002 branch 784012804
Tue Aug 14 14:44:28 2012
Archived Log entry 2 added for thread 1 sequence 9 ID 0xbacde77 dest 1:
TEST:/u00/app/oracle/diag/rdbms/stdby/STDBY/trace :TEST$
TEST:/u00/app/oracle/diag/rdbms/stdby/STDBY/trace :TEST$tail -f alert_STDBY.log
Primary database is in MAXIMUM PERFORMANCE mode
Tue Aug 14 14:44:27 2012
RFS[3]: Assigned to RFS process 6688
RFS[3]: Identified database type as 'physical standby': Client is ARCH pid 3141
RFS[2]: Selected log 4 for thread 1 sequence 9 dbid 195900002 branch 784012804
RFS[3]: Opened log for thread 1 sequence 8 dbid 195900002 branch 784012804
Archived Log entry 1 added for thread 1 sequence 8 rlc 784012804 ID 0xbacde77 dest 2:
RFS[2]: Selected log 5 for thread 1 sequence 10 dbid 195900002 branch 784012804
Tue Aug 14 14:44:28 2012
Archived Log entry 2 added for thread 1 sequence 9 ID 0xbacde77 dest 1:
Tue Aug 14 14:46:09 2012
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION
Attempt to start background Managed Standby Recovery process (STDBY)
Tue Aug 14 14:46:09 2012
MRP0 started with pid=30, OS id=6734
MRP0: Background Managed Standby Recovery process started (STDBY)
Serial Media Recovery started
Managed Standby Recovery starting Real Time Apply
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Media Recovery Log /u01/stdby/archive/1_8_784012804.dbf
Media Recovery Log /u01/stdby/archive/1_9_784012804.dbf
Media Recovery Waiting for thread 1 sequence 10 (in transit)
Recovery of Online Redo Log: Thread 1 Group 5 Seq 10 Reading mem 0
  Mem# 0: /u01/stdby/redoredo05.log
Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION 




=====================full output of duplicate database==================================


PROD:/u00/app/oracle/product/11.2.0/db_1/dbs :PROD$rman target  sys/system@PROD_SERV AUXILIARY sys/system@STDBY

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Aug 14 14:45:13 2012

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

connected to target database: PROD (DBID=195900002)
connected to auxiliary database: NOTREAL (not mounted)

RMAN> run{
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate channel prmy3 type disk;
allocate auxiliary channel stby1 type disk;
duplicate target database for standby from active database
spfile
parameter_value_convert='PROD','STDBY','/u01/test/','/u01/stdby/'
set db_file_name_convert='/u01/test/','/u01/stdby/'
set log_file_name_convert='/u01/test/redo/','/u01/stdby/redo'
set 'db_unique_name'='STDBY'
nofilenamecheck;
}

using target database control file instead of recovery catalog
allocated channel: prmy1
channel prmy1: SID=51 device type=DISK

allocated channel: prmy2
channel prmy2: SID=31 device type=DISK

allocated channel: prmy3
channel prmy3: SID=42 device type=DISK

allocated channel: stby1
channel stby1: SID=20 device type=DISK

Starting Duplicate Db at 14-AUG-12

contents of Memory Script:
{
   backup as copy reuse
   targetfile  '/u00/app/oracle/product/11.2.0/db_1/dbs/orapwPROD' auxiliary format
 '/u00/app/oracle/product/11.2.0/db_1/dbs/orapwSTDBY'   targetfile
 '/u00/app/oracle/product/11.2.0/db_1/dbs/spfilePROD.ora' auxiliary format
 '/u00/app/oracle/product/11.2.0/db_1/dbs/spfileSTDBY.ora'   ;
   sql clone "alter system set spfile= ''/u00/app/oracle/product/11.2.0/db_1/dbs/spfileSTDBY.ora''";
}
executing Memory Script

Starting backup at 14-AUG-12
Finished backup at 14-AUG-12

sql statement: alter system set spfile= ''/u00/app/oracle/product/11.2.0/db_1/dbs/spfileSTDBY.ora''

contents of Memory Script:
{
   sql clone "alter system set  control_files =
 ''/u01/stdby/data/control01.ctl'', ''/u01/stdby/data/control02.ctl'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_archive_dest_1 =
 ''LOCATION=/u01/stdby/archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=STDBY'' comment=
 '''' scope=spfile";
   sql clone "alter system set  db_file_name_convert =
 ''/u01/test/'', ''/u01/stdby/'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_file_name_convert =
 ''/u01/test/redo/'', ''/u01/stdby/redo'' comment=
 '''' scope=spfile";
   sql clone "alter system set  db_unique_name =
 ''STDBY'' comment=
 '''' scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script

sql statement: alter system set  control_files =  ''/u01/stdby/data/control01.ctl'', ''/u01/stdby/data/control02.ctl'' comment= '''' scope=spfile

sql statement: alter system set  log_archive_dest_1 =  ''LOCATION=/u01/stdby/archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=STDBY'' comment= '''' scope=spfile

sql statement: alter system set  db_file_name_convert =  ''/u01/test/'', ''/u01/stdby/'' comment= '''' scope=spfile

sql statement: alter system set  log_file_name_convert =  ''/u01/test/redo/'', ''/u01/stdby/redo'' comment= '''' scope=spfile

sql statement: alter system set  db_unique_name =  ''STDBY'' comment= '''' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     367439872 bytes

Fixed Size                     2213456 bytes
Variable Size                247466416 bytes
Database Buffers             113246208 bytes
Redo Buffers                   4513792 bytes
allocated channel: stby1
channel stby1: SID=18 device type=DISK

contents of Memory Script:
{
   backup as copy current controlfile for standby auxiliary format  '/u01/stdby/data/control01.ctl';
   restore clone controlfile to  '/u01/stdby/data/control02.ctl' from
 '/u01/stdby/data/control01.ctl';
}
executing Memory Script

Starting backup at 14-AUG-12
channel prmy1: starting datafile copy
copying standby control file
output file name=/u00/app/oracle/product/11.2.0/db_1/dbs/snapcf_PROD.f tag=TAG20120814T144542 RECID=1 STAMP=791304343
channel prmy1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 14-AUG-12

Starting restore at 14-AUG-12

channel stby1: copied control file copy
Finished restore at 14-AUG-12

contents of Memory Script:
{
   sql clone 'alter database mount standby database';
}
executing Memory Script

sql statement: alter database mount standby database

contents of Memory Script:
{
   set newname for tempfile  1 to
 "/u01/stdby/data/temp01.dbf";
   switch clone tempfile all;
   set newname for datafile  1 to
 "/u01/stdby/data/system01.dbf";
   set newname for datafile  2 to
 "/u01/stdby/data/sysaux01.dbf";
   set newname for datafile  3 to
 "/u01/stdby/data/undotbs01.dbf";
   set newname for datafile  4 to
 "/u01/stdby/data/users01.dbf";
   set newname for datafile  5 to
 "/u01/stdby/data/test.dbf";
   backup as copy reuse
   datafile  1 auxiliary format
 "/u01/stdby/data/system01.dbf"   datafile
 2 auxiliary format
 "/u01/stdby/data/sysaux01.dbf"   datafile
 3 auxiliary format
 "/u01/stdby/data/undotbs01.dbf"   datafile
 4 auxiliary format
 "/u01/stdby/data/users01.dbf"   datafile
 5 auxiliary format
 "/u01/stdby/data/test.dbf"   ;
   sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u01/stdby/data/temp01.dbf in control file

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting backup at 14-AUG-12
channel prmy1: starting datafile copy
input datafile file number=00001 name=/u01/test/data/system01.dbf
channel prmy2: starting datafile copy
input datafile file number=00002 name=/u01/test/data/sysaux01.dbf
channel prmy3: starting datafile copy
input datafile file number=00005 name=/u01/test/data/test.dbf
output file name=/u01/stdby/data/test.dbf tag=TAG20120814T144553
channel prmy3: datafile copy complete, elapsed time: 00:00:46
channel prmy3: starting datafile copy
input datafile file number=00003 name=/u01/test/data/undotbs01.dbf
output file name=/u01/stdby/data/sysaux01.dbf tag=TAG20120814T144553
channel prmy2: datafile copy complete, elapsed time: 00:01:13
channel prmy2: starting datafile copy
input datafile file number=00004 name=/u01/test/data/users01.dbf
output file name=/u01/stdby/data/system01.dbf tag=TAG20120814T144553
channel prmy1: datafile copy complete, elapsed time: 00:01:28
output file name=/u01/stdby/data/users01.dbf tag=TAG20120814T144553
channel prmy2: datafile copy complete, elapsed time: 00:00:15
output file name=/u01/stdby/data/undotbs01.dbf tag=TAG20120814T144553
channel prmy3: datafile copy complete, elapsed time: 00:00:42
Finished backup at 14-AUG-12

sql statement: alter system archive log current

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=1 STAMP=791304219 file name=/u01/stdby/data/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=2 STAMP=791304219 file name=/u01/stdby/data/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=3 STAMP=791304219 file name=/u01/stdby/data/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=4 STAMP=791304219 file name=/u01/stdby/data/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=5 STAMP=791304219 file name=/u01/stdby/data/test.dbf
Finished Duplicate Db at 14-AUG-12
released channel: prmy1
released channel: prmy2
released channel: prmy3
released channel: stby1

Tuesday, September 11, 2012

CTAS for partition tables / create table as select * from partition table

create table as select * from , for partition tables as below.

Here is Table DDL

CREATE TABLE CNS.COMM_CNS_dummy_data
(
  FILE_DT                         NUMBER(6),
  PARENT_HQ_NAME                  VARCHAR2(90 BYTE),
  PARENT_HQ_FIPS_COUNTRY_CODE     VARCHAR2(2 BYTE),
  PARENT_HQ_COUNTRY_CODE          VARCHAR2(3 BYTE),
  PARENT_HQ_STATE                 VARCHAR2(10 BYTE),
  HIERARCHY_CODE                  VARCHAR2(2 BYTE),
  DIAS_CODE                       VARCHAR2(9 BYTE),
  NUMBER_OF_FAMILY_MEMBERS        VARCHAR2(5 BYTE),
  FAMILY_UPDATE_DATE              VARCHAR2(8 BYTE),
  SIC1                            VARCHAR2(32 BYTE),
  SIC2                            VARCHAR2(32 BYTE),
  SIC3                            VARCHAR2(32 BYTE),
  SIC4                            VARCHAR2(32 BYTE),
  SIC5                            VARCHAR2(32 BYTE),
  SIC6                            VARCHAR2(32 BYTE),
  NATIONAL_IDENTIFICATION_NUMBER  VARCHAR2(20 BYTE),
  FILLER10                        VARCHAR2(6 BYTE),
  FILLER11                        VARCHAR2(6 BYTE),
  FIRST_EXECUTIVE_FIRST_NAME      VARCHAR2(13 BYTE),
  CENSUS_GEOCODE                  VARCHAR2(15 BYTE),
  CENSUS_GEOCODE_MATCH_FLAG       VARCHAR2(1 BYTE),
  CENSUS_2003_NECTA_DIV_FIPS      VARCHAR2(5 BYTE),
)
TABLESPACE CNS_DATA
PARTITION BY RANGE (FILE_DT)
(  
  PARTITION CNS_dummy_data_201105 VALUES LESS THAN (201106) TABLESPACE CNS_DATA,  
  PARTITION CNS_dummy_data_201106 VALUES LESS THAN (201107) TABLESPACE CNS_DATA,  
  PARTITION CNS_dummy_data_201107 VALUES LESS THAN (201108) TABLESPACE CNS_DATA,  
  PARTITION CNS_dummy_data_201108 VALUES LESS THAN (201109) TABLESPACE CNS_DATA,  
  PARTITION CNS_dummy_data_201109 VALUES LESS THAN (201110) TABLESPACE CNS_DATA,  
  PARTITION CNS_dummy_data_201110 VALUES LESS THAN (201111) TABLESPACE CNS_DATA,  
  PARTITION CNS_dummy_data_201111 VALUES LESS THAN (201112) TABLESPACE CNS_DATA,  
  PARTITION CNS_dummy_data_201112 VALUES LESS THAN (201201) TABLESPACE CNS_DATA,  
)
;


CTAS for above table will be

CREATE TABLE cns.COMM_cns_dummy_data_BK PARTITION BY RANGE (FILE_DT)
(
  PARTITION cns_dummy_data_201105 VALUES LESS THAN (201106),
  PARTITION cns_dummy_data_201106 VALUES LESS THAN (201107),
  PARTITION cns_dummy_data_201107 VALUES LESS THAN (201108),
  PARTITION cns_dummy_data_201108 VALUES LESS THAN (201109),
  PARTITION cns_dummy_data_201109 VALUES LESS THAN (201110),
  PARTITION cns_dummy_data_201110 VALUES LESS THAN (201111),
  PARTITION cns_dummy_data_201111 VALUES LESS THAN (201112),
  PARTITION cns_dummy_data_201112 VALUES LESS THAN (201201)
  )
  AS SELECT * FROM 
  cns.COMM_cns_dummy_data PARALLEL;

Thursday, September 6, 2012

Active Dataguard vs Goldengate.


Few days back i have provided Recommendation on what should use for DR. 

Active Data Guard or Oracle Goldengate. 

Primary Functional Comparison .

Oprations
Active Data Guard 
  GoldenGate V11.2
Suitable
Disaster recovery /  Read-only Reporting.
Fine-grain Replication / Object Transformation
Security
User  grant/privileges are same on Target & Source
User access can restricted as per requirement.
Data type support
All data-type supported by Primary
*  (Attached separately)
Replication
·      Physical block-to-block copy of whole DB on Target.  (Carried out by Redo logs). 
·      Target will be read only  (Can be Open temporary for read/write)
·      Support Parallel DML on RAC span on Multiple instances.

·      No object-Transformation allowed
·      Support compression.
·      Only Required Table are subject for Replication  (More controlled). (carried out by Trailfiles) 
·      Target will be in read/write all Time.
·      Does Not support Parallel DML on RAC  spawn from Multiple instances
·      Object-Transformation Allowed.
·      Not-support Compression. 
Maintenance.
Automatic Outage Gap resolution.
Low-Maintenance
Manual Invention needed for Troubleshoot.
Moderate - Maintenance.
Clustered DB
Only One instance will Perform recovery  on Target.
All instance will perform recovery on Target side.  (Load balance)


Other things to look for . 

·         Do you need Copy of source database or  Set of tables required to be Replicate
·         SLA for lag/latency.
·         Amount of Archive log Generated / day by database  ( Per Instance for RAC )
·         Is source & target are in different Time-zone.
·         No of tables with LOB/CLOB data to be replicate.
·         Network bandwidth.


Tuesday, August 14, 2012

resmgr:pq queued | enq: JX - SQL statement queue | PX Queuing: statement queue

We have 4 Node RAC on 11.2.0.2 on exadata machine.

Few days back we had problem of Trucate statment was running slow. it took around 1 hour.
when truncate is running slow.
either object is locked or its bug. But here it was something else.

TRUNCATE TABLE DUMMY_USAGE.DUMMY_CUST_BILL_CYC_USG_F_BLD1 DROP STORAGE;

After pulling AWR , we found that "resmgr:pq queued" is in Top 5 wait events.
It looks that database has been suffered from "lack of enough parallel servers".
even TRUNCATE statement also tried to ran into parallel.


in 11.2.0.2

resmgr:pq queued is The time the session waited for sufficient parallel query processes to become available to run this session with the requested degree of parallelism

in 11.2.0.1

Wait event "PX Queuing: statement queue" is the event When statement waits on about to run.

Wait event "enq: JX - SQL statement queue" is event when statement have few more statments lined up ahead of it.


Wait event on DB. So database has heavily waited on "resmgr:pq queued"

MIN(SAMPLE_TIME) MAX(SAMPLE_TIME)                 COUNT EVENT
8/10/2012 3:39:15.324 AM 8/10/2012 7:00:26.064 AM 11812 resmgr:pq queued
8/10/2012 2:13:36.850 AM 8/10/2012 7:00:16.054 AM 3045 CPU
8/10/2012 3:05:19.667 AM 8/10/2012 6:59:03.635 AM 2638 direct path read temp
8/10/2012 2:00:45.579 AM 8/10/2012 6:59:15.940 AM 1987 cell smart table scan

Which SQL has waited Most from "lack of Enogh parallel servers"

SELECT MIN(SAMPLE_TIME),MAX(SAMPLE_TIME),COUNT(*) AS COUNT , EVENT,SQL_ID FROM DBA_HIST_ACTIVE_sESS_HISTORY WHERE SNAP_ID BETWEEN 1594 AND 1598 AND EVENT='resmgr:pq queued' group by EVENT,SQL_ID ORDER BY COUNT DESC;

MIN(SAMPLE_TIME)         MAX(SAMPLE_TIME)        COUNT    EVENT           SQL_ID
---------------------------------------------------------------------------------------------
8/10/2012 4:24:47.633 AM 8/10/2012 6:25:40.210 AM 723 resmgr:pq queued brjbmruuj4qca

8/10/2012 4:06:58.060 AM 8/10/2012 5:49:08.703 AM 540 resmgr:pq queued 1ztm7k9fbawks
8/10/2012 4:07:05.815 AM 8/10/2012 5:38:45.312 AM 477 resmgr:pq queued 8fdq282ydmj9y
8/10/2012 4:06:58.060 AM 8/10/2012 5:37:57.564 AM 473 resmgr:pq queued 5pgx9fqn6b18k
8/10/2012 4:06:58.060 AM 8/10/2012 5:37:07.457 AM 470 resmgr:pq queued bfyb7a00r9m97
8/10/2012 4:06:58.060 AM 8/10/2012 5:34:07.155 AM 452 resmgr:pq queued dck4f08ywn2gk
8/10/2012 4:07:05.815 AM 8/10/2012 5:33:34.783 AM 448 resmgr:pq queued 2tjdy0su2yyrg
8/10/2012 4:06:58.060 AM 8/10/2012 5:32:26.963 AM 442 resmgr:pq queued a770bk5gnyp49
8/10/2012 4:06:58.060 AM 8/10/2012 5:31:56.913 AM 439 resmgr:pq queued 8qgm5az2pstpw
8/10/2012 4:07:05.815 AM 8/10/2012 5:31:24.561 AM 435 resmgr:pq queued 3gytqk6h6hy46
8/10/2012 4:07:05.815 AM 8/10/2012 5:31:14.513 AM 434 resmgr:pq queued 73bxznwgh04yf

8/10/2012 4:49:52.568 AM 8/10/2012 5:49:08.703 AM 356 resmgr:pq queued 3qkqq4w2z03jh
8/10/2012 4:06:58.060 AM 8/10/2012 5:03:13.976 AM 338 resmgr:pq queued g0b4p5zsn5xwp
8/10/2012 4:06:58.060 AM 8/10/2012 5:02:23.885 AM 333 resmgr:pq queued 0k5796sr9sgrq
8/10/2012 4:07:05.815 AM 8/10/2012 5:01:01.402 AM 324 resmgr:pq queued a8m336ddng5z7
8/10/2012 4:07:05.815 AM 8/10/2012 4:59:41.282 AM 316 resmgr:pq queued 8wz2qpu6t3b4r
8/10/2012 4:06:58.060 AM 8/10/2012 4:58:53.520 AM 312 resmgr:pq queued c1a03akcb57nm
8/10/2012 4:39:51.493 AM 8/10/2012 5:31:06.810 AM 308 resmgr:pq queued bsuwb8ksjgg7f
8/10/2012 5:38:15.272 AM 8/10/2012 6:32:10.874 AM 287 resmgr:pq queued 8tkfm8yg6fy3z

SQL> SELECT * FROM DBA_HIST_SQLTEXT WHERE sql_id in ('brjbmruuj4qca','1ztm7k9fbawks');

      DBID SQL_ID        SQL_TEXT                                                                         COMMAND_TYPE
---------- ------------- -------------------------------------------------------------------------------- ------------
1664458898 brjbmruuj4qca TRUNCATE TABLE DUMMY_USAGE.DUMMY_TOP_TALKERS_DLY_SUM_SWP DROP STORAGE                        85
2309640764 8fdq282ydmj9y SELECT Last_day(cduf.time_key)         AS time_key                                          3


when Oracle put statments to Queue for parallel servers.

When the parameter PARALLEL_DEGREE_POLICY is set to AUTO, Oracle Database queues SQL statements that require parallel execution if the necessary parallel server processes are not available. After the necessary resources become available, the SQL statement is dequeued and allowed to execute. The default dequeue order is a simple first in, first out queue based on the time a statement was issued.

The following is a summary of parallel statement processing.

1) A SQL statements is issued.

2) The statement is parsed and the DOP is automatically determined.

3) Available parallel resources are checked.

A) If there are enough parallel resources and there are no statements ahead in the queue waiting for the resources, the SQL statement is executed.

B) If there are not enough parallel servers, the SQL statement is queued based on specified conditions and dequeued from the front of the queue when specified conditions are met.

Parallel statements are queued if running the statements would increase the number of active parallel servers above the value of the PARALLEL_SERVERS_TARGET initialization parameter. For example, if PARALLEL_SERVERS_TARGET is set to 64, the number of current active servers is 60, and a new parallel statement needs 16 parallel servers, it would be queued because 16 added to 60 is greater than 64, the value of PARALLEL_SERVERS_TARGET.

The default value is described in "PARALLEL_SERVERS_TARGET". This value is not the maximum number of parallel server processes allowed on the system, but the number available to run parallel statements before parallel statement queuing is used. It is set lower than the maximum number of parallel server processes allowed on the system (PARALLEL_MAX_SERVERS) to ensure each parallel statement gets all of the parallel server resources required and to prevent overloading the system with parallel server processes. Note all serial (nonparallel) statements execute immediately even if parallel statement queuing has been activated.

If a statement has been queued, it is identified by the resmgr:pq queued wait event.

Parameter to define parallelism were defined something like below,
SQL> show parameter parallel

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
fast_start_parallel_rollback         string      LOW
parallel_adaptive_multi_user         boolean     FALSE
parallel_automatic_tuning            boolean     FALSE
parallel_degree_limit                string      16
parallel_degree_policy               string      AUTO   --AUTO DOP is used. 
parallel_execution_message_size      integer     16384
parallel_force_local                 boolean     FALSE
parallel_instance_group              string
parallel_io_cap_enabled              boolean     FALSE
parallel_max_servers                 integer     32
parallel_min_time_threshold          string      AUTO
parallel_server                      boolean     TRUE
parallel_server_instances            integer     4   
parallel_servers_target              integer     16
parallel_threads_per_cpu             integer     1

SQL> show parameter cpu

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
cpu_count                            integer     24  
parallel_threads_per_cpu             integer     1


It have only 32 Parallel servers and queuing will start even if 16 servers are Used.

so Both parallel_max_servers & parallel_servers_target have set incorrect.

Auto DOP is calculated as (parallel_threads_per_cpu × parallel_server_instances × cpu_count )= 96

The default value for parallel_server_target is set to 4 times the default DOP.

((4 × CPU_count) × parallel_threads_per_cpu) × active_instances = PARALLEL_SERVER_TARGET

((4 × 24) × 1) × 4) = 384 should be PARALLEL_SERVER_TARGET


Managing Parallel Statement Queuing with Hints

NO_STATEMENT_QUEUING

When PARALLEL_DEGREE_POLICY is set to AUTO, this hint enables a statement to bypass the parallel statement queue. For example:

SELECT /*+ NO_STATEMENT_QUEUING */ emp.last_name, dpt.department_name
FROM employees emp, departments dpt
WHERE emp.department_id = dpt.department_id;

STATEMENT_QUEUING

When PARALLEL_DEGREE_POLICY is not set to AUTO, this hint enables a statement to be delayed and to only run when parallel processes are available to run at the requested DOP. For example:

SELECT /*+ STATEMENT_QUEUING */ emp.last_name, dpt.department_name
FROM employees emp, departments dpt
WHERE emp.department_id = dpt.department_id;

There is also a hidden parameter which control parallel queuing.
_parallel_statement_queuing=TRUE