You might rightly think that the active/passive scenario is rather inefficient, because assuming your systems are generally reliable, you have a perfectly good server sitting doing nothing. Therefore, you might prefer to balance the load somewhat using an active/active configuration, where one node "normally" runs some services, and the other node "normally" runs some other (different) services. (See also A Two IP address Active/Active Configuration)
There are a couple of things you need to bear in mind before doing this:
If one node can comfortably cope with the load of running all the services, there isn't necessarily much point in trying to split them. However:
If one node can't cope with the load, then consider what's going to happen when you need to failover all services to one node
(these considerations are general to HA, not DRBD-specific)
However, assuming this is what you want to do, and that the services running on each node each require a shared filesystem (i.e. DRBD), then you need to take the following steps:
Make sure you have separate DRBD resources (drbd0, drbd1...) set up. Since it's not currently possible with DRBD to have a shared filesystem mounted on both primary and secondary nodes (unless you simulate it using cross-mounting with NFS or similar, which is way beyond the scope of this document), we need to separate the filesystem into groups according to which applications are going to be "grouped" together on the nodes when both nodes are up. For maximum flexibility in assigning nodes to applications, you might well want to have a DRBD share per application, assuming of course that no two applications need to access the same share.
If the DRBD devices are on the same disk spindle, use sync groups to ensure that DRBD sync happens at a reasonable speed
Configure Heartbeat appropriately
Let's run through these steps. We'll assume by way of example that you want to run MySQL and Apache. You need one DRBD share for the MySQL data, and one for the Apache data. The nodes will be called 'node1' and 'node2'. We decide to configure it as follows:
share
DRBD resource
DRBD device
Physical device
mountpoint
Apache
r0
/dev/drbd0
/dev/sda1
/ha/web
MySQL
r1
/dev/drbd1
/dev/sda2
/ha/mysql
/dev/drbdX have been /dev/nbX in drbd-0.6.x and older, see also DRBD/QuickStart07
Let's assume, to complicate things, that you have a limited number of physical disks and therefore are forced to have drbd0 and drbd1 on the same spindle (i.e. same hard disk) as shown in the table above (both resources are on /dev/sda in this case). This isn't ideal, but is OK thanks to the 'sync-groups' option. This governs the order in which DRBD resources synchronise (normally, they would sync in parallel, which is going to kill performance if you have got two resources on one disk as the drive would be constantly seeking backwards and forwards reading/writing from/to the two resources). So we use sync-groups to make one resource sync first. It doesn't really matter which goes first. Here's a snippet of a possible drbd.conf. NOTE Only the relevant options are shown here for clarity; you need all your usual options such as disk-size, sync-max etc. in there too:
Syntax was different with drbd-0.6
Just adopting the well commented example drbd.conf to your needs should be easy, though.
# Our web share
resource web {
protocol C;
incon-degr-cmd "echo '!DRBD! pri on incon-degr' | wall ; sleep 60 ; halt -f";
startup { wfc-timeout 0; degr-wfc-timeout 120; }
disk { on-io-error detach; } # or panic, ...
syncer {
group 0;
rate 6M;
}
on node1 {
device /dev/drbd0;
disk /dev/sda1;
address 192.168.99.1:7788;
meta-disk /dev/sdb1[0];
}
on node2 {
device /dev/drbd0;
disk /dev/sda1;
address 192.168.99.2:7788;
meta-disk /dev/sdb1[0];
}
}
# Our MySQL share
resource db {
protocol C;
incon-degr-cmd "echo '!DRBD! pri on incon-degr' | wall ; sleep 60 ; halt -f";
startup { wfc-timeout 0; degr-wfc-timeout 120; }
disk { on-io-error detach; } # or panic, ...
syncer {
group 1;
rate 6M;
}
on node1 {
device /dev/drbd1;
disk /dev/sda2;
address 192.168.99.1:7789;
meta-disk /dev/sdb1[1];
}
on node2 {
device /dev/drbd1;
disk /dev/sda2;
address 192.168.99.2:7789;
meta-disk /dev/sdb1[1];
}
}
In the above example, drbd0 will sync first and drbd1 second.
Now, for the heartbeat config. The resources section in haresources is going to look something like this: (you're probably going to need other resources too, like for example IP addresses; this is a simple example)
node1 drbddisk::web Filesystem::/dev/drbd0::/ha/web::ext3 httpd
node2 drbddisk::db Filesystem::/dev/drbd1::/ha/mysql::ext3 mysqld
Note how node1 will "normally" run Apache using the drbd0 resource, and node2 will "normally" run MySQL with the drbd1 resource. If failover occurs, obviously one node will run both, and become DRBD primary for both resources (and have both shares mounted).
Keeping config files in syncAn obvious question you might ask is "how do I keep config files in sync, e.g. for Apache". The simple answer is that you should probably look at using rsync, scp or some other similar method to keep your configs in sync.
If you have many config files (or "cluster files") to keep in sync over arbitrary many hosts, have a look at csync2 by LinBit
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment