Customers have always asked me to make NDB Cluster starts automatically upon startup of the servers. For the ones who know NDB Cluster, it is tricky to make it starts automatically. I know at least 2 sets of scripts to manage NDB startup, ndb-initializer and from Johan configurator www.severalnines.com. If all the nodes come up at about the same time, it is not too bad but what if one the critical node takes much longer to start because of an fsck on a large ext3 partition. Then, a startup script becomes a nightmare. Finally, if the box on which the script is supposed to run didn’t start at all. That’s a lot of rules to handle.

Since all aspects of HA interest me, I was recently reading the Pacemaker documentation and I realized that Pacemaker has all the logic required to manage NDB Cluster startup. Okay it might seems weird to control a cluster by cluster but if you think about it, this is, I think, the best solution.

The Linux-HA project has split the old Heartbeat-2 project in 2 parts, the clustering and communication layer, Heartbeat and the resources manager, Pacemaker. A key new features that has been added to Pacemaker recently, a Clone resources set, that allows an optional startup if only one of 2 similar resources starts. I use this feature to start the data nodes. If after a major outage, only one of the physical host where the data nodes are located comes up, the cluster will start. The other features of Pacemaker that I need are resource location rsc_location and resource ordering rsc_order.

Let’s start by the beginning. My NDB cluster is made of the following 3 nodes:

  • testvirtbox: ndb_mgmd (10.2.2.139)
  • test1: ndbd
  • test2: ndbd

For the sake of simplicity, I am not considering the SQL nodes but given the framework, extending to SQL nodes is trivial. Installing Pacemaker and Heartbeat is very easy on Lucid Lynx, just do the following:

On other distributions, you might have to build from sources, look here for help.

There 2 minimal configuration files:

And then, Heartbeat can be started on all nodes with /etc/init.d/heartbeat start.

Next, since Pacemaker is used to start resources and not to manage them, we don’t need to define Stonith devices so (run on only one node):

A last before defining resources, since the Heartbeat cluster is asymmetrical, meaning resources will not be able to run anywhere, we must create an “Opt-In” cluster with (run on only one node):

At this point, we have a running cluster controlling nothing. The trick with NDB Cluster is that Heartbeat is required to start the resources but not to stop them. In order to achieve this behavior, I created fake resource scripts that can be fully controlled by Heartbeat but allowing the one way behavior I wanted.

With Pacemaker it is not longer required to manipulate the cib in xml format but for this post, xml offers a compact way of presenting the configuration. The first things we need to define are the resources. A very handy resource type for us is the anything resource which allow an arbitrary script or binary to be run. The resources section will look like:

Please note the ndbd resource is defined through the use of a clone set. The clone set will allow the cluster to start even if only one to the ndb node group is available. If you have multiple ndb node groups, you’ll need one clone set per node group. The ndb_mgmd nodes or eventual SQL nodes could have been handled the same way although for SQL nodes, ndb_waiter is very handy. Once the resources are defined, we need to setup the constraints which cover mandatory locations and ordering.

And… that’s it. For my part, I configured Pacemaker by dumping the cib in xml format, editing and reloading. In term of commands, it means:

Once NDB is started, you can even stop heartbeat, it is no longer required.

P.S.:

As suggested by Florian, here is the configuration in CLI format:

10 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Florian Haas

Goodness, Yves! Please stop scaring people with XML dumps. 🙂 “crm configure show” dumps will do just fine, be much more concise, and easier to read.

Erkan

great post!
erkules;)

Didier

Any specific reasons to pick heartbeat instead of OpenAIS/corosync? While still compatible with heartbeat, pacemaker was rather designed with OpenAIS in mind …

Florian Haas

@Didier: sorry, that’s plain wrong. Pacemaker is a spin-off of the Linux-HA project (it’s the continuation of the CRM effort in Heartbeat 2, albeit in a separate project for various good reasons). It supports both messaging layers just fine.

Didier

@Florian: that’s right. Apologies.

Magnus

You can also use MySQL Cluster Manager – http://www.mysql.com/products/database/cluster/mcm/ – or Solaris Cluster – http://www.sun.com/software/solaris/cluster/ – to manage a MySQL Cluster.

laneovcc

I find u really like ocf:heartbeat:anything ……

but i think it’s better to use lsb:[xxx] which can use script in the /etc/init.d/[xxx], then you can add ‘sleep words’ in the start() :)

pacemaker is really powerfull.

remsnet

Yves ,

Geat work …….

Got it to work on raspberry PI Model B Together with SQL loadbalaning witz ldirectord managed by crm/corosync

2 Pi´s for ndb/sql
2 Pi´s for the LB
2 Pi´s for the WEB

regards