スケーラブルデータベースサーバ HiRDB Version 8 システム運用ガイド(UNIX(R)用)

[目次][索引][前へ][次へ]

21.1.4 アンロード統計ログファイルを特定のサーバマシンに作成するシェルスクリプト

実行者 HiRDB管理者

HiRDB/パラレルサーバで運用している場合,各々のサーバマシンで取得したアンロード統計ログファイルを特定のサーバマシンのディレクトリ下に集めるには,シェルスクリプト(pdstjacm)が利用できます。ここでは,アンロード統計ログファイルを特定のサーバマシンに作成するシェルスクリプトについて説明します。

<この項の構成>
(1) pdstjacmの機能
(2) pdstjacmの内容

(1) pdstjacmの機能

pdstjacmは,HiRDBが提供するシェルスクリプトです。pdstjacmを実行すると,複数のサーバマシンで出力した統計ログを特定のサーバマシンのディレクトリ下に集められます。このため,pdstjacmの内容を変更するとユーザの環境に合った,アンロード統計ログファイルを作成できます。なお,pdstjacmの内容を変更しないときは,pdstjacmを実行したホストの$PDDIR/spool/stjfilesにアンロード統計ログファイルが集められます。pdstjacmの概要を次の図に示します。

図21-3 pdstjacmの概要

[図データ]

〔説明〕
node1,node2,及びnode3の統計ログを$PDDIR/spool/stjfilesディレクトリ下に変更します。

(2) pdstjacmの内容

pdstjacmは,$PDDIR/binにpdstjacmとして格納されています。このため,pdstjacmの内容を変更する場合,シェルスクリプトをコピーしてください。また,pdstjacm以外に,OSのrcpコマンド(リモートコピー)やNFS(ネットワークファイルシステム)も利用できます。pdstjacmの内容を次に示します。

 
#!/bin/sh
# ALL RIGHTS RESERVED,COPYRIGHT (C) 1994,1995,HITACHI,LTD.
# LICENSED MATERIAL OF HITACHI,LTD.
# Name          : pdstjacm
# Function      : Collects statistics log files at host at which command is entered.
# Command Line  : pdstjacm [sysdef filename]
# Command option: sysdef filename - If name of system common definition at local
#                                   host is omitted, $PDCONFPATH/pdsys is assumed.
# Note          : (1) Change the OUTDIR as required.
#                 (2) Statistic log file is collected for each host under a separate 
#                     subdirectory of the $OUTDIR directory;
#                     the name of a subdirectory under $OUTDIR is the same as the
#                     correponding host name.
#                 (3) rcp command is used to transfer statistics log files between
#                     hosts.
#                 (4) A definition of pdstart operand and pdunit operand in definition
#                     files must not be written over several lines. If pdstart operand
#                     or pdunit operand is written over several lines in definition
#                     files, this command("pdstjacm") doesn't work correctly.
#
#                    (Example)
#                      pdstart -t SDS \ |    |
#                       -s sds01 \      | -> | pdstart -t SDS -s sds01 -x host01
#                       -x host01       |    |
#
#                      pdunit -u unt1 \ |    |
#                       -x host01 \     | -> | pdunit -u unt1 -x host01 -d "/HiRDB_S"
#                       -d "/HiRDB_S"   |    |
#
#                 (5) When system switching occurs, this command("pdstjacm") doesn't
#                     work correctly. Change the hostname(s) of the executing system
#                     to the one(s) of the standby system, in order to collect the 
#                     statistics log files of the standby system.
#                 (6) Pdstjacm shell is getten HiRDB operational directory name from
#                     system common definition file ($PDCONFPATH/pdsys or specified
#                     first argument). If pdunit operand in definition files is written
#                     over several lines in definition files, pdstjacm shell may be
#                     executed using $PDDIR in .cshrc on several local hosts.
#                 (7) If pdstart operands and/or pdunit operands are specified wrong
#                     in definition files, this command("pdstjacm") doesn't work
#                     correctly.
#
#******************************************************************************
##  Definition for canceling processing when Signal is received
trap "echo processing is canceled.; exit 1" 1 2 15
 
##  Definition of literals
OUTDIR=$PDDIR/spool/stjfiles      ………………………………※1
##  OUTDIR si directory under which statistics log files are collected.
##  Modify as required.
 
##  Checking of number of arguments
if [ $2 ] ; then
         echo  "Usage: $0 [input_file]"
         echo  "$0 processing is canceled."
         exit 1
fi
 
