Friday 28 May 2010

11G: AUTOMATIC DIAGNOSTIC REPOSITORY

Whenever critical errors are reported in the database, an incident is automatically created. Oracle collects lots of diagnostic data in the form of Trace and dump files in ADR, which may need to be sent to Oracle support. In order to send all required file for a specific problem or incident, we will use ADRCI or Enterprise Manager.

CREATING PACKAGE USING ADRCI

adrci> show incident
ADR Home = /home/oracle/app/diag/rdbms/orcl/orcl:
*************************************************************************
INCIDENT_ID PROBLEM_KEY CREATE_TIME
-------------------- ----------------------------- ----------------------------------
14773 ORA 1578 2007-08-15 09:08:51.749759 -04:00
14772 ORA 1578 2007-08-15 09:08:41.329081 -04:00
14771 ORA 1578 2007-08-15 09:08:39.554096 -04:00
14770 ORA 1578 2007-08-15 09:08:38.027391 -04:00
14769 ORA 1578 2007-08-15 09:05:38.961166 -04:00
5 rows fetched


adrci> host "ls -ltr /home/oracle/app/diag/rdbms/orcl/orcl"
total 60
drwxr-x--- 2 oracle oinstall 4096 Aug 13 10:39 cdump
drwxr-x--- 2 oracle oinstall 4096 Aug 13 10:39 metadata
drwxr-x--- 2 oracle oinstall 4096 Aug 13 12:34 hm
drwxr-x--- 2 oracle oinstall 4096 Aug 14 09:52 alert
drwxr-x--- 2 oracle oinstall 4096 Aug 14 11:01 ir
drwxr-x--- 2 oracle oinstall 4096 Aug 15 11:33 sweep
drwxr-x--- 2 oracle oinstall 4096 Aug 15 11:33 stage
drwxr-x--- 2 oracle oinstall 4096 Aug 15 11:33 lck
drwxr-x--- 7 oracle oinstall 4096 Aug 15 11:33 incident
drwxr-x--- 7 oracle oinstall 20480 Aug 15 11:35 trace
drwxr-x--- 3 oracle oinstall 4096 Aug 15 12:54 incpkg

Create the Logical Package for incident 14773

adrci> ips create package incident 14773
Created package 1 based on incident id 14773, correlation level typical


This will create a new sub-directory in the ADR_HOME/incpkg directory

adrci> host "ls -ltr /home/oracle/app/diag/rdbms/orcl/orcl/incpkg"
total 4


If you want to add another incident to bundle in the same package, use the following command or
go to next step

adrci> ips add incident 14769 package 1
Added incident 14769 to package 1


If you want to add more additional file to be bundled in the same package

adrci> ips add file /trace/alert_orcl.log package 1
Added file /trace/alert_orcl.log to package 1

Create physical package in the form of ZIP file in specified directory

adrci> ips generate package 1 in /tmp
Generated package 1 in file /tmp/ORA1578_20070815125445_COM_1.zip, mode complete

Verify the Zip file mentioned in the previous output

adrci> host "ls -ltr /tmp/ORA1578_20070815125445_COM_1.zip"
-rw-r--r-- 1 oracle oinstall 2088815 Aug 15 13:13 /tmp/ORA1578_20070815125445_COM_1.zip

Check the Content of the Zip file and you will see that Oracle has added lots of files like
Trace file, Trace Mapping etc

adrci> host "unzip -l /tmp/ORA1578_20070815125445_COM_1.zip"

Archive: /tmp/ORA1578_20070815125445_COM_1.zip
Length Date Time Name
-------- ---- ---- ----
0 08-13-07 10:39 diag/rdbms/orcl/orcl/
52681 08-15-07 09:05 diag/rdbms/orcl/orcl/incident/incdir_14769/orcl_ora_13914_i14769.trm
2053639 08-15-07 09:05 diag/rdbms/orcl/orcl/incident/incdir_14769/orcl_ora_13914_i14769.trc
120355 08-15-07 10:10 diag/rdbms/orcl/orcl/trace/orcl_ora_13914.trc
6583 08-15-07 10:10 diag/rdbms/orcl/orcl/trace/orcl_ora_13914.trm
2053097 08-15-07 09:08 diag/rdbms/orcl/orcl/incident/incdir_14770/orcl_ora_13914_i14770.trc
52510 08-15-07 09:08 diag/rdbms/orcl/orcl/incident/incdir_14770/orcl_ora_13914_i14770.trm
2053051 08-15-07 09:08 diag/rdbms/orcl/orcl/incident/incdir_14771/orcl_ora_13914_i14771.trc
52526 08-15-07 09:08 diag/rdbms/orcl/orcl/incident/incdir_14771/orcl_ora_13914_i14771.trm
52511 08-15-07 09:08 diag/rdbms/orcl/orcl/incident/incdir_14772/orcl_ora_13914_i14772.trm
2053005 08-15-07 09:08 diag/rdbms/orcl/orcl/incident/incdir_14772/orcl_ora_13914_i14772.trc
2053004 08-15-07 09:08 diag/rdbms/orcl/orcl/incident/incdir_14773/orcl_ora_13914_i14773.trc
52536 08-15-07 09:08 diag/rdbms/orcl/orcl/incident/incdir_14773/orcl_ora_13914_i14773.trm
205233 08-15-07 11:35 diag/rdbms/orcl/orcl/trace/alert_orcl.log
730289 08-15-07 11:35 diag/rdbms/orcl/orcl/alert/log.xml


