Chinaunix首页 | 论坛 | 博客
  • 博客访问: 383203
  • 博文数量: 146
  • 博客积分: 7142
  • 博客等级: 少将
  • 技术积分: 975
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-03 09:43
文章分类

全部博文(146)

文章存档

2012年(1)

2011年(5)

2010年(24)

2009年(116)

我的朋友

分类: LINUX

2009-12-23 22:44:45

Example of Setting Up Apache HTTP Server

The example describes how to set up a service to fail over an Apache HTTP Server. Variables in the example apply to this example only; they are provided to assist setting up a service that suits your requirements.

1. Apache HTTP Server Setup Overview

First, configure Apache HTTP Server on all nodes in the cluster. If using a failover domain assign the service to all cluster nodes configured to run the Apache HTTP Server. The cluster software ensures that only one cluster system runs the Apache HTTP Server at one time. The example configuration consists of installing the httpd RPM package on all cluster nodes (or on nodes in the failover domain, if used) and configuring a shared GFS shared resource for the Web content.

When installing the Apache HTTP Server on the cluster systems, run the following command to ensure that the cluster nodes do not automatically start the service when the system boots:

# chkconfig --del httpd

When adding an httpd service, a floating IP address must be assigned to the service so that the IP address will transfer from one cluster node to another in the event of failover or service relocation. The cluster infrastructure binds this IP address to the network interface on the cluster system that is currently running the Apache HTTP Server. This IP address ensures that the cluster node running httpd is transparent to the clients accessing the service.

The file systems that contain the Web content cannot be automatically mounted on the shared storage resource when the cluster nodes boot. Instead, the cluster software must mount and unmount the file system as the httpd service is started and stopped. This prevents the clustersystems from accessing the same data simultaneously, which may result in data corruption. Therefore, do not include the file systems in the /etc/fstab file.

2. Configuring Shared Storage

To set up the shared file system resource, perform the following tasks as root on one cluster system:

1. On one cluster node, use the interactive parted utility to create a partition to use for the document root directory. Note that it is possible to create multiple document root directories on different disk partitions.

2. Use the mkfs command to create an ext3 file system on the partition you created in the previous step. Specify the drive letter and the partition number. For example:

# mkfs -t ext3 /dev/sde3

3. Mount the file system that contains the 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.

4. Copy all the required files to the document root directory.

5. If you have CGI files or other files that must be in different directories or in separate partitions, repeat these steps, as needed.

3. Installing and Configuring the Apache HTTP Server

The Apache HTTP Server must be installed and configured on all nodes in the assigned failover domain, if used, or in the cluster. The basic server configuration must be the same on all nodes on which it runs for the service to fail over correctly. The following example shows a basic Apache HTTP Server installation that includes no third-party modules or performance tuning. On all node in the cluster (or nodes in the failover domain, if used), install the httpd RPM package. For example:

rpm -Uvh httpd-..rpm

To configure the Apache HTTP Server as a cluster service, perform the following tasks:

1. Edit the /etc/httpd/conf/httpd.conf configuration file and customize the file according toyour configuration. For example:

• Specify the directory that contains the HTML files. Also specify this mount point when adding the service to the cluster configuration. It is only required to change this field if the mount point for the web site's content differs from the default setting of /var/www/html/.

For example:

DocumentRoot "/mnt/httpdservice/html"

• Specify a unique IP address to which the service will listen for requests. For example:

Listen 192.168.1.100:80

This IP address then must be configured as a cluster resource for the service using the Cluster Configuration Tool.

• If the script directory resides in a non-standard location, specify the directory that contains

the CGI programs. For example:

ScriptAlias /cgi-bin/ "/mnt/httpdservice/cgi-bin/"

• Specify the path that was used in the previous step, and set the access permissions to

default to that directory. For example:

AllowOverride None

Options None

Order allow,deny

Allow from all

Additional changes may need to be made to tune the Apache HTTP Server or add module functionality.

 2. The standard Apache HTTP Server start script, /etc/rc.d/init.d/httpd is also used

within the cluster framework to start and stop the Apache HTTP Server on the active cluster

node. Accordingly, when configuring the service, specify this script by adding it as a Script

resource in the Cluster Configuration Tool.

3. Copy the configuration file over to the other nodes of the cluster (or nodes of the failover

domain, if configured).

Before the service is added to the cluster configuration, ensure that the Apache HTTP Server

directories are not mounted. Then, on one node, invoke the Cluster Configuration Tool to add

the service, as follows. This example assumes a failover domain named httpd-domain was

created for this service.

1. Add the init script for the Apache HTTP Server service.

• Select the Resources tab and click Create a Resource. The Resources Configuration

properties dialog box is displayed.

• Select Script form the drop down menu.

• Enter a Name to be associated with the Apache HTTP Server service.

• Specify the path to the Apache HTTP Server init script (for example,

/etc/rc.d/init.d/httpd) in the File (with path) field.

• Click OK.

2. Add a device for the Apache HTTP Server content files and/or custom scripts.

• Click Create a Resource.

• In the Resource Configuration dialog, select File System from the drop-down menu.

• Enter the Name for the resource (for example, httpd-content.

• Choose ext3 from the File System Type drop-down menu.

• Enter the mount point in the Mount Point field (for example, /var/www/html/).

• Enter the device special file name in the Device field (for example, /dev/sda3).

3. Add an IP address for the Apache HTTP Server service.

• Click Create a Resource.

• Choose IP Address from the drop-down menu.

• Enter the IP Address to be associated with the Apache HTTP Server service.

• Make sure that the Monitor Link checkbox is left checked.

• Click OK.

4. Click the Services property.

5. Create the Apache HTTP Server service.

• Click Create a Service. Type a Name for the service in the Add a Service dialog.

• In the Service Management dialog, select a Failover Domain from the drop-down menu or leave it as None.

• Click the Add a Shared Resource to this service button. From the available list, choose

each resource that you created in the previous steps. Repeat this step until all resources

have been added.

• Click OK.

6. Choose File => Save to save your changes.

Server

阅读(1248) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~