Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux-HA: Dev

first shot at a mysql-proxy ocf ra

 

 

Linux-HA dev RSS feed   Index | Next | Previous | View Threaded


r.bhatia at ipax

May 16, 2009, 11:02 AM

Post #1 of 11 (2112 views)
Permalink
first shot at a mysql-proxy ocf ra

hi,

this is my first shot at creating a ocf ra on my own. that's one reason
i do not fully know if this should belong to heartbeat or pacemaker ;)

> # Resource script for MySQL Proxy
> #
> # Description: Manages MySQL Proxy as an OCF resource in
> # an high-availability setup.
> #
> # Tested with mysql-proxy 0.7.0 on Debian 5.0.
> # Based on the mysql and Pure-Ftpd OCF resource agents.

i invite everyone to take a look and give me some feedback.
currently, i have the following todos on my list:

> # TODO
> # * remove debian specific code (e.g. start-stop-daemon)
> # * add error checking like in mysql ocf ra (e.g. socketdir)
> # * verify if mysql-proxy supports multiple --proxy-address(es)

i tested it with two instances of mysql-proxy, one using
--proxy-address=/var/run/mysqld/mysqld.sock and the second one using
--proxy-address=:3306 .

cheers,
raoul
--
____________________________________________________________________
DI (FH) Raoul Bhatia M.Sc. email. r.bhatia [at] ipax
Technischer Leiter

IPAX - Aloy Bhatia Hava OEG web. http://www.ipax.at
Barawitzkagasse 10/2/2/11 email. office [at] ipax
1190 Wien tel. +43 1 3670030
FN 277995t HG Wien fax. +43 1 3670030 15
____________________________________________________________________
Attachments: mysql-proxy (7.24 KB)


dejanmm at fastmail

May 18, 2009, 9:17 AM

Post #2 of 11 (2001 views)
Permalink
Re: first shot at a mysql-proxy ocf ra [In reply to]

Hi Raoul,

On Sat, May 16, 2009 at 08:02:41PM +0200, Raoul Bhatia [IPAX] wrote:
> hi,
>
> this is my first shot at creating a ocf ra on my own. that's one reason
> i do not fully know if this should belong to heartbeat or pacemaker ;)

I'd say to heartbeat.

> > # Resource script for MySQL Proxy
> > #
> > # Description: Manages MySQL Proxy as an OCF resource in
> > # an high-availability setup.
> > #
> > # Tested with mysql-proxy 0.7.0 on Debian 5.0.
> > # Based on the mysql and Pure-Ftpd OCF resource agents.
>
> i invite everyone to take a look and give me some feedback.
> currently, i have the following todos on my list:

The script looks good to me, though I've never used that
software. There's just one place where you should protect the
variable expansion with quotes ($PID). Also, a few places were
use of OCF_RESKEY_* variables makes it very hard to follow the
relevant context. Perhaps you'd want to replace OCF_RESKEY_*
variables with shorter names (i.e. pidf, defaultf, etc).

> > # TODO
> > # * remove debian specific code (e.g. start-stop-daemon)
> > # * add error checking like in mysql ocf ra (e.g. socketdir)
> > # * verify if mysql-proxy supports multiple --proxy-address(es)

Well, if you can make it distribution agnostic, that'd be great :)

Cheers,

Dejan

> i tested it with two instances of mysql-proxy, one using
> --proxy-address=/var/run/mysqld/mysqld.sock and the second one using
> --proxy-address=:3306 .
>
> cheers,
> raoul
> --
> ____________________________________________________________________
> DI (FH) Raoul Bhatia M.Sc. email. r.bhatia [at] ipax
> Technischer Leiter
>
> IPAX - Aloy Bhatia Hava OEG web. http://www.ipax.at
> Barawitzkagasse 10/2/2/11 email. office [at] ipax
> 1190 Wien tel. +43 1 3670030
> FN 277995t HG Wien fax. +43 1 3670030 15
> ____________________________________________________________________

