Hi,

On Tue, Jan 22, 2008 at 12:47:20PM +0100, Andreas Mather1 wrote:
> 
> 
> Hi all,
> 
> I ran into some troubles with the DB2 RA on an asymmetrical 4 node cluster.
> 
> I've changed the RA to cover my needs and want to share the patches (which
> I seperated as they address different issues):

That's very well :)

> db2_asym.patch:
> The first one is about the return code of the RA in case the DB2 instance
> is not availble. I've change the rc to $OCF_ERR_INSTALLED.

I guess that you mean "not installed" which is the case for
example when the software is on a shared storage. Funny, I
thought that I did fix this before.

The patch you posted is probably not enough. We have to handle
differently "not installed" and "not configured". Also, on
monitor operation, the RA should exit with OCF_NOT_RUNNING.
Please see if the attached patch works.

> db2_env.patch:
> In case the instance user's directory is shared, the ~/sqllib/db2nodes.cfg
> does not represent the current hostname after a takeover. This patch
> changes the RA to check the db2nodes.cfg for correct content and, if
> necessary, changes the hostname.

--- db2.orig    2008-01-22 10:52:15.460234564 +0100
+++ db2 2008-01-22 12:15:10.709047111 +0100
@@ -173,9 +173,41 @@
 
 
 #
+# db2_init_start: Prepare DB2 environment
+#
+db2_init_start() {
+
+  localhost=`hostname`
+  runasdb2 grep $localhost $db2sql/db2nodes.cfg &>/dev/null

Don't know what does db2nodes.cfg look like. Perhaps it's safer
to use 'grep -w ...'. '&>' is not necessary: use just '>'.

+
+  # if db2nodes.cfg is ok, return
+  [ $? -eq 0 ] && return
+
+  # ok, we need to change db2nodes.cfg to list our hostname
+  # if mktemp fails, we cannot recover so exit with error
+  tmpfile=`mktemp` || exit $OCF_ERR_GENERIC

mktemp's not available on all platforms. There's a function
provided which takes care of that: maketempfile.

+
+  cat $db2sql/db2nodes.cfg | sed "s#\(.*\)\s.*\s\(.*\)#\1 $localhost \2#" > 
$tmpfile

\s is a GNU extension. And the regular expression looks a bit
odd. Perhaps better to use awk:

  awk "{\$2=\"$localhost\"; print}" $db2sql/db2nodes.cfg > $tmpfile

+
+  # a sed failure is something we cannot recover from, so exit with error
+  [ -s $tmpfile ] || exit $OCF_ERR_GENERIC
+
+  chown --reference=$db2sql/db2nodes.cfg $tmpfile
+  chmod --reference=$db2sql/db2nodes.cfg $tmpfile

--reference is a GNU extension. Plain cp should preserved the
permissions of the target. Just drop these two...

+  mv $tmpfile $db2sql/db2nodes.cfg

and

  cp $tmpfile $db2sql/db2nodes.cfg
  rm $tmpfile

Can you please review the comments and suggestions and repost?
Thanks.

Dejan

+
+}
+
+
+
+#
 # db2_start: Start the given db2 instance
 #
 db2_start() {
+
+  # prepare db2 environment
+  db2_init_start
+  
   if
     output=`runasdb2 $db2adm/db2start`
   then

Attachment: db2_2.patch.gz
Description: GNU Zip compressed data

_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to