public inbox for cluster-cvs@sourceware.org help / color / mirror / Atom feed
From: Lon Hohberger <lon@fedoraproject.org> To: cluster-cvs-relay@redhat.com Subject: cluster: STABLE3 - rgmanager: Add resource agent for DRBD Date: Thu, 09 Jul 2009 17:31:00 -0000 [thread overview] Message-ID: <20090709173018.78F0A1201FE@lists.fedorahosted.org> (raw) Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=bd8dc44918a9ee71e3f8aa1c705eacd610a9b7de Commit: bd8dc44918a9ee71e3f8aa1c705eacd610a9b7de Parent: 6b751d048dd2068c5c62019b675d0d3699409a63 Author: Florian Haas <florian.haas@linbit.com> AuthorDate: Thu Jul 2 10:49:39 2009 +0200 Committer: Lon Hohberger <lhh@redhat.com> CommitterDate: Thu Jul 9 13:29:59 2009 -0400 rgmanager: Add resource agent for DRBD DRBD (www.drbd.org) is a shared-nothing synchronous storage replication capable of acting as a drop-in replacement for shared storage. This resource agent manages a DRBD device by switching it into the Primary and Secondary roles as needed. For a configuration example, please see http://www.drbd.org/users-guide/s-rhcs-failover-clusters.html Signed-off-by: Lon Hohberger <lhh@redhat.com> --- rgmanager/src/resources/Makefile | 4 +- rgmanager/src/resources/drbd.metadata | 51 ++++++++++++ rgmanager/src/resources/drbd.sh | 144 +++++++++++++++++++++++++++++++++ 3 files changed, 197 insertions(+), 2 deletions(-) diff --git a/rgmanager/src/resources/Makefile b/rgmanager/src/resources/Makefile index 08d5489..8d79cbe 100644 --- a/rgmanager/src/resources/Makefile +++ b/rgmanager/src/resources/Makefile @@ -12,11 +12,11 @@ RESOURCES=service.sh ip.sh nfsclient.sh nfsexport.sh \ apache.sh openldap.sh samba.sh mysql.sh \ postgres-8.sh tomcat-5.sh lvm.sh \ vm.sh SAPInstance SAPDatabase named.sh \ - ASEHAagent.sh + ASEHAagent.sh drbd.sh METADATA=apache.metadata openldap.metadata samba.metadata \ mysql.metadata postgres-8.metadata tomcat-5.metadata \ - named.metadata lvm.metadata + named.metadata lvm.metadata drbd.metadata EVENT_TARGETS= \ default_event_script.sl \ diff --git a/rgmanager/src/resources/drbd.metadata b/rgmanager/src/resources/drbd.metadata new file mode 100644 index 0000000..30fe122 --- /dev/null +++ b/rgmanager/src/resources/drbd.metadata @@ -0,0 +1,51 @@ +<?xml version="1.0" ?> +<resource-agent version="rgmanager 2.0" name="drbd"> + <version>1.0</version> + + <longdesc lang="en"> + This is a DRBD resource. The resource must be configured + in the configuration file (/etc/drbd.conf), and the + DRBD kernel module must be loaded. + </longdesc> + + <shortdesc lang="en"> + This is a DRBD resource. + </shortdesc> + + <parameters> + <parameter name="name" unique="1" primary="1"> + <longdesc lang="en"> + Symbolic name for this resource. + </longdesc> + <shortdesc lang="en"> + Cluster resource name + </shortdesc> + <content type="string"/> + </parameter> + <parameter name="resource" unique="1" required="1"> + <longdesc lang="en"> + The DRBD resource name, as specified in /etc/drbd.conf. + </longdesc> + <shortdesc lang="en"> + DRBD resource name + </shortdesc> + <content type="string"/> + </parameter> + </parameters> + + <actions> + <action name="start" timeout="20"/> + <action name="stop" timeout="20"/> + + <!-- Checks to see if the resource is Primary locally --> + <action name="status" depth="10" interval="60" timeout="20"/> + <action name="monitor" depth="10" interval="60" timeout="20"/> + + <action name="meta-data" timeout="20"/> + <action name="verify-all" timeout="20"/> + </actions> + + <special tag="rgmanager"> + <attributes maxinstances="1"/> + </special> +</resource-agent> diff --git a/rgmanager/src/resources/drbd.sh b/rgmanager/src/resources/drbd.sh new file mode 100644 index 0000000..4571660 --- /dev/null +++ b/rgmanager/src/resources/drbd.sh @@ -0,0 +1,144 @@ +#!/bin/bash +# +# Copyright LINBIT, 2008 +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. If not, write to the +# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, +# MA 02139, USA. +# + +# +# DRBD resource management using the drbdadm utility. +# + +LC_ALL=C +LANG=C +PATH=/bin:/sbin:/usr/bin:/usr/sbin +export LC_ALL LANG PATH + +. $(dirname $0)/ocf-shellfuncs + +drbd_verify_all() +{ + # Do we have the drbdadm utility? + if ! which drbdadm >/dev/null 2>&1 ; then + ocf_log error "drbdadm not installed, not found in PATH ($PATH), or not executable." + return $OCF_ERR_INSTALLED + fi + + # Is drbd loaded? + if ! grep drbd /proc/modules >/dev/null 2>&1; then + ocf_log error "drbd not found in /proc/modules. Do you need to modprobe?" + return $OCF_ERR_INSTALLED + fi + + # Do we have the "resource" parameter? + if [ -n "$OCF_RESKEY_resource" ]; then + + # Can drbdadm parse the resource name? + if ! drbdadm sh-dev $OCF_RESKEY_resource >/dev/null 2>&1; then + ocf_log error "DRBD resource \"$OCF_RESKEY_resource\" not found." + return $OCF_ERR_CONFIGURED + fi + + # Is the backing device a locally available block device? + backing_dev=$(drbdadm sh-ll-dev $OCF_RESKEY_resource) + if [ ! -b $backing_dev ]; then + ocf_log error "Backing device for DRBD resource \"$OCF_RESKEY_resource\" ($backing_dev) not found or not a block device." + return $OCF_ERR_INSTALLED + fi + + fi + + return 0 +} + +drbd_status() { + role=$(drbdadm role $OCF_RESKEY_resource) + case $role in + Primary/*) + return $OCF_RUNNING + ;; + Secondary/*) + return $OCF_NOT_RUNNING + ;; + + esac + return $OCF_ERR_GENERIC +} + +drbd_promote() { + drbdadm primary $OCF_RESKEY_resource || return $? +} + +drbd_demote() { + drbdadm secondary $OCF_RESKEY_resource || return $? +} + + +if [ -z "$OCF_CHECK_LEVEL" ]; then + OCF_CHECK_LEVEL=0 +fi + +# This one doesn't need to pass the verify check +case $1 in + meta-data) + cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'` && exit 0 + exit $OCF_ERR_GENERIC + ;; +esac + +# Everything else does +drbd_verify_all || exit $? +case $1 in + start) + if drbd_status; then + ocf_log debug "DRBD resource ${OCF_RESKEY_resource} already configured" + exit 0 + fi + drbd_promote + if [ $? -ne 0 ]; then + exit $OCF_ERR_GENERIC + fi + + exit $? + ;; + stop) + if drbd_status; then + drbd_demote + if [ $? -ne 0 ]; then + exit $OCF_ERR_GENERIC + fi + else + ocf_log debug "DRBD resource ${OCF_RESKEY_resource} is not configured" + fi + exit 0 + ;; + status|monitor) + drbd_status + exit $? + ;; + restart) + $0 stop || exit $OCF_ERR_GENERIC + $0 start || exit $OCF_ERR_GENERIC + exit 0 + ;; + verify-all) + exit 0 + ;; + *) + echo "usage: $0 {start|stop|status|monitor|restart|meta-data|verify-all}" + exit $OCF_ERR_GENERIC + ;; +esac
reply other threads:[~2009-07-09 17:31 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20090709173018.78F0A1201FE@lists.fedorahosted.org \ --to=lon@fedoraproject.org \ --cc=cluster-cvs-relay@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).