> #!/bin/sh
> #
> # Resource script for MySQL Proxy
> #
> # Description: Manages MySQL Proxy as an OCF resource in
> # an high-availability setup.
> #
> # Tested with mysql-proxy 0.7.0 on Debian 5.0.
> # Based on the mysql and Pure-Ftpd OCF resource agents.
> #
> # Author: Raoul Bhatia <r.bhatia [at] ipax> : Original Author
> # License: GNU General Public License (GPL)
> #
> #
> # usage: $0 {start|stop|status|monitor|validate-all|meta-data}
> #
> # The "start" arg starts a MySQL Proxy instance
> #
> # The "stop" arg stops it.
> #
> # TODO
> # * remove debian specific code (e.g. start-stop-daemon)
> # * add error checking like in mysql ocf ra (e.g. socketdir)
> # * verify if mysql-proxy supports multiple --proxy-address(es)
> #
> # OCF parameters:
> # OCF_RESKEY_binary
> # OCF_RESKEY_defaults_file
> # OCF_RESKEY_proxy_backend_addresses
> # OCF_RESKEY_proxy_address
> # OCF_RESKEY_admin_address
> # OCF_RESKEY_parameters
> # OCF_RESKEY_pidfile
> #
> ##########################################################################
>
> # Initialization:
>
> . ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
>
> : ${OCF_RESKEY_binary="/usr/sbin/mysql-proxy"}
> : ${OCF_RESKEY_defaults_file=""}
> : ${OCF_RESKEY_proxy_backend_addresses="127.0.0.1:3306"}
> : ${OCF_RESKEY_proxy_address=":4040"}
> : ${OCF_RESKEY_admin_address="127.0.0.1:4041"}
> : ${OCF_RESKEY_parameters=""}
> : ${OCF_RESKEY_pidfile="${HA_RSCTMP}/mysql-proxy-${OCF_RESOURCE_INSTANCE}.pid"}
> USAGE="Usage: $0 {start|stop|status|monitor|validate-all|meta-data}";
>
> ##########################################################################
>
> usage() {
> echo $USAGE >&2
> }
>
> meta_data() {
> cat <<END
> <?xml version="1.0"?>
> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
> <resource-agent name="mysql-proxy">
> <version>0.1</version>
> <longdesc lang="en">
> This script manages MySQL Proxy as an OCF resource in a high-availability setup.
> Tested with MySQL Proxy 0.7.0 on Debian 5.0.
> </longdesc>
> <shortdesc lang="en">OCF Resource Agent compliant MySQL Proxy script.</shortdesc>
>
> <parameters>
>
> <parameter name="binary" unique="1" required="1">
> <longdesc lang="en">
> Full path to the MySQL Proxy binary.
> For example, "/usr/sbin/mysql-proxy".
> </longdesc>
> <shortdesc lang="en">Full path to MySQL Proxy binary</shortdesc>
> <content type="string" default="/usr/sbin/mysql-proxy" />
> </parameter>
>
> <parameter name="defaults_file" unique="1" required="0">
> <longdesc lang="en">
> Full path to a MySQL Proxy configuration file.
> For example, "/etc/mysql-proxy.conf".
> </longdesc>
> <shortdesc lang="en">Full path to configuration file</shortdesc>
> <content type="string" default="" />
> </parameter>
>
> <parameter name="proxy_backend_addresses" unique="0" required="0">
> <longdesc lang="en">
> Address:port of the remote backend-servers (default: 127.0.0.1:3306).
> </longdesc>
> <shortdesc lang="en"></shortdesc>
> <content type="string" default="127.0.0.1:3306" />
> </parameter>
>
> <parameter name="proxy_address" unique="0" required="0">
> <longdesc lang="en">
> Listening address:port of the proxy-server (default: :4040).
> You can also specify a socket like "/tmp/mysql-proxy.sock".
> </longdesc>
> <shortdesc lang="en"></shortdesc>
> <content type="string" default=":4040" />
> </parameter>
>
> <parameter name="admin_address" unique="0" required="0">
> <longdesc lang="en">
> Listening address:port of the admin-server (default: 127.0.0.1:4041).
> </longdesc>
> <shortdesc lang="en"></shortdesc>
> <content type="string" default="127.0.0.1:4041" />
> </parameter>
>
> <parameter name="parameters" unique="1" required="0">
> <longdesc lang="en">
> The MySQL Proxy daemon may be called with additional parameters.
> Specify any of them here.
> </longdesc>
> <shortdesc lang="en"></shortdesc>
> <content type="string" default="" />
> </parameter>
>
> <parameter name="pidfile" unique="0">
> <longdesc lang="en">PID file</longdesc>
> <shortdesc lang="en">PID file</shortdesc>
> <content type="string" default="${HA_RSCTMP}/mysql-proxy-${OCF_RESOURCE_INSTANCE}.pid" />
> </parameter>
>
> </parameters>
>
> <actions>
> <action name="start" timeout="90" />
> <action name="stop" timeout="100" />
> <action name="monitor" depth="10" timeout="20s" interval="60s" start-delay="1s" />
> <action name="validate-all" timeout="30s" />
> <action name="meta-data" timeout="5s" />
> </actions>
> </resource-agent>
> END
> exit $OCF_SUCCESS
> }
>
> isRunning()
> {
> kill -0 "$1" 2>/dev/null
> }
>
> mysqlproxy_status()
> {
> if [ -f $OCF_RESKEY_pidfile ]; then
> # MySQL Proxy is probably running
> PID=`head -n 1 $OCF_RESKEY_pidfile`
> if [ ! -z $PID ] ; then
> isRunning "$PID"
> return $?
> fi
> fi
>
> # MySQL Proxy is not running
> false
> }
>
> mysqlproxy_start()
> {
> # if MySQL Proxy is running return success
> if mysqlproxy_status ; then
> exit $OCF_SUCCESS
> fi
>
> # check that the MySQL Proxy binary exists and can be executed
> if [ ! -x "$OCF_RESKEY_binary" ]; then
> ocf_log err "MySQL Proxy binary '$OCF_RESKEY_binary' does not exist or cannot be executed."
> exit $OCF_ERR_GENERIC
> fi
>
> # check if the MySQL Proxy defaults-file exist
> FIRST_PARAM=''
> if [ -f "$OCF_RESKEY_defaults_file" ]; then
> FIRST_PARAM="--defaults-file=$OCF_RESKEY_defaults_file "
> fi
>
> OPTIONS="$FIRST_PARAM--proxy-backend-addresses=$OCF_RESKEY_proxy_backend_addresses --admin-address=$OCF_RESKEY_admin_address"
> # split multiple proxy-address options
> for pa in $OCF_RESKEY_proxy_address; do
> OPTIONS=" $OPTIONS --proxy-address=$pa"
> done
>
> # start MySQL Proxy
> start-stop-daemon --start --quiet --pidfile $OCF_RESKEY_pidfile --make-pidfile --name mysql-proxy --startas $OCF_RESKEY_binary -b -- $OPTIONS
> ret=$?
>
> if [ $ret -ne 0 ]; then
> ocf_log info "MySQL Proxy returned error" $?
> exit $OCF_ERR_GENERIC
> fi
>
> exit $OCF_SUCCESS
> }
>
>
> mysqlproxy_stop()
> {
> LA=`mysqlproxy_status`
> echo $LA
> if mysqlproxy_status ; then
> start-stop-daemon --stop --quiet --retry 3 --exec $OCF_RESKEY_binary --pidfile $OCF_RESKEY_pidfile
>
> # remove dangling socketfile if specified
> for pa in $OCF_RESKEY_proxy_address; do
> if [ -S "$pa" ]; then
> ocf_log info "Removing dangling socket file '$pa'."
> rm -f "$pa"
> fi
> done
> fi
>
> exit $OCF_SUCCESS
> }
>
> mysqlproxy_monitor()
> {
>
> if mysqlproxy_status ; then
> return $OCF_SUCCESS
> fi
>
> return $OCF_NOT_RUNNING
> }
>
> mysqlproxy_validate_all()
> {
>
> # @TODO
> return $OCF_SUCCESS
> }
>
> #
> # Main
> #
>
> if [ $# -ne 1 ]; then
> usage
> exit $OCF_ERR_ARGS
> fi
>
> case $1 in
> start) mysqlproxy_start
> ;;
>
> stop) mysqlproxy_stop
> ;;
>
> status) if mysqlproxy_status; then
> ocf_log info "MySQL Proxy is running"
> exit $OCF_SUCCESS
> else
> ocf_log info "MySQL Proxy is stopped"
> exit $OCF_NOT_RUNNING
> fi
> ;;
>
> monitor) mysqlproxy_monitor
> exit $?
> ;;
>
> validate-all) mysqlproxy_validate_all
> exit $?
> ;;
>
> meta-data) meta_data
> ;;
>
> usage) usage
> exit $OCF_SUCCESS
> ;;
>
> *) usage
> exit $OCF_ERR_UNIMPLEMENTED
> ;;
> esac
>

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

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


r.bhatia at ipax

May 22, 2009, 8:13 AM

Post #3 of 11 (1955 views)
Permalink
Re: first shot at a mysql-proxy ocf ra [In reply to]

hi dejan,

thank you for your feedback. please see inline.

Dejan Muhamedagic wrote:
>>> # Resource script for MySQL Proxy
>>> #
>>> # Description: Manages MySQL Proxy as an OCF resource in
>>> # an high-availability setup.
>>> #
>>> # Tested with mysql-proxy 0.7.0 on Debian 5.0.
>>> # Based on the mysql and Pure-Ftpd OCF resource agents.
>> i invite everyone to take a look and give me some feedback.
>> currently, i have the following todos on my list:
>
> The script looks good to me, though I've never used that
> software. There's just one place where you should protect the
> variable expansion with quotes ($PID). Also, a few places were
> use of OCF_RESKEY_* variables makes it very hard to follow the
> relevant context. Perhaps you'd want to replace OCF_RESKEY_*
> variables with shorter names (i.e. pidf, defaultf, etc).

i am now parsing everything to more meaningful names. (line 253ff).
did you mean it this way?

