This chapter contains instructions for configuring Red Hat Enterprise Linux AS to make the Apache Web server highly available.
This section provides an example of setting up a cluster service that will fail over an Apache Web server. Although the actual variables used in the service depend on the specific configuration, the example may assist in setting up a service for a particular environment.
To set up an Apache service, you must configure both cluster systems as Apache servers. The cluster software ensures that only one cluster system runs the Apache software at one time. The Apache configuration will consist of installing the apache RPM packages on both cluster members and configuring a shared filesystem to house the web site's content.
When installing the Apache software on the cluster systems, do not configure the cluster systems so that Apache automatically starts when the system boots by performing the following command: chkconfig --del httpd. Rather than having the system startup scripts spawn httpd, the cluster infrastructure will do that on the active cluster server for the Apache service. This will ensure that the corresponding IP address and filesystem mounts are active on only one cluster member at a time.
When adding an Apache service, a "floating" IP address must be assigned to it. The cluster infrastructure binds this IP address to the network interface on the cluster system that is currently running the Apache service. This IP address ensures that the cluster system running the Apache software is transparent to the HTTP clients accessing the Apache server.
The file systems that contain the Web content must not be automatically mounted on shared disk storage when the cluster systems boot. Instead, the cluster software must mount and unmount the file systems as the Apache service is started and stopped on the cluster systems. This prevents both cluster systems from accessing the same data simultaneously, which may result in data corruption. Therefore, do not include the file systems in the /etc/fstab file.
Setting up an Apache service involves the following four steps:
Set up the shared file system for the service. This filesystem is used to house the website's content.
Install the Apache software on both cluster systems.
Configure the Apache software on both cluster systems.
Add the service to the cluster database.
To set up the shared file systems for the Apache service, perform the following tasks as root user on one cluster system:
On a shared disk, use the interactive fdisk utility to create a partition that will be used for the Apache document root directory. Note that it is possible to create multiple document root directories on different disk partitions. See the Section called Partitioning Disks in Chapter 2 for more information.
Use the mkfs command to create an ext2 file system on the partition you created in the previous step. Specify the drive letter and the partition number. For example:
Mount the file system that will contain the Web content on the Apache document root directory. For example:
mount /dev/sde3 /var/www/html
Do not add this mount information to the /etc/fstab file, because only the cluster software can mount and unmount file systems used in a service.
Copy all the required files to the document root directory.
If you have CGI files or other files that must be in different directories or is separate partitions, repeat these steps, as needed.
Apache must be installed on both cluster systems. Note that the basic Apache server configuration must be the same on both cluster systems in order for the service to fail over correctly. The following example shows a basic Apache Web server installation, with no third-party modules or performance tuning. To install Apache with modules, or to tune it for better performance, see the Apache documentation that is located in the Apache installation directory, or on the Apache Web site, http://httpd.apache.org/docs-project/.
On both cluster systems, install the Apache RPMs. For example:
rpm -Uvh apache-1.3.20-16.i386.rpm
To configure the cluster systems as Apache servers, customize the httpd.conf Apache configuration file, and create a script that will start and stop the Apache service. Then, copy the files to the other cluster system. The files must be identical on both cluster systems in order for the Apache service to fail over correctly.
On one system, perform the following tasks:
Edit the /etc/httpd/conf/httpd.conf Apache configuration file and customize the file according to your configuration. For example:
Specify the directory that will contain the HTML files. You will specify this mount point when adding the Apache service to the cluster database. It is only required to change this field if the mountpoint for the web site's content differs from the default setting of /var/www/html. For example:
If the script directory resides in a non-standard location, specify the directory that will contain the CGI programs. For example:
ScriptAlias /cgi-bin/ "/mnt/apacheservice/cgi-bin/"
Specify the path that was used in the previous step, and set the access permissions to default to that directory. For example:
<Directory mnt/apacheservice/cgi-bin"> AllowOverride None Options None Order allow,deny Allow from all </Directory>
Additional changes may need to be made in order to tune Apache or add third-party module functionality,. For information on setting up other options, refer to the Apache project documentation on the Apache Web site, http://httpd.apache.org/docs-project/.
The standard Apache start script, /etc/rc.d/init.d/httpd will also be used within the cluster framework to start and stop the Apache server on the active cluster member. Accordingly, when configuring the service, specify that script when prompted for the User script.
Depending on the release version, the default Apache service script /etc/rc.d/init.d/httpd may not correctly return the status of the httpd daemons in response to service httpd status commands. This precludes correct operation of the cluster's monitoring of this service (if optionally designating a monitoring interval when configuring the service). The status clause of this script may appear as follows:
If this is the case, in order to make service monitoring of Apache work properly, add an additional line as follows to the status clause:
Before the Apache service is added to the cluster database, ensure that the Apache directories are not mounted. Then, on one cluster system, add the service. Specify an IP address, which the cluster infrastructure will bind to the network interface on the cluster system that runs the Apache service.
The following is an example of using the cluadmin utility to add an Apache service.
cluadmin> service add apache The user interface will prompt you for information about the service. Not all information is required for all services. Enter a question mark (?) at a prompt to obtain help. Enter a colon (:) and a single-character command at a prompt to do one of the following: c - Cancel and return to the top-level cluadmin command r - Restart to the initial prompt while keeping previous responses p - Proceed with the next prompt Preferred member [None]: devel0 Relocate when the preferred member joins the cluster (yes/no/?) \ [no]: yes User script (e.g., /usr/foo/script or None) [None]: \ /etc/rc.d/init.d/httpd Do you want to add an IP address to the service (yes/no/?): yes IP Address Information IP address: 10.1.16.150 Netmask (e.g. 255.255.255.0 or None) [None]: 255.255.255.0 Broadcast (e.g. X.Y.Z.255 or None) [None]: 10.1.16.255 Do you want to (a)dd, (m)odify, (d)elete or (s)how an IP address, or are you (f)inished adding IP addresses: f Do you want to add a disk device to the service (yes/no/?): yes Disk Device Information Device special file (e.g., /dev/sda1): /dev/sdb3 Filesystem type (e.g., ext2, reiserfs, ext3 or None): ext3 Mount point (e.g., /usr/mnt/service1 or None) [None]: /var/www/html Mount options (e.g., rw, nosuid): rw Forced unmount support (yes/no/?) [no]: yes Do you want to (a)dd, (m)odify, (d)elete or (s)how devices, or are you (f)inished adding device information: f Disable service (yes/no/?) [no]: no name: apache disabled: no preferred node: node1 relocate: yes user script: /etc/rc.d/init/httpd IP address 0: 10.1.16.150 netmask 0: 255.255.255.0 broadcast 0: 10.1.16.255 device 0: /dev/sde3 mount point, device 0: /var/www/html mount fstype, device 0: ext3 mount options, device 0: rw,sync force unmount, device 0: yes owner, device 0: nobody group, device 0: nobody Add apache service as shown? (yes/no/?) y Added apache. cluadmin>
The Red Hat Cluster Manager GUI can not be used on clusters where high-availability Apache services are configured. Refer to Chapter 9 for more information.