How check that the Oracle Database is up?
For our application we have a configuration file for connecting to the Oracle database (URL, username, password).
The application takes 2-5 minutes to start. If there is something wrong with database I see this in logs, but I have to wait 2-5 minutes. This is a lot of time.
So I want to find out quickly and simply a way to determine that the database is all OK and online.
Do you have any idea how I might do it ?
First thing first: you need to know the username and password to connect to database for step 2
Check the oracle process runs:
ps -ef|grep pmon
tasklist|findstr /i oracle
if the command in any case returns output i.e. if the pmon/oracle process is running in your environment the database is running.
If after login you get errors, then the database does not run:
SQL*Plus: Release 184.108.40.206.0 Production on Sat Feb 31 21:61:61 2014 Copyright (c) 1982, 2014, Oracle. All rights reserved. Enter user-name: oracle Enter password: ERROR: ORA-01034: ORACLE not available ORA-27101: shared memory realm does not exist Linux-x86_64 Error: 2: No such file or directory Process ID: 0 Session ID: 0 Serial number: 0
You should use/write a script that will connect to the server and see if your database is online. Here the Oracle guys will help. Just execute it from a batch/shell script (see Running Scripts From SQL Command Line) and see it's output. If everything is alright than you have your answer.
Or just try with SQL*Plus client.
To check general database status, I recommend:
Check if database processes are running. For example, from a Unix shell, running:
$ ps -ef | grep pmon
will show the running databases, startup times, and which Oracle users started each one.
Check if listeners are running using
$ ps -ef | grep tnsand
$ lsnrctl status LISTENER
gv$resource_limitwill show if database reached some configured limit.
To check if there were any database errors, you should check
For more details see my blog post.