moreover, i now protect the $PID in line 153. i hope that was the
place you were refering to.

>>> # TODO
>>> # * remove debian specific code (e.g. start-stop-daemon)
this is still open. i would like to see mysql-proxy included so i
can provide patches against the hg repository instead of re-submitting
the ocf every time.

>>> # * add error checking like in mysql ocf ra (e.g. socketdir)
open. will provide patches as needed

>>> # * verify if mysql-proxy supports multiple --proxy-address(es)
i think that you cannot use multiple --proxy-address options.
but you can use multiple proxy-backend-addresses and
proxy-read-only-backend-addresses which i have now implemented
(but not tested yet).

> Well, if you can make it distribution agnostic, that'd be great :)
i'll do that in one of the patches to come, ok?

thanks,
raoul
--
____________________________________________________________________
DI (FH) Raoul Bhatia M.Sc. email. r.bhatia [at] ipax
Technischer Leiter

IPAX - Aloy Bhatia Hava OEG web. http://www.ipax.at
Barawitzkagasse 10/2/2/11 email. office [at] ipax
1190 Wien tel. +43 1 3670030
FN 277995t HG Wien fax. +43 1 3670030 15
____________________________________________________________________
Attachments: mysql-proxy (9.18 KB)


dejanmm at fastmail

May 25, 2009, 8:39 AM

Post #4 of 11 (1912 views)
Permalink
Re: first shot at a mysql-proxy ocf ra [In reply to]

Hi Raoul,

On Fri, May 22, 2009 at 05:13:02PM +0200, Raoul Bhatia [IPAX] wrote:
> hi dejan,
>
> thank you for your feedback. please see inline.
>
> Dejan Muhamedagic wrote:
> >>> # Resource script for MySQL Proxy
> >>> #
> >>> # Description: Manages MySQL Proxy as an OCF resource in
> >>> # an high-availability setup.
> >>> #
> >>> # Tested with mysql-proxy 0.7.0 on Debian 5.0.
> >>> # Based on the mysql and Pure-Ftpd OCF resource agents.
> >> i invite everyone to take a look and give me some feedback.
> >> currently, i have the following todos on my list:
> >
> > The script looks good to me, though I've never used that
> > software. There's just one place where you should protect the
> > variable expansion with quotes ($PID). Also, a few places were
> > use of OCF_RESKEY_* variables makes it very hard to follow the
> > relevant context. Perhaps you'd want to replace OCF_RESKEY_*
> > variables with shorter names (i.e. pidf, defaultf, etc).
>
> i am now parsing everything to more meaningful names. (line 253ff).
> did you mean it this way?

Great!

> moreover, i now protect the $PID in line 153. i hope that was the
> place you were refering to.

Yes.

> >>> # TODO
> >>> # * remove debian specific code (e.g. start-stop-daemon)
> this is still open. i would like to see mysql-proxy included so i
> can provide patches against the hg repository instead of re-submitting
> the ocf every time.
>
> >>> # * add error checking like in mysql ocf ra (e.g. socketdir)
> open. will provide patches as needed
>
> >>> # * verify if mysql-proxy supports multiple --proxy-address(es)
> i think that you cannot use multiple --proxy-address options.
> but you can use multiple proxy-backend-addresses and
> proxy-read-only-backend-addresses which i have now implemented
> (but not tested yet).
>
> > Well, if you can make it distribution agnostic, that'd be great :)
> i'll do that in one of the patches to come, ok?

At risk of being ungrateful and rude, I'd still insist on this
point, because people expect the whole shebang to run on Linux,
not just on distribution XY. It shouldn't be that hard to do
after all :) Take a look at this changeset for example:

changeset: 12393:60cc2d6eee88
user: NAKAHIRA Kazutomo <nakahira [at] intellilink>
date: Fri Apr 24 08:38:48 2009 +0200
summary: High (LF 2112): RA: sfex: checkproc/killproc are not available everywhere

Cheers,

Dejan

> thanks,
> raoul
> --
> ____________________________________________________________________
> DI (FH) Raoul Bhatia M.Sc. email. r.bhatia [at] ipax
> Technischer Leiter
>
> IPAX - Aloy Bhatia Hava OEG web. http://www.ipax.at
> Barawitzkagasse 10/2/2/11 email. office [at] ipax
> 1190 Wien tel. +43 1 3670030
> FN 277995t HG Wien fax. +43 1 3670030 15
> ____________________________________________________________________

