On Wed, Dec 23, 2009 at 02:24:10AM -0700, Tim Serong wrote:
> On 12/23/2009 at 12:42 AM, Jiaju Zhang <[email protected]> wrote:
> > On Tue, Dec 22, 2009 at 8:56 PM, Dejan Muhamedagic <[email protected]>
> > wrote:
> > >
> > >> Thank you for stepping forward!
> > >
> > > Jiaju, many thanks for the contribution. Any chance to also
> > > implement the suggested improvements?
> >
> > Sure :)
> > Thanks for all the suggestions. I'll improve it and update it soon.
>
> Another suggestion:
>
> # diff -u IPaddr2 IPaddr2.new
> --- IPaddr2 2009-12-23 20:10:33.089860727 +1100
> +++ IPaddr2.new 2009-12-23 20:17:31.656957776 +1100
> @@ -532,13 +532,14 @@
> }
>
> save_tcp_connections() {
> + [ -z "$OCF_RESKEY_tickle_dir" ] && return
> mydir=$OCF_RESKEY_tickle_dir/`hostname`
why the hostname part?
why not just statefile=$OCF_RESKEY_tickle_dir/$OCF_RESKEY_ip ?
the IP may only be active on one server at a time,
so only one may write to the file.
> rm -f $mydir/*
not good, removes everything.
should only remove _one_ statefile.
we may have multiple IPs!
we may want to be able to do ip switchover independently.
also, please quote, this script runs as root.
rm is not necessary at all.
maybe do
generate_client_server_list_for_this_ip |
dd of="$statefile".new conv=fsync &&
mv "$statefile"
only that not all versions of dd support fsync ;)
> netstat -tn |egrep
> '^tcp[[:space:]]+[0-9]+[[:space:]]+[0-9]+[[:space:]]+[0-9\.]+:[0-9]+.*ESTABLISHED'
> |
> awk '{print $4" "$5}' |
> while read server client; do
> ip=${server%:*}
> - echo $client $server >> $mydir/$ip
> + [ "$ip" == "$OCF_RESKEY_ip" ] && echo $client $server
> >> $mydir/$ip
> done
> }
how about:
# use lsof, to avoid issues with truncated output
# let lsof do numerical output, filter on $OCF_RESKEY_ip already,
# and prepare the output for "other programs", see lsof man page ;)
# use sed to get the remote ip address and port.
lsof -nP -i4...@$ocf_reskey_ip -F nT |
sed -ne '/^n/h; /^TST=ESTABLISHED/ { g;s/^.*->//p; }' \
> "$statefile.new" &&
mv "$statefile.new" "$statefile"
(same would work for a wrapper script around ocf:IPv6addr , only change:
# I'm not sure about the form of the ipv6addr parameter.
# lsof filter requires the [] however.
case $OCF_RESKEY_ipv6addr in
\[*\]) ipv6=$OCF_RESKEY_ipv6addr;;
*) ipv6="[$OCF_RESKEY_ipv6addr]";;
esac
lsof -nP "-i6...@$ipv6" .F nT | ...
)
then provide the "local" address (OCF_reskey) via command line option to
tickle_ack, and feed it remote-address:port via stdin.
not sure about cluster ip clones, which usually are active on more than
one node. They probably need to put the "instance number" into the
statefile name as well, to not step on each others toes.
maybe tickle_acks make not much sense with cluster ip anyways,
so cloned IPaddr2 should just not do all this stuff.
> Also, I suppose it's kind of obvious, but might be worth mentioning
> in the tickle_dir metadata that the directory needs to be on shared
> storage.
Absolutely.
--
: Lars Ellenberg
: LINBIT | Your Way to High Availability
: DRBD/HA support and consulting http://www.linbit.com
DRBD® and LINBIT® are registered trademarks of LINBIT, Austria.
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/