Oracle Database Connection detection (Shell), oracle Database Connection
Version 1
Oracle Database Version: Oracle Release 10.2.0.1.0
System Version: Red Hat guest iselinux 5.4
2 Check Step 2.1 write Shell scripts
Edit the check_oracle_connection.sh script for a user with SQLPLUS execution permission.
vi check_oracle_connection.sh
The Edit content is as follows:
#! /Bin/bash # functions: connect oracle server test # author: AresKris John # modify_date: 2014-11-18.mkdir-p/home/gapsv4/log/oracle # create a log storage path LOG_DIR =/home/gapsv4/log/oracle # log storage path rm-rf $ LOG_DIR/* # Delete the old one log USERNAME = bodcmp # Database username password = bodcmp # Database password sidname = ora10g # database instance name icount = 0 while ["$ icount"-lt 100] do {count = 0 while ["$ count"-lt 100] do LOG_FILE = $ LOG_DIR/check_oracle _ $ icount. $ count. log echo 'sqlplus $ USERNAME/$ PASSWORD @ $ SIDNAME <EOF set echo off set feedback off spool $ LOG_FILE alter session set nls_date_format = 'yyyy-MM-DD: HH24: MI: ss'; select sysdate from dual; spool off set echo on set feedback on exit EOF '> $ LOG_FILE let count = $ count + 1 done} & let icount = $ icount + 1 done
2.2 execute Shell scripts
Directly call bash to execute the check_oracle_connection.sh script.
bash check_oracle_connection.sh
2.3 script execution Result Analysis
After the script is executed, the Oracle database connection is analyzed based on the script execution results. The situation is as follows:
1. If some logs report connection or query failure errors during execution, the Oracle database connection is unstable and there is a problem.
2. If all logs report connection or query failure errors during execution, it indicates that the Oracle instance or listener process is not started.
3. If no log error is reported during execution, the Oracle database connection is normal and the instance runs normally.