Wednesday, November 14, 2012

Datapump notes

Datapump
Exporting table
syntax 
expdp username_taking_export/passwd directory=directory_name dumpfile=some_related_name.dmp logfile=some_related_name.log tables=username.table_name

Example--> 
expdp system/passwd directory=dba_dir dumpfile=exp_scott_emp.dmp logfile=exp_scott_emp.log tables=scott.emp

usename_taking_export---> is the user as whom you are taking export backup.Can be the owner of table or any other user who has required privileges.

directory--> a directory which has been created & from above username_taking_export user should have been granted read, write privileges. It is here the dumpfiles are going to be created.

tables--> if the table is to be exported from another schema, then qualify it with the schema/user name

Wednesday, November 7, 2012

Hidden parameters - Oracle Tidbits

Upgrade brought an issue with new optimizer features. On analysis an optimizer feature had to be turned off. While I save that experience for another day in here I wanted to share about how the particular feature a hidden parameter setting had to be changed.

To get its current value from "v$parameter"
SQL> select name, value from v$parameter where name like '/_fix%' escape '/';
no rows selected
For finding the hidden parameter the following Query should help.  I was searching for "_fix_control"

set escape '\'
select a.ksppinm name,b.ksppstvl value, b.ksppstdf deflt,
decode (a.ksppity, 1,'boolean',
     2,'string',
     3,'number',
     4,'file', a.ksppity) type,
a.ksppdesc description
from
sys.x$ksppi a,
sys.x$ksppcv b
where
a.indx = b.indx
and
a.ksppinm like '\_fix\_contr%'
order by
name;

NAME                 VALUE      DEFLT     TYPE                                     DESCRIPTION
-------------------- ---------- --------- ---------------------------------------- --------------------------
_fix_control                    TRUE      string                                   bug fix control parameter


We have the option of changing it session or system level. For changing any hidden parameters it is required to check with oracle support. As an example its being changed at system level here.

SQL> alter system set "_fix_control"='8893626:OFF' scope=both;
System altered.
NAME                 VALUE      DEFLT     TYPE                                     DESCRIPTION
-------------------- ---------- --------- ---------------------------------------- ------------------------
_fix_control         8893626:OFF TRUE      string                                   bug fix control parameter
                    

Thursday, September 20, 2012

Rename DB and DBID after refreshing on another server

Changing DB name & DBID using NID utility

[oracle@lnx-122 dbs]$ nid target=sys/abc123 dbname=cric
DBNEWID: Release 11.2.0.2.0 - Production on Thu Sep 20 09:40:32 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to database MAZE (DBID=1370075061)
Connected to server version 11.2.0
Control Files in database:
/u01/app/oracle/oradata1/cric/control01.ctl
/u01/app/oracle/oradata2/cric/control02.ctl
Change database ID and database name MAZE to CRIC? (Y/[N]) => Y
Proceeding with operation
Changing database ID from 1370075061 to 566499152
Changing database name from MAZE to CRIC
Control File /u01/app/oracle/oradata1/cric/control01.ctl - modified
Control File /u01/app/oracle/oradata2/cric/control02.ctl - modified
Datafile /u01/app/oracle/oradata2/cric/system01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata2/cric/sysaux01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata1/cric/undotbs01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata1/cric/users01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata1/cric/example01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata2/cric/appstbs_01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata1/cric/appstbs_01.db - dbid changed, wrote new name
Control File /u01/app/oracle/oradata1/cric/control01.ctl - dbid changed, wrote new name
Control File /u01/app/oracle/oradata2/cric/control02.ctl - dbid changed, wrote new name
Instance shut down
Database name changed to CRIC.
Modify parameter file and generate a new password file before restarting.
Database ID for database CRIC changed to 566499152.
All previous backups and archived redo logs for this database are unusable.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.

SQL*Plus: Release 11.2.0.2.0 Production on Thu Sep 20 09:41:20 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 422670336 bytes
Fixed Size 1344616 bytes
Variable Size 331352984 bytes
Database Buffers 83886080 bytes
Redo Buffers 6086656 bytes
ORA-01103: database name 'CRIC' in control file is not 'MAZE'
 
SQL> shut immediate;
ORA-01507: database not mounted
 
ORACLE instance shut down.
SQL> exit

Since I didnt' make the changes to pfile & orapwd file the above error popped out. Make the changes in pfile & then set the right ORACLE_SID.  
[oracle@lnx-122 dbs]$ export ORACLE_SID=cric
[oracle@lnx-122 dbs]$ sql
SQL*Plus: Release 11.2.0.2.0 Production on Thu Sep 20 09:51:39 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 422670336 bytes
Fixed Size 1344616 bytes
Variable Size 260049816 bytes
Database Buffers 155189248 bytes
Redo Buffers 6086656 bytes
SQL> alter database mount;
Database altered.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
 --> start datbase with open resetlogs
SQL> alter database open resetlogs;
Database altered.
SQL> select name from v$database;
NAME
---------
CRIC
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oraredo/cric/redo03.log
/u01/app/oracle/oraredo/cric/redo02.log
/u01/app/oracle/oraredo/cric/redo01.log
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata1/cric/control01.ctl
/u01/app/oracle/oradata2/cric/control02.ctl
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata2/cric/system01.dbf
/u01/app/oracle/oradata2/cric/sysaux01.dbf
/u01/app/oracle/oradata1/cric/undotbs01.dbf
/u01/app/oracle/oradata1/cric/users01.dbf
/u01/app/oracle/oradata1/cric/example01.dbf
/u01/app/oracle/oradata2/cric/appstbs_01.dbf
/u01/app/oracle/oradata1/cric/appstbs_01.dbf
7 rows selected.

Note: Refer to oracle documention before using nid utility.

Wednesday, September 19, 2012

Incorrect password during Grid agent (OMA) installation

Installing agent an incorrect password was specified for agent resulted in OMA not being able to do a handshake with OMS

servvertst1:/app/oracle/product/agent11g/agent11g/bin-->./emctl status agent
Oracle Enterprise Manager 11g Release 1 Grid Control 11.1.0.1.0
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
---------------------------------------------------------------
Agent Version : 11.1.0.1.0
OMS Version : 11.1.0.1.0
Protocol Version : 11.1.0.0.0
Agent Home : /app/oracle/product/agent11g/agent11g
Agent binaries : /app/oracle/product/agent11g/agent11g
Agent Process ID : 20447384
Parent Process ID : 23068916
Agent URL : http://servvertst1:3872/emd/main/
Repository URL : https://xx.xxx.xxx.xx:1159/em/upload/
Started at : 2012-09-18 16:07:44
Started by user : oracle
Last Reload : 2012-09-18 16:07:44
Last successful upload : (none)
Last attempted upload : (none)Total Megabytes of XML files uploaded so far : 0.00
Number of XML files pending upload : 417
Size of XML files pending upload(MB) : 18.89
Available disk space on upload filesystem : 18.80%
Last attempted heartbeat to OMS : 2012-09-19 16:37:18
Last successful heartbeat to OMS : unknown
---------------------------------------------------------------
Agent is Running and Ready
 
 
To resolve the issue follow the below steps
Go to grid_agent_home/bin

