[DRBD-user] heartbeat + drbd + apache

Diego Julian Remolina diego.remolina at ibb.gatech.edu
Tue Feb 14 14:56:30 CET 2006

Note: "permalinks" may not be as permanent as we would like,
direct links of old sources may well be a few messages off.


There are two ways.

1. Using symbolic links
Let's say that you mount your drbd partition in /web and that you have a folder called www for your 
files.
On drbd primary
mkdir -p /web/var
cp -rp /var/www /web/var/
Now you have copied all www files to /web/var

mv /var/www /var/www.bak
I like keeping copies, don't you?

ln -s /web/var/www /var/www

On the secondary there is no /web/var/www since /web cannot be mounted when the machine is in drbd 
secondary state, so you have to do:

mv /var/www /var/www.bak
ln -sf /web/var/www /var/www

You do the same thing for /etc/httpd so that you only need to modify the config file on one machine 
and if it goes down, the second machine will have the same configuration file since it lives in the 
drbd partition under /web/etc/httpd.

2. Put a new etc, var, www folders on your drbd partition and make httpd read its configuration from 
there. This is done by modifying the init scripts to tell it to use the configuration files from a 
specific directory.  If you use Fedora Core or RHEL, then this can be done without touching the init 
script /etc/init.d/httpd, by modifying /etc/sysconfig/httpd
The Red Hat distros make /etc/init.d/httpd read the file /etc/sysconfig/httpd for aditional 
configuration options, so I added the line:

OPTIONS="-f /web/etc/httpd/conf/httpd.conf"

This means that every time that httpd is started, it is reading its configuration from:
/web/etc/httpd/conf/httpd.conf
Since /web is the mounted drbd partition, then when the server switches, the other node will have 
all apache configuration files as well to run the web server. You will also need to modify 
httpd.conf and any other configuration files to point to /web/var/www, /web/var/logs/https, etc

The downside of option #1 is that if your package managment software is not careful enough, next 
time you update a package, your symbolic link can be blown and you will need to recreate it again.

The downside to option #2 is that if you have to put the entry directly in your /etc/init.d/httpd 
script (non Red Hat distros may need it done this way), then upon a package upgrade the init script 
may be overwritten and you will need to modify it again to make sure it reads httpd.conf from: 
/web/etc/httpd/conf/httpd.conf

Diego

Christophe Mailhebuau wrote:
> Hi,
> 
> Do you know a howto to replicate /var/www on master and slave server
> with heartbeat ?
> 
> I installing drbd and he running successful.
> 
> I just need configuring heartbeat
> 
> thank for you help.
> 




More information about the drbd-user mailing list