> #!/bin/sh
> #
> # Resource script for MySQL Proxy
> #
> # Description: Manages MySQL Proxy as an OCF resource in
> # an high-availability setup.
> #
> # Tested with mysql-proxy 0.7.0 on Debian 5.0.
> # Based on the mysql and Pure-Ftpd OCF resource agents.
> #
> # Author: Raoul Bhatia <r.bhatia [at] ipax> : Original Author
> # License: GNU General Public License (GPL)
> #
> #
> # usage: $0 {start|stop|status|monitor|validate-all|meta-data}
> #
> # The "start" arg starts a MySQL Proxy instance
> #
> # The "stop" arg stops it.
> #
> # TODO
> # * remove debian specific code (e.g. start-stop-daemon)
> # * add error checking like in mysql ocf ra (e.g. socketdir)
> # * verify if mysql-proxy supports multiple --proxy-address(es)
> #
> # OCF parameters:
> # OCF_RESKEY_binary
> # OCF_RESKEY_defaults_file
> # OCF_RESKEY_proxy_backend_addresses
> # OCF_RESKEY_proxy_read_only_backend_addresses
> # OCF_RESKEY_proxy_address
> # OCF_RESKEY_admin_address
> # OCF_RESKEY_parameters
> # OCF_RESKEY_pidfile
> #
> ##########################################################################
>
> # Initialization:
>
> . ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
>
> : ${OCF_RESKEY_binary="/usr/sbin/mysql-proxy"}
> : ${OCF_RESKEY_defaults_file=""}
> : ${OCF_RESKEY_proxy_backend_addresses="127.0.0.1:3306"}
> : ${OCF_RESKEY_proxy_read_only_backend_addresses=""}
> : ${OCF_RESKEY_proxy_address=":4040"}
> : ${OCF_RESKEY_admin_address="127.0.0.1:4041"}
> : ${OCF_RESKEY_parameters=""}
> : ${OCF_RESKEY_pidfile="${HA_RSCTMP}/mysql-proxy-${OCF_RESOURCE_INSTANCE}.pid"}
> USAGE="Usage: $0 {start|stop|status|monitor|validate-all|meta-data}";
>
> ##########################################################################
>
> usage() {
> echo $USAGE >&2
> }
>
> meta_data() {
> cat <<END
> <?xml version="1.0"?>
> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
> <resource-agent name="mysql-proxy">
> <version>0.1</version>
> <longdesc lang="en">
> This script manages MySQL Proxy as an OCF resource in a high-availability setup.
> Tested with MySQL Proxy 0.7.0 on Debian 5.0.
> </longdesc>
> <shortdesc lang="en">OCF Resource Agent compliant MySQL Proxy script.</shortdesc>
>
> <parameters>
>
> <parameter name="binary" unique="1" required="1">
> <longdesc lang="en">
> Full path to the MySQL Proxy binary.
> For example, "/usr/sbin/mysql-proxy".
> </longdesc>
> <shortdesc lang="en">Full path to MySQL Proxy binary</shortdesc>
> <content type="string" default="/usr/sbin/mysql-proxy" />
> </parameter>
>
> <parameter name="defaults_file" unique="1" required="0">
> <longdesc lang="en">
> Full path to a MySQL Proxy configuration file.
> For example, "/etc/mysql-proxy.conf".
> </longdesc>
> <shortdesc lang="en">Full path to configuration file</shortdesc>
> <content type="string" default="" />
> </parameter>
>
> <parameter name="proxy_backend_addresses" unique="0" required="0">
> <longdesc lang="en">
> Address:port of the remote backend-servers (default: 127.0.0.1:3306).
> </longdesc>
> <shortdesc lang="en"></shortdesc>
> <content type="string" default="127.0.0.1:3306" />
> </parameter>
>
> <parameter name="proxy_read_only_backend_addresses" unique="0" required="0">
> <longdesc lang="en">
> Address:port of the remote slave-server (default: not set).
> </longdesc>
> <shortdesc lang="en"></shortdesc>
> <content type="string" default="127.0.0.1:3306" />
> </parameter>
>
> <parameter name="proxy_address" unique="0" required="0">
> <longdesc lang="en">
> Listening address:port of the proxy-server (default: :4040).
> You can also specify a socket like "/tmp/mysql-proxy.sock".
> </longdesc>
> <shortdesc lang="en"></shortdesc>
> <content type="string" default=":4040" />
> </parameter>
>
> <parameter name="admin_address" unique="0" required="0">
> <longdesc lang="en">
> Listening address:port of the admin-server (default: 127.0.0.1:4041).
> </longdesc>
> <shortdesc lang="en"></shortdesc>
> <content type="string" default="127.0.0.1:4041" />
> </parameter>
>
> <parameter name="parameters" unique="1" required="0">
> <longdesc lang="en">
> The MySQL Proxy daemon may be called with additional parameters.
> Specify any of them here.
> </longdesc>
> <shortdesc lang="en"></shortdesc>
> <content type="string" default="" />
> </parameter>
>
> <parameter name="pidfile" unique="0">
> <longdesc lang="en">PID file</longdesc>
> <shortdesc lang="en">PID file</shortdesc>
> <content type="string" default="${HA_RSCTMP}/mysql-proxy-${OCF_RESOURCE_INSTANCE}.pid" />
> </parameter>
>
> </parameters>
>
> <actions>
> <action name="start" timeout="90" />
> <action name="stop" timeout="100" />
> <action name="monitor" depth="10" timeout="20s" interval="60s" start-delay="1s" />
> <action name="validate-all" timeout="30s" />
> <action name="meta-data" timeout="5s" />
> </actions>
> </resource-agent>
> END
> exit $OCF_SUCCESS
> }
>
> isRunning()
> {
> kill -0 "$1" 2>/dev/null
> }
>
> mysqlproxy_status()
> {
> if [ -f $pidfile ]; then
> # MySQL Proxy is probably running
> PID=`head -n 1 $pidfile`
> if [ ! -z "$PID" ] ; then
> isRunning "$PID"
> return $?
> fi
> fi
>
> # MySQL Proxy is not running
> false
> }
>
> mysqlproxy_start()
> {
> # if MySQL Proxy is running return success
> if mysqlproxy_status ; then
> exit $OCF_SUCCESS
> fi
>
> # check that the MySQL Proxy binary exists and can be executed
> if [ ! -x "$binary" ]; then
> ocf_log err "MySQL Proxy binary '$binary' does not exist or cannot be executed."
> exit $OCF_ERR_GENERIC
> fi
>
> # check if the MySQL Proxy defaults-file exist
> PARAM_PREFIX=''
> if [ -f "$defaults_file" ]; then
> PARAM_PREFIX="--defaults-file=$defaults_file "
> fi
>
> # split multiple proxy-address options.
> # currently unsupported but let us hope for the future ;)
> for pa in $proxy_address; do
> [ -z "$pa" ] && continue
> OPTIONS=" $OPTIONS --proxy-address=$pa"
> done
>
> # split multiple proxy-backend-addresses options.
> for pba in $proxy_backend_addresses; do
> [ -z "$pba" ] && continue
> OPTIONS=" $OPTIONS --proxy-backend-addresses=$pba"
> done
>
> # split multiple proxy-backend-addresses options.
> for proba in $proxy_read_only_backend_addresses; do
> [ -z "$proba" ] && continue
> OPTIONS=" $OPTIONS --proxy-read-only-backend-addresses=$proba"
> done
>
> OPTIONS="$PARAM_PREFIX $OPTIONS --admin-address=$admin_address $PARAM_SUFFIX"
>
> # start MySQL Proxy
> #echo start-stop-daemon --start --quiet --pidfile $pidfile --make-pidfile --name mysql-proxy --startas $binary -b -- $OPTIONS
> start-stop-daemon --start --quiet --pidfile $pidfile --make-pidfile --name mysql-proxy --startas $binary -b -- $OPTIONS
> ret=$?
>
> if [ $ret -ne 0 ]; then
> ocf_log info "MySQL Proxy returned error" $?
> exit $OCF_ERR_GENERIC
> fi
>
> exit $OCF_SUCCESS
> }
>
>
> mysqlproxy_stop()
> {
> LA=`mysqlproxy_status`
> if mysqlproxy_status ; then
> start-stop-daemon --stop --quiet --retry 3 --exec $binary --pidfile $pidfile
>
> # remove dangling socketfile if specified
> for pa in $proxy_address; do
> if [ -S "$pa" ]; then
> ocf_log info "Removing dangling socket file '$pa'."
> rm -f "$pa"
> fi
> done
> fi
>
> exit $OCF_SUCCESS
> }
>
> mysqlproxy_monitor()
> {
>
> if mysqlproxy_status ; then
> return $OCF_SUCCESS
> fi
>
> return $OCF_NOT_RUNNING
> }
>
> mysqlproxy_validate_all()
> {
>
> # @TODO
> return $OCF_SUCCESS
> }
>
> #
> # Main
> #
>
> if [ $# -ne 1 ]; then
> usage
> exit $OCF_ERR_ARGS
> fi
>
> pidfile=$OCF_RESKEY_pidfile
> binary=$OCF_RESKEY_binary
> defaults_file=$OCF_RESKEY_defaults_file
> proxy_backend_addresses=$OCF_RESKEY_proxy_backend_addresses
> proxy_read_only_backend_addresses=$OCF_RESKEY_proxy_read_only_backend_addresses
> admin_address=$OCF_RESKEY_admin_address
> proxy_address=$OCF_RESKEY_proxy_address
>
> # debugging stuff
> #echo OCF_RESKEY_binary=$OCF_RESKEY_binary >> /tmp/prox_conf_$OCF_RESOURCE_INSTANCE
> #echo OCF_RESKEY_defaults_file=$OCF_RESKEY_defaults_file >> /tmp/prox_conf_$OCF_RESOURCE_INSTANCE
> #echo OCF_RESKEY_proxy_backend_addresses=$OCF_RESKEY_proxy_backend_addresses >> /tmp/prox_conf_$OCF_RESOURCE_INSTANCE
> #echo OCF_RESKEY_proxy_read_only_backend_addresses=$OCF_RESKEY_proxy_read_only_backend_addresses >> /tmp/prox_conf_$OCF_RESOURCE_INSTANCE
> #echo OCF_RESKEY_proxy_address=$OCF_RESKEY_proxy_address >> /tmp/prox_conf_$OCF_RESOURCE_INSTANCE
> #echo OCF_RESKEY_admin_address=$OCF_RESKEY_admin_address >> /tmp/prox_conf_$OCF_RESOURCE_INSTANCE
> #echo OCF_RESKEY_parameters=$OCF_RESKEY_parameters >> /tmp/prox_conf_$OCF_RESOURCE_INSTANCE
> #echo OCF_RESKEY_pidfile=$OCF_RESKEY_pidfile >> /tmp/prox_conf_$OCF_RESOURCE_INSTANCE
>
>
> case $1 in
> start) mysqlproxy_start
> ;;
>
> stop) mysqlproxy_stop
> ;;
>
> status) if mysqlproxy_status; then
> ocf_log info "MySQL Proxy is running"
> exit $OCF_SUCCESS
> else
> ocf_log info "MySQL Proxy is stopped"
> exit $OCF_NOT_RUNNING
> fi
> ;;
>
> monitor) mysqlproxy_monitor
> exit $?
> ;;
>
> validate-all) mysqlproxy_validate_all
> exit $?
> ;;
>
> meta-data) meta_data
> ;;
>
> usage) usage
> exit $OCF_SUCCESS
> ;;
>
> *) usage
> exit $OCF_ERR_UNIMPLEMENTED
> ;;
> esac
>

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

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


r.bhatia at ipax

May 26, 2009, 2:51 AM

Post #5 of 11 (1911 views)
Permalink
Re: first shot at a mysql-proxy ocf ra [In reply to]

hi dejan,

Dejan Muhamedagic wrote:
>>>>> # TODO
>>>>> # * remove debian specific code (e.g. start-stop-daemon)
>> this is still open. i would like to see mysql-proxy included so i
>> can provide patches against the hg repository instead of re-submitting
>> the ocf every time.
...
> At risk of being ungrateful and rude, I'd still insist on this
> point, because people expect the whole shebang to run on Linux,
> not just on distribution XY. It shouldn't be that hard to do
> after all :) Take a look at this changeset for example:
>
> changeset: 12393:60cc2d6eee88
> user: NAKAHIRA Kazutomo <nakahira [at] intellilink>
> date: Fri Apr 24 08:38:48 2009 +0200
> summary: High (LF 2112): RA: sfex: checkproc/killproc are not available everywhere

i now replaced the start-stop-daemon calls. however, i left these
calls as comments for reference. if the ra proves stable, one can
remove them during the next maintanance.

thank you for the reference. it saved me some time!

changes:
* replace debian specific start-stop-daemon calls
* protect $pidfile
* remove obsolete code/comments
* add some more error checking

is it ready for initial inclusion now?

cheers,
raoul
--
____________________________________________________________________
DI (FH) Raoul Bhatia M.Sc. email. r.bhatia [at] ipax
Technischer Leiter

IPAX - Aloy Bhatia Hava OEG web. http://www.ipax.at
Barawitzkagasse 10/2/2/11 email. office [at] ipax
1190 Wien tel. +43 1 3670030
FN 277995t HG Wien fax. +43 1 3670030 15
____________________________________________________________________
Attachments: mysql-proxy (9.61 KB)


r.bhatia at ipax

May 26, 2009, 2:53 AM

Post #6 of 11 (1896 views)
Permalink
Re: first shot at a mysql-proxy ocf ra [In reply to]

ups, it seems that i messed something up.
will fix and resend the ra asap!

cheers,
raoul

Raoul Bhatia [IPAX] wrote:
> hi dejan,
>
> Dejan Muhamedagic wrote:
>>>>>> # TODO
>>>>>> # * remove debian specific code (e.g. start-stop-daemon)
>>> this is still open. i would like to see mysql-proxy included so i
>>> can provide patches against the hg repository instead of re-submitting
>>> the ocf every time.
> ...
>> At risk of being ungrateful and rude, I'd still insist on this
>> point, because people expect the whole shebang to run on Linux,
>> not just on distribution XY. It shouldn't be that hard to do
>> after all :) Take a look at this changeset for example:
>>
>> changeset: 12393:60cc2d6eee88
>> user: NAKAHIRA Kazutomo <nakahira [at] intellilink>
>> date: Fri Apr 24 08:38:48 2009 +0200
>> summary: High (LF 2112): RA: sfex: checkproc/killproc are not available everywhere
>
> i now replaced the start-stop-daemon calls. however, i left these
> calls as comments for reference. if the ra proves stable, one can
> remove them during the next maintanance.
>
> thank you for the reference. it saved me some time!
>
> changes:
> * replace debian specific start-stop-daemon calls
> * protect $pidfile
> * remove obsolete code/comments
> * add some more error checking
>
> is it ready for initial inclusion now?
>
> cheers,
> raoul
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________________
> Linux-HA-Dev: Linux-HA-Dev [at] lists
> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/


--
____________________________________________________________________
DI (FH) Raoul Bhatia M.Sc. email. r.bhatia [at] ipax
Technischer Leiter

IPAX - Aloy Bhatia Hava OEG web. http://www.ipax.at
Barawitzkagasse 10/2/2/11 email. office [at] ipax
1190 Wien tel. +43 1 3670030
FN 277995t HG Wien fax. +43 1 3670030 15
____________________________________________________________________
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev [at] lists
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/


r.bhatia at ipax

May 26, 2009, 3:06 AM

Post #7 of 11 (1892 views)
Permalink
Re: first shot at a mysql-proxy ocf ra [In reply to]

i missed a "!". fixed version attached.

Raoul Bhatia [IPAX] wrote:
> ups, it seems that i messed something up.
> will fix and resend the ra asap!
>
> cheers,
> raoul
>
> Raoul Bhatia [IPAX] wrote:
>> hi dejan,
>>
>> Dejan Muhamedagic wrote:
>>>>>>> # TODO
>>>>>>> # * remove debian specific code (e.g. start-stop-daemon)
>>>> this is still open. i would like to see mysql-proxy included so i
>>>> can provide patches against the hg repository instead of re-submitting
>>>> the ocf every time.
>> ...
>>> At risk of being ungrateful and rude, I'd still insist on this
>>> point, because people expect the whole shebang to run on Linux,
>>> not just on distribution XY. It shouldn't be that hard to do
>>> after all :) Take a look at this changeset for example:
>>>
>>> changeset: 12393:60cc2d6eee88
>>> user: NAKAHIRA Kazutomo <nakahira [at] intellilink>
>>> date: Fri Apr 24 08:38:48 2009 +0200
>>> summary: High (LF 2112): RA: sfex: checkproc/killproc are not available everywhere
>> i now replaced the start-stop-daemon calls. however, i left these
>> calls as comments for reference. if the ra proves stable, one can
>> remove them during the next maintanance.
>>
>> thank you for the reference. it saved me some time!
>>
>> changes:
>> * replace debian specific start-stop-daemon calls
>> * protect $pidfile
>> * remove obsolete code/comments
>> * add some more error checking
>>
>> is it ready for initial inclusion now?
>>
>> cheers,
>> raoul
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________________
>> Linux-HA-Dev: Linux-HA-Dev [at] lists
>> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
>> Home Page: http://linux-ha.org/
>
>