501 08-15-07 13:13 metadata.xml
-------- -------
11822447 83 files

11g: LDAP_DIRECTORY_SYSAUTH

Connections with sysdba or sysoper privileges must always be authenticated. This is possible through OS authentication by assigning the appropriate OS group to the OS user.

Another method is the use of a password file.

If there is concern that the password file might be vulnerable the following strong authentication methods can be used with Oracle database 11g:

  • Oracle Internet Directory (OID) grants for sysdba and sysoper
  • Kerberos ticket server
  • Secure Socket Layer (SSL) certificates

In order to use OID the parameter LDAP_DIRECTORY_ACCESS must be set to PASSWORD or SSL.

If you intend to use any of these strong authentication methods the initialization parameter LDAP_DIRECTORY_SYSAUTH must be set to YES. Its default is NO.

11g: Health Monitor (DBMS_HM)

DBMS_HS:

When Using DBMS_HS failure can be detected and logged automatically in reaction to the table creation failure. If there is a low use corrupt tablespace datafile, we may not notice the problem for some time.

The Health Monitor also allows us to perform the same integrity checks manually, rather than waiting for the reactive tests to take place. This may help you identify and fix problems before they are ever noticed by users.

Access to Health Monitor is available using the DBMS_HM package

The available checks are displayed using the V$HM_CHECK view

SQL> SELECT name FROM v$hm_check WHERE internal_check='N';

NAME
----------------------------------
DB Structure Integrity Check
Data Block Integrity Check
Redo Integrity Check
Transaction Integrity Check
Undo Segment Integrity Check
Dictionary Integrity Check

6 rows selected.

Most of the health checks accept parameters, which are displayed using the V$HM_CHECK_PARAM view.

SET LINESIZE 120
COLUMN check_name FORMAT A30
COLUMN parameter_name FORMAT A15
COLUMN type FORMAT A15
COLUMN default_value FORMAT A15
COLUMN description FORMAT A20

SELECT c.name check_name, p.name parameter_name, p.type, p.default_value, p.description
FROM v$hm_check_param p, v$hm_check c
WHERE p.check_id = c.id
AND c.internal_check = 'N'
ORDER BY c.name;

CHECK_NAME PARAMETER_NAME TYPE DEFAULT_VALUE DESCRIPTION
------------------------------ --------------- --------------- --------------- -------------------
Data Block Integrity Check BLC_DF_NUM DBKH_PARAM_UB4 Block Data File number
Data Block Integrity Check BLC_BL_NUM DBKH_PARAM_UB4 Datablock number
Dictionary Integrity Check CHECK_MASK DBKH_PARAM_TEXT ALL Check Mask
Dictionary Integrity Check TABLE_NAME DBKH_PARAM_TEXT ALL_CORE_TABLES Table Name
Redo Integrity Check SCN_TEXT DBKH_PARAM_TEXT 0 SCN ofthe latest good redo (if known)
Transaction Integrity Check TXN_ID DBKH_PARAM_TEXT Transaction ID
Undo Segment Integrity Check USN NUMBER DBKH_PARAM_TEXT Undo Segment Number

7 rows selected.

The DBMS_HM.RUN_CHECK procedure is used to run a specific check with the appropriate parameters.

BEGIN
DBMS_HM.run_check (
check_name => 'DB Structure Integrity Check',
run_name => 'my_test_run');
END;
/

PL/SQL procedure successfully completed.

The findings of the health checks can be displayed using a variety of methods:

