Thursday, April 22, 2010

Restore and recovery of new database using rman backup (controlfile backup).

· Backups are taken using controlfile.
· The refresh is from PROD to DEV database as of 31st Dec 2009.
· We are not going to connect to Production DB or server (This will be an advantage).
· We use 30th Dec 2009 controlfile to restore DB as 31st Dec 2009 controlfile is lost.
· FYI. Production and Development are in different servers.

Backup Location in:-

Prod is /u22/MAX/ora_flash_area/MAXPRD
Dev is /u01/u22/MAX/ora_flash_area/MAXPRD (copied from Production server)

In Development Server
1. Export production SID
$ export ORACLE_SID=MAXPRD ß-Production SID this is throughout the process till NID utility used.

2. Change the DB name in init.ora and also rename init.ora to match Production.
db_name=MAXDEV to db_name=MAXPRD
initMAXDEV.ora to initMAXPRD.ora

3. startup nomount instance on a new server (here it is Dev)

SQL>startup nomount;
4. Restore the controlfile from the backup restored at dev server.
$ rman target /
RMAN>restore controlfile from '/u01/u22/MAX/ora_flash_area/MAXPRD/autobackup/2009_12_30/o1_mf_s_707002930_5mpp5n5z_.bkp’

RMAN>switch database to copy;

run
{ set until time "to_date( '31-12-2009 21:57', 'DD-MM-RRRR HH24:MI')";
recover database;

}
5. Actually, need to rename the online redolog files before opening the database in case the production path of redo log files is different from Development (in this case yes).

SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u12/oraprod/MAXPRDdata/logMAXPRD6a.dbf
/u14/oraprod/MAXPRDdata/logMAXPRD6b.dbf
/u14/oraprod/MAXPRDdata/stdbylog1
…..
…..
SQL> alter database rename file '/u12/oraprod/MAXPRDdata/logMAXPRD6a.dbf' to '/u01/oramax/maxdevdata/logMAXPRD6a.dbf'; ß-location in Development server.

Database altered.
Do it for all the files seen above..


6. Drop and Add temp tablespace.
SQL> ALTER DATABASE TEMPFILE '/u12/oraprod/MAXPRDdata/temp01.dbf' DROP;

SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/oramax/maxdevdata/temp01.dbf' SIZE 3000M REUSE AUTOEXTEND OFF;

7. Open database

Sql> alter database open resetlogs;

8. Once DB is open use below NID utility to rename the database as required & also the DBID.

SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;
$ nid TARGET=sys/manager DBNAME=MAXDEV
( DB will shutdown itself).

9. change DB Name in init.ora
db_name= MAXPRD to db_name= MAXDEV
initMAXPRD.ora to initMAXDEV.ora

10. Export development SID
$ export ORACLE_SID=MAXDEV

11. Open Database now ad Development

SQL> alter database open;



12. Start the listener
lsnrctl start MAXDEV.


Please comment if any concerns in the steps posted.
Shekhar

Wednesday, April 21, 2010

Steps to Follow for RMDC Box while bringing down nd bringing up

Steps to Follow for RMDC Box

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

Procedure to be followed on an environment that is having DR system

(to keep standby DB at RM fine and in synch) :-

At the Primary DB site (ADC)

============================
1 - With the outage start and after shutting down the MT

2 - Force archiving of current redo logs :-
    SQL> alter system archive log current;

    (Note : in case of RAC, issue this statement from each RAC node)

