Showing posts with label alert log. Show all posts
Showing posts with label alert log. Show all posts

Monday, December 11, 2023

How to write custom messages to the alert log file

exec sys.dbms_system.ksdwrt(2,'Your message here')
The first argument can be either

  • 1 -> Write to the trace file
  • 2 -> Write to the database alert log file
  • 3 -> Write to both of the above files
  • Friday, March 11, 2022

    How to use adrci to show all messages related to shutdown and startup of a database

    These commands will give you all messages related to a shutdown and a startup of an oracle database, respectively:
    adrci> show alert -p "MESSAGE_GROUP LIKE 'shutdown'"
    adrci> show alert -p "MESSAGE_GROUP LIKE 'startup'"
    
    Example output for a shutdown:
    Instance shutdown complete (OS id: 4058731)
    2022-03-10 18:00:18.042000 +01:00
    License high water mark = 863
    2022-03-10 18:00:19.115000 +01:00
    Instance shutdown complete (OS id: 3611031)
    2022-03-10 18:00:33.286000 +01:00
    Shutting down instance: further logons disabled
    2022-03-10 18:00:36.357000 +01:00
    License high water mark = 1
    Shutting down archive processes
    Archiving is disabled
    2022-03-10 18:00:37.519000 +01:00
    Shutting down archive processes
    Archiving is disabled
    2022-03-10 18:00:43.753000 +01:00
    Instance shutdown complete (OS id: 3611306)
    
    For the startup sequence, adrci will show you all the details of the startup, in other words what you normally see if you put a tail on the alert log. This is a rather lengthy output, so I am shorting it down. It should be familiar to most DBAs:
    2022-03-10 18:00:22.413000 +01:00
    Oracle instance running with ODM in PGA: Oracle Direct NFS ODM Library Version 6.0
    2022-03-10 18:00:25.600000 +01:00
    LICENSE_MAX_SESSION = 0
    LICENSE_SESSIONS_WARNING = 0
    Using LOG_ARCHIVE_DEST_1 parameter default value as USE_DB_RECOVERY_FILE_DEST
    Autotune of undo retention is turned on.
    IMODE=BR
    ILAT =249
    LICENSE_MAX_USERS = 0
    SYS auditing is enabled
    Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
    Version 19.14.0.0.0.
    ORACLE_HOME:    /sw/oracle/product/19c
    System name:    Linux
    Node name:      myserver.mydomain.com
    Release:        4.18.0-348.12.2.el8_5.x86_64
    Version:        #1 SMP Mon Jan 17 07:06:06 EST 2022
    Machine:        x86_64
    Using parameter settings in server-side spfile /sw/oracle/product/19c/dbs/spfiletestdb01.ora
    System parameters with non-default values:
    etc etc
    
    Since the output is very long, if you simply want to check for an indication of a database startup you could use this command instead:
    adrci> show alert -p "message_text like '%Starting ORACLE instance%'"
    
    which will give you a shorter list to examine, and in my case showing that the database was restarted Jan 28th and March 10th:
    2022-02-28 07:46:54.505000 +01:00
    Starting ORACLE instance (restrict) (OS id: 4058595)
    2022-02-28 07:47:39.567000 +01:00
    Starting ORACLE instance (normal) (OS id: 3300)
    2022-03-10 18:00:22.421000 +01:00
    Starting ORACLE instance (restrict) (OS id: 3611160)
    2022-03-10 18:02:06.831000 +01:00
    Starting ORACLE instance (normal) (OS id: 3429)