Database Health check scripts (10g,11g).

Oracle Database Health check scripts Health of the Database can be check in various ways. It includes: Monitoring Scope Current Status OS Level : 1 Physical memory / Load :Load normal, Load averages: 0.35, 0.37, 0.36 2 OS Space threshold ( archive, ora_dump etc.. ) :Sufficient Space available. 3 Top 10 process consuming memory:No process using exceptional high memory 4 Free volumes available :Sufficient disk space is available on the mount points 5 Filesystem space Under normal threshold Database level. 6 Check extents / Pro active Space addition:Space is being regularly added. 7 Check alert log for ORA- and warn messages. 8 Major wait events (latch/enqueue/Lib cache pin) No major wait events 9 Max Sessions 10 Long running Jobs 6 inactive sessions running for more than 8 hrs 11 Invalid objects 185 12 Analyze Jobs ( once in a week ) Done on 20-JAN-2008 Time 06:00:06 13 Temp usage / Rollback segment usage Normal 14 Nologging Indexes 15 Hotbackup/Coldbackup Gone fine 16 Redo generation normal 17 PQ proceses Normal 18 I/O Generation Under normal threshold 19 2 PC Pending transactions 0 DR / backup 1 Sync arch Normal 2 Purge arch Normal 3 Recovery status Normal 20)DATABASE HEALTH CHECK SCRIPT: Showing locks and Archive generation details In Detail DATABASE Health check: OPERATING SYSTEM: 1)Physical memory/ Load: 1) Free:free command displays amount of total, free and used physical memory (RAM) in the system as well as showing information on shared memory, buffers, cached memory and swap space used by the Linux kernel. Usage: $ free -m 2) vmstat:vmstat reports report virtual memory statistics, which has information about processes, swap, free, buffer and cache memory, paging space, disk IO activity, traps, interrupts, context switches and CPU activity

ora_dump etc.specially the location which is having archive logs .Check the filesystem in the OS side whether the sufficient space is available at all mount points. The memory usage stats by top command include real-time live Database files. ): Checking the OS space is available in all filesystems. With this command. Usage: $ps aux 2) OS Space threshold ( archive. SET LINES 1000 .ps aux|sort -m We can use the top command. ps will show the percentage of memory resource that is used by each process or task running in the system.We can use the below OS commands: $df –h $du –csh * 3) Top 10 process consuming memory: We can Displaying top 10 memory consuming processes as follows: ps aux|head -1..Index and temporary tablespaces for extend and blocks Allocation details. DATABASE : 6)Check extents / Pro active Space addition: Check each of the Data. used and free physical memory and swap memory with their buffers and cached memory sizerespectively Usage: $top 4) ps :ps command reports a snapshot on information of the current active processes. and press M which orders the process list by memory usage.Usage: $vmstat 5 3) top:top command displays dynamic real-time view of the running tasks managed by kernel and in Linux system. 4) Free volumes available: We have to make sure Sufficient disk space is available on the mount points on each OS servers where the Database is up and running. top memory hogging processes can be identified. $df –h 5)Filesystem space: Under normal threshold.

user#. s.In the 11g Database we can look for TNS errors in the alert log file. s.event#.client_identifier.last_call_et. s.seconds_in_wait.blocking_instance.wait_class. s.failover_method.prev_hash_value. s.command. s.blocking_session. s. 8) Major wait events (latch/enqueue/Lib cache pin): We can check the wait events details with the help of below queries: SELECT s.wait_class#. s. s.program) program. s. s. s.p1raw.seq#. s. s.username. s. s. s. s. s.wait_time.row_wait_file#.TYPE. s.SELECT SEGMENT_NAME. s. s.p1text. s. s.osuser.Increase in the size of the Database parameters. s. s. s.state. s.sql_hash_value.blocking_session_status. SELECT SEGMENT_NAME.prev_sql_addr. s. s. s.module. s.sql_exec_start. s. s. s. s. s. s. s. s. s.p3raw.status. s.prev_child_number.fixed_table_sequence. s. s. 7) Check alert log for ORA.sql_trace.In the alert log files we have to looks for the following things: 1) Look for any of the oracle related errors. s. Open the alert log file with less or more command and search for ORAThis will give you the error details and time of occurrence.schema#. s.wait_time_micro.sql_id.BLOCKS FROM DBA_SEGMENTS WHERE TABLESPACE_NAME=’STAR01D’.p2raw.logon_time. s.audsid.sql_address.plsql_entry_object_id.sql_exec_id. s.p2text. s.serial#.pdml_status.paddr.p3text. s. s. s. s. s.wait_class_id.plsql_entry_subprogram_id. s.time_since_last_wait_micro.lockwait.schemaname.service_name.pddl_status. s.row_wait_obj#. s. s. s.prev_exec_id.TABLESPACE_NAME. s. s. s. s.failed_over. 2) Look for the Database level or Tablespace level changes Monitor the alert log file and search the file for each Day activities happening In the Database either whether it is bouncing of Database.failover_type.row_wait_block#. s.pq_status. s.plsql_object_id.prev_exec_start.client_info. s. UPPER (s.and warn messages: Checking the alert log file regulary is a vital task we have to do.current_queue_duration. s. s. s.time_remaining_micro. s.EXTENTS.process. s. s.prev_sql_id.Increase in the size of the tablespaces.plsql_subprogram_id. s. s.ownerid.SID.module_hash. s. s. s.saddr.sql_child_number.server.event.action. .EXTENTS.p1. s.action_hash.p2.row_wait_row#. s.p3. s.BLOCKS FROM DBA_SEGMENTS.taddr.TABLESPACE_NAME.resource_consumer_group.pdml_enabled.machine.terminal. s. s. s.

