oracle、filesystem、backup日常巡檢指令碼
今天整理了一下自己總結的日常巡檢指令碼,和大家分享下,禁止商業用途:
1.總指令碼xunjian.code
export PS1="`hostname`$"'[$PWD] '
umask 022
cd /u02/xunjian
#######################xunjian check#################################################
#----1. filesystem check 檔案系統檢查
rm -f /u02/xunjian/devdb2_xunjian.txt
echo "
1.filesystem check" >> /u02/xunjian/devdb2_xunjian.txt
head -11 /u02/xunjian/devdb1_xunjian.txt >> /u02/xunjian/devdb2_xunjian.txt
echo "###############182.22.3.111######################" >> /u02/xunjian/devdb2_xunjian.txt
echo "
182.22.3.111 filesystem check" >> /u02/xunjian/devdb2_xunjian.txt
filesystem='/usr /var /tmp /home /opt /u01 /u02'
for fs in $filesystem
do
size=`df -k $fs|grep $fs|awk '{ print $4 }'`
lowlimit=`more fslimite.txt|grep $fs|awk '{ print $2 }'`
s=`echo $size|tr -d "%"`
l=`echo $lowlimit|tr -d "%"`
# if [ $s -lt $l ]
# then
echo $fs "now:" $size "normal:"$lowlimit >> /u02/xunjian/devdb2_xunjian.txt
# fi
done
# ssh devdb1
#----2. database status check 資料庫狀態檢查
echo "
2.database status check" >> /u02/xunjian/devdb2_xunjian.txt
sqlplus -s system/devdb1234@devdb1 @/u02/xunjian/database_check.code >> /u02/xunjian/devdb2_xunjian.txt
sqlplus -s system/devdb1234@devdb2 @/u02/xunjian/database_check.code >> /u02/xunjian/devdb2_xunjian.txt
#----3. database tablespace check 資料庫空間大小檢查
echo "
3.database tablespace check " >> /u02/xunjian/devdb2_xunjian.txt
sqlplus -s system/devdb1234@devdb1 @/u02/xunjian/tablespace_check.code >> /u02/xunjian/devdb2_xunjian.txt
#----4. TSM check 磁帶庫日誌檢查
echo "
4.TSM status check" >> /u02/xunjian/devdb2_xunjian.txt
cd /u02/expdata
backdate=`date +%Y%m%d`
more /u02/expdata/dsmc.log | grep dmp |grep $backdate|awk '$2 == "B" {print $3 "\t" $4 "\t" $7 }' >> /u02/xunjian/devdb2_xunjian.txt
#----5. delete dmp file check 只保留最近2天的dmp檔案
echo "
5. delete already archivelog dmp file check" >> /u02/xunjian/devdb2_xunjian.txt
cd /u02/expdata/backup
find /u02/expdata/backup -mtime +2 \( -name 'sg*' -o -name 'nj*' \) -exec rm -f {} \;--保留最近2天的檔案,檔名還有sg或者nj的
ls -l -t |grep dmp|awk '{print $6$7 "\t" $8 "\t" $9 "\t" $5"k" }'>> /u02/xunjian/devdb2_xunjian.txt
#----6. rman full backup check rman日誌的檢查
tail -9 /u02/xunjian/devdb1_xunjian.txt >> /u02/xunjian/devdb2_xunjian.txt
echo "
182.22.3.110 check finished
182.22.3.111 check finished" >> /u02/xunjian/devdb2_xunjian.txt
2.資料庫狀態檢查database_check.code
-- +----------------------------------------------------------------------------+
-- | - INSTANCE OVERVIEW - |
-- +----------------------------------------------------------------------------+
prompt Instance Overview
COLUMN host_name format a20
set linesize 300
SELECT host_name ,
instance_name ,
instance_number ,
version ,
TO_CHAR(startup_time,'mm/dd/yyyy HH24:MI:SS') start_time,
status ,
DECODE(archiver, 'FAILED', archiver,archiver) archiver,
DATABASE_STATUS
FROM v$instance
ORDER BY instance_number;
exit
3.資料庫空間大小檢查tablespace_check.code
-- +----------------------------------------------------------------------------+
-- | - TABLESPACE OVERVIEW - |
-- +----------------------------------------------------------------------------+
prompt TABLESPACE OVERVIEW
COLUMN tablespace_name format a20
COLUMN autoextensible format a15
COLUMN total format a15
COLUMN used format a15
COLUMN free format a15
COLUMN used_percent format a25
set linesize 300
set pagesize 200
select a.tablespace_name, a.autoextensible,
total_m||'M' total,
(case when total_m-free_m < 1 then '0' else null end)||to_char(round(total_m-free_m,2))||'M' used ,
round(free_m,2)||'M' free,
100*round((total_m-free_m)/total_m,4)||'%' used_percent
from
(
select a.tablespace_name, a.autoextensible,sum(a.bytes)/1024/1024 total_m
from dba_data_files a
group by a.tablespace_name, a.autoextensible
)a,
(select b.tablespace_name, sum(b.bytes)/1024/1024 free_m
from dba_free_space b
group by b.tablespace_name
) b
where a.tablespace_name = b.tablespace_name
order by autoextensible asc;
exit
4. 邏輯備份exp指令碼
export ORACLE_SID=devdb2
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$ORA_CRS_HOME/bin:$PATH
export NLS_LANG=american_america.ZHS16GBK
export PS1="`hostname`$"'[$PWD] '
umask 022
#######################exp devdb data#######################################################
backdate=`date +%Y%m%d%H%M`
begintime=`date +%Y-%m-%d:%H-%M`
cd /u02/expdata/backup
exp leiz/leiz@devdb2 file=/u02/expdata/backup/leiz_$backdate.dmp log=/u02/expdata/backup/leiz_$backdate.log wner=leiz
5. tsm磁帶庫備份
cd /usr/tivoli/tsm/client/ba/bin/
dsmc incremental -subdir=yes "/u02/expdata/backup/*" >> /u02/expdata/dsmc.log
echo "######################`date`##############################################" >> /u02/expdata/dsmc.log
dsmc q backup -inactive -subdir=yes "/u02/expdata/backup/*" >> /u02/expdata/dsmc.log
6.傳送郵件
VA_HOME=/usr/java14/bin
MAILTO_HOME=/usr/local/mailto
MAILFROM_PASS=12345
MAILSERVERIP=172.22.3.113
PATH=$JAVA_HOME:$PATH
cd $MAILTO_HOME
java -cp ./activation.jar:./dsn.jar:./imap.jar:./mail.jar:./mailapi.jar:./pop3.jar:./s
mtp.jar:./mailto.jar mail.Mailto $MAILFROM_USER $MAILFROM_PASS $MAILSERVERIP $MAILTO_U
SER "$1" $2 $3
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9252210/viewspace-594562/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- (轉):oracle、filesystem、backup日常巡檢指令碼Oracle指令碼
- 【SCRIPT】Oracle日常巡檢指令碼通用版Oracle指令碼
- 【SCRIPT】Oracle12C日常巡檢指令碼通用版Oracle指令碼
- (轉)ORACLE 巡檢指令碼Oracle指令碼
- 巡檢指令碼OS+Oracle指令碼Oracle
- oracle 巡檢指令碼(自動化)Oracle指令碼
- mysql巡檢指令碼MySql指令碼
- dba巡檢指令碼指令碼
- sqlserver 巡檢指令碼SQLServer指令碼
- SQLServer巡檢指令碼SQLServer指令碼
- Oracle運維指令碼-巡檢(RAC版)Oracle運維指令碼
- Oracle 10G RAC巡檢指令碼Oracle 10g指令碼
- Oracle運維指令碼-巡檢(單機版)Oracle運維指令碼
- AIX巡檢指令碼(轉)AI指令碼
- 系統巡檢指令碼指令碼
- SQL SERVER巡檢指令碼SQLServer指令碼
- shell指令碼企業巡檢指令碼
- Oracle運維指令碼-巡檢(RAC版本)-V1.1Oracle運維指令碼
- Oracle ERP系統日常維護和巡檢Oracle
- mysql 伺服器巡檢指令碼MySql伺服器指令碼
- db2巡檢小指令碼DB2指令碼
- Linux 系統健康巡檢指令碼Linux指令碼
- ORACLE日常備份指令碼Oracle指令碼
- 【Oracle】11g RAC R2 日常巡檢--GridOracle
- oracle巡檢(轉)Oracle
- oracle的巡檢Oracle
- Linux基礎服務巡檢指令碼模板Linux指令碼
- SCRIPT】Oracle巡檢報告html格式樣例指令碼,帶趨勢圖OracleHTML指令碼
- Oracle 資料庫巡檢指令碼 單例項 RAC 輸出HTML格式Oracle資料庫指令碼單例HTML
- Oracle 巡檢手冊Oracle
- Oracle巡檢內容Oracle
- oracle巡檢工具-RDAOracle
- 透過 Prometheus 編寫 TiDB 巡檢指令碼(指令碼已開源,內附連結)PrometheusTiDB指令碼
- python編寫的簡單的mysql巡檢指令碼PythonMySql指令碼
- oracle DBA 巡檢專案Oracle
- Oracle資料庫巡檢Oracle資料庫
- oracle健康巡檢筆記Oracle筆記
- 檢視ORACLE AS 埠指令碼Oracle指令碼