实战:oracle巡检脚本v1(四)
s执行结果回显
set heading off;
set feedback off;
set termout off;
set pagesize 0;
set verify off;
set echo off;
spool 2.txt
select dbid,name,created,log_mode,open_mode,db_unique_name from v\$database;
spool off
exit;
!01
cechon "2.2 oracle database information is : " red
echo
cat 2.txt |xargs |awk '{print "dbid:"$1,"\nname:"$2, \
"\ncreated:"$3" "$4,"\nlog_mode:"$5,"\nopen_mode:"$6" "$7,"\ndb_unique_name:"$8}'
echo
rm -rf 2.txt
#2.3 oracle instance information
sqlplus -S "${ora_user}/${ora_pass} as sysdba" </dev/null #禁止sqlplus执行结果回显
set heading off;
set feedback off;
set termout off;
set pagesize 0;
set verify off;
set echo off;
spool 3.txt
select instance_name,host_name,version,startup_time,status,database_status,
instance_role from v\$instance;
spool off
exit;
!01
cechon "2.3 oracle instance information is : " red
echo
cat 3.txt |xargs |awk '{print "instance_name:"$1,"\nhostname:"$2, \
"\nversion:"$3,"\nstartup_time:"$4" "$5,"\nstatus:"$6,"\ndatabase_status:"$7,"\ninstance_role:"$8}'
echo
rm -rf 3.txt
#2.4 数据库非缺省初始化参数
sqlplus -S "${ora_user}/${ora_pass} as sysdba" </dev/null #禁止sqlplus执行结果回显
set heading off;
set feedback off;
set termout off;
set pagesize 0;
set verify off;
set echo off;
spool 4.txt
SELECT name ,value FROM V\$PARAMETER where ISDEFAULT='FALSE' order by name;
spool off
exit;
!01
cechon "2.4 Database non-default initialization parameters is : " red
echo
cat 4.txt
echo
rm -rf 4.txt
#2.5 database default temp tempspace
sqlplus -S "${ora_user}/${ora_pass} as sysdba" <
/dev/null #禁止sqlplus执行结果回显
set heading off;
set feedback off;
set termout off;
set pagesize 0;
set verify off;
set echo off;
spool 25.txt
select property_value from database_properties
where property_name='DEFAULT_TEMP_TABLESPACE';
spool off
exit;
!01
cechon "2.5 database default temp tempspace is : " red
echo
cat 25.txt
echo
rm -rf 25.txt
#2.6 database trace position
sqlplus -S "${ora_user}/${ora_pass} as sysdba" </dev/null #禁止sqlplus执行结果回显
set heading off;
set feedback off;
set termout off;
set pagesize 0;
set verify off;
set echo off;
spool 26.txt
SELECT P1.VALUE||''||P2.VALUE||'_ORA_'||P.SPID FILENAME
FROM
V\$PROCESS P,
V\$SESSION S,
V\$PARAMETER P1,
V\$PARAMETER P2
WHERE P1.NAME = 'user_dump_dest'
AND P2.NAME = 'db_name'
AND P.ADDR = S.PADDR
AND S.AUDSID = USERENV ('SESSIONID');
spool off
exit;
!01
cechon "2.6 database trace position is : " red
echo
cat 26.txt
echo
rm -rf 26.txt
cechon "***********************************************************************" yellow
echo
cechon "3.Check the database object stauts:" green
echo
cechon "***********************************************************************" yellow
echo
#3.1 control file
sqlplus -S "${ora_user}/${ora_pass} as sysdba" </dev/null #禁止sqlplus执行结果回显
set heading off;
set feedback off;
set termout off;
set pagesize 0;
set verify off;
set echo off;
spool 31.txt
select name from v\$controlfile;
spool off
exit;
!01
cechon "3.1 Database control file is : " red
echo
cat 31.txt
echo
rm -rf 31.txt
#3.2 Online Redo Logfiles Status
sqlplus -S "${ora_user}/${ora_pass} as sysdba" </dev/null #禁止sqlplus执行结果回显
set heading off;
set feed