shows Day wise.username is not null order by VALUE desc. event. b) Users and Sessions CPU and I/O consumption can be obtained by below query: -. a)Users and Sessions CPU consumption can be obtained by below query: Set lines 1000 select ss.TYPE <> 'BACKGROUND') AND STATUS='ACTIVE' ) ORDER BY "PROGRAM".SID = sw. sw. s.VALUE/100 cpu_usage_seconds from v$session ss.serial#.sql_trace_binds. The below Query gives details of Users sessions wait time and state: SELECT NVL (s. p1raw.sql_trace_waits.state FROM v$session_wait sw.sql_trace_plan_stats. sw. wait_time From v$session_wait Where event = 'library cache pin' And state = 'WAITING'.osuser.SID and ss. s.CPU and I/O consumption set linesize 140 col spid for a6 . sw.event.SID ORDER BY sw.SID. s.User wise.creator_serial# FROM v$session s WHERE ( (s. se.username IS NOT NULL) AND (NVL (s.username. v$statname sn where se. sw.session_edition_id. '(oracle)') AS username.status='ACTIVE' and ss. v$sesstat se. s. s.s.SID. The following query provides clues about whether Oracle has been waiting for library cache activities: Select sid.STATISTIC# = sn. s.username. 9) Max Sessions: There should not be more than 6 inactive sessions running for more than 8 hours in a Database in order to minimize the consumption of CPU and I/O resources.creator_addr. seconds_in_wait.wait_time. 'x') <> 'SYSTEM') AND (s.seconds_in_wait DESC. v$session s WHERE s. s.SID = ss.Process id of server wise.STATISTIC# and NAME like '%CPU used by this session%' and se.seconds_in_wait.