servvertst1:/app/oracle/product/agent11g/agent11g/bin-->./emctl unsecure agentOracle Enterprise Manager 11g Release 1 Grid Control 11.1.0.1.0
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
DelKeyWallet: Cannot open wallet. (error=28759):/app/oracle/product/agent11g/agent11g/sysman/config
clearsudoprops error: Could not delete key from wallet.
Checking Agent for HTTP... Done.
Agent is already unsecured.


Now we can assign the correct password

servvertst1:/app/oracle/product/agent11g/agent11g/bin-->./emctl secure agent
Oracle Enterprise Manager 11g Release 1 Grid Control 11.1.0.1.0
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
Agent successfully stopped... Done.
Securing agent... Started.
Enter Agent Registration Password :specify_correct_passwd_here

Agent successfully restarted... Done.
Securing agent... Successful.

servvertst1:/app/oracle/product/agent11g/agent11g/bin-->./emctl status agent
Oracle Enterprise Manager 11g Release 1 Grid Control 11.1.0.1.0
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
---------------------------------------------------------------Agent Version : 11.1.0.1.0
OMS Version : 10.2.0.3.0
Protocol Version : 10.2.0.3.0
Agent Home : /app/oracle/product/agent11g/agent11g
Agent binaries : /app/oracle/product/agent11g/agent11g
Agent Process ID : 22282428
Parent Process ID : 18415688
Agent URL : https://servvertst1:3872/emd/main/
Repository URL : https://gridserver:1159/em/upload
Started at : 2012-09-19 16:40:34
Started by user : oracle
Last Reload : 2012-09-19 16:40:34
Last successful upload : 2012-09-19 16:41:03
Total Megabytes of XML files uploaded so far : 8.65
Number of XML files pending upload : 1
Size of XML files pending upload(MB) : 0.01

Available disk space on upload filesystem : 19.45%
Last successful heartbeat to OMS : 2012-09-19 16:40:40

---------------------------------------------------------------
Agent is Running and Ready



This indicates that OMA was able to do a handshake with OMS, once this is done you can go to grid control & add the new target

Sunday, July 8, 2012

Creating Database Manually

CREATING DATABASE MANUALLY
Steps to follow to create a database manually
  1. Create a pfile
  2. Create a sql script to create database
  3. Startup database in nomount
  4. Execute the sql script to create database
  5. Run the post database creation scripts


Create pfile
$ cat inittest.ora
db_name=test
memory_max_target=1024m
memory_target=1024m
control_files='/app/oracle/oradata/TEST/controlfile01.ctl','/app/oracle/oradata/TEST/controlfile02.ctl'
audit_file_dest='/app/oracle/admin/test/adump'
audit_trail='db'
compatible='11.2.0.0.0'
db_block_size=8192
diagnostic_dest='/app/oracle'
open_cursors=300
processes=150
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'

observations:
These are few of the parameters which are defining the database, noticeably control_files, diagnostic_dest, compatible, memory_target

Create SQL script to create database-à Create a sql script at a desired location, so that it can be called during execution.
$ cat dbcreate.sql
create database test
datafile '/app/oracle/oradata/TEST/system1.dbf' size 500m
sysaux datafile '/app/oracle/oradata/TEST/sysaux01.dbf' size 100m
default tablespace users datafile '/app/oracle/oradata/TEST/users1.dbf' size 100m
default temporary tablespace temp tempfile '/app/oracle/oradata/TEST/temp1.dbf' size 100m
undo tablespace undotbs1 datafile '/app/oracle/oradata/TEST/undo1.dbf' size 100m
logfile
group 1 ('/app/oracle/oradata/TEST/redolog1.log') size 10m,
group 2 ('/app/oracle/oradata/TEST/redolog2.log') size 10m,
group 3 ('/app/oracle/oradata/TEST/redolog3.log') size 10m;

Observationsà syntax is important, typo’s, incorrect names, incorrect syntax will cause failure of database creation

Startup database in NOMOUNT
Connect as “ / as sysdba” & startup the instance in nomount. If the pfile entries are correct (depending on the location/directories specified) it will start up the instance, where in it allocates memory to Oracle.


Execute the Database creation script
On starting up the database in NOMOUNT state, being connected as “ / as sysdba” execute the create database script
SQL> @dbcreate.sql;


You can monitor the alert_test.log to see the database creation in progress.

Post database creation steps
These include building data dictionary views, creating public synonyms, granting access to public.
Run the following scripts as “ / as sysdba”
@ORACLE_HOME/rdbms/admin/catalog.sql
@ORACLE_HOME/rdbms/admin/catproc.sql
 .
..
....
.....

SQL> SELECT dbms_registry_sys.time_stamp('CATPROC') AS timestamp FROM DUAL;
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP CATPROC    2012-07-08 12:41:35
1 row selected.

Run the following script as “SYSTEM” user
@ORACLE_HOME/sqlplus/admin/pupbld.sql
...
...
...
......
SQL> CREATE PUBLIC SYNONYM PRODUCT_USER_PROFILE FOR SYSTEM.PRODUCT_PRIVS;
Synonym created.
SQL>
SQL> -- End of pupbld.sql

 For database created manually we will need to add the lines in "/etc/oratab", whereas databases created by DBCA entries get added.

SQL> select instance_name, host_name, status from v$instance;
INSTANCE_NAME    HOST_NAME                                                        STATUS
---------------- ---------------------------------------------------------------- ------------
test             aix-lab                                                          OPEN


SQL> select tablespace_name, status from dba_tablespaces;
TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM                         ONLINE
SYSAUX                         ONLINE
UNDOTBS1                       ONLINE
TEMP                           ONLINE
USERS                          ONLINE
5 rows selected.

Saturday, July 7, 2012

Understanding Oracle Memory Structures

Please refer to Oracle documentation

Memory-->
Oracle uses memory for
  • Holding on information about code(program)
  • User session info (active/passive both)
  • Info about what code(program) is doing --> active, executing, running..
  • Information that needs to be shared among various process  (ex locking)
  • For caching data (redo blocks, data blocks)
Basic Memory Structures are
  • SGA
  • PGA
  • Software Code Areas
SGA--> system global area
  • contains data & control information about instance
  • Data in it is shared among all users--> hence Shared Global Area
  • SGA + oracle process==> Oracle instance
  • Oracle allocates memory for SGA when you start instance & OS reclaims it when you shutdown instance
  • Each instance has its own SGA
  • SGA --> read/write
SGA consists of following data structures
  • Buffer Cache
  • Redo log Buffer
  • Shared Pool ( Data dictionary + library cache)
  • Java pool
  • Large pool (optional)
  • other miscellaneous pools

Fixed SGA --> contains info about state of DB/ instance, which background process need to access, no user data is stored here.

SGA also contains info about communication between process (such as locking)

PGA
  • contains data & control information for a server process or background process
  • non shared memory
  • total memory allocated for all individual PGA"s --> instance PGA

Data structure components of SGA
Buffer Cache
  • A pool which holds data blocks read from datafiles
  • All users connected to instance share access to buffer cache
  • Buffers here are divided into 2 lists
  • write list & LRU (least recently used) list

dirty buffers-->buffers having data that has been modified but not written to disk
free buffers--> free buffers
Pinned --> which are being processed/accessed


write list --> has those buffers which contains data & not written to disk yet
DBWR will periodically move them to datafiles

LRU list--> contains free, pinned & dirty buffers.

Cache hit--> if process finds data in memory
Cache miss--> if process doesn't find it in memory & needs to get that info from datafiles

Each process (SP or Background process) when it accesses buffer it moves it to the MRU side, so on frequent access ( different queries) buffers are moved towards MRU end & dirty buffers age /go toward the LRU end of the LRU list.

So when a user process requires data it searches in buffer cache, it could be a cache hit or cache miss.
Say it was a cache miss, so before reading data into cache, it needs to find free buffers, the process searches LRU list  starting at LRU end for free buffers, it either finds or it doesn't find (till a threshold limit is reached).

If the user finds a dirty buffer as it searches the LRU list, it will move the dirty buffer to write list & still continues to search.

If it finds a free buffer it will read the block into buffer and move the buffer to MRU end of LRU list
OR
If its searching & doesn't find any free buffers till it reaches a threshold limit, process stops & signals the DBWn to write the dirty buffers to the disk.


For full table scans the blocks read into memory are placed on the MRU end of the LRU list, so they age out more frequently, although this can be avoided by using "CACHE" clause in the alter/create table statement.

Good to use this with small lookup tables or static tables.


REDOLOG BUFFER (RLB)
  • This buffer holds the changes made to database.
  • Info is stored as redo entries
  • Redo entries --> it is the info which is necessary to reconstruct/redo the changes made to database by insert, update, delete, create, alter, drop.
  • Redo entries are used for recovery
Redo entries are copied from user's memory space to redolog buffer (in SGA), it is a circular buffer. Redo entries however take up continuous, sequential space in RLB.
LGWR writes then from RLB to redologfiles.

SHARED POOL
Consists of
LIBRARY CACHE, DICTIONARY CACHE, RESULTS CACHE, PARALLEL EXECUTION MESSAGES & CONTROL STUCTURES

LIBRARY CACHE
consists of
  • Shared sql area (accessible to all users)
  • Private sql area
  • Pl/sql program units & packages
  • Locks
  • Library cache handles
Shared & private sql areas
Oracle represents each sql statement it runs with a shared sql area & private sql area.
If multiple users are running the same sql statement then oracle recognizes it & uses the shared sql area for those users. however each user must have a seperate copy of statements in private sql area.


Shared sql area == parse tree + execution plan

When a new sql statement is parsed Oracle allocates memory from shared pool, size it allocates depends on the complexity of sql statement. If entire SP has been allocated, Oracle can de-allocate items from SP using LRU algorithm until there is enough free space for the statements shared sql area. Also the above de-allocation (of shared sql are) does happen then the sql statement must be reparsed for next execution.


PL/SQL program units
Oracle Database processes PL/SQL program units (procedures, functions, packages, anonymous blocks, and database triggers)
processes same way it processes individual SQL statements.
Oracle Database allocates a shared area to hold the parsed, compiled form of a program unit. Oracle Database allocates a private area to hold values specific to the session that runs the program unit, including local, global, and package variables (also known as package instantiation) and buffers for executing SQL.

If more than one user runs the same program unit, then a single, shared area is used by all users, while each user maintains a separate copy of his or her private SQL area, holding values specific to his or her session.
Individual SQL statements contained within a PL/SQL program unit are processed as described in the previous sections. Despite their origins within a PL/SQL program unit, these SQL statements use a shared area to hold their parsed representations and a private area for each session that runs the statement.


when a sql statement is submitted for execution in a database, oracle checks if shared sql area exists for an identical statement, if yes===> it uses this shared sql area for subsequent executions. if NO shared sql area is allocated===> then oracle allocates shared sql area in the shared pool.

IN both the cases user's private sql area is related to shared sql area that contains the statement.

Shared sql area can be flushed out from the shared pool (even if the shared sql area corresponds to open cursor, the only change is next time open cursor is used Oracle will re-parse the statement  & allocate a new shared sql area in shared pool).

When does/can the shared sql area get flushed from shared pool
Oracle Database also flushes a shared SQL area from the shared pool in these circumstances:

  •             When the ANALYZE statement is used to update or delete the statistics of a table, cluster, or index, all shared SQL areas that contain statements referencing the analyzed schema object are flushed from the shared pool. The next time a flushed statement is run, the statement is parsed in a new shared SQL area to reflect the new statistics for the schema object.
  •             If a schema object is referenced in a SQL statement and that object is later modified in any way, the shared SQL area is invalidated (marked invalid), and the statement must be reparsed the next time it is run.
  •             If you change a database's global database name, all information is flushed from the shared pool.
  •             The administrator can manually flush all information in the shared pool to assess the performance (with respect to the shared pool, not the data buffer cache) that can be expected after instance startup without shutting down the current instance. The statement ALTER SYSTEM FLUSH SHARED_POOL is used to do this.

DATA DICTIONARY
The data dictionary is a collection of database tables and views containing reference information about the database, its structures, and its users.
Oracle Database accesses the data dictionary frequently during SQL statement parsing.
This access is essential to the continuing operation of Oracle Database.
The data dictionary is accessed so often by Oracle Database that two special locations in memory are designated to hold dictionary data.
One area is called the data dictionary cache, also known as the row cache because it holds data as rows instead of buffers (which hold entire blocks of data).
The other area in memory to hold dictionary data is the library cache.
All Oracle Database user processes share these two caches for access to data dictionary information.


Result Cache
The result cache is composed of the SQL query result cache and PL/SQL function result cache, which share the same infrastructure.
dbms_result_cache to administer cached results, turn on & off result caching

v$result_cache-*

SQL Query Result Cache-->
It contains the results of queries & caches it in memory
DB can use these cached results & improve performance for next runs
hint--> result cache can be used to indicate if the results are to be stored in sql query result cache
RESULTS_CACHE_MODE  parameter helps us to control if query results needs to be cached or not on system wide basis
The database automatically invalidates a cached result whenever a transaction modifies the data or metadata of any of the database objects used to construct that cached result.

PL/SQL Function Result Cache