--
____________________________________________________________________
DI (FH) Raoul Bhatia M.Sc. email. r.bhatia [at] ipax
Technischer Leiter

IPAX - Aloy Bhatia Hava OEG web. http://www.ipax.at
Barawitzkagasse 10/2/2/11 email. office [at] ipax
1190 Wien tel. +43 1 3670030
FN 277995t HG Wien fax. +43 1 3670030 15
____________________________________________________________________
Attachments: mysql-proxy (9.61 KB)


r.bhatia at ipax

May 26, 2009, 3:53 AM

Post #8 of 11 (1900 views)
Permalink
Re: first shot at a mysql-proxy ocf ra [In reply to]

again, the mysql-proxy script is not behaving as intended.
please forgive me and wait for the next revision.

thanks,
raoul
--
____________________________________________________________________
DI (FH) Raoul Bhatia M.Sc. email. r.bhatia [at] ipax
Technischer Leiter

IPAX - Aloy Bhatia Hava OEG web. http://www.ipax.at
Barawitzkagasse 10/2/2/11 email. office [at] ipax
1190 Wien tel. +43 1 3670030
FN 277995t HG Wien fax. +43 1 3670030 15
____________________________________________________________________
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev [at] lists
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/


r.bhatia at ipax

May 26, 2009, 5:26 AM

Post #9 of 11 (1895 views)
Permalink
Re: first shot at a mysql-proxy ocf ra [In reply to]

Raoul Bhatia [IPAX] wrote:
> again, the mysql-proxy script is not behaving as intended.
> please forgive me and wait for the next revision.

ok, hopefully i resolved all issues. find my current working ra
attached.

i tested it with the ocf-tester using the following command lines:
> * /usr/sbin/ocf-tester -n mp /usr/lib/ocf/resource.d/heartbeat/mysql-proxy
> * /usr/sbin/ocf-tester -n ms -o binary="/usr/sbin/mysql-proxy" -o defaults_file="" -o parameters="--proxy-skip-profiling" \
> -o admin_address="127.0.0.1:4041" -o proxy_backend_addresses="192.168.100.200:42006" \
> -o proxy_address="/var/run/mysqld/mysqld.sock" /usr/lib/ocf/resource.d/heartbeat/mysql-proxy

moreover, i tested the script in my testing environment:
> * adding two mysql-instances (mysql-proxy-tcp and mysql-proxy-socket) and killing mysql-proxy-tcp
> beware, that as of mysql-proxy 0.7.0 (and possibly later), the socket is not automatically removed

please review, test and commit.

thanks,
raoul
--
____________________________________________________________________
DI (FH) Raoul Bhatia M.Sc. email. r.bhatia [at] ipax
Technischer Leiter

IPAX - Aloy Bhatia Hava OEG web. http://www.ipax.at
Barawitzkagasse 10/2/2/11 email. office [at] ipax
1190 Wien tel. +43 1 3670030
FN 277995t HG Wien fax. +43 1 3670030 15
____________________________________________________________________
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev [at] lists
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/


r.bhatia at ipax

May 26, 2009, 5:29 AM

Post #10 of 11 (1913 views)
Permalink
Re: first shot at a mysql-proxy ocf ra [In reply to]

Raoul Bhatia [IPAX] wrote:
> again, the mysql-proxy script is not behaving as intended.
> please forgive me and wait for the next revision.

ok, hopefully i resolved all issues. find my current working ra
attached.

i tested it with the ocf-tester using the following command lines:
> * /usr/sbin/ocf-tester -n mp /usr/lib/ocf/resource.d/heartbeat/mysql-proxy
> * /usr/sbin/ocf-tester -n ms -o binary="/usr/sbin/mysql-proxy" -o defaults_file="" -o parameters="--proxy-skip-profiling" \
> -o admin_address="127.0.0.1:4041" -o proxy_backend_addresses="192.168.100.200:42006" \
> -o proxy_address="/var/run/mysqld/mysqld.sock" /usr/lib/ocf/resource.d/heartbeat/mysql-proxy

moreover, i tested the script in my testing environment:
> * adding two mysql-instances (mysql-proxy-tcp and mysql-proxy-socket) and killing mysql-proxy-tcp
> beware, that as of mysql-proxy 0.7.0 (and possibly later), the socket is not automatically removed

please review, test and commit.

thanks,
raoul
--
____________________________________________________________________
DI (FH) Raoul Bhatia M.Sc. email. r.bhatia [at] ipax
Technischer Leiter

IPAX - Aloy Bhatia Hava OEG web. http://www.ipax.at
Barawitzkagasse 10/2/2/11 email. office [at] ipax
1190 Wien tel. +43 1 3670030
FN 277995t HG Wien fax. +43 1 3670030 15
____________________________________________________________________
Attachments: mysql-proxy (10.5 KB)


dejanmm at fastmail

May 26, 2009, 9:02 AM

Post #11 of 11 (1913 views)
Permalink
Re: first shot at a mysql-proxy ocf ra [In reply to]

Hi,

On Tue, May 26, 2009 at 02:29:19PM +0200, Raoul Bhatia [IPAX] wrote:
> Raoul Bhatia [IPAX] wrote:
> > again, the mysql-proxy script is not behaving as intended.
> > please forgive me and wait for the next revision.
>
> ok, hopefully i resolved all issues. find my current working ra
> attached.
>
> i tested it with the ocf-tester using the following command lines:
> > * /usr/sbin/ocf-tester -n mp /usr/lib/ocf/resource.d/heartbeat/mysql-proxy
> > * /usr/sbin/ocf-tester -n ms -o binary="/usr/sbin/mysql-proxy" -o defaults_file="" -o parameters="--proxy-skip-profiling" \
> > -o admin_address="127.0.0.1:4041" -o proxy_backend_addresses="192.168.100.200:42006" \
> > -o proxy_address="/var/run/mysqld/mysqld.sock" /usr/lib/ocf/resource.d/heartbeat/mysql-proxy
>
> moreover, i tested the script in my testing environment:
> > * adding two mysql-instances (mysql-proxy-tcp and mysql-proxy-socket) and killing mysql-proxy-tcp
> > beware, that as of mysql-proxy 0.7.0 (and possibly later), the socket is not automatically removed
>
> please review, test and commit.

