脚本:检查数据库的连通性
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
[oracle@ora12c - allah:~]$ cat check_db_connectivity.sh #!/bin/bash if [ $# -ne 1 ] then echo "Usage: $0 SID" exit 1 fi echo "select 'successful' from dual;" | sqlplus -s system/oracle@$1 | grep successful if [[ $? -ne 0 ]] then echo "Problem with $1" else echo "Database: $1 is ok" fi exit 0 [oracle@ora12c - allah:~]$ [oracle@ora12c - allah:~]$ sh check_db_connectivity.sh Usage: check_db_connectivity.sh SID [oracle@ora12c - allah:~]$ [oracle@ora12c - allah:~]$ sh check_db_connectivity.sh allah successful Database: allah is ok [oracle@ora12c - allah:~]$ [oracle@ora12c - allah:~]$ sqlplus / as sysdba SQL*Plus: Release 12.1.0.2.0 Production on Tue Nov 18 18:09:33 2014 Copyright (c) 1982, 2014, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> exit Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options [oracle@ora12c - allah:~]$ [oracle@ora12c - allah:~]$ sh check_db_connectivity.sh allah Problem with allah [oracle@ora12c - allah:~]$ |
——————————————————————
Ending。