A PL/SQL function is sometimes used to return the result of a computation whose inputs are one or several parameterized queries issued by the function. In some cases, these queries access data that changes very infrequently compared to the frequency of calling the function. You can include syntax in the source text of a PL/SQL function to request that its results be cached and, to ensure correctness, that the cache be purged when any of a list of tables experiences DML. The look-up key for the cache is the combination of actual arguments with which the function is invoked. When a particular invocation of the result-cached function is a cache hit, then the function body is not executed; instead, the cached value is returned immediately.
Large Pool
The database administrator can configure an optional memory area called the large pool to provide large memory allocations for:
  •       Session memory for the shared server and the Oracle XA interface (used where transactions interact with more than one database. 
  •       I/O server processes
  •       Oracle Database backup and restore operations
By allocating memory from the large pool for shared server, Oracle XA, or parallel query buffers, Oracle Database can use the shared pool primarily for caching shared SQL and avoid the performance overhead otherwise caused by de-allocating memory from the shared SQL cache.
In addition, the memory for Oracle Database backup and restore operations, for I/O server processes, and for parallel buffers is allocated in buffers of a few hundred kilobytes. The large pool is better able to satisfy such large memory requests than the shared pool.
The large pool does not have an LRU list. It is different from reserved space in the shared pool, which uses the same LRU list as other memory allocated from the shared pool.
Java Pool
This pool is used for all session-specific Java code and data within the JVM. The Java Pool Advisor statistics provide information about library cache memory used for Java and predict how changes in the size of the Java pool can affect the parse rate. The Java Pool Advisor is internally turned on when statistics_level is set to TYPICAL or higher. These statistics reset when the advisor is turned off.

Streams Pool
Used only when oracle streams is used. This component of sga stores queue messages & provides memory for streams capture & apply processes. Default size is 0, it grows as needed when Oracle streams is used.

PGA Program Global Area
Oracle allocates PGA for each server process/Background Process
PGA is used to process sql statements, hold logon & other session info.
instance PGA= sum of individual pga's
Only instance PGA is set & database distributes memory to individual PGA's as needed
Content of PGA
Session memory---> memory allocated to hold a session's variables (login info) & other info related to session {for a shared server the session memory is shared not private}

Private sql area--> it contains info such as bind variable values, query execution state info, query execution work areas. Each session issuing a sql statement has a private sql area. Each user that submits the same sql statement has his/her own private sql area that uses a single shared sql area===> many private sql areas are related to same shared sql area.


The location of a private SQL area depends on the type of connection established for a session. If a session is connected through a dedicated server, private SQL areas are located in the server process's PGA. However, if a session is connected through a shared server, part of the private SQL area is kept in the SGA.
Cursors and SQL Areas
Developer can explicitly open cursors, or handles to specific private SQL areas, and use them as a named resource throughout the execution of the program. Recursive cursors that Oracle Database issues implicitly for some SQL statements also use shared SQL areas.
The management of private SQL areas is the responsibility of the user process. The allocation and deallocation of private SQL areas depends largely on which application tool you are using, although the number of private SQL areas that a user process can allocate is always limited by the initialization parameter OPEN_CURSORS. The default value of this parameter is 50.
A private SQL area continues to exist until the corresponding cursor is closed or the statement handle is freed. Although Oracle Database frees the run-time area after the statement completes, the persistent area remains waiting. Application developers close all open cursors that will not be used again to free the persistent area and to minimize the amount of memory required for users of the application.
Private SQL Area Components
The private SQL area of a cursor is itself divided into two areas whose lifetimes are different:
·        The persistent area—This area contains bind variable values. It is freed only when the cursor is closed.
·        The runtime area—Oracle Database creates this area as the first step of an execute request. It contains the following structures:
·     Query execution state information
For example, for a full table scan, this area contains information on the progress of the scan
·     SQL work areas
These areas are allocated as needed for memory-intensive operations like sorting or hash-joins.
For DML, the run-time area is freed when the statement finishes running. For queries, it is freed after all rows are fetched or the query is canceled.

SQL Work Areas
SQL work areas are allocated to support memory-intensive operators such as the following:
·        Sort-based operators (order by, group-by, rollup, window function)
·        Hash-join
·        Bitmap merge
·        Bitmap create
For example, a sort operator uses a work area (sometimes called the sort area) to perform the in-memory sort of a set of rows. Similarly, a hash-join operator uses a work area (also called the hash area) to build a hash table from its left input. If the amount of data to be processed by these two operators does not fit into a work area, the input data is divided into smaller pieces. This enables some data pieces to be processed in memory while the rest are spilled to temporary disk storage to be processed later. Although bitmap operators do not spill to disk when their associated work area is too small, their complexity is inversely proportional to the size of their work area. Thus, these operators run faster with larger work area.
The size of a work area can be controlled and tuned. The database automatically tunes work area sizes when automatic PGA memory management is enabled.
Generally, bigger work areas can significantly improve the performance of a particular operator at the cost of higher memory consumption. Optimally, the size of a work area is big enough to accommodate the input data and auxiliary memory structures allocated by its associated SQL operator. If not, response time increases, because part of the input data must be spilled to temporary disk storage. In the extreme case, if the size of a work area is far too small compared to the input data size, multiple passes over the data pieces must be performed. This can dramatically increase the response time of the operator.

if dedicated server--> private sql area is located in server process's PGA
if Shared server==> part of private sql area is kept in SGA


Memory management--> goal is to manage different structures (SGA & PGA)
Different methods
AMM--> automatic memory management (from11g can manage both sga & pga automatically). You can designate total memory size to be used by instance oracle manages dynamic exchanges between sga & pga. ( Implied==> sga components & pga components are tuned as well)

ASMM (Automatic shared memory management) --> if you need to control SGA you can disable AMM & enable ASMM ( With ASMM, you set target and maximum sizes for the SGA. The database then tunes the total size of the SGA to your designated target, and dynamically tunes the sizes of all SGA components.)

MSMM (Memory shared Memory management)--> if you want to have fine grain control over SGA, i.e. want to control the pools within SGA you can disable both AMM & ASMM. It gives the flexiblity of manually tuning SGA pools on need basis.

APMM(Automatic PGA Memory Management)--> when you disable AMM & enable ASMM or MSMM you implicitly enable Automatic PGA memory management. In this method you set a target size for instance PGA, Oracle will then tune the size of instance PGA to the target size & dynamically tunes the sizes of individual PGA's.  Since APMM is the default method for instance PGA, if you do not set it explicity, Oracle will compute & configure a reasonable default size.

MPMM (Manual PGA Memory Management)
Earlier versions of Oracle Database required the DBA to manually specify the maximum work area size for each type of SQL operator (such as sort or hash-join). This proved to be very difficult, because the workload is always changing. Although the current release of Oracle Database supports this manual PGA memory management method, Oracle strongly recommends that you leave automatic PGA memory management enabled.

if you create Database using dbca then AMM is enabled when you select basic installation
if you choose advanced installation it lets you choose from
AMM OR "ASMM +APMM" OR "MSMM + APMM"
if you create database manually & omit the parameters for memory management then it sets MSMM + APMM.

Monday, June 25, 2012

ASM administration

ASM "Automatic Storage Management" as we experience simplifies DBA's manage storage. In coordination with OMF (oracle managed files) it helps us get away by avoiding micro-management  of datafiles, where files can be added by referring to diskgroups.

Oracle recommendation is to keep asm disks of same size
Some of the administration you can do with ASM & see the benefits of adding/removing storage while database remains available.

In 11gR2 you need to connect as "sysasm" to add/drop disks, mount/dismount diskgroups

Below find some commands while you are working with ASM


Adding Diskgroup
create diskgroup data external redundancy disk '/dev/rhdiskasm001';

Drop diskgroup
drop diskgroup data including contents;


Find asm disks allocated
SELECT group_number, disk_number, mount_status, header_status, state, path  FROM   v$asm_disk;

ASM disks which can be added to diskgroups--> CANDIDATE/ FORMER
SELECT group_number, disk_number, mount_status, header_status, state, path 
FROM   v$asm_disk
where header_status='CANDIDATE' OR HEADER_STATUS='FORMER' ;


GROUP_Nu DISK_NUMBER MOUNT_S HEADER_STATU STATE    PATH
------------   -----------            -------      ------------    --------                  -----------------------------
           0           1                       CLOSED  FORMER       NORMAL          /dev/rhdiskasm011
           0          63                      CLOSED  CANDIDATE NORMAL          /dev/rhdiskasm064
           0           3                       CLOSED  FORMER       NORMAL           /dev/rhdiskasm006
           0          37                      CLOSED  CANDIDATE NORMAL           /dev/rhdiskasm137_T2
           0          38                      CLOSED  CANDIDATE NORMAL           /dev/rhdiskasm138_T2

Query disks in a specific diskgroup
select d.group_number, d.disk_number, d.name, d.path, dg.name, dg.group_number from
v$asm_disk d, v$asm_diskgroup dg
where d.group_number=dg.group_number
and dg.name='&NAME';


Add disk
alter diskgroup DATA add disk '/dev/rhdiskasm104_T2' rebalance power 11;

Drop disk from Diskgroup
alter diskgroup DATA drop disk DATA_0000;
or
alter diskgroup DATA drop disk DATA_0001 rebalance power 11;
or
alter diskgroup DATA drop disk DATA_0002, DATA_0003, DATA_0004 rebalance power 11;

To monitor the progress of rebalancing operation

SQL> SELECT group_number, operation, state, power,sofar,est_work, est_minutes
FROM v$asm_operation;
GROUP_NUMBER OPERA STAT      POWER      SOFAR   EST_WORK   EST_MINUTES
     ------------           -----     ----        ----------    ----------     ----------           -----------
           4                      REBAL RUN          11            100918         321268                   35
During rebalancing you can alos monitor the work & see the size of disk & how much of it is free.

select group_number, name, total_mb/1024 "SizeofDisk_GB", free_mb/1024 "FreesizeofDisk_now_GB"  from v$asm_disk_stat where group_number=4 and name LIKE 'DATA_00%' ;
GROUP_NUMBER NAME                           SizeofDisk_GB FreesizeofDisk_now_GB
------------ ------------------------------ ------------- ---------------------
           4 DATA_0085                         50.5810547            20.9111328
           4 DATA_0081                         50.5810547            20.9101563
           4 DATA_0082                         50.5810547            20.9130859
           4 DATA_0083                         50.5810547            20.9140625
           4 DATA_0084                         50.5810547            20.9121094
           4 DATA_0077                         50.5810547            20.9140625
           4 DATA_0078                         50.5810547            20.9140625


Thursday, June 21, 2012

RMAN Restore/ Recovery using Incremental backups--serial#1

To recover to a particular point in time, getting details about time or scn will help in doing a point in time recovery. The goal here is limited to do recovery using incremental backups.
SQL> conn / as sysdba
Connected.
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
8142998
SQL> select systimestamp from dual;
SYSTIMESTAMP
---------------------------------------------------------------------------
21-JUN-12 02.22.37.519217 PM -05:00
 
Kick off by taking a level 0 Backup, Taking a level 0 cumulative backup
[oracle@lnx133 work]$ ls -lrt r*
-rwxr-xr-x 1 oracle oinstall 294 Jun 21 13:58 rmanbackup.sh
-rw-r--r-- 1 oracle oinstall 586 Jun 21 14:31 rmanhotbackup.sh
drwxrwxr-x 2 oracle oinstall 16K Dec 19 2011 lost+found
A look at the RMAN scripts to take hot backup
[oracle@lnx133 work]$ cat rmanbackup.sh#!/bin/ksh
export ORACLE_SID=maze
export ORACLE_HOME=/u01/app/oracle/product/11g/11.2.0.2/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
msglog=rman_hot_backup_`date +\%Y\%m\%d`.log
rman target / cmdfile=rmanhotbackup.sh log=$msglog append
The command file for RMAN, you can configure it as per your requirement, here basic few parameters
have been configured.
[oracle@lnx133 work]$ cat rmanhotbackup.shrun
{
configure CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/oracle/backup/maze/ctl%d_%F';
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/backup/maze/sncf_%d';
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
backup tag HBlevel0 filesperset 10 format '/u01/app/oracle/backup/maze/Hot_Base_%d_s%s_%U' as compressed backupset incremental level 0 cumulative database plus archivelog;
release channel c1;
release channel c2;
release channel c3;
}
exit;
 
Ready to run the script
[oracle@lnx133 work]$ nohup ./rmanbackup.sh &[1] 3764
[oracle@lnx133 work]$ nohup: appending output to `nohup.out'
[oracle@lnx133 work]$ ls -lrt r*
-rwxr-xr-x 1 oracle oinstall 294 Jun 21 13:58 rmanbackup.sh
-rw-r--r-- 1 oracle oinstall 586 Jun 21 14:31 rmanhotbackup.sh
-rw-r--r-- 1 oracle oinstall 6195 Jun 21 14:34 rman_hot_backup_20120621.logmonitoring the rman log
[oracle@lnx133 work]$ tail -f rman_hot_backup_20120621.logchannel c1: starting piece 1 at 21-JUN-12
channel c2: starting compressed archived log backup set
channel c2: specifying archived log(s) in backup set
input archived log thread=1 sequence=341 RECID=2 STAMP=786550083
input archived log thread=1 sequence=342 RECID=3 STAMP=786550332
channel c2: starting piece 1 at 21-JUN-12
channel c3: starting compressed archived log backup set
channel c3: specifying archived log(s) in backup set
input archived log thread=1 sequence=343 RECID=4 STAMP=786551149
channel c3: starting piece 1 at 21-JUN-12
channel c1: finished piece 1 at 21-JUN-12
piece handle=/u01/app/oracle/backup/maze/Hot_Base_MAZE_s15_0fne3kli_1_1 tag=HBLEVEL0 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:04
channel c1: starting compressed archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=344 RECID=5 STAMP=786551357
input archived log thread=1 sequence=345 RECID=6 STAMP=786551473
channel c1: starting piece 1 at 21-JUN-12
channel c2: finished piece 1 at 21-JUN-12
piece handle=/u01/app/oracle/backup/maze/Hot_Base_MAZE_s16_0gne3kli_1_1 tag=HBLEVEL0 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:04
channel c3: finished piece 1 at 21-JUN-12
piece handle=/u01/app/oracle/backup/maze/Hot_Base_MAZE_s17_0hne3klj_1_1 tag=HBLEVEL0 comment=NONE
channel c3: backup set complete, elapsed time: 00:00:03
channel c1: finished piece 1 at 21-JUN-12
piece handle=/u01/app/oracle/backup/maze/Hot_Base_MAZE_s18_0ine3klm_1_1 tag=HBLEVEL0 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 21-JUN-12
Starting backup at 21-JUN-12
channel c1: starting compressed incremental level 0 datafile backup setchannel c1: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata1/maze/sysaux01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata1/maze/sj01.dbf
channel c1: starting piece 1 at 21-JUN-12
channel c2: starting compressed incremental level 0 datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/app/oracle/oradata1/maze/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata1/maze/example01.dbf
channel c2: starting piece 1 at 21-JUN-12
channel c3: starting compressed incremental level 0 datafile backup set
channel c3: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata1/maze/system01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata1/maze/users01.dbf
channel c3: starting piece 1 at 21-JUN-12
channel c2: finished piece 1 at 21-JUN-12
piece handle=/u01/app/oracle/backup/maze/Hot_Base_MAZE_s20_0kne3klo_1_1 tag=HBLEVEL0 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:45
channel c3: finished piece 1 at 21-JUN-12
piece handle=/u01/app/oracle/backup/maze/Hot_Base_MAZE_s21_0lne3klo_1_1 tag=HBLEVEL0 comment=NONE
channel c3: backup set complete, elapsed time: 00:03:06
channel c1: finished piece 1 at 21-JUN-12
piece handle=/u01/app/oracle/backup/maze/Hot_Base_MAZE_s19_0jne3klo_1_1 tag=HBLEVEL0 comment=NONE
channel c1: backup set complete, elapsed time: 00:03:16
Finished backup at 21-JUN-12
Starting backup at 21-JUN-12
current log archivedchannel c1: starting compressed archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=346 RECID=7 STAMP=786551678
channel c1: starting piece 1 at 21-JUN-12
channel c1: finished piece 1 at 21-JUN-12
piece handle=/u01/app/oracle/backup/maze/Hot_Base_MAZE_s22_0mne3ks0_1_1 tag=HBLEVEL0 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 21-JUN-12
Starting Control File and SPFILE Autobackup at 21-JUN-12
piece handle=/u01/app/oracle/backup/maze/ctlMAZE_c-1370075061-20120621-02 comment=NONE
Finished Control File and SPFILE Autobackup at 21-JUN-12
released channel: c1
released channel: c2
released channel: c3
Recovery Manager complete.
[1]+ Done nohup ./rmanbackup.sh
 
level 0 backup is followed by generating activity--> creating & inserting records in scott.worker2 table, followed by incremental level 1 cumulative backup[oracle@lnx133 work]$ sql
SQL*Plus: Release 11.2.0.2.0 Production on Thu Jun 21 14:35:13 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> conn scott/abc123;
Connected.
SQL> create table worker2 as select * from worker;Table created.
SQL> insert into worker2 select * from worker2;6 rows created.
SQL> /
12 rows created.
SQL> /
24 rows created.
SQL> /
48 rows created.
SQL> /
96 rows created.
SQL> /
192 rows created.
SQL> /
384 rows created.
SQL> /
768 rows created.
SQL> /
1536 rows created.
SQL> /
3072 rows created.
SQL> /
6144 rows created.
SQL> /
12288 rows created.
SQL> /
24576 rows created.
SQL> /
49152 rows created.
SQL> /
98304 rows created.
SQL> commit;
Commit complete.
SQL> select count(*) from worker2;COUNT(*)
----------
196608
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Ready to take level 1 incremental cumulative backup so it back's up the changes.
[oracle@lnx133 work]$ ls -lrt r*
-rwxr-xr-x 1 oracle oinstall 294 Jun 21 13:58 rmanbackup.sh
-rw-r--r-- 1 oracle oinstall 586 Jun 21 14:31 rmanhotbackup.sh
-rw-r--r-- 1 oracle oinstall 6195 Jun 21 14:34 rman_hot_backup_20120621.log
-rwxr-xr-x 1 oracle oinstall 301 Jun 21 14:42 rmanincbackup.sh
-rw-r--r-- 1 oracle oinstall 585 Jun 21 14:44 rmaninchotbackup.sh
[oracle@lnx133 work]$ cat rmanincbackup.sh#!/bin/ksh
export ORACLE_SID=maze
export ORACLE_HOME=/u01/app/oracle/product/11g/11.2.0.2/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
msglog=rman_hot_backup_`date +\%Y\%m\%d_\%T`.log
rman target / cmdfile=rmaninchotbackup.sh log=$msglog append

[oracle@lnx133 work]$ cat rmaninchotbackup.shrun
{
configure CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/oracle/backup/maze/ctl%d_%F';
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/backup/maze/sncf_%d_`date`';
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
backup tag HBlevel1 filesperset 10 format '/u01/app/oracle/backup/maze/Hot_Inc_%d_s%s_%U' as compressed backupset incremental level 1 cumulative database plus archivelog;
release channel c1;
release channel c2;
release channel c3;
}
exit;

Ready to run incremental backup
[oracle@lnx133 work]$ nohup ./rmanincbackup.sh &[1] 3973
[oracle@lnx133 work]$ nohup: appending output to `nohup.out'
[oracle@lnx133 work]$ ls -lrt r*
-rwxr-xr-x 1 oracle oinstall 294 Jun 21 13:58 rmanbackup.sh
-rw-r--r-- 1 oracle oinstall 586 Jun 21 14:31 rmanhotbackup.sh
-rw-r--r-- 1 oracle oinstall 6195 Jun 21 14:34 rman_hot_backup_20120621.log
-rwxr-xr-x 1 oracle oinstall 301 Jun 21 14:42 rmanincbackup.sh
-rw-r--r-- 1 oracle oinstall 585 Jun 21 14:44 rmaninchotbackup.sh
-rw-r--r-- 1 oracle oinstall 6316 Jun 21 14:49 rman_hot_backup_20120621_14:45:42.logmonitoring the rman backup log
[oracle@lnx133 work]$ tail -f rman_hot_backup_20120621_14\:45\:42.logchannel c2: starting compressed incremental level 1 datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/app/oracle/oradata1/maze/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata1/maze/example01.dbf
channel c2: starting piece 1 at 21-JUN-12
channel c3: starting compressed incremental level 1 datafile backup set
channel c3: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata1/maze/system01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata1/maze/users01.dbf
channel c3: starting piece 1 at 21-JUN-12
channel c3: finished piece 1 at 21-JUN-12
piece handle=/u01/app/oracle/backup/maze/Hot_Inc_MAZE_s30_0une3lh5_1_1 tag=HBLEVEL1 comment=NONE
channel c3: backup set complete, elapsed time: 00:02:06
channel c2: finished piece 1 at 21-JUN-12
piece handle=/u01/app/oracle/backup/maze/Hot_Inc_MAZE_s29_0tne3lh5_1_1 tag=HBLEVEL1 comment=NONE
channel c2: backup set complete, elapsed time: 00:02:26
channel c1: finished piece 1 at 21-JUN-12
piece handle=/u01/app/oracle/backup/maze/Hot_Inc_MAZE_s28_0sne3lh5_1_1 tag=HBLEVEL1 comment=NONE
channel c1: backup set complete, elapsed time: 00:02:56
Finished backup at 21-JUN-12
Starting backup at 21-JUN-12
current log archived
channel c1: starting compressed archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=348 RECID=9 STAMP=786552534
channel c1: starting piece 1 at 21-JUN-12
channel c1: finished piece 1 at 21-JUN-12
piece handle=/u01/app/oracle/backup/maze/Hot_Inc_MAZE_s31_0vne3lmn_1_1 tag=HBLEVEL1 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 21-JUN-12
Starting Control File and SPFILE Autobackup at 21-JUN-12
piece handle=/u01/app/oracle/backup/maze/ctlMAZE_c-1370075061-20120621-03 comment=NONE
Finished Control File and SPFILE Autobackup at 21-JUN-12
released channel: c1
released channel: c2
released channel: c3
Recovery Manager complete.
[1]+ Done nohup ./rmanincbackup.sh
 
Now to imitate failure, lets move the database file from its location to another location & try to insert data in scott.worker2 table.
[oracle@lnx133 work]$ sql
SQL*Plus: Release 11.2.0.2.0 Production on Thu Jun 21 14:50:17 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> conn scott/abc123;
Connected.
SQL> select count(*) from worker2;
COUNT(*)
----------
196608
SQL> insert into worker2 select * from worker;
6 rows created.
SQL> commit;
Commit complete.
SQL> insert into worker2 select * from worker2;
insert into worker2 select * from worker2
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: '/u01/app/oracle/oradata1/maze/users01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
 
SQL> conn / as sysdba
Connected.
SQL> shut immediate;
ORA-01116: error in opening database file 4
ORA-01110: data file 4: '/u01/app/oracle/oradata1/maze/users01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> shutdown abort;
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@lnx133 work]$ sql
SQL*Plus: Release 11.2.0.2.0 Production on Thu Jun 21 14:52:30 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup mount;ORACLE instance started.
Total System Global Area 422670336 bytes
Fixed Size 1344616 bytes
Variable Size 318770072 bytes
Database Buffers 96468992 bytes
Redo Buffers 6086656 bytes
Database mounted.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
We can/have to run the recovery from a script, but here I chose to run by connecting to rman & then issuing commands to restore/recover.
[oracle@lnx133 work]$ rman target /
Recovery Manager: Release 11.2.0.2.0 - Production on Thu Jun 21 14:52:57 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: MAZE (DBID=1370075061, not open)
RMAN> list backup summary;
using target database control file instead of recovery catalog
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
15 B A A DISK 21-JUN-12 1 1 YES HBLEVEL0
16 B A A DISK 21-JUN-12 1 1 YES HBLEVEL0
17 B A A DISK 21-JUN-12 1 1 YES HBLEVEL0
18 B A A DISK 21-JUN-12 1 1 YES HBLEVEL0
19 B 0 A DISK 21-JUN-12 1 1 YES HBLEVEL0
20 B 0 A DISK 21-JUN-12 1 1 YES HBLEVEL0
21 B 0 A DISK 21-JUN-12 1 1 YES HBLEVEL0
22 B A A DISK 21-JUN-12 1 1 YES HBLEVEL0
23 B F A DISK 21-JUN-12 1 1 NO TAG20120621T143442
24 B A A DISK 21-JUN-12 1 1 YES HBLEVEL1
25 B A A DISK 21-JUN-12 1 1 YES HBLEVEL1
26 B A A DISK 21-JUN-12 1 1 YES HBLEVEL1
27 B A A DISK 21-JUN-12 1 1 YES HBLEVEL1
28 B 1 A DISK 21-JUN-12 1 1 YES HBLEVEL1
29 B 1 A DISK 21-JUN-12 1 1 YES HBLEVEL1
30 B 1 A DISK 21-JUN-12 1 1 YES HBLEVEL1
31 B A A DISK 21-JUN-12 1 1 YES HBLEVEL1
32 B F A DISK 21-JUN-12 1 1 NO TAG20120621T144856
RMAN> run {Starting restore at 21-JUN-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=133 device type=DISK
channel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata1/maze/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata1/maze/example01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/backup/maze/Hot_Base_MAZE_s20_0kne3klo_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/backup/maze/Hot_Base_MAZE_s20_0kne3klo_1_1 tag=HBLEVEL0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:25
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata1/maze/system01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata1/maze/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/backup/maze/Hot_Base_MAZE_s21_0lne3klo_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/backup/maze/Hot_Base_MAZE_s21_0lne3klo_1_1 tag=HBLEVEL0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:56
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata1/maze/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata1/maze/sj01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/backup/maze/Hot_Base_MAZE_s19_0jne3klo_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/backup/maze/Hot_Base_MAZE_s19_0jne3klo_1_1 tag=HBLEVEL0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:35
Finished restore at 21-JUN-12Starting recover at 21-JUN-12using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /u01/app/oracle/oradata1/maze/system01.dbf
destination for restore of datafile 00004: /u01/app/oracle/oradata1/maze/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/backup/maze/Hot_Inc_MAZE_s30_0une3lh5_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/backup/maze/Hot_Inc_MAZE_s30_0une3lh5_1_1 tag=HBLEVEL1
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00003: /u01/app/oracle/oradata1/maze/undotbs01.dbf
destination for restore of datafile 00005: /u01/app/oracle/oradata1/maze/example01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/backup/maze/Hot_Inc_MAZE_s29_0tne3lh5_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/backup/maze/Hot_Inc_MAZE_s29_0tne3lh5_1_1 tag=HBLEVEL1
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00002: /u01/app/oracle/oradata1/maze/sysaux01.dbf
destination for restore of datafile 00006: /u01/app/oracle/oradata1/maze/sj01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/backup/maze/Hot_Inc_MAZE_s28_0sne3lh5_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/backup/maze/Hot_Inc_MAZE_s28_0sne3lh5_1_1 tag=HBLEVEL1
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
starting media recovery
media recovery complete, elapsed time: 00:00:14
Finished recover at 21-JUN-12
sql statement: alter database open
RMAN> exit
Recovery Manager complete.
2> restore database;
3> recover database;
4> sql 'alter database open';
5> }
 
