Home > Oracle Tips > Oracle Database Administrator > Run multiple sessions of DBV
Oracle Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ORACLE DATABASE ADMINISTRATOR

Run multiple sessions of DBV


Michael Vergara
10.19.2003
Rating: -4.50- (out of 5) Hall of fame tip of the month winner


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


Ever had to do a lot of DBVERIFY commands? You build a script, or multiple scripts, and when they start running you wish you had more or less of them? Here's a UNIX script that will run a dynamically variable number of concurrent dbv commands.

#!/usr/bin/ksh
#
# *************************************************************************
# *                                                                       *
# * Name    : run_dbv.sh                                                  *
# * Author  : M. Vergara                                                  *
# * Date    : 29-Sep-2003                                                 *
# * Purpose : This script is designed to perform Oracle 'dbv' (dbverify)  *
# *           commands against a list of files from a database.           *
# *                                                                       *
# * Change Log:                                                           *
# * Chg#   Date          Description                                      *
# * ----   -----------   ---------------------------------                *
# *   1    20-Sep-2003   Created                                          *
# *                                                                       *
# *************************************************************************
# * Instructions:                                                         *
# * 1) Copy this file from /usr/local/bin to a temporary working          *
# *    directory.  NEVER RUN THIS FILE FROM /usr/local/bin!               *
# * 2) Create your list of database files to be verified using whatever   *
# *    tool you are comfortable with.  'grep', 'find', 'ls' are all valid *
# *    commands to use.  Name the file "files_to_check.txt".              *
# * 3) (Optional)  Create a file called "dbvcnt.max", containing one line *
# *    with the number of concurrent dbv processes that you wish to run.  *
# *    The script builds a default file containing '4'.                   *
# * 4) (Optional)  Create a file called "dbvsleep.time", containing one   *
# *    line with the number of seconds to sleep before checking the status*
# *    of the running processes.  The script builds a default file with   *
# *    a wait time of '21'.                                               *
# * 5) Set the Oracle environment variables for the instance you are      *
# *    checking against.  This script needs to know where $ORACLE_HOME is.*
# * 6) Execute the script with ./run_dbv.sh.  The script will start with  *
# *    four concurrent sessions of dbv.  If you decide that your system   *
# *    is capable of running more than four, merely update the            *
# *    "dbvcnt.max" file with the number of processes.  It won't change   *
# *    immediately, only when it reads the next line from the list of     *
# *    database files.  You can change this number up or down.            *
# * 7) The output log files from the 'dbv' commands are kept in the local *
# *    directory.  You can look for files that fail with commands like:   *
# *        grep -i fail *.log | grep -v ': 0'                             *
# * 8) Modify as you see fit to make it work better for you.
# *    there
# *************************************************************************
# *                                                                       *
# * (c) Copyright 2003 Guidant Corporation                                *
# * No Warranty is expressed or implied.  Use at your own risk.  Works    *
# * best on HP-UX;  your mileage may vary.  Tastes great.  Less Filling.  *
# *                                                                       *
# * M. Vergara  29-Sep-2003                                               *
# *************************************************************************
#

#
# Existence Checks
if ! [ -f files_to_check.txt ] ; then
   echo 007
   echo Error!
   echo File "files_to_check.txt" is missing.  Cannot continue.
   echo 007
   exit 1
fi
#
if ! [ -f dbvcnt.max ] ; then
   echo 4 > dbvcnt.max
fi
#
if ! [ -f dbvsleep.time ] ; then
   echo 21 > dbvsleep.time
fi
#

#
# Main
typeset -i BaseProcs=`ps | wc -l`

cat files_to_check.txt |
while read line
do
  echo "-----"
  date
  FileName=`echo ${line} | awk -F/ ' { print $NF } '`
  LogFileName=${FileName}.log
  typeset -i NumProcs=`ps | wc -l`-${BaseProcs}
  typeset -i MaxProcs=`cat dbvcnt.max`
  typeset -i SleepTime=`cat dbvsleep.time`
#
  echo ${NumProcs}
  if [ ${NumProcs} -lt ${MaxProcs} ] ; then
    echo Verifying file ${FileName}
    ${ORACLE_HOME}/bin/dbv file=${line} blocksize=8192 logfile=${LogFileName} & > /dev/null
    sleep 1
  else
    until [ ${NumProcs} -lt ${MaxProcs} ]
    do
      typeset -i SleepCtr=0
      echo "Max processes at `date`"
      echo Sleeping c
      while [ ${SleepCtr} -lt ${SleepTime} ]
      do
        sleep 1
        typeset -i SleepCtr=${SleepCtr}+1
        echo "."c
      done
      echo " "
      typeset -i NumProcs=`ps | wc -l`-${BaseProcs}
    done
    echo Verifying file ${FileName}
    /oracle/CTV/920_64/bin/dbv file=${line} blocksize=8192 logfile=${LogFileName} & > /dev/null
    sleep 1
  fi
done
#
#       ###EOF###

For More Information

  • Feedback: E-mail the editor with your thoughts about this tip.
  • More tips: Hundreds of free Oracle tips and scripts.
  • Tip contest: Have an Oracle tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize -- submit your tip today!
  • Ask the Experts: Our applications, SQL, database administration, and data warehousing gurus are waiting to answer your toughest questions.
  • Forums: Ask your technical Oracle questions--or help out your peers by answering them--in our active forums.
  • Best Web Links: Oracle tips, tutorials, and scripts from around the Web.

Rate this Tip
To rate tips, you must be a member of SearchOracle.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Oracle Database Administrator
What is the difference between a database engineer, architect and administrator?
Import on one table from dump file
Error during RMAN backup
Can I drop a column in SYS schema?
STATSPACK tool: transaction vs. execution measurement
Should I port from Microsoft Access?
Installing multiple Oracle homes
How can I find statistics on total memory usage and database connections?
Modifying SYS password in a RAC environment
How to create Datafiles in a Data Guard (10g) environment

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts