Add some documentation on carp(4), provide an example configuration for

fail over cases.

Sponsored by:	AiNET Corp.
This commit is contained in:
Tom Rhodes 2007-04-26 08:10:29 +00:00
parent ac0dc22ace
commit 113943ac4d
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=30091

View file

@ -47,6 +47,11 @@
<listitem>
<para>How to configure ATM.</para>
</listitem>
<listitem>
<para>How to enable and utilize the features of CARP, the
Common Access Redundancy Protocol in &os;</para>
</listitem>
</itemizedlist>
<para>Before reading this chapter, you should:</para>
@ -4709,6 +4714,137 @@ route_hostD="192.168.173.4 hatm0 0 102 llc/snap ubr"</programlisting>
</sect3>
</sect2>
</sect1>
<sect1 id="carp">
<sect1info>
<authorgroup>
<author>
<firstname>Tom</firstname>
<surname>Rhodes</surname>
<contrib>Contributed by </contrib>
</author>
</authorgroup>
</sect1info>
<title>Common Access Redundancy Protocol</title>
<indexterm><primary>CARP</primary></indexterm>
<indexterm><primary>Common Access Redundancy Protocol</primary></indexterm>
<para>The Common Access Redundancy Protocol, or
<acronym>CARP</acronym> allows multiple hosts to share the same
<acronym>IP</acronym> address. In some configurations, this may
be used for availability or load balancing. Hosts may use separate
<acronym>IP</acronym> addresses as well, as in the example provided
here.</para>
<para>To enable support for <acronym>CARP</acronym>, the &os;
kernel must be rebuilt with the following option:</para>
<programlisting>device carp</programlisting>
<para><acronym>CARP</acronym> functionality should now be available
and may be tuned via several <command>sysctl</command>
<acronym>OID</acronym>s. Devices themselves may be loaded via
the <command>ifconfig</command> command:</para>
<screen>&prompt.root; <userinput>ifconfig carp0 create</userinput></screen>
<para>In a real environment, these interfaces will need unique
identification numbers known as a <acronym>VHID</acronym>. This
<acronym>VHID</acronym> or Virtual Host Identification will be
used to distinguish the host on the network.</para>
<sect2>
<title>Using CARP For Server Availability (CARP)</title>
<para>One use of <acronym>CARP</acronym>, as noted above, is for
server availability. This example will provide fail over support
for three hosts, both with unique <acronym>IP</acronym>
addresses and provide the same web content. These machines will
act in conjunction with a Round Robin <acronym>DNS</acronym>
configuration. The fail over machine will have two additional
<acronym>CARP</acronym> interfaces, one for each of the content
server's <acronym>IP</acronym>s. When a failure occurs, the
fail over server should pick up failed machine's
<acronym>IP</acronym> address. This means the failure should
go completely unnoticed to the user. The fail over server
requires identical content and services as the other content
servers it is expected to pick up load for.</para>
<para>The two machines should be configured identically other
than their issued hostnames and <acronym>VHID</acronym>s.
This example calls these machines
<hostid>hosta.example.org</hostid> and
<hostid>hostb.example.org</hostid> respectively. Begin their
<acronym>CARP</acronym> configuration by adding the required
lines to <filename>rc.conf</filename>. For
<hostid>hosta.example.org</hostid>, the
<filename>rc.conf</filename> file contains the following
lines:</para>
<programlisting>hostname="hosta.example.org"
ifconfig_fxp0="inet 192.168.1.3 netmask 255.255.255.0"
cloned_interfaces="carp0"
ifconfig_carp0="vhid 1 pass testpast 192.168.1.50/24"</programlisting>
<para>And on <hostid>hostb.example.org</hostid> has the following
lines in <filename>rc.conf</filename>:</para>
<programlisting>hostname="hostb.example.org"
ifconfig_fxp0="inet 192.168.1.4 netmask 255.255.255.0"
cloned_interfaces="carp0"
ifconfig_carp0="vhid 2 pass testpass 192.168.1.51/24"</programlisting>
<note>
<para>It is very important the passwords are identical, the
<devicename>carp</devicename> devices will only listen to
and accept advertisements from machines with the correct
password. The <acronym>VHID</acronym> must also be different
for each machine.</para>
</note>
<para>Prepare the third machine,
<hostid>provider.example.org</hostid>, so that it may handle
fail over from either host. This machine will require two
<devicename>carp</devicename> devices, one to handle each of
host. The appropriate <filename>rc.conf</filename>
configuration lines will be similar to the following:</para>
<programlisting>hostname="provider.example.org"
ifconfig_fxp0="inet 192.168.1.5 netmask 255.255.255.0"
cloned_interfaces="carp0 carp1"
ifconfig_carp0="vhid 1 advskew 100 pass testpass 192.168.1.50/24"
ifconfig_carp1="vhid 2 advskew 100 pass testpass 192.168.1.51/24"</programlisting>
<para>Having the two <devicename>carp</devicename> devices will
allow <hostid>provider.example.org</hostid> to notice and pick
up the <acronym>IP</acronym> address of either machine should
it stop responding.</para>
<note>
<para>The default &os; kernel <emphasis>may</emphasis> have
preemption enabled. If so,
<hostid>provider.example.org</hostid> may not relinquish the
<acronym>IP</acronym> address back to the original content
server. In this case, an administrator may
<quote>nudge</quote> the interface. The following command
should be issued on
<hostid>provider.example.org</hostid>:</para>
<screen>&prompt.root; <userinput>ifconfig carp0 down && ifconfig carp0 up</userinput></screen>
<para>This should be done on the <devicename>carp</devicename>
interface which corresponds to the correct host.</para>
</note>
<para>At this point, <acronym>CARP</acronym> should be completely
enabled and available for testing. Either restart networking
or reboot the machines and test.</para>
<para>More information is always available in the &man.carp.4;
manual page.</para>
</sect2>
</sect1>
</chapter>
<!--