Showing posts with label Core DBA. Show all posts
Showing posts with label Core DBA. Show all posts

Friday, 3 January 2014

Enabling Archivelog Mode in Oracle9i

Problem:
How do I enable archivelog in an Oracle9i database?
Solution:
After logging into the running Oracle9i instance as the SYS user (sqlplus “/ as sysdba”), check the log_archive parameters:
show parameter log_archive
Set the archive log destination directory (note that these commands assume that the database uses the spfile):
alter system set log_archive_start=TRUE scope=spfile;
alter system set log_archive_dest_1='location=/u01/archive/ORCL/' scope=spfile;
alter system set log_archive_format='arch_%t_%s.arc' scope=spfile;
Then shutdown and mount the database, and enable archivelog:
shutdown immediate;
startup mount;
archive log start;
alter database archivelog;
alter database open;
Reference:
http://www.oracle-base.com/articles/9i/ArchivelogModeOnRAC9i.php

Regards,
Vijay.

RMAN Recovery Catalog Configuration

 Consider the recovery catalog Dbname is cln and tns entry is cln. Kindly follow the below steps in recovery catalog database.

Tablespace name              =>   RMAN
Temporary tablespace name    =>   TEMP
User name                    =>   rman


 1.Create tablespace.

   SQL> create tablespace RMAN datafile '/test/oracle/uatdata/rman1.dbf' size 2048M;

Tablespace created.

2.Create user.

   SQL> create user rman identified by rman
  2  default tablespace RMAN
  3  temporary tablespace TEMP
  4  quota unlimited on RMAN;

User created.

3.Granting Privilege.

   SQL> Grant connect,resource,recovery_catalog_owner to rman;

Grant succeeded.

4.Recovery catalog Creation

           Please check the recovery catalog IP address in production whether pinging is happening or not. Then put the tns entry of recovery in production database. Follow the steps in production.

[oracln@test dbs]$ rman catalog=rman/rman@cln
Recovery Manager: Release 9.2.0.5.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to recovery catalog database
recovery catalog is not installed

RMAN> create catalog;
recovery catalog created

5. Register the Target Database with Recovery Catalog

[oracln@test dbs]$ rman catalog=rman/rman@cln target /
Recovery Manager: Release 9.2.0.5.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database: CLN (DBID=4233744721)
connected to recovery catalog database

RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN>

6. Final Step

 Now the recovery catalog will successfully created and try to connect with recovery catalog in production.

[oracln@test dbs]$ rman target / catalog=rman/rman@cln
Recovery Manager: Release 9.2.0.5.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database: CLN (DBID=4233744721)
connected to recovery catalog database

RMAN>

Now we can change all the RMAN parameters as per our database requirement using show all command.

Rman>show all;

After the successful Catalog configuration we can schedule the RMAN backup in crontab as per the backup location if required.


I hope the above mentioned steps will assist you to configure the Recovery Catalog easily.

Regards,
Vijay

Friday, 4 October 2013

Compatible Initialization Parameter and Upgrade/Downgrade

Compatibility: 


The COMPATIBLE initialization parameter controls the compatibility level of your database.

This parameter controls the database behavior for example whether a feature will work for a database. For example if database version is 10.2.0.4 but compatible parameter is set to 9.2 then certain feature like RMAN compression will not work. 

When you no longer need the ability to downgrade your database back to its original version, set the COMPATIBLE initialization parameter based on the compatibility level you want for your new database.

InCompatible :

When you upgrade to a new release of Oracle Database, certain new features might make your database incompatible with your previous release.

Conditions for Incompatible:

Your upgraded database becomes incompatible with your previous release under the following conditions: 

A new feature stores any data on disk (including data dictionary changes) that cannot be processed with your previous release. 

An existing feature behaves differently in the new environment as compared to the old environment. This type of incompatibility is classified as a language incompatibility.  

Purpose:

The COMPATIBLE initialization parameter enables or disables the use of features in the database that affect file format or disk and also you prevents from downgrading to your previous release.

After upgrading to Oracle Database new release, you can set the COMPATIBLE initialization parameter to match the release number of the new release.

COMPATIBLE Initialization Parameter and upgrade to 10g and 11g :

Oracle Database Release
Default Value
Minimum Value
Maximum Value
Oracle Database 9i Release 2 (9.2)
8.1.0
8.1.0.0.0
9.2.0.n.n
Oracle Database 10g Release 1 (10.1)
10.0.0
9.2.0.0.0
10.1.0.n.n
Oracle Database 10g Release 2 (10.2)
10.2.0
9.2.0.0.0
10.2.0.n.n
Oracle Database 11g Release 1 (11.1)
Oracle Database 11g Release 2 (11.2)
11.0.0
11.2.0
10.0.0.0.0
10.0.0.0.0
11.1.0.n.n
11.2.0.n.n

You have to set the Minimum compatible value to the current database while upgrading to new release.

The COMPATIBLE Initialization Parameter and downgrade from 11g:

If, after upgrading, you want to downgrade, and you have never set the COMPATIBLE value to 11.0.0 or higher, then the COMPATIBLE initialization parameter must be left (not changed) as follows after the upgrade: 

        1. Set to 10.1.0 if you upgraded from Oracle Database 10g Release 1 (10.1) 
        2. Set to 10.2.0 or earlier if you upgraded from Oracle Database 10g Release 2 (10.2)

Checking the Current Value of the COMPATIBLE Initialization Parameter:

You can  check the current value of the COMPATIBLE initialization parameter, enter the following SQL statement: 
SQL> SELECT name, value, description FROM v$parameter WHERE name = 'compatible';

SQL> show parameter compatible;

When to Set the COMPATIBLE Initialization Parameter:

After the upgrade is complete, you can increase the setting of the COMPATIBLE initialization parameter to the maximum level for Oracle Database 11g Release 1 (11.1).
However, after you do this, the database cannot subsequently be downgraded

Setting the COMPATIBLE Initialization Parameter
Complete the following steps to set the COMPATIBLE initialization parameter to a higher value: 

      1) Perform a backup of your database before you raise the COMPATIBLE initialization parameter (optional). 
Raising the COMPATIBLE initialization parameter might cause your database to become incompatible with earlier releases of Oracle Database, and a backup ensures that you can return to the earlier release if necessary by restoring the backup. 

     2) If you are using a server parameter file, then complete the following steps:

           i)  Update the server parameter file to set or change the value of the COMPATIBLE initialization parameter.  
For example, to set the COMPATIBLE initialization parameter to 11.0.0, enter the following statement:
              SQL> ALTER SYSTEM SET COMPATIBLE = '11.0.0' SCOPE=SPFILE; 
          ii) Shut down and restart the instance. 

   3) If you are using an initialization parameter file, then complete the following steps: 

          i) Shut down the instance if it is running:                 
               SQL> SHUTDOWN IMMEDIATE 
         ii)Edit the initialization parameter file to set or change the value of the COMPATIBLE initialization parameter. 
For example, to set the COMPATIBLE initialization parameter to 11.0.0, enter the following in the initialization parameter file: 
           COMPATIBLE = 11.0.0 

        iii) Start the instance using STARTUP.
Checking the Current Value of the COMPATIBLE Initialization Parameter:
You can  check the current value of the COMPATIBLE initialization parameter, enter the following SQL statement: 
SQL> SELECT name, value, description FROM v$parameter WHERE name = 'compatible';

SQL> show parameter compatible;

Downgrade the Oracle Database :

Make sure your database is compatible with the release to which you are downgrading before you perform the downgrade steps in this section.

Complete the following steps to downgrade your release 10.1 database to the previous Oracle Database release:

Log in to the system as the owner of the release 10.1 Oracle home directory.
 
  1. At a system prompt, change to the ORACLE_HOME/rdbms/admin directory.
  2. Start SQL*Plus.
  3. Connect to the database instance as a user with SYSDBA privileges.
  4. Start up the instance in DOWNGRADE mode:

SQL> STARTUP DOWNGRADE

You may need to use the PFILE option to specify the location of your initialization parameter file.

Set the system to spool results to a log file for later verification of success:

SQL> SPOOL downgrade.log

Run dold_release.sql, where old_release refers to the release to which you are downgrading. See Table 7-1 to choose the correct script. Each script provides a direct downgrade to the release specified in the "Downgrading To" column.

To run a script, enter the following:

SQL> @dold_release.sql

Reference :

1.      COMPATIBLE Initialization Parameter and Upgrade/Downgrade in 11g R1 or 11gR2 (Doc ID 444709.1)
2.      11g Compatible Initialization Parameter Setting When Upgrading Agile (Doc ID 1324734.1)
3.      How To Change The COMPATIBLE Parameter And What Is The Significance? (Doc ID 733987.1)
4.      How to Downgrade from Oracle RDBMS 10gR2? (Doc ID 398372.1)

Regards, 
Vijay.

Friday, 5 July 2013

Oracle Database Monitoring Scripts

Normal Database and Application Maintenance monitoring scripts.

===========================Database Related Scripts============================
Check Database Size In MB:
======================

SELECT d.name,d.open_mode,d.log_mode, a.data_size+b.temp_size+c.redo_size "DB_Total_Size_MB"
FROM ( SELECT SUM(bytes)/1024/1024 data_size
FROM dba_data_files )a,
( SELECT NVL(SUM(bytes),0)/1024/1024 temp_size
FROM dba_temp_files) b,
( SELECT SUM(bytes)/1024/1024 redo_size
FROM sys.v_$log ) c,v$database d;