The DBMS_HM.GET_RUN_REPORT function returns a report of the findings in TEXT, HTML or XML format.

The findings are visible using the RMAN LIST FAILURE command, as seen previously.

The results can be queried directly from the V$HM_RUN, V$HM_FINDING, and V$HM_RECOMMENDATION views.

Enterprise Manager supports the Data Recovery Advisor and Health Monitor.

Automatic Diagnostic Repository Command Interpreter (ADRCI) utility. The example below shows the test output of the DBMS_HM.GET_RUN_REPORT function.

SET LONG 100000
SET LONGCHUNKSIZE 1000
SET PAGESIZE 1000
SET LINESIZE 512

SELECT DBMS_HM.get_run_report('MY_TEST_RUN') FROM dual;

DBMS_HM.GET_RUN_REPORT('MY_TEST_RUN')
------------------------------------------------------------------------------
Basic Run Information

Run Name : my_test_run
Run Id : 330
Check Name : DB Structure Integrity Check
Mode : MANUAL
Status : COMPLETED
Start Time : 2008-01-04 11:30:27.293105 +00:00
End Time : 2008-01-04 11:30:27.345898 +00:00
Error Encountered : 0
Source Incident Id : 0
Number of Incidents Created : 0
Input Paramters for the Run
Run Findings And Recommendations
Finding
Finding Name : Corrupt Datafile
Finding ID : 334
Type : FAILURE
Status : OPEN
Priority : HIGH
Message : Datafile 4: '/u01/app/oracle/oradata/DB11G/users01.dbf' is
corrupt
Message : Some objects in tablespace USERS might be unavailable

The ADR Command Interpreter (ADRCI) utility is initiated by issuing the "adrci" command on the command line.

$ adrci
ADRCI: Release 11.1.0.6.0 - Beta on Fri Jan 4 12:01:20 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
ADR base = "/u01/app/oracle"

Health Monitor runs are displayed using the following command.

adrci> show hm_run

11g: Data Recovery Advisor

The Data Recovery Advisor automatically diagnoses corruption or loss of persistent data on disk, determines the appropriate repair options, and executes repairs at the user's request. This reduces the complexity of recovery process, thereby reducing the Mean Time To Recover (MTTR).

Create a Failure:

Before we can start identifying and repairing failures, we need to create one. Probably the easiest way to do this is to corrupt a datafile using the "echo" command. The following script navigates to the directory holding the datafiles, checks the current size of the users01.dbf file, echos nothing to it, then checks the file size once more.

$ cd /u01/app/oracle/oradata/DB11G

$ ls -l users01.dbf
-rw-r----- 1 oracle oinstall 57745408 Jan 3 11:42 users01.dbf

$ echo > users01.dbf

$ ls -l users01.dbf
-rw-r----- 1 oracle oinstall 1 Jan 3 13:26 users01.dbf

You can see the file size has been reduced to a single byte.Next, we connect to the database and try to create a table in the USERS tablespace.

