# Building a FreeBSD cluster



## doublejay (Jan 5, 2011)

Hey guys,

I hope I'm right in this section.

I have two servers running FreeBSD 8.1. Each server has two network cards and each server is reachable under a specific ip-adress.

My goal is to build a cluster out of this two machines. the first machine should be the productive machine and the second one the standy box. when box one goes down, box two should get the productive one.

The problem is I have no idea how to implement that. Can someone help me?


----------



## SirDice (Jan 5, 2011)

Handbook: 31.13 Common Address Redundancy Protocol (CARP)

Everything else depends on what you plan on running on it.


----------



## fraenki (Jan 5, 2011)

doublejay said:
			
		

> My goal is to build a cluster out of this two machines. the first machine should be the productive machine and the second one the standy box. when box one goes down, box two should get the productive one.



In a traditional active/standby scenario you may probably want to use two things:


uCARP, a CARP implementation in userland. (no need to recompile kernel)
HAST, a high available storage framework. (sync data over the TCP/IP network)

Bye
- Frank


----------



## olav (Jan 6, 2011)

Are there any downside using uCARP? Slower performance perhaps?


----------



## aragon (Jan 6, 2011)

There's also sysutils/heartbeat.


----------



## phoenix (Jan 6, 2011)

carp(4) is part of the base OS and can very easily be configured to work with devd.conf(5) to automatically run scripts when the CARP master status changes.  Works really well with hastd(8).

net/ucarp is a port that has to be installed manually, and you have to write your own scripts to detect the change, and do things when that happens.  There's more customisability available, but it also makes the simple things harder.

In my testing with HAST, I tried to get uCARP working for 2 or 3 days and couldn't, even with the sample scripts provided by Pawel.  Delving into the man pages for devd and carp, I was able to get a working fail-over HAST+ZFS setup working in a couple of hours.  Things are just so nicely integrated in FreeBSD.  

Michael Lucas (famed BSD author) took my scripts, polished them up a bit, and blogged about them.    That should get you started.

Granted, the use of CARP+HAST above works for a "full server fail-over" setup, when if the network connection to a server fails (or power fails to a server) or otherwise makes an entire server go offline, then it will fail-over to the second server.  The scripts run by devd will start the services running on the backup once the storage is up.  Kind of like the shotgun approach.

If you want a "service" level fail-over, where if Apache on hostA stops responding then start running Apache on hostB, you want to look at something like heartbeat as well.  More like the sniper rifle approach.


----------



## fraenki (Jan 7, 2011)

olav said:
			
		

> Are there any downside using uCARP? Slower performance perhaps?



I've been using uCARP for nearly 3 years now. CARP was the last thing that forced me to customize and recompile the KERNEL. I really hate this, it makes updating the system more complex, so I try to avoid it wherever possible. I was glad to replace it with uCARP. 

I did not face any performance issues with uCARP. Actually I never realized the uCARP daemon on the process list.

EDIT: I just read the blog post by Michael Lucas and realized that CARP finally is available as a kernel module. I will give it a try.


Bye
- Frank


----------



## mlevel (Mar 15, 2011)

I have 3 servers, want to configure *CARP* between them. Each of these 3 servers are *MASTER* (firewall`s that routing different subnets).
If one of those servers goes down, any of working server must take ONLY his subnets for routing.
How I can know what server of those three goes down? I can only operate with LINK_DOWN/LINK_UP info in *devd.conf* on *carp0* interface, that is general for all servers.
Please, help..


----------

