Oracle Database Connection detection (Shell)

Source: Internet
Author: User
Tags sqlplus

1 Version Information

Oracle Database version: Oracle release 10.2.0.1.0

System version: Red Hat enterpriselinux 5.4

2 Detection Step 2.1 writing a shell script

Under users who have Sqlplus Execute permissions, edit the check_oracle_connection.sh script.

VI check_oracle_connection.sh
Edit the contents as follows:
#!/bin/bash#functions:connect Oracle Server Test#author:areskris john#modify_date:2014-11-18.mkdir-p/home/gapsv4/ Log/oracle  #创建日志存放路径LOG_DIR =/home/gapsv4/log/oracle  #日志存放路径rm-rf $LOG _dir/*  #删除旧日志USERNAME =bodcmp  #数据库用户名PASSWORD =bodcmp  #数据库密码SIDNAME =ora10g  #数据库实例名icount =0while ["$icount"-lt]do  {  count=0 while  ["$count"-lt] do    log_file= $LOG _dir/check_oracle_$icount. $count. LOG    Echo ' Sqlplus $USERNAME/[email protected] $SIDNAME << EOF      set echo off      set feedback off      spool $LOG _file< C15/>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 +1done

2.2 Executing shell scripts

Call bash directly to execute the check_oracle_connection.sh script.

Bash check_oracle_connection.sh

2.3 Script Execution Results analysis

After the script is executed, the Oracle database connection is analyzed based on the results of the script execution. The situation is as follows:

1, if there are individual log reports during the execution of the connection or failure of the query, then prove that the Oracle database connection is not stable, there is a problem.

2, if in the execution process all log the connection or the query failure error, then proves that the Oracle instance or the listener process did not start.

3, if there is no log error during the execution, then it proves that the Oracle database connection is normal and the instance is running correctly.

Oracle Database Connection detection (Shell)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.