##  Checking of input definition file
if [ $# -eq 1 ]
then DEFFILE=$1
else DEFFILE=$PDCONFPATH/pdsys
fi
if [ ! -r $DEFFILE ] ; then
         echo "$DEFFILE is not found or cannot be read."
         echo "$0 processing is canceled."
         exit 1
fi
 
 
##  Set host name in ${proc_host}.
proc_host=`cat $DEFFILE | sed -n '/^[   ]*pdunit.*[   ]-x/{s/.*[   ]-x//;p;}' \
                         | awk '{print $1}' - | sort | uniq`
set ${proc_host:=no_host_name}
 
if [ $1 = no_host_name ] ; then
proc_host=`cat $DEFFILE | sed -n '/^[   ]*pdstart.*[   ]-x/{s/.*[   ]-x//;p;}' \
                         | awk '{print $1}' - | sort | uniq`
set ${proc_host:=no_host_name}
 
##  Validity checking of host name
if [ $1 = no_host_name ] ; then
         echo "No host name to be processed."
         echo "pdstjacm processing terminated."
         exit 1
fi
fi
 
##  Checking of transfer destination directory
if [ ! -d $OUTDIR ] ; then
         mkdir $OUTDIR
fi
 
##  Copy local host statistics log file   …………………※3
set ${proc_host}      ……………………………………………1
while [ $# -ne 0 ]
do
     if [ ! -d $OUTDIR/$1 ] ; then
              mkdir $OUTDIR/$1
     fi
     proc_dir=`cat $DEFFILE | /bin/grep '[   ]-x[   ]*'$1'[   ]' \
               | sed -n '/^[   ]*pdunit/{s/.*[   ]-d//;p;}' | awk '{print $1}' -`
     if [ -z "$proc_dir" ] ; then
       proc_dir=`cat $DEFFILE | /bin/grep '[   ]-x[   ]*'$1'$' \
              | sed -n '/^[   ]*pdunit/{s/.*[   ]-d//;p;}' | awk '{print $1}' -`
     fi
##  Validity checking of pddir name on pdunit operand
         case ${proc_dir} in
                  /*)
                         rcp $1:$proc_dir/spool/pdstj1 $OUTDIR/$1
                         rcp $1:$proc_dir/spool/pdstj2 $OUTDIR/$1
                 ;;
                 *)
                         rcp $1:'$'PDDIR/spool/pdstj1 $OUTDIR/$1   …………※2
                         rcp $1:'$'PDDIR/spool/pdstj2 $OUTDIR/$1
                 ;;
         esac
##  rcp command is used to transfer statistics log files between hosts.   …………※4
##  Environment must be set up so that remote shell can be executed between hosts.
         shift
done      ……………………………………………2
 
##  End of processing
echo "pdstjacm : Processing completed."
exit 0
 

注※1
アンロード統計ログファイルを特定のサーバマシンに作成する場合は,$PDDIR/spool/stjfilesの部分を編集してください。

注※2
特定のサーバマシン上の統計ログファイルが取得できない場合は,'$'PDDIR/spool/pdstj1及び'$'PDDIR/spool/pdstj2の部分を編集してください。

注※3
系切り替え機能を使用して待機系にHiRDBの実行が切り替わった場合,このシェルを修正しないで実行すると,統計ログファイルを正しく取得できません。この場合は,シェル中の1.から2.までのスクリプトを次のように変更してください。
 
 if[ ! -d $OUTDIR/HOST1 ] ; then
  mkdir $OUTDIR/HOST1
 fi          # HOST1の統計ロク゛ファイルのコヒ゜ー
 rcp HOST1:HOST1_pddir/spool/pdstj1 $OUTDIR/HOST1
 rcp HOST1:HOST1_pddir/spool/pdstj2 $OUTDIR/HOST1
 
 if [ ! -d $OUTDIR/HOST2 ] ; then
  mkdir $OUTDIR/HOST2
 fi          # HOST2の統計ロク゛ファイルのコヒ゜ー
 rcp HOST2:HOST2_pddir/spool/pdstj1 $OUTDIR/HOST2
 rcp HOST2:HOST2_pddir/spool/pdstj2 $OUTDIR/HOST2
 

上記スクリプトを統計ログを出力したユニット数分,繰り返してください。ただし,次の定数は必要に応じて変更してください。

HOST1,HOST2:統計ログを出力したホスト名

HOST1_pddir,HOST2_pddir:統計ログを出力したHiRDB運用ディレクトリ

注※4
統計ログファイルを取得するときにrcpコマンドを使用するため,/etc/hosts.equivや$HOME/.rhostsなどを正しく設定してください。また,pdstjacmはコマンドを実行したサーバマシンの統計ログファイルもrcpコマンドで取得するため,/etc/hosts.equivや$HOME/.rhostsに自ホスト名を指定しておく必要があります。