On Fri, Jul 02, 2010 at 12:16:03AM +0200, Marek Marczykowski wrote:
> On Thu, Jul 01, 2010 at 05:42:00PM +0200, Dejan Muhamedagic wrote:
> > On Tue, Jun 29, 2010 at 06:53:23PM +0200, Marek Marczykowski wrote:
> > > --- mysql-05      2010-06-29 18:23:43.806105971 +0200
> > > +++ mysql 2010-06-29 18:23:55.882104463 +0200
> > > @@ -730,6 +730,19 @@
> > >   # don't know what master to replicate from), we simply start
> > >   # in read only mode.
> > >   set_read_only on
> > > +
> > > + master_host=`echo $OCF_RESKEY_CRM_meta_notify_master_uname|tr -d " "`
> > > + if [ "$master_host" -a "$master_host" != `uname -n` ]; then
> > > +     ocf_log info "Changing MySQL configuration to replicate from 
> > > $master_host."
> > > +     set_master $master_host
> > > +     ocf_run $MYSQL $MYSQL_OPTIONS_LOCAL $MYSQL_OPTIONS_REPL \
> > > +         -e "SLAVE START"
> > > +     if [ $? -ne 0 ]; then
> > > +         ocf_log err "Failed to start slave";
> > > +         return $OCF_ERR_GENERIC;
> > > +     fi
> > > + fi
> > > +
> > >   # We also need to set a master preference, otherwise Pacemaker
> > >   # won't ever promote us in the absence of any explicit
> > >   # preference set by the administrator. We choose a low
> > 
> > This part I don't understand. set_master does:
> > 
> > ocf_run $MYSQL $MYSQL_OPTIONS_LOCAL $MYSQL_OPTIONS_REPL ...
> 
> It does only "CHANGE MASTER TO ..." - set from which master replicate, but
> do not start it. When called from pre-promote, we start replication from
> post-promote, so this function cannot "START SLAVE".
> 
> > and then you have the same thing repeated afterwards:
> > 
> > > +     ocf_run $MYSQL $MYSQL_OPTIONS_LOCAL $MYSQL_OPTIONS_REPL ...
> > > +         -e "SLAVE START"
> > 
> > Otherwise, set_master is invoked in pre-promote(). This patch
> > invokes it from the start operation. Is that a duplicate?
> 
> No. This is used on new slave start when master already exists. In this
> situation it doesn't receive pre-promote notification. Or maybe I'm
> wrong?
> 
> > I also don't understand why that function is called set_master
> > when it's all about the slave replication.
> 
> This function point slave what master replicate from.

In addition to patch above ([1]) it is also needed to disable replication
after mysql start when there is no master node (only slaves). Without
this monitor action fails (replication started, but not connected to any
master). Patch attached (and also available in [2]).

From comment in mysql script:
# Since we can't start as a MySQL slave (we
# don't know what master to replicate from), we simply start
# in read only mode.

We know master (if any exists). It is available in
$OCF_RESKEY_CRM_meta_notify_master_uname and this patch ([1]) use this
knowledge.

[1]
http://marmarek.w.staszic.waw.pl/patches/ha-mysql-ra/06_mysql-ra-slave-start-replication.patch
[2]
http://marmarek.w.staszic.waw.pl/patches/ha-mysql-ra/09_mysql-ra-disable-slave-on-no-master.patch

-- 
Best Regards,
Marek Marczykowski          |   gg:2873965      | RLU #390519
marmarek at staszic waw pl  | xmpp:marmarek at staszic waw pl

--- /usr/lib/ocf/resource.d/heartbeat/mysql-repl.orig   2010-07-20 
04:32:01.681369222 +0200
+++ /usr/lib/ocf/resource.d/heartbeat/mysql-repl        2010-07-20 
04:33:06.374301483 +0200
@@ -802,6 +802,9 @@
                ocf_log err "Failed to start slave";
                return $OCF_ERR_GENERIC;
            fi
+       else 
+           ocf_log info "No MySQL master present - clearing replication state"
+           unset_master
        fi
 
        # We also need to set a master preference, otherwise Pacemaker

Attachment: smime.p7s
Description: S/MIME cryptographic signature

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

Reply via email to