Check Tablespace Sizes ( Without Temp Tablespace):
==========================================
SELECT /* + RULE */ df.tablespace_name "Tablespace",
df.bytes / (1024 * 1024) "Size (MB)",
SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
NVL(ROUND(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
ROUND((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
FROM dba_free_space fs,
(SELECT tablespace_name,SUM(bytes) bytes
FROM dba_data_files
GROUP BY tablespace_name) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY df.tablespace_name,df.bytes;
Check the Temp Tablespace Free Size:
==============================
SELECT   A.tablespace_name tablespace, D.mb_total,
SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_used,
D.mb_total - SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_free
FROM    v$sort_segment A,
(
SELECT   B.name, C.block_size, SUM (C.bytes) / 1024 / 1024 mb_total
FROM     v$tablespace B, v$tempfile C
WHERE    B.ts#= C.ts#
GROUP BY B.name, C.block_size
) D
WHERE    A.tablespace_name = D.name
GROUP by A.tablespace_name, D.mb_total;
Check Default temp tablespace:
=========================
SELECT property_value FROM database_properties where property_name='DEFAULT_TEMP_TABLESPACE';
Check temp tblspace free space:
=========================
SELECT tablespace_name,bytes_used/1024/1024 AS USED,bytes_free/1024/1024 AS FREE FROM v$temp_space_header WHERE tablespace_name='TEMP01';
Check Invalid Status:
=================
Select count(*) from dba_objects  where status='INVALID';
Script for Archive log generation per day:
=================================
SELECT to_date(first_time) DAY,
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'99') "00",
to_char(sum(decode(to_char(first_time,'HH24'),'01',1,0)),'99') "01",
to_char(sum(decode(to_char(first_time,'HH24'),'02',1,0)),'99') "02",
to_char(sum(decode(to_char(first_time,'HH24'),'03',1,0)),'99') "03",
to_char(sum(decode(to_char(first_time,'HH24'),'04',1,0)),'99') "04",
to_char(sum(decode(to_char(first_time,'HH24'),'05',1,0)),'99') "05",
to_char(sum(decode(to_char(first_time,'HH24'),'06',1,0)),'99') "06",
to_char(sum(decode(to_char(first_time,'HH24'),'07',1,0)),'99') "07",
to_char(sum(decode(to_char(first_time,'HH24'),'08',1,0)),'99') "08",
to_char(sum(decode(to_char(first_time,'HH24'),'09',1,0)),'99') "09",
to_char(sum(decode(to_char(first_time,'HH24'),'10',1,0)),'99') "10",
to_char(sum(decode(to_char(first_time,'HH24'),'11',1,0)),'99') "11",
to_char(sum(decode(to_char(first_time,'HH24'),'12',1,0)),'99') "12",
to_char(sum(decode(to_char(first_time,'HH24'),'13',1,0)),'99') "13",
to_char(sum(decode(to_char(first_time,'HH24'),'14',1,0)),'99') "14",
to_char(sum(decode(to_char(first_time,'HH24'),'15',1,0)),'99') "15",
to_char(sum(decode(to_char(first_time,'HH24'),'16',1,0)),'99') "16",
to_char(sum(decode(to_char(first_time,'HH24'),'17',1,0)),'99') "17",
to_char(sum(decode(to_char(first_time,'HH24'),'18',1,0)),'99') "18",
to_char(sum(decode(to_char(first_time,'HH24'),'19',1,0)),'99') "19",
to_char(sum(decode(to_char(first_time,'HH24'),'20',1,0)),'99') "20",
to_char(sum(decode(to_char(first_time,'HH24'),'21',1,0)),'99') "21",
to_char(sum(decode(to_char(first_time,'HH24'),'22',1,0)),'99') "22",
to_char(sum(decode(to_char(first_time,'HH24'),'23',1,0)),'99') "23"
from
v$log_history
where to_date(first_time) > sysdate -2
GROUP by
to_char(first_time,'YYYY-MON-DD'), to_date(first_time)
order by to_date(first_time);
**********************************End of Database Related Queries*******************************
 ========================== Application Tier Related Scripts========================
Workflow Service Components Status:
===============================
SELECT DECODE(component_type,
‘WF_AGENT_LISTENER’,'Agent Listener’,
‘WF_DOCUMENT_WEB_SERVICES’,’ Doc. Web Services’,
‘WF_JAVA_AGENT_LISTENER’,'JAVA Agent Listener’,
‘WF_MAILER’, ‘Mailer’,
‘default’
) “TYPE”,
component_name “NAME”,
Component_status “STATUS”,
COMPONENT_STATUS_INFO “ERROR”
FROM fnd_svc_components
WHERE component_type LIKE ‘WF%’
ORDER BY 3,1 DESC,2;
Checking the WF NOTIFICATION OUT table for the total number of notifications in different states:
===============================================================================
SELECT   DECODE (wfo.state,
0, ‘Ready’,
1, ‘Delayed’,
2, ‘Processed’,
3, ‘Exception’,
TO_CHAR (SUBSTR (wfo.state, 1, 12))
) state,
COUNT (*) COUNT
FROM applsys.wf_notification_out wfo
GROUP BY wfo.state;
Checking the Long Running Requests:
==============================
SELECT FND_CONCURRENT_REQUESTS.REQUEST_ID “Request ID”,
FND_USER.USER_NAME “Requestor”,
fnd_concurrent_programs_vl.user_concurrent_program_name “User Conc.Program Name”,
TO_CHAR(FND_CONCURRENT_REQUESTS.ACTUAL_START_DATE , ‘DD-MON-YYYY HH24:MI:SS’) ” Actual Start Date”,
TO_CHAR(SYSDATE, ‘DD-MON-YYYY HH24:MI:SS’) ” System Date”,
round(((SYSDATE-FND_CONCURRENT_REQUESTS.ACTUAL_START_DATE)*1440),2) “Minutes”,
‘Running’ Phase,
DECODE(FND_CONCURRENT_REQUESTS.Status_code,
‘D’, ‘Cancelled’,
‘U’, ‘Disabled’,
‘E’, ‘Error’,
‘M’, ‘No Manager’,
‘R’, ‘Normal’,
‘I’, ‘Normal’,
‘C’, ‘Normal’,
‘H’, ‘On Hold’,
‘W’, ‘Paused’,
‘B’, ‘Resuming’,
‘P’, ‘Scheduled’,
‘Q’, ‘Standby’,
‘S’, ‘Suspended’,
‘X’, ‘Terminated’,
‘T’, ‘Terminating’,
‘A’, ‘Waiting’,
‘Z’, ‘Waiting’,
‘G’, ‘Warning’) “Status”
FROM applsys.FND_USER, applsys.FND_CONCURRENT_REQUESTS, apps.fnd_concurrent_programs_vl
WHERE (FND_CONCURRENT_REQUESTS.PHASE_CODE = ‘R’
AND FND_CONCURRENT_REQUESTS.REQUESTED_BY = FND_USER.USER_ID
AND FND_CONCURRENT_REQUESTS.concurrent_program_id = fnd_concurrent_programs_vl.concurrent_program_id)
ORDER BY 6 desc,2, 5;
Checking the Concurrent Queues Details:
=================================
SELECT fcq.concurrent_queue_name || ‘ – ‘ || target_node “Concurrent Queue Name” ,
fcq.running_processes “Actual”,
fcq.max_processes “Target”,
SUM(DECODE(fcr.phase_code,’R',1,0)) – SUM(DECODE(fcr.status_code,’W',1,0)) “Running”,
SUM(DECODE(fcr.phase_code,’P',1,0)) “Pending”,
NVL(SUM(DECODE(fcr.status_code,’W',1,’H',1,’S',1,’A’ ,1,’Z',1,0)),0) “Paused”,
(case
when  AVG((NVL(fcr.actual_start_date,fcr.requested_start_date) – fcr.requested_start_date)*1440) < 0 then 0
else round(nvl(AVG((NVL(fcr.actual_start_date,fcr.requested_start_date) – fcr.requested_start_date)*1440),0),2)
end)
“Average Q Time”
FROM applsys.fnd_concurrent_requests fcr,
applsys.fnd_concurrent_processes fcp,
applsys.fnd_concurrent_queues fcq
WHERE fcr.controlling_manager (+) = fcp.concurrent_process_id
AND fcp.queue_application_id = fcq.application_id
AND fcp.concurrent_queue_id = fcq.concurrent_queue_id
AND fcq.max_processes > 0
AND ((fcr.phase_code IN (‘R’,'P’,'I’) AND UPPER(‘&dispmethod’) = ‘Y’) OR UPPER(‘&dispmethod’) != ‘Y’)
GROUP BY fcq.concurrent_queue_name || ‘ – ‘ || target_node, fcq.running_processes, fcq.max_processes
order by  7 desc;
Active Processes Status in Standard / CRM / ICM Managers:
================================================
SELECT   DECODE (fcq.concurrent_queue_name,
‘STANDARD’, ‘Standard Manager’,
‘FNDCRM’, ‘Conflict Resolution Manager’,
‘FNDICM’, ‘Internal Concurrent Manager’
) “Concurrent Queue”,
‘Active’ “Process Status”, COUNT (*) “Count”
FROM fnd_concurrent_queues fcq, fnd_concurrent_processes fcp
WHERE fcq.concurrent_queue_id = fcp.concurrent_queue_id
AND fcp.process_status_code = ‘A’
AND fcq.concurrent_queue_name IN (‘STANDARD’, ‘FNDCRM’, ‘FNDICM’)
GROUP BY fcq.concurrent_queue_name, fcp.process_status_code;
********************************End of Application Related Queries****************************
Best regards,
Vijay.