3 - Check current archive logs on primary DB and save the output for reference using :-

    SQL> set linesize 100
    SQL> col name format a50

    SQL> select name,THREAD#,SEQUENCE#,Applied,to_char(COMPLETION_TIME,'yyyy/mm/dd hh24:mi:ss')

         from V$archived_log where (THREAD#,RECID) in (select THREAD#,max(RECID)

         from V$archived_log where APPLIED='YES' group by THREAD#);

4 - Shutdown primary DB and you can proceed with primary env cold snap


At the DR (Standby) site (RM)
=============================

7 - Cancel the managed recovery at the DR DB and get all pending archivelogs applied

    sqlplus " / as sysdba"

    SQL> alter database recover managed standby database cancel;

    SQL> recover standby database until cancel;
    AUTO

    Enter "AUTO" for automatic archivelog files picking

    (Note : in case of RAC, at DR site, only one DB instance is running in managed recovery mode)

8 - When all pending archivelogs are applied check current archivelogs status using :-

    SQL> set linesize 100
    SQL> col name format a50

    SQL> select name,THREAD#,SEQUENCE#,Applied,to_char(COMPLETION_TIME,'yyyy/mm/dd hh24:mi:ss')

         from V$archived_log where (THREAD#,RECID) in (select THREAD#,max(RECID)

         from V$archived_log where APPLIED='YES' group by THREAD#);

9 - Shutdown standby DB and you can proceed with its cold snap

10 - After cold snaps are completed on both sites, startup the primary DB normally and startup

     the standby DB in managed recovery as follows :-
     SQL> startup nomount;

     SQL> alter database mount standby database;

     At this point put the standby database in managed recovery mode.

     SQL> recover managed standby database disconnect;

11 - Make sure automatic archive shipping and application at standby keeps on going during

     and after planned work. Verify this from V$archived_log

Theme of ORA-WEEK

Guy's....

ORA-WEEK is a Commitment which we all Committed to...

A Commitment to Work / Study any Finally Share on any of the Good Topics.. U Know / Interested / Worked.

Let's Do It...

Let's C ORA-WEEK in ACTION.........

Cheers ! :)

Key Run

Monday, April 19, 2010

DR Setup Configuration: ( ORA-WEEK on 19th Apr )

ORA-WEEK:
=========

19th APR:
---------

DR Setup Configuration:
-----------------------

Imp Pts 2 Remember:
===================

On Primary:
-----------
Enable Force Logging
You should enable Force logging in primary database else if some transaction which doesn’t generate redo log can corrupt your standby database.
(Careful in OLTP transactions or long running requests in Apps)
SQL> ALTER DATABASE FORCE LOGGING;

Create the  standby control file:
---------------------------------
go to mount state and then

SQL> alter database create standby controlfile as ‘/stdbyctl.dbf’

init.ora para's to set:
-----------------------
LOG_ARCHIVE_DEST_1 =’LOCATION=/u01/oracle/data/arch’
LOG_ARCHIVE_DEST_2 =’SERVICE=PROD_remote1.domain.com LGWR ASYNC REOPEN=60'
fal_client =
server_client=

Dataguard broker tool:
----------------------
These primary & standby database can be monitored by command line (sql) as well from GUI (Graphical User Interface) Tool called as Dataguard broker.

2 Services will be running to keep standby database in synch with primary database:
----------------------------------------------------------------------------------
1. redo transport service - transfer(Pull/Push) redo logs from primary to standby database &
2. Log apply service - applies that redo logs to standby database.

Switchover & Failover:
----------------------
These are basically two kind of roles in dataguard Failover & Switchover;
Switchover:
Primary database becomes standby database & one of (If there are more than one standby) standby database becomes primary database for ex. during server maintenance.

Failover:
Failover is used in scenarion in which your primary database is not available and you want to convert role of one of standby database to primary database for ex. during primary database failure.

Data Protection Mode : 3 Modes ( Maximum Protection Mode , Maximum Availability Mode & Maximum Performance Mode )


Maximum Protection Mode:
------------------------

In maximum protection mode as name suggest no data loss will occur if primary database fails. This is achieved by oracle by ensuring that redo data must be written to both local online redo log location & standby redo log location before transaction commits. This standby redo log will ensure full data protection. For full protection mode atleast one standby database should have standby redo log and LGWR, SYNC, and AFFIRM attribute should be used with LOG_ARCHIVE_DEST_n parameter. (I am going to discuss about these parameters in next post)
Here your primary database will shutdown if it is unable to write redo records to atleast one standby location.


Maximum Availability Mode:
--------------------------

This is similar to Maximum protection mode except that it will not shutdown primary database if primary database is not able to write standby redo logs to atleast one standby location but in that case Maximum Availability will act in Maximum Performance Mode until fault is corrected and all gaps in redo logs are resolved. Once all gaps are resolved primary database will automatically goes into Maximum Availability Mode.


Maximum Performance Mode:
-------------------------

This is default mode in which redo stream is written asynchronously with respect to the commitment of the transactions that create the redo data. You can use LGWR and ASYNC attribute or ARCH attribute in LOG_ARCHIVE_DEST_n

You can check your database mode as

SQL> select PROTECTION_LEVEL from v$database;
PROTECTION_LEVEL
—————————-
MAXIMUM PERFORMANCE

More and More in

http://onlineappsdba.com/index.php/2006/11/28/configure-oracle-dataguard/

ORA-WEEK ( 19th Apr - 25 Apr )

Hi Guy's,

As we thought of before... ORA-WEEK Started 2day ie ( 19th Apr - 25 Apr ). Today...as Part of tht...I did DR Site Configuration and I am ready to share the same with U Guys.

I request you to pls...U too go through Ur Own topic of Interest..Discuss and Post the things..

Thanks,
Kiran Ch

Sunday, April 18, 2010

Enabling DB Audit

SQL> show parameter audit


NAME                                       TYPE          VALUE
------------------------------      ----------- ------------------------------
 audit_file_dest                            string         /test/oracle/product/adump                            
audit_sys_operations                   boolean      TRUE
audit_syslog_level                       string
audit_trail                                    string          DB





Set the above parameters in Init file
and bounce the DB


SQL> audit connect;
Audit succeeded.

SQL> audit create user;
Audit succeeded.
SQL> audit drop user;
Audit succeeded.
SQL> audit alter user;
Audit succeeded.

Sample Audit File that created by enabling Audit.
=================================================

Audit file /Test/oracle/product/102/admin/TEST/adump/Test_ora_18632_1.aud


Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORACLE_HOME = /Test/oracle/product/102

System name: HP-UX

Node name: test02

Release: B.11.31

Version: U

Machine: ia64

Instance name: TEST

Redo thread mounted by this instance: 1

Oracle process number: 56

Unix process pid: 18632, image: oracle@test02



Sun Apr 18 05:53:41 2010

LENGTH : '139'

ACTION :[7] 'CONNECT'

DATABASE USER:[1] '/'

PRIVILEGE :[6] 'SYSDBA'

CLIENT USER:[8] 'orTest'

CLIENT TERMINAL:[5] 'pts/6'

STATUS:[1] '0'



Sun Apr 18 05:54:00 2010

LENGTH : '416'

ACTION :[282] 'SELECT NAME NAME_COL_PLUS_SHOW_PARAM,DECODE(TYPE,1,'boolean',2,'string',3,'integer',4,'file',5,'number', 6,'big integer', 'unknown') TYPE,DISPLAY_VALUE VALUE_COL_PLUS_SHOW_PARAM FROM V$PARAMETER WHERE UPPER(NAME) LIKE UPPER('%audit%') ORDER BY NAME_COL_PLUS_SHOW_PARAM,ROWNUM'

DATABASE USER:[1] '/'

PRIVILEGE :[6] 'SYSDBA'

CLIENT USER:[8] 'orTest'

CLIENT TERMINAL:[5] 'pts/6'

STATUS:[1] '0'



$ s^?

$ date

Sun Apr 18 05:54:59 EDT 2010

$ cat Test_ora_14418_1.aud

Audit file /Test/oracle/product/102/admin/TEST/adump/Test_ora_14418_1.aud

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORACLE_HOME = /Test/oracle/product/102

System name: HP-UX

Node name: test02

Release: B.11.31

Version: U

Machine: ia64

Instance name: TEST

Redo thread mounted by this instance: 1

Oracle process number: 125

Unix process pid: 14418, image: oracle@test02



Sun Apr 18 04:17:17 2010

LENGTH : '134'

ACTION :[7] 'CONNECT'

DATABASE USER:[1] '/'

PRIVILEGE :[6] 'SYSDBA'

CLIENT USER:[8] 'orTest'

CLIENT TERMINAL:[0] ''

STATUS:[1] '0'



Sun Apr 18 04:17:17 2010

LENGTH : '161'

ACTION :[33] 'select name, dbid from v$database'

DATABASE USER:[1] '/'

PRIVILEGE :[6] 'SYSDBA'

CLIENT USER:[8] 'orTest'

CLIENT TERMINAL:[0] ''

STATUS:[1] '0'



Sun Apr 18 04:17:17 2010

LENGTH : '220'

ACTION :[92] 'select nvl(max(cpmid),0) from x$kcccp where cpsta = 2'

DATABASE USER:[1] '/'

PRIVILEGE :[6] 'SYSDBA'

CLIENT USER:[8] 'orTest'

CLIENT TERMINAL:[0] ''

STATUS:[1] '0'



Sun Apr 18 04:17:17 2010

LENGTH : '216'

ACTION :[88] 'select distinct my.sid, sex.serial from v$mystat my, x$ksusex sex where sex.sid = my.sid'

DATABASE USER:[1] '/'

PRIVILEGE :[6] 'SYSDBA'

CLIENT USER:[8] 'orTest'

CLIENT TERMINAL:[0] ''

STATUS:[1] '0'



Sun Apr 18 04:17:17 2010

LENGTH : '230'

ACTION :[101] 'select instance_name, instance_number, decode(parallel, 'YES', 1, 0) parallel from v$instance'

DATABASE USER:[1] '/'

PRIVILEGE :[6] 'SYSDBA'

CLIENT USER:[8] 'orTest'

CLIENT TERMINAL:[0] ''

STATUS:[1] '0'



Sun Apr 18 04:17:17 2010

LENGTH : '182'

ACTION :[55] 'alter session set remote_dependencies_mode = signature'

DATABASE USER:[1] '/'

PRIVILEGE :[6] 'SYSDBA'

CLIENT USER:[8] 'orTest'

CLIENT TERMINAL:[0] ''

STATUS:[1] '0'



Sun Apr 18 04:17:17 2010

LENGTH : '195'

ACTION :[67] 'alter session set events 'immediate trace name krb_options level 5''

DATABASE USER:[1] '/'

PRIVILEGE :[6] 'SYSDBA'

CLIENT USER:[8] 'orTest'

CLIENT TERMINAL:[0] ''

STATUS:[1] '0'



Sun Apr 18 04:17:17 2010

LENGTH : '161'

ACTION :[34] 'select distinct sid from v$mystat'

DATABASE USER:[1] '/'

PRIVILEGE :[6] 'SYSDBA'

CLIENT USER:[8] 'orTest'

CLIENT TERMINAL:[0] ''

STATUS:[1] '0'



Sun Apr 18 04:17:25 2010

LENGTH : '158'

ACTION :[30] 'SELECT SYSDATE FROM X$DUAL '

DATABASE USER:[1] '/'

PRIVILEGE :[6] 'SYSDBA'

CLIENT USER:[8] 'orTest'

CLIENT TERMINAL:[0] ''

STATUS:[1] '0'



Sun Apr 18 04:17:32 2010

LENGTH : '173'

ACTION :[45] 'SELECT ABS(SYSDATE - :b1 ) FROM X$DUAL '

DATABASE USER:[1] '/'

PRIVILEGE :[6] 'SYSDBA'

CLIENT USER:[8] 'orTest'

CLIENT TERMINAL:[0] ''

STATUS:[1] '0'



Sun Apr 18 04:17:33 2010

LENGTH : '155'

ACTION :[27] 'select count(*) from x$dual'

DATABASE USER:[1] '/'

PRIVILEGE :[6] 'SYSDBA'

CLIENT USER:[8] 'orTest'

CLIENT TERMINAL:[0] ''

STATUS:[1] '0'



Sun Apr 18 04:17:33 2010

LENGTH : '160'

ACTION :[32] 'select count(*) from sys.x$kcrmx'

DATABASE USER:[1] '/'

PRIVILEGE :[6] 'SYSDBA'

CLIENT USER:[8] 'orTest'

CLIENT TERMINAL:[0] ''

STATUS:[1] '0'



Cheers :)
Viswanath

