Samstag, 18 of Mai of 2013

Category » code for Linux/Unix/Windows

Shell script xmpDB2All.sh to execute commands at all DB2 instances

Do you need to execute one ore more commands at all of your DB2 instances? Then you should deploy xmpDB2all.sh!

This script …

  • locates all DB2 instances using profiles.reg (DB2 9.1) or global.reg (9.7 or later)
  • executes commands passed as arguments

(Some comments are in german language. If you need assistence, please contact!)

This script may helps administrators to …

  • first stop all application services
  • then stop all DB2 instances
  • to do their maintenance, e.g. full system backups, hardware or software maintenance
  • use it in rc2.d to start/stop DB2, so help starting/stopping a server

Starting and stopping an CLI and JDBC trace in a shell environment

 

 

 


Perl Script xmpTBSCStmt.pl to generate useful tablespace statements

xmpTBSCStmt.pl provides following functions:

  • creates CREATE TABLESPACE statements for existing database
  • creates REDIRECTED RESTORE statements for a database you possibly want to or need to recover at a remote site
  • creates ALTER TABLESPACE statements to reduce tablespace size and/or to lower the high water mark. Action depends on type of tablespace: Automatic storage, SMS and DMS tablespaces are supported.

Options supported: (Invoke script w/o parms will show all possible parameters)

[perl] xmpTBSCStmt.pl -d db [-u parm -p parm] -f file [-t {RESTORE|CREATE|AUTOSIZE} -o {CURRENT|HWM}] [-g nn] [-s pattern] [-ns pattern]

  • -d database
  • -u User (opt. if exists in environment 1)
  • -p Password (opt. if exists in environment 1)
  • -f output file receiving all the generated statements
  • -t type of statement to generate (opt)
  • -o current allocation or HWM (High Water Mark) (opt.)
  • -g fill-meter (AUTOSIZE target usage %) or growth (additional uplift % on HWM) (opt.)
  • -s tablespace name pattern (opt.)
  • -ns single tablespace name exclude pattern (opt.),

Using patterns, examples and usage comments:

  • -ns patt Do not use replace chars like ‘*’ or ‘%’\n”.
  • -s ‘patt1|patt2′ Imbed multiple patterns in (double) quotes
  • -ns patt1 -s patt2 Paired patterns work like OR condition

1 See xmpPerl.pm library for details on how to optionally deposit user and password, used in perl scripts, in user’s profile.

 


Perl Script xmpTerm.pl to list or terminate DB2 connections

xmpTerm.pl provides following functions …

  • lists all databases (local and remote) at current DB2 instance
  • lists all connections at the DB2 instance, or only those connected to a specified database
  • terminates all connections, or only those connected to a specified database, or a specific thread id

Options supported:

  • -l: (deflt. option) display all threads
  • -d {dbname|*}: display threads on distinct or all databases
  • -t {id|*}: terminate distinct thread id or all threads (on database or instance)
  • -a LOCKS: display locks

 Any suggestions – don’t hesitate to contact me!


How to retrieve JCC version

You need to check the version of your Java Combined Client (JCC) installed? Try this way:

All DB2 JDBC Driver versions, see here!

More information on DB2, Java, JDBC and JCC.


Perl Script xmpPerlDB2Test.pl to verify DBI and DBD::DB2 installation

This Perl script verifies the interface to DB2 whicht consists of the general database interface, called DBI, and the DB2-specific supplement, called DBD::DB2.

This script uses the xmpPerl.pm library, which is also available at this site.


Perl statements to generate (DB2) timestamp

Do you want to generate a timestamp in external DB2 format YYYY-MM-DD-HH.MM.SS.ssssss?

Use either following functions which is already part of the xmpPerl.pm function library:

Or try following Perl statements which are compatible to POSIX and are portable to other platforms:


Perl module xmpPerl.pm – function package used by DBA Perl scripts

This perl module contains all functions need by xmp perl scripts, published at www.ruban.de. You should easily adapt some constant values to your pesonal needs.

Some comments are in german. If you need assistence, don’t hesitate to contact me.