Linux Oracle Database Connection Test Script

Database connection testing scripts are out there, but not all of them provide a one stop way to test more than 1 node of the RAC at the same time.  Sure you can do simple tests using “tnsping”, “nc -z” or even “telnet” to confirm the listener is up.  Actually testing a login is a far better way to know if your listener and database are up and functioning.

Below you’ll find samples of how to use the script and the output of said script.  The script can be downloaded HERE

Too few variables

-bash-4.1$ sh dbcontest.sh 5

!!!! Not enough variables.  Please review syntax and example below !!!!

Syntax: sh dbcontest.sh[timeout value] [dbips] [dbname] [dbport] [user]
Example: sh dbcontest.sh5 10.10.10.1,10.10.10.2 mwdbtest 1521 scott

Too many variables

-bash-4.1$ sh dbcontest.sh5 10.10.10.1,10.10.10.2 mwdbtest 1521 scott bob

!!!! Too many variables.  Please review syntax and example below !!!!

Syntax: sh dbcontest.sh[timeout value] [dbips] [dbname] [dbport] [user]
Example: sh dbcontest.sh5 10.10.10.1,10.10.10.2 mwdbtest 1521 scott

No /path/to/file for sqlplus binary
-bash-4.1$ sh dbcontest.sh 5 10.10.10.1,10.10.10.2 mwdbtest 1521 scott
!!!! SQLPLUS is not in path.  Please set appropriate variables to continue...see example below !!!!

export ORACLE_SID={DATABASE}
export ORACLE_HOME=your_install_location
export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/bin

Sample run

-bash-4.1$ sh dbcontest.sh 5 10.10.10.1,10.10.10.2 mwdbtest 1521 scott
######################################################################
Script: dbtestnew.sh
Date: Wed Dec  2 11:50:44 PST 2015
Database Name: mwdbtest
Database Port: 1521
Database IPs: 10.10.10.1,10.10.10.2
Username: scott
######################################################################

Enter your password:
Failed to connect --> using 10.10.10.1
Successfully connected --> using 10.10.10.2

Really easy to use.  Please note that the use of the script identified above and any script found in the DOWNLOADS page are for testing purposes only.  Use at your own risk!!!

Leave a Reply

Your email address will not be published.