Wednesday, April 14, 2010

Hi Sony Erricson Guys

Hi Sony Erricson Guys,

Gud New...
As a DBA now U can Backup Ur Contacts, SMS, MMS nd All using simple software. Easy 2 USE.
"MyPhoneExplorer"

http://www.softpedia.com/progDownload/MyPhoneExplorer-Download-26177.html

Keep Updating.. new Good Soft ware things too...

We will try to c any option for Softwares.

Thanks,
"Key""Run"

Last Gather Schema/Table Concurrent Processes ran for HR or ALL

*** Last Gather Schema/Table Concurrent Processes ran for HR or ALL ***


COLUMN pReqId      format a10 heading 'Request|ID'
COLUMN pProg       format a15 heading 'Concurrent|Process'
COLUMN parentReqId format a10 heading 'Parent'
COLUMN pStatus     format a10 heading 'Phase|Status'
COLUMN pParms      format a30 heading 'Parameters'
COLUMN pStartDate  format a6 heading 'Start|Date'
COLUMN pEndDate    format a6 heading 'End|Date'
COLUMN pMinutes    format a5 heading 'Dur.|(Min)'

SELECT * FROM (
SELECT TO_CHAR(request_id) pReqId
   , program pProg
   , TO_CHAR(decode(fcrs.PARENT_REQUEST_ID,-1,null,fcrs.PARENT_REQUEST_ID)) parentReqId
   , PHAS.MEANING || ' ' || STAT.MEANING pStatus
   , fcrs.ARGUMENT_TEXT pParms
   ,REQUESTED_START_DATE pStartDate
   ,ACTUAL_COMPLETION_DATE pEndDate
   , to_char(round((fcrs.ACTUAL_COMPLETION_DATE - fcrs.REQUESTED_START_DATE) * 1440)) pMinutes
FROM FND_CONC_REQ_SUMMARY_V fcrs
 , FND_LOOKUPS STAT
 , FND_LOOKUPS PHAS
WHERE STAT.LOOKUP_CODE = FCRS.STATUS_CODE
AND STAT.LOOKUP_TYPE = 'CP_STATUS_CODE'
AND PHAS.LOOKUP_CODE = FCRS.PHASE_CODE
AND PHAS.LOOKUP_TYPE = 'CP_PHASE_CODE'
AND UPPER(program) LIKE 'GATHER%'
AND substr(UPPER(ARGUMENT_TEXT),1,3) in ('HR,','ALL')
ORDER BY 1 desc)
where rownum < 2;

Note:
===> Remove the last line --- where rownum < 2;
         to get all the resquests history

Recent Applied Patches to Instance

Recent Applied Patches to Instance:
===================================

select BUG_NUMBER, LAST_UPDATE_DATE from ad_bugs order by LAST_UPDATE_DATE ;
select BUG_NUMBER, LAST_UPDATE_DATE from ad_bugs where LAST_UPDATE_DATE like '%-APR-10' order by LAST_UPDATE_DATE;

Saturday, April 10, 2010

Hi Team..Happy to say Now we r Team of 8

Hi Frds,

V Happy to introduce to U... 3 more Guys ( Idiots ;) ) to Our Team...

Shekhar, Suman nd Rakesh

Shekhar - Already he contributed to d Blog.. as Data Guard Implementation Doc has been given by him only.
                Currently working as Apps DBA in Malaysia.
Suman   - Our Guy only U Guys already knw him...
nd
Rakesh  - He is a DBA from HP Bangalore. V Good Guy nd Having Good hands-on on RAC and DBA            advanced Concept.

Guys...This Blog created 4 a Purpose... Make it Big.. Use it Daily nd Update Daily.

Thx C U...
Key Run :)