You are on page 1of 6

Oracle's alert.log chronologically records messages and errors arising from the daily database operation.

Also, there are pointers to trace files and dump files These messages include

startups and shutdowns of the instance Messages to the operator console Errors causing trace files.

Create, alter and drop SQL statements on databases, tablespaces and rollback segments.
Errors when a materialized view is refreshed. ORA-00600 (internal) errors. ORA-01578 errors (block corruption) ORA-00060 errors (deadlocks)

alert.log is a text file that can be opened with any text editor. The directory where it is found can be determined by the background_dump_dest initialization parameter:

select value from v$parameter where name = 'background_dump_dest';


OR

SQL> show parameter background_dump_dest


If the background_dump_dest parameter is not specified, Oracle will write the alert.log into the $ORACLE_HOME/RDBMS/trace directory.

ARCx: Media recovery disabled This message will be written into the alert.log if the arch process is started with the database being in noarchive log mode. It's unfortunately possible for ARCH to be sitting around doing nothing apart from just taking up memory when the database is in noarchive log mode. The archiver can be stopped dynamically: alter system archive log stop. Ignoring SIGALARM Such a message is written into the alert log when a process that waited for a semaphore gets the semaphore shortly befor the timeout expires and doesn't have the time to switch the timeout mechanism off. Thread 1 cannot allocate new log, sequence 1558 Checkpoint not complete This error message is written into the alert.log if a checkpoint cannot write all dirty db blocks to the online redo log. Usually, this message is a sign that the size of the redo logs is to small or that there should be Rotating the alert logs Within Oracle, it is perfectly possible to delete, or rename, the alert.log, if desired (for example, if it reaches a certain size). Oracle simply recreates a new alert.log the next time it writes to it.

Linux (and other Unixes?) has an utility called logrotate to automate that task.

Script to read Oracle's alert log

The following script creates two tables: read_alert and read_alert_disk. read_alert_disk is an external table and contains the content of the alert log. read_alert will be empty after this script has been executed. It is used by the update_alert_log script, shown further below.

define alert_length="2000"

drop table alert_log;

create table alert_log ( alert_date date, alert_text varchar2(&&alert_length) ) storage (initial 512k next 512K pctincrease 0);

create index alert_log_idx on alert_log(alert_date) storage (initial 512k next 512K pctincrease 0);

column db

new_value _DB

noprint;

column bdump new_value _bdump noprint;

select instance_name db from v$instance;

select value bdump from v$parameter where name ='background_dump_dest';

drop directory BDUMP; create directory BDUMP as '&&_bdump';

drop table alert_log_disk;

create table alert_log_disk ( text varchar2(&&alert_length) ) organization external ( type oracle_loader default directory BDUMP access parameters ( records delimited by newline nologfile nobadfile fields terminated by "&" ltrim ) location('alert_&&_DB..log') ) reject limit unlimited;

update_alert_log.sql
Now, after the two tables are created, the alert_log table can be filled with the following script. It only loads those records that are greater than the last time it loaded. And it loads the date/time on every line for convienance. It also helps when the alertlogs get rotated. You still keep the history within an Oracle table. Finally, it also strips out all the crap that is really not needed to see if you are looking for errors.
update_alert_log.sql

set serveroutput on

declare

isdate

number := 0;

start_updating number := 0; rows_inserted number := 0;

alert_date max_date

date; date;

alert_text

alert_log_disk.text%type;

begin

/* find a starting date */

select max(alert_date) into max_date from alert_log;

if (max_date is null) then max_date := to_date('01-jan-1980', 'dd-mon-yyyy'); end if;

for r in ( select substr(text,1,180) text from alert_log_disk where text not like '%offlining%' and text not like 'ARC_:%' and text not like '%LOG_ARCHIVE_DEST_1%' and text not like '%Thread 1 advanced to log sequence%' and text not like '%Current log#%seq#%mem#%' and text not like '%Undo Segment%lined%' and text not like '%alter tablespace%back%' and text not like '%Log actively being archived by another process%' and text not like '%alter database backup controlfile to trace%' and text not like '%Created Undo Segment%' and text not like '%started with pid%' and text not like '%ORA-12012%' and text not like '%ORA-06512%' and text not like '%ORA-000060:%' and text not like '%coalesce%' and text not like '%Beginning log switch checkpoint up to RBA%' and text not like '%Completed checkpoint up to RBA%' and text not like '%specifies an obsolete parameter%' and text not like '%BEGIN BACKUP%' and text not like '%END BACKUP%' ) loop

isdate

:= 0;

alert_text := null;

select count(*) into isdate from dual where substr(r.text, 21) in ('2003','2004','2005','2006','2007') and r.text not like '%cycle_run_year%';

if (isdate = 1) then

select to_date(substr(r.text, 5),'Mon dd hh24:mi:ss rrrr') into alert_date from dual;

if (alert_date > max_date) then start_updating := 1; end if;

else alert_text := r.text; end if;

if (alert_text is not null) and (start_updating = 1) then

insert into alert_log values (alert_date, substr(alert_text, 1, 180)); rows_inserted := rows_inserted + 1; commit;

end if;

end loop;

sys.dbms_output.put_line('Inserting after date '||to_char(max_date, 'MM/DD/RR HH24:MI:SS'));

sys.dbms_output.put_line('Rows Inserted: '||rows_inserted);

commit;

end; /
Let's execute the script:

SQL> @update_alert_log Inserting after date 01/01/80 00:00:00 Rows Inserted: 17361

PL/SQL procedure successfully completed.


The alert_log table now contains the errors as recorded in the alert.log file:

select alert_date, substr(alert_text,1, 69) from alert_log;

You might also like