SQL> CREATE TABLE test_tab (id NUMBER) TABLESPACE USERS;
CREATE TABLE test_tab (id NUMBER) TABLESPACE USERS
*
ERROR at line 1:
ORA-01115: IO error reading block from file 4 (block # 3)
ORA-01110: data file 4: '/u01/app/oracle/oradata/DB11G/users01.dbf'
ORA-27072: File I/O error
Additional information: 4
Additional information: 2

The resulting error triggers a data integrity check that searches the database for failures related to the error and records them in the Automatic Diagnostic Repository (ADR).

Relevant RMAN Functionality:

LIST FAILURE:

The LIST FAILURE command displays any failures with a status OPEN and a priority of CRITICAL or HIGH in order of importance. If no such failures exist it will list LOW priority failures.

RMAN> LIST FAILURE;

List of Database Failures
=========================

Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
202 HIGH OPEN 03-JAN-08

One or more non-system datafiles are corrupt

The LIST FAILURE command has a number of options that can be combined to alter the failures listed.

ADVISE FAILURE:

The ADVISE FAILURE command, as the name implies, provides repair advice for failures listed by the LIST FAILURE command, as well as closing all open failures that are already repaired.

RMAN> ADVISE FAILURE;

List of Database Failures
=========================

Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
202 HIGH OPEN 03-JAN-08 One or more non-system datafiles are corrupt


analyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=124 device type=DISK
analyzing automatic repair options complete

Mandatory Manual Actions
========================
no manual actions available

Optional Manual Actions
=======================
no manual actions available

Automated Repair Options
========================

Option Repair Description
------ ------------------
1 Restore and recover datafile 4
Strategy: The repair includes complete media recovery with no data loss
Repair script: /u01/app/oracle/diag/rdbms/db11g/DB11G/hm/reco_3657335472.hm

If manual repair actions are produced you should attempt them first, as they are likely to be less disruptive. If manual repair actions aren't present, or they do not fix the problem, you can use the automated repair option.

REPAIR FAILURE:

The REPAIR FAILURE command applies the repair scripts produced by the ADVISE FAILURE command. Using the PREVIEW option lists the contents of the repair script without applying it.

RMAN> REPAIR FAILURE PREVIEW;

Strategy: The repair includes complete media recovery with no data loss
Repair script: /u01/app/oracle/diag/rdbms/db11g/DB11G/hm/reco_2408143298.hm
contents of repair script:
# restore and recover datafile
sql 'alter database datafile 4 offline';
restore datafile 4;
recover datafile 4;
sql 'alter database datafile 4 online';

By default, the REPAIR FAILURE command prompts the user to confirm the repair, but this can be prevented using the NOPROMPT keyword.

RMAN> REPAIR FAILURE NOPROMPT;

Strategy: The repair includes complete media recovery with no data loss
Repair script: /u01/app/oracle/diag/rdbms/db11g/DB11G/hm/reco_2408143298.hm
contents of repair script:
# restore and recover datafile
sql 'alter database datafile 4 offline';
restore datafile 4;
recover datafile 4;
sql 'alter database datafile 4 online';
executing repair script

sql statement: alter database datafile 4 offline

Starting restore at 03-JAN-08
using channel ORA_DISK_1

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 00004 to /u01/app/oracle/oradata/DB11G/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/DB11G/backupset/
2008_01_03/o1_mf_nnndf_BACKUP_DB11G.WORLD_0_3qsl2hy4_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/DB11G/backupset/2008_01_03/
o1_mf_nnndf_BACKUP_DB11G.WORLD_0_3qsl2hy4_.bkp tag=BACKUP_DB11G.WORLD_010308113407
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 03-JAN-08

Starting recover at 03-JAN-08
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:01

Finished recover at 03-JAN-08

sql statement: alter database datafile 4 online
repair failure complete

CHANGE FAILURE:

The CHANGE FAILURE command allows you to change the priority of a failure or close an open failure. You may wish to change the priority of a failure if it does not represent a problem to you. For example, a failure associated with a tablespace you know longer use may be listed as a high priority, when in fact it has no effect on the normal running of your system.

RMAN> CHANGE FAILURE 202 PRIORITY LOW;

It is unlikely you will need to close an open failure, as even manually repaired failures are closed implicitly, but the option is there should you need it.

VALIDATE:

The VALIDATE command initiates data integrity checks, logging physical, and optionally logical, block corruptions of database files and backups in the V$DATABASE_BLOCK_CORRUPTION view and the Automatic Diagnostic Repository as one or more failures.

The following code shows some of the possible syntax variations.
# Check for physical corruption of all database files.
VALIDATE DATABASE;

# Check for physical and logical corruption of a tablespace.
VALIDATE CHECK LOGICAL TABLESPACE USERS;

# Check for physical and logical corruption of a datafile.
VALIDATE CHECK LOGICAL DATAFILE 4;

# Check for physical corruption of all archived redo logs files.
VALIDATE ARCHIVELOG ALL;

# Check for physical and logical corruption of the controlfile.
VALIDATE CHECK LOGICAL CURRENT CONTROLFILE;

# Check for physical and logical corruption of a specific backupset.
VALIDATE CHECK LOGICAL BACKUPSET 3;

The BACKUP VALIDATE and RESTORE VALIDATE commands perform the same checks as the VALIDATE command for the files targeted by the backup or restore command, but they don't actually perform the specified backup or restore operation. This allows you to check the integrity of a backup or restore operation before actually performing it.

The following code shows some of the possible syntax variations:

# Check for physical corruption of files to be backed up.
BACKUP VALIDATE DATABASE ARCHIVELOG ALL;

# Check for physical and logical corruption of files to be backed up.
BACKUP VALIDATE CHECK LOGICAL DATABASE ARCHIVELOG ALL;

# Check for physical corruption of files to be restored.
RESTORE VALIDATE DATABASE;

# Check for physical and logical corruption of files to be restored.
RESTORE VALIDATE CHECK LOGICAL DATABASE;

Wednesday 19 May 2010

How to run a Shell script from oracle DBMS_SCHEDULER

This is an example to show how to run a shell script from DBMS_SCHEDULER

Example :

#!/usr/bin/ksh

$ vi /tmp/try.sh
#!/usr/bin/ksh
ls >> /tmp/try.log


SQL> conn system/****
Connected.


SQL> BEGIN DBMS_SCHEDULER.CREATE_JOB
2 ( job_name=>'try2',
3 job_type=>'EXECUTABLE',
4 job_action=>'/tmp/try.sh',
5 enabled=>true,
6 auto_drop=>true);
7 END ;
8 /
PL/SQL procedure successfully completed.

SQL> select log_id, log_date, job_name, status, error#, additional_info2 from dba_scheduler_job_run_details3 where job_name ='Try2';

LOG_ID
----------
LOG_DATE
--------------------------------------------------------------------------- JOB_NAME STATUS ERROR#
------------------------------ ------------------------------ ----------
ADDITIONAL_INFO
---------------
1102 03-MAR-08 11.44.02.827232 AM -07:00 TRY2 SUCCEEDED 0

Script to create definition of indexes

declare
s varchar2(4000);
begin
for c1 in (
select dbms_metadata.get_ddl(object_type=>'INDEX',name=>cur.index_name)
from user_indexes)
loop
s := dbms_metadata.get_ddl(object_type=>'INDEX',name=>c1.index_name);
end loop;
dbms_output.put_line('S= 's);
end;

Tuesday 18 May 2010

Monday 17 May 2010

Oracle DBA Consultant

10g certified senior Oracle DBA with more than 10 years of Oracle Production Support, design & architecture experience in various phases of including Planning of database design/architect, Database Tuning, Disaster recovery, System Analysis, Testing, Implementation and skilled with creative problem resolution capabilities. Highly skilled in Tuxedo administration and Unix Administration. Extensive experience in implementing disaster recovery plans and backup strategy. Excellent leadership, communication & interpersonal skills.

Technical Skills Summary till date

Oracle 8i/9i/10g/11g Internals & optimizers
Tuxedo 6.5/7.1/8.1 Administrator
Oracle 9i/10g/11g Data Guard
Oracle 8i Parallel Server (OPS)
Oracle 9i/10g/11g Real Application Clusters (RAC)
Performance Tuning advisors / SQL Access advisor
Replication & Streams
Oracle Database Upgrades
Oracle Application Server
Disaster Recovery Solutions
Database Design
System/Interface Design
Data Modelling
ASM 10g/11g
10g /11g Grid Control
Oracle data migration
Database Security Administration
Oracle Backup Strategy & RMAN
Oracle 9i/10g Data warehousing, OBI, OWB
Oracle Enterprise Manager (OEM)
Unix Shell Scripting
PL/SQL, Forms, SQL, C, Clear Basic
Application Performance Tuning & Partitioning
AWR/ASH/ADDM reports for performance
Unix, Solaris, HPUX, Tru64, AIX
Cluster, Volume manager ,SAN & RAID design
Project Management
Application Migration
Oracle Apps architecture
Database Services 10g/11g
SQL Server 2000/2005
rapidclone / adclone

Platform/Tools Used:

Hardware Sun F15K/E25K, V480, V490, Compaq ES40 / DS20e, IBM RS6000, Alpha 1200, HP, Veritas Netbackup, Veritas Volume manager

Operating Systems Sun 5.8/5.9/5.10, Tru64 5.1A, IBM AIX, HP 11.0, Redhat/SUSE Linux, Windows NT
Languages UNIX Shell Scripting, SQL, PL/SQL, C, Clear Basic, Java
Databases Oracle 7.3.4, 8, 8i, 9i, 10g, 11g, 9i/10g/11g Data Guard, 9i/10g/11g RAC, 9i Replication
Middleware Tuxedo 6.5, 7.1, 8.1, Oracle Apps
CRM Amdocs Clarify CRM 10.1, 12.5
Tools Toad, OEM, Glance, Top, prstat, .ssh, Erwin Data model

Major Demonstrated Strengths:

Has endeavored excellence by focusing solely on Oracle database Technology & has rich depth of experience.
Keeping stake holders updated with the latest technology options/features by presenting whitepapers
Result oriented, analytical & self-driven professional seasoned with years of working handling role of Oracle DBA/Designer/architect.
Has demonstrated depth of knowledge by imparting a lot of training sessions on Oracle 9i/10g architecture & tuning.