1.1.spid SPID.value/100).'J')).sid=s. time_remaining remaining.'J')trunc(logon_time.col program for a35 trunc select p.to_char(start_time. the job status is Initialization Error.'J')) days.V$SESS_IO si. message from v$session_longops where time_remaining = 0 order by time_remaining desc.0.(trunc( disk_io.to_char(s.program ) program.addr and ss.username. 11) Invalid objects: We can check the invalid objects with the help of the below query: select owner||' '||object_name||' '||created||' '||status from dba_objects where status='INVALID'.addr and round((ss. 12) Analyze Jobs ( once in a week ): We need to analyze the jobs that are running once in a week as a golden rule. Analyzing a Running Job The status of a job or a task changes several times during its life cycle. s.sid=s. Initialization Error: The job or step could not be run successfully.V$SESSION s.V$BGPROCESS bg where s.description. ss.'DDMonYY HH24:MI') date_login.0). A job can have the following as its status: Scheduled: The job is created and will run at the specified time. The below steps can be considered for analyzing jobs.decode(nvl(p.0) > 10 order by 8. round((ss.(trunc(sysdate.statistic#=12 and si.paddr=p.V$SESSTAT ss.value/100 CPU.sid and ss. 'hh24:mi:ss dd/mm/yy') started.'J')-trunc(logon_time.'J')-trunc(logon_time. Succeeded: The job was executed completely.LOGON_TIME.background.'J')))). 10) Long running Jobs: We can find out long running jobs with the help of the below query: col username for a20 col message for a50 col remaining for 9999 select username. .s. Failed: The job was executed but failed.2) cpu_per_day from V$PROCESS p.sid and bg.value/100)/(decode((trunc(sysdate.paddr(+)=p. If a step in a job fails initialization. Running: The job is being executed and is in progress.

session_addr ORDER BY b.sid)||'.tablespace.program.instance from = 'db_block_size' AND a.saddr = b.tablespace.blocks*p. b.serial#) = 'db_block_size'.program FROM sys.used_ublk * TO_NUMBER(x. Inactive: This status indicates that the target has been deleted. NVL(s.addr AND r.value)/1024/1024). The running jobs can be found out by the help of below query: select sid.v_$transaction undoseg. Stop Pending: The user has stopped the job. sys. r.value)/1024||'K' "Undo" FROM sys.xidusn(+) AND x.v_$session s.v_$rollname r. We can find out the failed jobs and Broken jobs details with the help of the Below query: select job||' '||schema_user||' '||Broken||' '||failures||' '||what||' '||last_date||' '||last_sec from dba_jobs. sys.username. . We can get information of Undo tablespace usage details with the help of the below query: set lines 1000 SELECT TO_CHAR(s. 'None') orauser. a. sys.blocks.sid||'.taddr = t. The already running steps are completing execution. a.usn = t.v_$parameter p WHERE p. job. s.v_$parameter x WHERE s. sys. t. Reassigned: The owner of the job has changed.v_$session a.username. a.'||TO_CHAR(s. sys. Skipped: The job was not executed at the specified time and has been omitted.serial# SID_SERIAL.'||a.Stopped: The user canceled the job.2)||'M' "SIZE". Suspended: This indicates that the execution of the job is deferred. 13) Temp usage / Rollback segment/PGA usage: We can get information of temporary tablespace usage details with the help of below query: Set lines 1000 SELECT b.v_$sort_usage b. ROUND(((b.

'11'.'HH24').'HH24').'HH24').1.'99') " 06".'HH24').If there are frequent log switches than archive logs might generate more which may decrease the performance of the Database however in a production Database log switches could vary depending upon the Server configuration between 5 to 20. .0)).'HH24') "TYPE".value desc.'99') " 11".'HH24'). Enter value for user: STARTXNAPP 14)Validating the Backup: We have to verify the Hotbackup/Coldbackup(or any physical or logical backup) of all the Production and non-production Databases went fine.0)). to_char(sum(decode(to_char(first_time. to_char(sum(decode(to_char(first_time.0)).'99') " 08".1.0)).'03'.'DD-MON-RR') "Date". to_char(sum(decode(to_char(first_time.'HH24').sid "SID". to_char(sum(decode(to_char(first_time.'07'.value / 1024 / 1024/1024) "GB" from v$sesstat st. We can the log switch details with the help of the below query: Redolog switch Datewise and hourwise: ------------------------------set lines 120.'99') " 10".Check the Backup locations to make sure the Backup completed on time with the required Backup data. to_char(sum(decode(to_char(first_time.1.'04'. to_char(sum(decode(to_char(first_time.'02'.1.0)). to_char(sum(decode(to_char(first_time.0)).'99') " 03".'HH24').'99') " 05".0)). v$statname sn where st.'00'. set pages 999.1.1.'10'.1. st.0)). to_char(sum(decode(to_char(first_time.statistic# = sn.'09'.0)). select to_char(first_time.'HH24').'99') " 04".'99') " 01".0)).'99') " 07".0)). to_char(sum(decode(to_char(first_time. sn.'99') " 02".'06'.'HH24').'HH24'). ceil(st.'08'.1.'05'.0)). 15) Redo generation/Archive logs generation details: We should make sure there should not be frequent log switch happening in a Database.1.Make sure you are having a valid backups of all the like '%PGA%' order by st.'99') " 09".It should complete on time with the required data for restoring and recovery purpose if required.1.sid.1.We can get the PGA usage details with the help of the below query: select st.'HH24'). to_char(sum(decode(to_char(first_time.statistic# and sid in (select sid from v$session where username like UPPER('&user')) and upper(sn. to_char(sum(decode(to_char(first_time. to_char(sum(decode(to_char(first_time.'99') " 00". 14)Hotbackup/Coldbackup: Validating the backup of Database.'01'.

to_char(sum(decode(to_char(first_time.1.'HH24'). to_char(sum(decode(to_char(first_time.'02'.'99') " 00".0)). to_char(sum(decode(to_char(first_time.0)).1.'HH24').'HH24').'HH24').'10'.1.'HH24').'99') " 20".0)).0)).'HH24'). to_char(sum(decode(to_char(first_time.1.0)).'HH24').'05'.'HH24').0)).1.1.0)).'HH24').'HH24').1.0)).0)).'HH24').1. to_char(sum(decode(to_char(first_time.1.'99') " 12". .'HH24').'HH24'). to_char(sum(decode(to_char(first_time. to_char(sum(decode(to_char(first_time.'99') " 19".'99') " 07".0)). to_char(sum(decode(to_char(first_time. to_char(sum(decode(to_char(first_time.'99') " 06".'18'.0)). to_char(sum(decode(to_char(first_time.0)). to_char(sum(decode(to_char(first_time.1.'99') " 13".to_char(sum(decode(to_char(first_time.'01'.'03'. to_char(sum(decode(to_char(first_time.1.1.0)).1.'12'.'99') " 16".0)). to_char(sum(decode(to_char(first_time.'99') " 12".'15'.'20'.'HH24').'99') " 01".'17'.0)).'HH24').'99') " 17".'21'.'06'. to_char(sum(decode(to_char(first_time.'99') " 03".'HH24').0)).0)). to_char(sum(decode(to_char(first_time.'23'. to_char(sum(decode(to_char(first_time.'99') " 17".'19'.'99') " 09".'99') " 21". to_char(sum(decode(to_char(first_time.'99') " 19".'HH24').'99') " 18".'HH24').0)).0)).'11'. to_char(sum(decode(to_char(first_time.1.'HH24').0)). to_char(sum(decode(to_char(first_time.'HH24').'HH24').'07'.'HH24'). to_char(sum(decode(to_char(first_time.'12'.0)).1.0)).'HH24'). to_char(sum(decode(to_char(first_time.'04'.'99') " 14".'HH24').1.'DD-MON-RR') "Date". to_char(sum(decode(to_char(first_time.'09'. We can use the below queries for archive logs generation details: a)Archive logs by dates: set lines 1000 select to_char(first_time.'08'.0)).0)).'99') " 15".'99') " 08".'14'.1.'13'.'99') " 15".1.'HH24').'22'.'99') " 14".'99') " 11".'HH24').'99') " 18".'99') " 16".1. to_char(sum(decode(to_char(first_time. to_char(sum(decode(to_char(first_time.1.'99') " 02".'14'.'16'.1.'16'.'19'.'99') " 13".'HH24').1. to_char(sum(decode(to_char(first_time.'99') " 10".1.1.0)).'18'.'HH24').'DD-MON-RR') order by 1 / Archive logs generations is directly proportional to the number of log switches happening in a Database.'00'.0)).'99') " 04". to_char(sum(decode(to_char(first_time. If there are frequent log switches than archive logs might generate more which can affect the performance of Database.'99') " 23" from v$log_history group by to_char(first_time.'HH24'). to_char(sum(decode(to_char(first_time.'HH24').'HH24').'99') " 05".'17'. to_char(sum(decode(to_char(first_time.1.1.0)).0)). to_char(sum(decode(to_char(first_time. to_char(sum(decode(to_char(first_time.1.0)).'15'.'99') " 22".'HH24'). to_char(sum(decode(to_char(first_time.'13'.0)).

.0)).'21'.'HH24').'99') " 05".'99') " 22".'08'.'HH24').0)). to_char(sum(decode(to_char(first_time.'HH24').'17'.1.0)).1.'HH24').1.'HH24').'99') " 01".'99') " 00".'99') " 13".0)).'99') " 03".'DD-MON-RR') order by 1 / b)Archive log generation details Day-wise : select to_char(COMPLETION_TIME.0)). to_char(sum(decode(to_char(first_time.'HH24').0)).'02'.1.0)).'19'.'HH24').0)).'HH24').1.1. to_char(sum(decode(to_char(first_time.1.1.0)).'HH24').'HH24').0)). to_char(sum(decode(to_char(first_time.1. to_char(sum(decode(to_char(first_time. to_char(sum(decode(to_char(first_time. to_char(sum(decode(to_char(first_time.1.0)).'99') " 21".'HH24'). to_char(sum(decode(to_char(first_time.'HH24').'HH24').'99') " 17".'DD-MON-YYYY').'HH24').1.1. to_char(sum(decode(to_char(first_time.1.1. to_char(sum(decode(to_char(first_time.'22'.1.'01'.'13'.0)).'HH24'). to_char(sum(decode(to_char(first_time.'99') " 16".0)).'HH24').'99') " 12".'12'.'99') " 23" from v$log_history group by to_char(first_time. to_char(sum(decode(to_char(first_time. to_char(sum(decode(to_char(first_time.'22'.'99') " 21".'DD-MON-YYYY') order by to_char(COMPLETION_TIME.'99') " 20".'07'.'HH24').0)).'99') " 11".'09'.1.count(*) from v$archived_log group by to_char(COMPLETION_TIME.0)).0)).'05'.'04'.'16'.'HH24').1.'99') " 19". to_char(sum(decode(to_char(first_time.'HH24').'HH24').'HH24').'DD-MON-RR') "Date".0)).0)).'14'.'HH24'). to_char(sum(decode(to_char(first_time. to_char(sum(decode(to_char(first_time.1. c) Archive log count of the day: select count(*) from v$archived_log where trunc(completion_time)=trunc(sysdate).'HH24').'HH24'). to_char(sum(decode(to_char(first_time.0)).'00'.'99') " 07".0)).1.0)).0)).'99') " 22".'99') " 04".1.'99') " 18". to_char(sum(decode(to_char(first_time.'99') " 20".'99') " 02". to_char(sum(decode(to_char(first_time.'99') " 14".1.'20'.1.'23'.0)).'06'.'15'.1.1.'11'.'99') " 10". to_char(sum(decode(to_char(first_time. to_char(sum(decode(to_char(first_time.0)).'21'.'10'. to_char(sum(decode(to_char(first_time. to_char(sum(decode(to_char(first_time.'99') " 09". to_char(sum(decode(to_char(first_time.1.'HH24').'03'.'HH24').0)).'18'.'99') " 08".'20'.1.1.to_char(sum(decode(to_char(first_time.0)).'99') " 15". count of archived logs generated today on hourly basis: ------------------------------------------------------select to_char(first_time.'HH24').'99') " 06". to_char(sum(decode(to_char(first_time. to_char(sum(decode(to_char(first_time.'DD-MON-YYYY').0)).

statistic#=12 and si. set linesize 140 col spid for a6 col program for a35 trunc select p.'J')trunc(logon_time. q.to_char(sum(decode(to_char(first_time.paddr=p.value/100)/(decode((trunc($BGPROCESS bg where s. STATUS FROM V$MANAGED_STANDBY.'HH24').Show IO per session.'J')-trunc(logon_time.2) cpu_per_day from V$PROCESS p.'J')-trunc(logon_time.what kind of sql a session is using set lines 9999 set pages 9999 select s.physical_reads disk_io. CLIENT_PROCESS.background.0.sql_address and s. round((ss.sql_text from v$sqltext q.'J')) days.'23'.(trunc(sysdate.value/100).'99') " 23" from v$log_history where to_char(first_time.sid and ss.sid.value/100 CPU.sid = &sid order by piece.'DD-MON-RR') order by 1 / 16)I/O Generation: We can find out CPU and I/O generation details for all the users in the Database with the help of the below query: -. s.1.1. To know what the session is doing and what kind of sql it is using: -.'J')).spid SPID.(trunc(sysdate.sid=s.0) > 10 order by 8.to_char(s. SEQUENCE#. sessionIOS.address = s.0).program ) program.'DDMonYY HH24:MI') date_login.s.sid and bg.This we can check as follows: The V$ MANAGED_STANDBY view on the standby database site shows you the activities performed by both redo transport and Redo Apply processes in a Data Guard environment SELECT PROCESS.sid=s.V$SESSION s. eg: sid=1853 17)Sync arch: In a Dataguard environment we have to check primary is in sync with the secondary Database.addr and ss. ss. In some situations.paddr(+)=p.'J')))).V$SESSTAT ss.addr and round((ss.decode(nvl(p.'DD-MON-RR')='16-AUG-10' group by to_char(first_time.0)). v$session s where q.CPU in seconds.1.description.V$SESS_IO si.username.LOGON_TIME. automatic gap recovery may not take place and you will need to perform gap .

Repeat this process until there are no more gaps.THREAD# = THREAD#) 4> ORDER BY THREAD#. query the V$ARCHIVE_GAP view as shown in the following example: SQL> SELECT * FROM V$ARCHIVE_GAP. query the DBA_LOGSTDBY_LOG view on the logical standby database. THREAD# SEQUENCE# FILE_NAME .) The output shows that the highest registered file is sequence number 10. FILE_NAME FROM DBA_LOGSTDBY_LOG L 2> WHERE NEXT_CHANGE# NOT IN 3> (SELECT FIRST_CHANGE# FROM DBA_LOGSTDBY_LOG WHERE L.recovery manually.arc'. After you register these log files on the physical standby database. After you identify the gap. For example. SQL> ALTER DATABASE REGISTER LOGFILE '/physical_standby1/thread1_dest/arcr_1_8. For example. On a physical standby database To determine if there is an archive gap on your physical standby database. you can restart Redo Apply. On a logical standby database: To determine if there is an archive gap. The V$ARCHIVE_GAP fixed view on a physical standby database only returns the next gap that is currently blocking Redo Apply from continuing. If it displays no rows than the primary Database is in sync with the standy Database. issue the following SQL statement on the primary database to locate the archived redo log files on your primary database (assuming the local archive destination on the primary database is LOG_ARCHIVE_DEST_1): Eg: SELECT NAME FROM V$ARCHIVED_LOG WHERE THREAD#=1 AND DEST_ID=1 AND SEQUENCE# BETWEEN 7 AND 10. SEQUENCE#. the following query indicates there is a gap in the sequence of archived redo log files because it displays two files for THREAD 1 on the logical standby database. query the V$ARCHIVE_GAP fixed view again on the physical standby database to determine the next gap sequence.If it display any information with row than manually we have to apply the archive logs.arc'. you will need to perform gap recovery manually if you are using logical standby databases and the primary database is not available. the query will show only one file for each thread. if there is one.SEQUENCE#. (If there are no gaps. The following sections describe how to query the appropriate views to determine which log files are missing and perform manual recovery. Copy these log files to your physical standby database and register them using the ALTER DATABASE REGISTER LOGFILE statement on your physical standby database. For example: SQL> ALTER DATABASE REGISTER LOGFILE '/physical_standby1/thread1_dest/arcr_1_7. but there is a gap at the file shown as sequence number 6: SQL> COLUMN FILE_NAME FORMAT a55 SQL> SELECT THREAD#. After resolving the gap and starting Redo Apply.

SEQUENCE#. a status other than VALID might identify an error encountered during the archival operation to that destination.----------------------------------------------1 6 /disk1/oracle/dbs/log-1292880008_6.---------. ARCHIVED_SEQ# 2> FROM V$ARCHIVE_DEST_STATUS 3> WHERE STATUS <> 'DEFERRED' AND STATUS <> 'INACTIVE'. ARCHIVED.------------/private1/prmy/lad VALID 1 947 standby1 VALID 1 947 The most recently written archived redo log file should be the same for each archive destination listed.arc'. 8. For example: SQL> ALTER DATABASE REGISTER LOGICAL LOGFILE '/disk1/oracle/dbs/log1292880008_10. The DBA_LOGSTDBY_LOG view on a logical standby database only returns the next gap that is currently blocking SQL Apply from continuing. After you register these log files on the logical standby database. You can query the DEST_ID column of the V$ARCHIVE_DEST fixed view on the primary database to identify each destination's ID number. and 9.---------------. STATUS FROM V$LOG WHERE STATUS='CURRENT'. Step 3 Determine the most recent archived redo log file at each destination. you can restart SQL Apply. Enter the following query at the primary database to determine which archived redo log file contains the most recently transmitted redo data: SQL> SELECT MAX(SEQUENCE#). Monitoring Log File Archival Information: Step 1 Determine the current archived redo log file sequence numbers. Enter the following query on the primary database to determine the current archived redo log file sequence numbers: SQL> SELECT THREAD#. THREAD# FROM V$ARCHIVED_LOG GROUP BY THREAD#. Step 4 Find out if archived redo log files have been received. if there is one. with sequence numbers 7.arc Copy the missing log files.---------. Step 2 Determine the most recent archived redo log file. ARCHIVED_THREAD#. .arc 1 10 /disk1/oracle/dbs/log-1292880008_10. If it is not. After resolving the identified gap and starting SQL Apply. to the logical standby system and register them using the ALTER DATABASE REGISTER LOGICAL LOGFILE statement on your logical standby database.-----. DESTINATION STATUS ARCHIVED_THREAD# ARCHIVED_SEQ# -----------------. STATUS. Enter the following query at the primary database to determine which archived redo log file was most recently transmitted to each of the archiving destinations: SQL> SELECT DESTINATION. You can issue a query at the primary database to find out if an archived redo log file was not received at a particular site. Repeat this process until there are no more gaps. query the DBA_LOGSTDBY_LOG view again on the logical standby database to determine the next gap sequence. Each destination has an ID number associated with it.

'HH24'). SEQUENCE# FROM V$ARCHIVED_LOG WHERE DEST_ID=1) 3> LOCAL WHERE 4> LOCAL. job.'HH24'). to_char(sum(decode(to_char(first_time.SHOWS ARCHIVE LOGS GENERAION DETAILS HOURLY AND DATE WISE BASIS select 'ARCHIVE LOG REPORT'.'07'.1.'HH24').'99') " 11".1.'HH24').THREAD#).'99') " 08".'HH24'). issue the following query: SQL> SELECT LOCAL.'DD-MON-RR') "Date". to_char(sum(decode(to_char(first_time.1.SHOWS RUNNING JOBS select 'RUNNING JOBS'. to_char(sum(decode(to_char(first_time. to_char(sum(decode(to_char(first_time.'HH24'). to_char(sum(decode(to_char(first_time.'05'. to_char(sum(decode(to_char(first_time. to_char(sum(decode(to_char( that you can restore and do the recovery if required.1.0)).1.1.'99') " 09".1.'99') " 05".'01'.'HH24').'02'.0)).0)). to_char(sum(decode(to_char(first_time.'03'.'09'.1.0)). to_char(sum(decode(to_char(first_time. to_char(sum(decode(to_char(first_time. sid.'06'.'99') " 01".'99') " 03".'11'.THREAD#.Assume the current local destination is 1.1.to_char(first_time.SEQUENCE# NOT IN 5> (SELECT SEQUENCE# FROM V$ARCHIVED_LOG WHERE DEST_ID=2 AND 6> THREAD# = LOCAL. and one of the remote standby destination IDs is 2.'HH24'). LOCAL. 20) MY DATABASE HEALTH CHECK SCRIPT: /* SCRIPT FOR MONITORING AND CHECKING HEALTH OF DATABASE-USEFUL FOR PRODUCTION DATABASES */ -. to_char(sum(decode(to_char(first_time.SEQUENCE# FROM 2> (SELECT THREAD#.--------1 12 1 13 1 14 18)Purge arch: We have to make sure the archive logs files are purged safely or move to Tape drive or any other location in order to make space for new archive logs files in the Archive logs destination locations.1.'10'. 19)Recovery status: In order to do recover make sure you are having latest archive logs.0)). .0)).'99') " 04".1.'99') " 07".'04'.'HH24').'99') " 02".0)).'00'. set lines 1000 -.0)).'99') " 06".'HH24').'08'. THREAD# SEQUENCE# --------.1.'99') " 00".0)).instance from dba_jobs_running.0)). to_char(sum(decode(to_char(first_time.0)).'HH24').'HH24').0)).'99') " 10". To identify which log files are missing at the standby destination.

'13'.2) cpu_per_day from V$PROCESS p.1.'16'.0)). to_char(sum(decode(to_char(first_time.'J')-trunc(logon_time.0)). to_char(sum(decode(to_char(first_time. to_char(sum(decode(to_char( IO per session / CPU in seconds.sid || ' ) is blocking ' || s2.0)).id2 . to_char(sum(decode(to_char(first_time.'20'.'J')) days.sid and block_changes > 10000 order by block_changes desc.spid SPID.'HH24').0)).V$BGPROCESS bg where s.'J')-trunc(logon_time.'15'.0)).0)). -.'HH24').SHOWS BLOCK CHANGES DETAILS AND PHYSICAL READS DETAIL select a.1.block_gets.machine || ' ( SID=' || s2. to_char(sum(decode(to_char(first_time.'99') " 14".0)).'J')).s.sid and s2.background.'DDMonYY HH24:MI') date_login.'99') " 13".program ) program.'99') " 19".value/100 CPU.value/100)/(decode((trunc(sysdate.'23'.'HH24'). v$session s1.sid. to_char(sum(decode(to_char(first_time.'HH24'). to_char(sum(decode(to_char(first_time.paddr=p.block_changes from V$SESS_IO || '@' || s2.0)). to_char(sum(decode(to_char(first_time.1.round((ss.'99') " 18".0.'HH24').username. blocking_session from v$session where blocking_session is not null.'21'.'HH24').(trunc(sysdate.sid=b.(trunc(sysdate.'99') " 22".'HH24').sid=s. -.BLOCK=1 and l2.V$SESSION s.id1 = l2.1.physical_reads.'99') " 21".'22'.V$SESSION b where a.sid and l1.request > 0 and l1.machine || ' ( SID=' || s1.'18'.0)). to_char(sum(decode(to_char(first_time.1.'HH24').'J')))).'J')trunc(logon_time.1.'99') " 16".'99') " 15".id1 and l2.0)).sid and ss.1.'HH24').'12'. -.'17'.'14'.1.id2 = l2.'19'.sid .sid.physical_reads disk_io.'99') " 12". sessionIOS. s.1.1. v$lock l2.sid=l2.'DD-MON-RR') order by 1 / -.statistic#=12 and si.username || '@' || s1.sql set linesize 140 col spid for a6 col program for a35 trunc select p.V$SESS_IO si. v$session s2 where s1.LOGON_TIME.WHAT ALL THE SESSIONS ARE GETTING BLOCKED select 'SESSIONS BLOCKED'.'99') " 17".V$SESSTAT ss.WHICH SESSION IS BLOCKING WHICH SESSION set lines 9999 set pages 9999 select s1.sid=l1. to_char(sum(decode(to_char(first_time.'HH24'). to_char(sum(decode(to_char(first_time.sid || ' ) ' AS blocking_status from v$lock l1.0)).process.addr and ss.'99') " 23" from v$log_history group by to_char(first_time.username.description.0).0)).'HH24').'99') " 20".sid=s.'HH24').to_char(sum(decode(to_char(first_time.decode(nvl(p.consistent_gets.

sofar. -.sql: ttitle "1. serial#. sid.machine.ACTIVE SESSIONS IN DATABASE select 'ACTIVE SESSION'. :============== Tablespace Usage Information ==================:" skip 2 set linesize 140 . units.username. time_remaining. osuser. sofar/totalwork*100 fertig from v$session_longops where time_remaining > 0 / -.addr and round((ss.occupied and available and Tablespace usage details along with hit ratio of various SGA components which can be very helpfull to monitor the performance of the Databases. target. Database_monitor.99 heading "complete[%]" select sid.status from v$session where username!='NULL' and status='ACTIVE'. Oracle Deutschland GmbH set linesize 120 col opname format a20 col target format a15 col units format a10 col time_remaining format 99990 heading Remaining[s] col bps format 9990.sid.sql_address and s.0) > 10 order by 8.sql_text from v$sqltext q. q. v$session s where q.value/100).99 heading [Units/s] col fertig format 90. totalwork.address = s.sid = &sid order by piece. opname. eg:SID=1844 I would like to add one more script which will tell me details regarding the Size of the Database used.SQL rem Long Running Statements rem Helmut Pfau.WHAT SQL A SESSION IS USING set lines 9999 set pages 9999 select s. (totalwork-sofar)/time_remaining bps.and bg.SCRIPT TO IDENTIFY LONG RUNNING STATEMENTS rem LONGOPS. -.paddr(+)=p.

0).bytes.tablespace_name.tablespace_name(+) and b. round( nvl( b.bytes/1024/1024. ttitle off col val4 new_val log1_reads noprint select Value val4 from V$SYSSTAT where Name = 'db block gets'.col Total format 99999. round(nvl(c.0)*100/nvl(a.bytes. 0)/1024/1024.2) Used. round(a. round(nvl(b.2) "% Used" from sys.tablespace_name=b.tablespace_name(+). ttitle "2. :============== Hit Ratio Information ==================:" skip 2 set linesize 80 clear columns clear breaks set pagesize 60 heading off termout off echo off verify off REM col val1 new_val lib noprint select 100*(1-(SUM(Reloads)/SUM(Pins))) val1 from V$LIBRARYCACHE.2) Free .sm$ts_avail a. ttitle off col val3 new_val phys_reads noprint select Value val3 from V$SYSSTAT where Name = 'physical reads'.2) Total.tablespace_name=c. sys.99 heading "Free space(MB)" break on report compute sum of Total space(MB) on report compute sum of Used space(MB) on report compute sum of Free space(MB) on report select a.bytes.bytes.99 heading "Total space(MB)" col Used format 99999. ttitle off col val5 new_val log2_reads noprint select Value val5 from V$SYSSTAT .sm$ts_free c where a. sys.0)/1024/1024. ttitle off col val2 new_val dict noprint select 100*(1-(SUM(Getmisses)/SUM(Gets))) val2 from V$$ts_used b.99 heading "Used space(MB)" col Free format 99999.

ttitle off col val6 new_val chr noprint select 100*(1-(&phys_reads / (&log1_reads + &log2_reads))) val6 from DUAL. V$SYSSTAT B where A. ttitle off col val7 new_val avg_users_cursor noprint col val8 new_val avg_stmts_exe noprint select SUM(Users_Opening)/COUNT(*) val7.Name = 'sorts (memory)'. ROUND(100*A. ' Cache Hit Ratio : '||&lib lib_hit. ttitle off set termout on set heading off ttitle center 'SGA Cache Hit Ratios' skip 2 select 'Data Block Buffer Hit Ratio : '||&chr db_hit_ratio. ' Shared SQL Buffers (Library Cache) '.Value)).2) Pct_Disk_Sorts from V$SYSSTAT A.1. Executes/Stmt : '|| &avg_stmts_exe||' ' from DUAL. Users/Stmt : '|| &avg_users_cursor||' '.Value Memory_Sorts.Value+B.0.Value/ DECODE((A. ' Dictionary Hit Ratio : '||&dict dict_hit.(A. ttitle "4.where Name = 'consistent gets'. :============== Sort Information ==================:" skip 2 select A.Value). :============== Database Size Information ==================:" skip 2 select sum(bytes/1024/1024/1024) Avail from sm$ts_avail union all select sum(bytes/1024/1024/1024) Used from sm$ts_used union all select sum(bytes/1024/1024/1024) . ' Avg.Name = 'sorts (disk)' and B.Value+B. B. ' Shared SQL Pool '.Value Disk_Sorts. ' Avg. SUM(Executions)/COUNT(*) val8 from V$SQLAREA. ttitle "3.

. Hope this helps you in monitoring your Databases.Free from sm$ts_free.

Sign up to vote on this title
UsefulNot useful