Discussion:
Run a script automatically when an IP is added
Yong Huang
2014-08-26 16:37:07 UTC
Permalink
Oracle's clusterware can migrate a VIP from one server to another. I'd like to have the target server automatically run a shell script once the new IP comes in. Is there a way to detect that and trigger execution of this script?

This
http://www.diglinux.com/2012/04/07/linux-heartbeat-ip-fail-over-2/
looks like what I need. But I wonder if a simpler solution exists, preferably without installing extra package. In fact, yum install heartbeat on my Red Hat box didn't find the package.

Thanks.
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Cameron Simpson
2014-08-27 22:47:05 UTC
Permalink
Post by Yong Huang
Oracle's clusterware can migrate a VIP from one server to another. I'd like to have the target server automatically run a shell script once the new IP comes in. Is there a way to detect that and trigger execution of this script?
This
http://www.diglinux.com/2012/04/07/linux-heartbeat-ip-fail-over-2/
looks like what I need. But I wonder if a simpler solution exists, preferably without installing extra package. In fact, yum install heartbeat on my Red Hat box didn't find the package.
Since nobody has replied, this is something you can do yourself with a little
script. As a starting point, this lists all the IPv4 addresses on my host
(current OSX, but adjusting for Linux "ifconfig" output should be easy):

ifconfig -a | sed -n 's/^ inet \([1-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\) .*/\1/p'

Note that the first whitespace before "inet" is a TAB character.

Have a look at "ifconfig -a" on your system and adjust the regexp.

(Or, if you care only about a specific interface, use "ifconfig eth0" or
whatever to monitor just that interface.)

Then all you would do is run that, pipe it through "sort -u", and put the
output in a file.

Next time, run it, sort, put in a temp file.

Compare them ("cmp -13 old-file tmp-file" should be useful) to get a list of
new IP addresses. When you get a new one, do what you want. Save the tmp-file
to the old-file for use on the next run.

Put it in cron to run regularly.

Cheers,
Cameron Simpson <***@zip.com.au>

WFO: the normal throttle position for Denizens, squids, and unfortunates on
50cc Honda step-throughs.
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Pedro unpete
2014-08-28 07:56:45 UTC
Permalink
Hi,

Try this:

1. create an application vips, this app moves with your VIPS (see appvipcfg)
2. create a profile which has an action_script=your_script.sh and
start/stop_dependencies=hard(previous_vipappname)
your _script must contains start, stop. Put the script you want to run.
3. add a resource -type= cluster_resource -file previous_profile_script.
(crsctl add resource -type cluster_resource -f your_profile_script)

Other solution:

http://docs.oracle.com/cd/E11882_01/rac.112/e17264/configwlm.htm#TDPRC296

About FAN Callouts

FAN callouts are server-side executable files that Oracle RAC runs
immediately when high availability events occur. A callout is essentially a
shell script or precompiled executable written in any programming language.
Some examples of how you can use FAN callouts to automate the actions
performed when events occur in a cluster configuration are as follows:

-

Starting and stopping server-side applications
-

Relocating low-priority services when high-priority services come online
-

Sending text or numeric messages to pagers
-

Executing shell scripts

The executable files for FAN callouts are stored in the
Grid_home/racg/usrco subdirectory.
If this subdirectory does not exist in your Grid home, then you must create
this directory with the same permissions and ownership as the Grid_home/
racg/tmp subdirectory.

All executables in the Grid_home/racg/usrco subdirectory are executed
immediately, in an asynchronous fashion, when a FAN event received through
the ONS. A copy of the executable files used by FAN callouts should be
available on every node that runs Oracle Clusterware. Example callout
scripts are available on Oracle Technology Network at
http://www.oracle.com/technetwork/database/enterprise-edition/twpracwkldmgmt-132994.pdf


Regards,

Pedro
Post by Cameron Simpson
Post by Yong Huang
Oracle's clusterware can migrate a VIP from one server to another. I'd
like to have the target server automatically run a shell script once the
new IP comes in. Is there a way to detect that and trigger execution of
this script?
This
http://www.diglinux.com/2012/04/07/linux-heartbeat-ip-fail-over-2/
looks like what I need. But I wonder if a simpler solution exists,
preferably without installing extra package. In fact, yum install heartbeat
on my Red Hat box didn't find the package.
Since nobody has replied, this is something you can do yourself with a
little script. As a starting point, this lists all the IPv4 addresses on my
host (current OSX, but adjusting for Linux "ifconfig" output should be
ifconfig -a | sed -n 's/^ inet \([1-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)
.*/\1/p'
Note that the first whitespace before "inet" is a TAB character.
Have a look at "ifconfig -a" on your system and adjust the regexp.
(Or, if you care only about a specific interface, use "ifconfig eth0" or
whatever to monitor just that interface.)
Then all you would do is run that, pipe it through "sort -u", and put the
output in a file.
Next time, run it, sort, put in a temp file.
Compare them ("cmp -13 old-file tmp-file" should be useful) to get a list
of new IP addresses. When you get a new one, do what you want. Save the
tmp-file to the old-file for use on the next run.
Put it in cron to run regularly.
Cheers,
WFO: the normal throttle position for Denizens, squids, and unfortunates on
50cc Honda step-throughs.
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Yong Huang
2014-08-28 16:40:52 UTC
Permalink
Thanks Pedro. How will the action script for the new profile be triggered? Will VIP relocation trigger it?


I already tested Oracle RAC's FAN callout, i.e., a script in $GRID_HOME/racg/usrco is run on certain events. It works on instance or service up or down event. But it does NOT work on VIP relocation (crsctl relocate resource ora.thisserver.vip -n anotherserver).

Camero, thanks. I already scheduled a cron job to do exactly what you described. But it's not *triggered* on VIP relocation. So it's not ideal.
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Pedro unpete
2014-08-28 17:31:27 UTC
Permalink
Hi,

Will VIP relocation trigger it? <---- unfortunately, i have not an RAC
environment to try it and i've never used somethig like this, but maybe the
answer is yes, because the resource moves with de vip.


1. appvipcfg create -network=1 -ip <your_vip> -vipname myapp -user=root

2. crsctl start rest myapp

3 cat myapp.sh

#!/bin/bash
case $1 in
'start')
(your script)
;;
'stop')
(your script).
;;
esac

exit 0

4. cat myapp_profile

ACTION_SCRIPT=[ANY_PATH]/myapp.sh
HOSTING_MEMBERS= host1 [host2 host3]
START_DEPENDENCIES=hard(myapp)
STOP_DEPENDENCES=hard(myapp)

crsctl add resource myresource -type=cluster_resource -file myapp_profile

crsctl start resource myresource

Regards
Pedro
Post by Yong Huang
Thanks Pedro. How will the action script for the new profile be triggered?
Will VIP relocation trigger it?
I already tested Oracle RAC's FAN callout, i.e., a script in
$GRID_HOME/racg/usrco is run on certain events. It works on instance or
service up or down event. But it does NOT work on VIP relocation (crsctl
relocate resource ora.thisserver.vip -n anotherserver).
Camero, thanks. I already scheduled a cron job to do exactly what you
described. But it's not *triggered* on VIP relocation. So it's not ideal.
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Loading...