Tuesday, August 13, 2013

Oracle RAC connectivity test with shell script and sql script.

If you need to make connectivity check for Oracle RAC cluster database here is sample scripts for that.
With this you can check connections for all cluster database instances. 

First create sql script connectivity_test_shell.sql (text file with .sql extension.) and add following into it:
----

select instance_name from v$instance;

----




Here is example shell script that makes connectivity checks for selected Oracle database.
Add following text in text file with .sh extension ( connectivity_test_shell.sh ). And change username , password and database name. You can also change numbers in loop (how many connection tests you want to run). Database user you are using should have select permission for v$instance view used in connectivity_test_shell.sql script.

Script creates conn_test_testdb.txt file where connection information is printed (so user must have write permissions in the directory where this script is.). In this log you find also information of instance which you are connected. This way you can check that you can connect all instances of cluster database.

----

#!/bin/bash

for x in {0..100};
  do
    echo quit | sqlplus testuser/<testuser_password>@<cluster_database_name> @connectivity_test_shell.sql >> conn_test_testdb.txt;
  done

----

Give permissions to scripts:
chmod 755 connectivity_test_shell*

Run script:
./connectivity_test_shell.sh

No comments:

Post a Comment