Below is the activity in aler*log

Completed: ALTER DATABASE MOUNTThu Jun 21 14:55:25 2012
Full restore complete of datafile
checkpoint is 8143741
last deallocation scn is 8133875
Undo Optimization current scn is 8139292
Thu Jun 21 14:55:40 2012
Full restore complete of datafile 5 /u01/app/oracle/oradata1/maze/example01.dbf. Elapsed time: 0:01:16
checkpoint is 8143741
last deallocation scn is 7542368
Full restore complete of datafile 4 /u01/app/oracle/oradata1/maze/users01.dbf. Elapsed time: 0:00:02
checkpoint is 8143742
last deallocation scn is 8142856
Thu Jun 21 14:57:35 2012
Full restore complete of datafile 1 /u01/app/oracle/oradata1/maze/system01.dbf. Elapsed time: 0:01:49
checkpoint is 8143742
last deallocation scn is 7355940
Undo Optimization current scn is 8139292
Thu Jun 21 14:58:08 2012
Full restore complete of datafile 6 /u01/app/oracle/oradata1/maze/sj01.dbf. Elapsed time: 0:00:20
checkpoint is 8143740
last deallocation scn is 770465
Thu Jun 21 15:00:10 2012
Full restore complete of datafile 2 /u01/app/oracle/oradata1/maze/sysaux01.dbf. Elapsed time: 0:02:24
checkpoint is 8143740
last deallocation scn is 8093014
Thu Jun 21 15:00:22 2012
Incremental restore complete of datafile
checkpoint is 8144777
last deallocation scn is 8142856
Incremental restore complete of datafile 1 /u01/app/oracle/oradata1/maze/system01.dbf
checkpoint is 8144777
last deallocation scn is 7355940
Incremental restore complete of datafile 5 /u01/app/oracle/oradata1/maze/example01.dbf
checkpoint is 8144776
last deallocation scn is 7542368
Incremental restore complete of datafile 3 /u01/app/oracle/oradata1/maze/undotbs01.dbf
checkpoint is 8144776
last deallocation scn is 8133875
Incremental restore complete of datafile 6 /u01/app/oracle/oradata1/maze/sj01.dbf
checkpoint is 8144775
last deallocation scn is 770465
Incremental restore complete of datafile 2 /u01/app/oracle/oradata1/maze/sysaux01.dbf
checkpoint is 8144775
last deallocation scn is 8093014
Thu Jun 21 15:00:31 2012
alter database recover datafile list clear
Completed: alter database recover datafile list clear
alter database recover datafile list
1 , 2 , 3 , 4 , 5 , 6
Completed: alter database recover datafile list
1 , 2 , 3 , 4 , 5 , 6
alter database recover if needed
start
Media Recovery Start
started logmerger process
Parallel Media Recovery started with 2 slaves
Thu Jun 21 15:00:39 2012
Recovery of Online Redo Log: Thread 1 Group 3 Seq 348 Reading mem 0
Mem# 0: /u01/app/oracle/oradata1/maze/redo03.log
Recovery of Online Redo Log: Thread 1 Group 1 Seq 349 Reading mem 0
Mem# 0: /u01/app/oracle/oradata1/maze/redo01.log
Thu Jun 21 15:00:45 2012
Media Recovery Complete (maze)
Completed: alter database recover if needed
start
alter database open
Beginning crash recovery of 1 threads
parallel recovery started with 2 processes
Started redo scan
Completed redo scan
read 0 KB redo, 0 data blocks need recovery
Started redo application at
Thread 1: logseq 349, block 154, scn 8145023
Recovery of Online Redo Log: Thread 1 Group 1 Seq 349 Reading mem 0
Mem# 0: /u01/app/oracle/oradata1/maze/redo01.log
Completed redo application of 0.00MB
Completed crash recovery at
Thread 1: logseq 349, block 154, scn 8165024
0 data blocks read, 0 data blocks written, 0 redo k-bytes read
Thu Jun 21 15:00:48 2012
LGWR: STARTING ARCH PROCESSES
Thu Jun 21 15:00:48 2012
ARC0 started with pid=24, OS id=4258
ARC0: Archival started
LGWR: STARTING ARCH PROCESSES COMPLETE
ARC0: STARTING ARCH PROCESSES
Thu Jun 21 15:00:49 2012
ARC1 started with pid=25, OS id=4260
Thu Jun 21 15:00:49 2012
ARC2 started with pid=26, OS id=4262
ARC1: Archival started
ARC2: Archival started
Thu Jun 21 15:00:49 2012
ARC3 started with pid=27, OS id=4264
ARC1: Becoming the 'no FAL' ARCH
ARC1: Becoming the 'no SRL' ARCH
ARC2: Becoming the heartbeat ARCH
Thread 1 advanced to log sequence 350 (thread open)
ARC3: Archival started
ARC0: STARTING ARCH PROCESSES COMPLETE
Thread 1 opened at log sequence 350
Current log# 2 seq# 350 mem# 0: /u01/app/oracle/oradata1/maze/redo02.log
Successful open of redo thread 1
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Thu Jun 21 15:00:50 2012
SMON: enabling cache recovery
Archived Log entry 10 added for thread 1 sequence 349 ID 0x51a9aeb5 dest 1:
Thu Jun 21 15:00:56 2012
[4206] Successfully onlined Undo Tablespace 2.
Undo initialization finished serial:0 start:447383434 end:447385294 diff:1860 (18 seconds)
Verifying file header compatibility for 11g tablespace encryption..
Verifying 11g file header compatibility for tablespace encryption completed
SMON: enabling tx recovery
Database Characterset is AL32UTF8
No Resource Manager plan active
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC
Thu Jun 21 15:01:05 2012
QMNC started with pid=28, OS id=4268
Thu Jun 21 15:01:13 2012
Completed: alter database open
Thu Jun 21 15:01:20 2012
4 /u01/app/oracle/oradata1/maze/users01.dbf
3 /u01/app/oracle/oradata1/maze/undotbs01.dbf. Elapsed time: 0:00:42
 
Once the database is open, connecting to verify records.
SQL> select count(*) from scott.worker2;COUNT(*)
----------
196614
SQL> conn scott/abc123;
Connected.
SQL> insert into worker2 select * from worker2;
196614 rows created.
SQL> commit;
Commit complete.
SQL> select count(*) from scott.worker2;
COUNT(*)
----------
393228
 

Confirms we have recovered the failure.

Please refer to oracle documentation for a complete/accurate information.