Couldn't test, but I guess that you tested it. Applied.

Many thanks.

Dejan

> thanks,
> raoul
> --
> ____________________________________________________________________
> DI (FH) Raoul Bhatia M.Sc. email. r.bhatia [at] ipax
> Technischer Leiter
>
> IPAX - Aloy Bhatia Hava OEG web. http://www.ipax.at
> Barawitzkagasse 10/2/2/11 email. office [at] ipax
> 1190 Wien tel. +43 1 3670030
> FN 277995t HG Wien fax. +43 1 3670030 15
> ____________________________________________________________________
>

> #!/bin/sh
> #set -x
> #
> # Resource script for MySQL Proxy
> #
> # Description: Manages MySQL Proxy as an OCF resource in
> # an high-availability setup.
> #
> # Tested with mysql-proxy 0.7.0 on Debian 5.0.
> # Based on the mysql and Pure-Ftpd OCF resource agents.
> #
> # Author: Raoul Bhatia <r.bhatia [at] ipax> : Original Author
> # License: GNU General Public License (GPL)
> #
> #
> # usage: $0 {start|stop|status|monitor|validate-all|meta-data}
> #
> # The "start" arg starts a MySQL Proxy instance
> #
> # The "stop" arg stops it.
> #
> # TODO
> # * add error checking like in mysql ocf ra (e.g. socketdir)
> # * verify if mysql-proxy supports multiple --proxy-address(es)
> #
> # Test via
> # */usr/sbin/ocf-tester -n mp /usr/lib/ocf/resource.d/heartbeat/mysql-proxy
> # */usr/sbin/ocf-tester -n ms -o binary="/usr/sbin/mysql-proxy" -o defaults_file="" -o parameters="--proxy-skip-profiling" \
> # -o admin_address="127.0.0.1:4041" -o proxy_backend_addresses="192.168.100.200:42006" \
> # -o proxy_address="/var/run/mysqld/mysqld.sock" /usr/lib/ocf/resource.d/heartbeat/mysql-proxy
> #
> # * adding two mysql-instances (mysql-proxy-tcp and mysql-proxy-socket) and killing mysql-proxy-tcp
> # beware, that as of mysql-proxy 0.7.0 (and possibly later), the socket is not automatically removed
> #
> #
> # OCF parameters:
> # OCF_RESKEY_binary
> # OCF_RESKEY_defaults_file
> # OCF_RESKEY_proxy_backend_addresses
> # OCF_RESKEY_proxy_read_only_backend_addresses
> # OCF_RESKEY_proxy_address
> # OCF_RESKEY_admin_address
> # OCF_RESKEY_parameters
> # OCF_RESKEY_pidfile
> #
> ##########################################################################
>
> # Initialization:
>
> . ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
>
> : ${OCF_RESKEY_binary="/usr/sbin/mysql-proxy"}
> : ${OCF_RESKEY_defaults_file=""}
> : ${OCF_RESKEY_proxy_backend_addresses="127.0.0.1:3306"}
> : ${OCF_RESKEY_proxy_read_only_backend_addresses=""}
> : ${OCF_RESKEY_proxy_address=":4040"}
> : ${OCF_RESKEY_admin_address="127.0.0.1:4041"}
> : ${OCF_RESKEY_parameters=""}
> : ${OCF_RESKEY_pidfile="${HA_RSCTMP}/mysql-proxy-${OCF_RESOURCE_INSTANCE}.pid"}
> USAGE="Usage: $0 {start|stop|reload|status|monitor|validate-all|meta-data}";
>
> ##########################################################################
>
> usage() {
> echo $USAGE >&2
> }
>
> meta_data() {
> cat <<END
> <?xml version="1.0"?>
> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
> <resource-agent name="mysql-proxy">
> <version>0.1</version>
> <longdesc lang="en">
> This script manages MySQL Proxy as an OCF resource in a high-availability setup.
> Tested with MySQL Proxy 0.7.0 on Debian 5.0.
> </longdesc>
> <shortdesc lang="en">OCF Resource Agent compliant MySQL Proxy script.</shortdesc>
>
> <parameters>
>
> <parameter name="binary" unique="1" required="1">
> <longdesc lang="en">
> Full path to the MySQL Proxy binary.
> For example, "/usr/sbin/mysql-proxy".
> </longdesc>
> <shortdesc lang="en">Full path to MySQL Proxy binary</shortdesc>
> <content type="string" default="/usr/sbin/mysql-proxy" />
> </parameter>
>
> <parameter name="defaults_file" unique="1" required="0">
> <longdesc lang="en">
> Full path to a MySQL Proxy configuration file.
> For example, "/etc/mysql-proxy.conf".
> </longdesc>
> <shortdesc lang="en">Full path to configuration file</shortdesc>
> <content type="string" default="" />
> </parameter>
>
> <parameter name="proxy_backend_addresses" unique="0" required="0">
> <longdesc lang="en">
> Address:port of the remote backend-servers (default: 127.0.0.1:3306).
> </longdesc>
> <shortdesc lang="en"></shortdesc>
> <content type="string" default="127.0.0.1:3306" />
> </parameter>
>
> <parameter name="proxy_read_only_backend_addresses" unique="0" required="0">
> <longdesc lang="en">
> Address:port of the remote slave-server (default: not set).
> </longdesc>
> <shortdesc lang="en"></shortdesc>
> <content type="string" default="127.0.0.1:3306" />
> </parameter>
>
> <parameter name="proxy_address" unique="0" required="0">
> <longdesc lang="en">
> Listening address:port of the proxy-server (default: :4040).
> You can also specify a socket like "/tmp/mysql-proxy.sock".
> </longdesc>
> <shortdesc lang="en"></shortdesc>
> <content type="string" default=":4040" />
> </parameter>
>
> <parameter name="admin_address" unique="0" required="0">
> <longdesc lang="en">
> Listening address:port of the admin-server (default: 127.0.0.1:4041).
> </longdesc>
> <shortdesc lang="en"></shortdesc>
> <content type="string" default="127.0.0.1:4041" />
> </parameter>
>
> <parameter name="parameters" unique="1" required="0">
> <longdesc lang="en">
> The MySQL Proxy daemon may be called with additional parameters.
> Specify any of them here.
> </longdesc>
> <shortdesc lang="en"></shortdesc>
> <content type="string" default="" />
> </parameter>
>
> <parameter name="pidfile" unique="0">
> <longdesc lang="en">PID file</longdesc>
> <shortdesc lang="en">PID file</shortdesc>
> <content type="string" default="${HA_RSCTMP}/mysql-proxy-${OCF_RESOURCE_INSTANCE}.pid" />
> </parameter>
>
> </parameters>
>
> <actions>
> <action name="start" timeout="90" />
> <action name="stop" timeout="100" />
> <action name="reload" timeout="100" />
> <action name="monitor" depth="10" timeout="20s" interval="60s" start-delay="1s" />
> <action name="validate-all" timeout="30s" />
> <action name="meta-data" timeout="5s" />
> </actions>
> </resource-agent>
> END
> exit $OCF_SUCCESS
> }
>
> isRunning()
> {
> kill -0 "$1" 2>/dev/null
> }
>
> mysqlproxy_status()
> {
> if [ -f "${pidfile}" ]; then
> # MySQL Proxy is probably running
> PID=`head -n 1 "${pidfile}"`
> if [ ! -z "$PID" ] ; then
> isRunning "$PID"
> return $?
> fi
> fi
>
> # MySQL Proxy is not running
> false
> }
>
> mysqlproxy_start()
> {
> # if MySQL Proxy is running return success
> if mysqlproxy_status ; then
> ocf_log info "MySQL Proxy already running."
> exit $OCF_SUCCESS
> fi
>
> # check that the MySQL Proxy binary exists and can be executed
> if [ ! -x "$binary" ]; then
> ocf_log err "MySQL Proxy binary '$binary' does not exist or cannot be executed."
> exit $OCF_ERR_GENERIC
> fi
>
> # check if the MySQL Proxy defaults-file exist
> PARAM_PREFIX=''
> if [ -f "$defaults_file" ]; then
> PARAM_PREFIX="--defaults-file=$defaults_file "
> fi
>
> # split multiple proxy-address options.
> # currently unsupported but let us hope for the future ;)
> for pa in $proxy_address; do
> [ -z "$pa" ] && continue
> OPTIONS=" $OPTIONS --proxy-address=$pa"
> done
>
> # split multiple proxy-backend-addresses options.
> for pba in $proxy_backend_addresses; do
> [ -z "$pba" ] && continue
> OPTIONS=" $OPTIONS --proxy-backend-addresses=$pba"
> done
>
> # split multiple proxy-backend-addresses options.
> for proba in $proxy_read_only_backend_addresses; do
> [ -z "$proba" ] && continue
> OPTIONS=" $OPTIONS --proxy-read-only-backend-addresses=$proba"
> done
>
> # build $OPTIONS and add addmin-address and pidfile
> OPTIONS="$PARAM_PREFIX $OPTIONS --admin-address=$admin_address --pid-file=${pidfile} $PARAM_SUFFIX"
>
> # start MySQL Proxy
> #start-stop-daemon --start --quiet --pidfile $pidfile --make-pidfile --name mysql-proxy --startas $binary -b -- $OPTIONS
> $binary --daemon $OPTIONS
> ret=$?
>
> if [ $ret -ne 0 ]; then
> ocf_log err "MySQL Proxy returned error." $ret
> exit $OCF_ERR_GENERIC
> fi
>
> exit $OCF_SUCCESS
> }
>
>
> mysqlproxy_stop()
> {
> LA=`mysqlproxy_status`
> if mysqlproxy_status ; then
> #start-stop-daemon --stop --quiet --retry 3 --exec $binary --pidfile $pidfile
> /bin/kill `cat "${pidfile}"`
> ret=$?
>
> if [ $ret -ne 0 ]; then
> ocf_log err "MySQL Proxy returned an error while stopping." $ret
> exit $OCF_ERR_GENERIC
> fi
>
> # grant some time for shutdown and recheck
> sleep 1
> if mysqlproxy_status ; then
> ocf_log err "MySQL Proxy failed to stop."
> exit $OCF_ERR_GENERIC
> fi
>
> # remove dangling socketfile, if specified
> for pa in $proxy_address; do
> if [ -S "$pa" ]; then
> ocf_log info "Removing dangling socket file '$pa'."
> rm -f "$pa"
> fi
> done
>
> # remove dangling pidfile
> if [ -f "${pidfile}" ]; then
> ocf_log info "Removing dangling pidfile '${pidfile}'."
> rm -f "${pidfile}"
> fi
> fi
>
> exit $OCF_SUCCESS
> }
>
> mysqlproxy_reload()
> {
> if mysqlproxy_status; then
> ocf_log info "Reloading MySQL Proxy."
> kill -HUP `cat ${pidfile}`
> fi
> }
>
> mysqlproxy_monitor()
> {
> if mysqlproxy_status ; then
> return $OCF_SUCCESS
> fi
>
> return $OCF_NOT_RUNNING
> }
>
> mysqlproxy_validate_all()
> {
>
> # @TODO
> return $OCF_SUCCESS
> }
>
> #
> # Main
> #
>
> if [ $# -ne 1 ]; then
> usage
> exit $OCF_ERR_ARGS
> fi
>
> pidfile=$OCF_RESKEY_pidfile
> binary=$OCF_RESKEY_binary
> defaults_file=$OCF_RESKEY_defaults_file
> proxy_backend_addresses=$OCF_RESKEY_proxy_backend_addresses
> proxy_read_only_backend_addresses=$OCF_RESKEY_proxy_read_only_backend_addresses
> admin_address=$OCF_RESKEY_admin_address
> proxy_address=$OCF_RESKEY_proxy_address
>
> # debugging stuff
> #echo OCF_RESKEY_binary=$OCF_RESKEY_binary >> /tmp/prox_conf_$OCF_RESOURCE_INSTANCE
> #echo OCF_RESKEY_defaults_file=$OCF_RESKEY_defaults_file >> /tmp/prox_conf_$OCF_RESOURCE_INSTANCE
> #echo OCF_RESKEY_proxy_backend_addresses=$OCF_RESKEY_proxy_backend_addresses >> /tmp/prox_conf_$OCF_RESOURCE_INSTANCE
> #echo OCF_RESKEY_proxy_read_only_backend_addresses=$OCF_RESKEY_proxy_read_only_backend_addresses >> /tmp/prox_conf_$OCF_RESOURCE_INSTANCE
> #echo OCF_RESKEY_proxy_address=$OCF_RESKEY_proxy_address >> /tmp/prox_conf_$OCF_RESOURCE_INSTANCE
> #echo OCF_RESKEY_admin_address=$OCF_RESKEY_admin_address >> /tmp/prox_conf_$OCF_RESOURCE_INSTANCE
> #echo OCF_RESKEY_parameters=$OCF_RESKEY_parameters >> /tmp/prox_conf_$OCF_RESOURCE_INSTANCE
> #echo OCF_RESKEY_pidfile=$OCF_RESKEY_pidfile >> /tmp/prox_conf_$OCF_RESOURCE_INSTANCE
>
>
> case $1 in
> start) mysqlproxy_start
> ;;
>
> stop) mysqlproxy_stop
> ;;
>
> reload) mysqlproxy_reload
> ;;
>
> status) if mysqlproxy_status; then
> ocf_log info "MySQL Proxy is running."
> exit $OCF_SUCCESS
> else
> ocf_log info "MySQL Proxy is stopped."
> exit $OCF_NOT_RUNNING
> fi
> ;;
>
> monitor) mysqlproxy_monitor
> exit $?
> ;;
>
> validate-all) mysqlproxy_validate_all
> exit $?
> ;;
>
> meta-data) meta_data
> ;;
>
> usage) usage
> exit $OCF_SUCCESS
> ;;
>
> *) usage
> exit $OCF_ERR_UNIMPLEMENTED
> ;;
> esac
>

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

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

Linux-HA dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.