DB2 Snapshop 指令可以用來取得DB2 在某一個時間點的狀態

■ Get monitor switches

GET MONITOR SWITCHES < AT DBPARTITIONNUM [PartitionNum] > 

C:\> db2 get monitor  switches

            Monitor Recording Switches

Switch list for db partition number 0
Buffer Pool Activity Information  (BUFFERPOOL) = ON  10/01/2009 11:19:08.902660
Lock Information                        (LOCK) = ON  10/01/2009 11:19:08.902660
Sorting Information                     (SORT) = ON  10/01/2009 11:19:08.902660
SQL Statement Information          (STATEMENT) = ON  10/01/2009 11:19:08.902660
Table Activity Information             (TABLE) = ON  10/01/2009 11:19:08.902660
Take Timestamp Information         (TIMESTAMP) = ON  10/01/2009 11:19:08.902660
Unit of Work Information                 (UOW) = ON  10/01/2009 11:19:08.902660

■ Open/Close Monitor switches

UPDATE MONITOR SWITCHES USING [[SwitchID] ON | OFF ,...]

C:\> db2 update monitor switches using bufferpool on lock on sort on statement on table on uow on
C:\> db2 update monitor switches using bufferpool off lock off sort off statement off table off uow off

■ Reset Monitor

   RESET MONITOR ALL 
   RESET MONITOR FOR [DATABASE | DB] [DatabaseAlias]  [DatabaseAlias]
   
   RESET MONITOR FOR DATABASE SAMPLE

■ Get Snapshop

C:\> db2 get snapshot for all on sample

■ Snapshop Sample script

#!/usr/bin/ksh  
#  take a snapshot after specified sleep   
#  period for a number of iterations  
#  parameters:   
#     (1) database name  
#     (2) directory for output  
#     (3) interval between iterations (seconds)  
#     (4) maximum number of iterations  
#            
#  Note: You may receive an error about the   
#        monitor heap being too small. You may
#        want to set mon_heap_sz to 2048 while monitoring.  
   

if [ $# -ne 4 ]  
  then echo "4 parameters required: dbname output_dir sleep_interval iterations"; exit 
fi 
dbname=$1
runDir=$2
sleep_interval=$3
iterations=$4
stat_interval=3 
stat_iterations=$(($sleep_interval/$stat_interval))
if [[ -d $runDir ]]; then 
   echo "dir: $runDir already exists, either remove it or use another directory name" 
   exit 
fi 
mkdir  $runDir  
cd     $runDir  
db2 update monitor switches using bufferpool on lock on sort on statement on table on uow on  

# repeat the snapshot loop for the specified iterations  
let i=1  
while [ i -le $iterations ]   
  do 
    if [ $i -le 9 ]  
    then  
      i2="0$i" 
    else 
      i2="$i" 
    fi  
    echo "Iteration $i2 (of $iterations) starting at `date`" 
    vmstat $stat_interval $stat_iterations > vmstat_$i2  
    iostat $stat_interval $stat_iterations > iostat_$i2  
    db2 -v reset monitor all  
    sleep $sleep_interval  
    db2 -v get snapshot for dbm > snap_$i2  
    db2 -v get snapshot for all on $dbname >> snap_$i2  
    echo "Iteration $i2 (of $iterations) complete at `date`" 
    let i=$i+1  
  done 
  
db2 update monitor switches using bufferpool off lock off sort off statement off table off uow off   
db2 terminate 
arrow
arrow
    文章標籤
    [學習筆記]DB2
    全站熱搜

    rickyju 發表在 痞客邦 留言(0) 人氣()