提取DB2多分割槽環境當前的狀態

myamor發表於2013-06-03
##最近整理了一下先前主機的內容,竟然發現好多的內容都沒有備份,失誤呀
########################################################################
##echo "本指令碼是提取DB2多分割槽環境當前的狀態"
##echo "主要是每個分割槽中對應的表空間和容器的資訊"
##echo "使用方法:db2_check_dpf_status.sh dbname"
##echo "CopyRight  "
########################################################################
#!/bin/sh
check_time=`date '+%Y%m%d'`
FILEPATH=$0
FILENAME=${FILEPATH##*/}
echo
    usage()
    {
        echo "Invalid parameter,you must use it like this:${FILENAME} dbname !"
        exit 3
    }
if [ $# -ne 1 ]
then
  usage
fi
dbname=$1
db2level >> db2status.${dbname}.log.$check_time
db2 list db directory >> db2status.${dbname}.log.$check_time
db2 get dbm cfg show detail>> db2status.${dbname}.log.$check_time
db2 connect to $dbname >> db2status.${dbname}.log.$check_time
db2 list database partition groups >> db2status.${dbname}.log.$check_time
db2 "select * from syscat.bufferpools" >> db2status.${dbname}.log.$check_time
db2 list DBPARTITIONNUMS | grep "      " >> /tmp/DBPARTITIONNUMS.$dbname.log
cat /tmp/DBPARTITIONNUMS.$dbname.log | while read line
do
   db_partnum=`echo $line | awk '{print $1}'`
   if [ "$db_partnum" = "" ]
   then
       break
   fi
   echo "Begin to get Information of partition Node $db_partnum " >> db2status.${dbname}.log.$check_time
   export DB2NODE=$db_partnum >> db2status.${dbname}.log.$check_time
   db2 terminate >> db2status.${dbname}.log.$check_time
   db2 connect to $dbname >> db2status.${dbname}.log.$check_time
   db2 "values (current dbpartitionnum)" >> db2status.${dbname}.log.$check_time
   db2 get db cfg for $dbname show detail >> db2status.${dbname}.log.$check_time
   db2 list tablespaces show detail >> db2status.${dbname}.log.$check_time
   db2 list tablespaces | grep "Tablespace ID" | while read line2
   do
      tbsp_id=`echo $line2 | awk '{print $4}'`
      if [ "$tbsp_id" = "" ]
      then
         break
      fi
      db2 list tablespace containers for $tbsp_id show detail  >> db2status.${dbname}.log.$check_time    
   done
   sleep 2
done
rm -rf /tmp/DBPARTITIONNUMS.$dbname.log
echo "Get Information successful!"
exit 0

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/177006/viewspace-762832/,如需轉載,請註明出處,否則將追究法律責任。

相關文章