Chinaunix首页 | 论坛 | 博客
  • 博客访问: 247211
  • 博文数量: 41
  • 博客积分: 1523
  • 博客等级: 上尉
  • 技术积分: 579
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-05 21:23
文章分类

全部博文(41)

文章存档

2014年(1)

2013年(2)

2012年(1)

2011年(2)

2010年(3)

2009年(1)

2008年(20)

2007年(11)

分类: LINUX

2007-11-09 11:38:02

UCARP 1.2版本的文档

软件介绍:
UCARP可以在一对普通的主机上设置虚拟IP地址,并让他们实现自动热备。
这是一个非常简单地址冗余协议,并且他是可以免费下载到的。
它可以用来替换OPENBSD下面的CARP,VRRP。
carp:
vrrp:
主页地址是

编译条件:
你必须在你的系统上安装libpcap,UCARP编译需要libpcap的头文件,如果没有安装可以在上面找到。
如果你已经具备了上面的条件请按照传统的方式编译安装。
./configure
make install-strip
具体的细节可以参考安装文档 INSTALL 。
这个软件已经成功的在 Linux 2.4, Linux 2.6, MacOS X,OpenBSD, MirBSD and NetBSD 上运行过。

配置需求:
我们必须配置一对虚拟主机
还需要为这个虚拟主机配置一对虚拟的IP,这个是用来说明主机是否正常,如果你需要高可用的服务,这些配置是必需的。
主机共同标识的虚拟IP地址必须在1-255之间。
每个主机还需要一个真实的IP。
每个主机都会在一定的时间发布广播公布他的状态,默认的来说1就表示主机正常,0表示主机有问题。
这个协议非常的精简,所使用的包也非常的小,所以请放心不会因为这个广播而影响到你的网络的正常运行。
一个共享的密码,他在网络上不是明文传送的。
一个脚本,让他在主机出错的时候取代主机状态。
另一个脚本,让他在主机恢复的时候放弃主机状态。

使用方法:
服务通常安装在 :/usr/local/sbin/ucarp
所有侧操作都是通过UCARP这个命令实现的。
想了解参数详情请看 :/usr/local/sbin/ucarp -h

ucarp -h 帮助信息
ucarp 1.2 - Mar 27 2007

--interface= (-i ): bind interface (网络接口 绑定网络接口)
--srcip= (-s ): source (real) IP address of that host (源地址真实ip)
--vhid= (-v ): virtual IP identifier (1-255) (虚拟ip标识 (1-255))
--pass= (-p ): password (密码)
--preempt (-P): becomes a master as soon as possible (以最快的速度成为主服务器的角色)
--neutral (-n): don't run downscript at start if backup (如果是备份主机,启动的时候不运行downscript.)
--addr= (-a ): virtual shared IP address( 虚拟共享ip地址)
--help (-h): summary of command-line options (命令行帮助)
--advbase= (-b ): advertisement frequency (广播的频率(秒))
--advskew= (-k ): advertisement skew (0-255) (????不广播)
--upscript= (-u ): run to become a master (运行一个脚本文件,使本服务器成为主服务器)
--downscript= (-d ): run to become a backup (运行一个脚本文件,使本服务器成为从服务器)
--deadratio= (-r ): ratio to consider a host as dead (认定主机已经死掉的比率(阀值))
--shutdown (-z): call shutdown script at exit (在退出的时候,执行shutdown的指令)
--daemonize (-B): run in background (运行在后台)
--facility= (-f): set syslog facility (default=daemon) (设置syslog工具,默认在后台)

(使用例子:
管理设置网络接口eth0上的虚拟ip 10.1.1.252,虚拟ip地址标识为1,密码是mypassword,真实地址为10.1.1.1,
运行脚本/etc/vip-up.sh当主机成为主服务器的时候,运行脚本/etc/vip-down.sh当虚拟ip被禁用的时候.
请报告bug到bugs@uarp.org)
Sample usage:
Manage the 10.1.1.252 shared virtual address on interface eth0, with
1 as a virtual address idenfitier, mypassword as a password, and
10.1.1.1 as a real permanent address for this host.
Call /etc/vip-up.sh when the host becomes a master, and
/etc/vip-down.sh when the virtual IP address has to be disabled.

ucarp --interface=eth0 --srcip=10.1.1.1 --vhid=1 --pass=mypassword \
--addr=10.1.1.252 \
--upscript=/etc/vip-up.sh --downscript=/etc/vip-down.sh

Please report bugs to bugs@ucarp.org.

下面是一个比较好的安装例子。
例如你有一个邮件服务器IP地址是10.1.1.252,每个使用者都在自己的邮件客户端配置了主机IP地址
如果你的邮件服务器不能正常运行,客户端将不能使用这个服务。
现在需要两台服务器,并且配制相同,两台服务器上分别设置地址10.1.1.1 和 10.1.1.2 让两个服务器
都能响应同一IP地址(10.1.1.252)的请求,当一个服务器出现问题停止,另一个服务器接管这个服务。
首先我们来创建一个脚本,用来添加实IP地址,我们先把脚本存放到/etc/vip-up.sh
#! /bin/sh
/sbin/ip addr add 10.1.1.252/24 dev eth0
我们在创建一个用来关闭实IP的脚本,我们先把脚本存放到/etc/vip-down.sh
#! /bin/sh
/sbin/ip addr del 10.1.1.252/24 dev eth0
当然,你可以使用任何方法实现和修改这些脚本,例如你想要添加一个路由,想给你的操作做一个日志,或者直接给你发邮件。
最后别忘了连接你的交换接刷新ARP的缓存,用户都会很快的更新他们的MAC地址列表。
如果你的网卡使用的不是ETH0请根据你的实际情况修改上面脚本中的内容。
别忘了加一个可执行的权限
chmod +x /etc/vip-up.sh /etc/vip-down.sh
现在. 我们现在需要的是一个虚拟的IP标识,我们就使用"42"。我们也需要一个口令,让我们使用"LOVE".
现在我们在第一个主机上添加实IP地址并作相应的标示 10.1.1.1 。(MASTER)
/usr/local/sbin/ucarp -v 42 -p love -a 10.1.1.252 -s 10.1.1.1 &
现在我们在第二个主机上添加实IP地址并作相应的标示 10.1.1.2 。(SLAVE)
/usr/local/sbin/ucarp -v 42 -p love -a 10.1.1.252 -s 10.1.1.2 &
现在你应该能看见一个已经成为了主服务器,另一个成为了从服务器,根据你的实际情况修改你的脚本。
现在我们断开主服务器,你会发现从服务器在几秒种以后接管了主服务器。
你也可以通过"-b"这个参数修改广播时间,多个从服务器当中,广播时间较小的那个将成为主服务器。。
请注意:当一个服务器从另一个服务器接管服务以后将自动变成主服务器,而且不会因为另一个服务器从新使用而降为从服务器
如果你想让一个服务器立即变成主服务器请在这个主机上使用一个"-p"的选项,使另一台变成从服务器。
当UCARP在服务器上第一次会以从服务器方式运行,并且看是否需要变成主服务器。
当进入从服务器状态的时候,正常情况下将运行关闭脚本,这有利于删除旧的临时文件或清除网卡的未知的状态.
然而在一些特殊的环境里,如果ucarp服务还没有启动起来的时候,不需要运行downscript.如果是那样的话,使用-n参数。
当它第一次进入从服务器状态时,不运行关闭脚本在运行以后,发生所有改变从主服务器状态到备份服务器状态
使用"-z"的选项服务器将会先切换到从服务器的状态然后再推出,如果服务器本身工作在从的状态将直接推出。
使用"-r"的选项是让从服务器在主服务器丢失响应多常时间后,把自己升级成为新的主服务器。如果没有指定的话这个值默认是3。
如果UCARP运行在daemon状态(-B 后台运行),他的标准输出和标准错误日志默认将发送给系统的syslog进程,如果你不想记录他可以使用--syslog=none 或这也可以使用你自己的日志工具。

如何获得这个软件:
软件主页: / .
邮件地址列表: /ml/
谢谢你的支持

-Frank DENIS "Jedi/Sector One" .



.:. UCARP .:.
Documentation for version 1.2

其他的资料


------------------------ BLURB ------------------------


UCARP allows a couple of hosts to share common virtual IP addresses in order
to provide automatic failover. It is a portable userland implementation of the
secure and patent-free Common Address Redundancy Protocol (CARP, OpenBSD's
alternative to the patents-bloated VRRP).

Strong points of the CARP protocol are: very low overhead, cryptographically
signed messages, interoperability between different operating systems and no
need for any dedicated extra network link between redundant hosts.

Home page is /


------------------------ COMPILATION ------------------------


libpcap (/) must be installed on your system, with
development files (headers).

Then, follow the boring traditional procedure:

./configure
make install-strip

For details, have a look at the INSTALL file.

The software has been successfully tested on Linux 2.4, Linux 2.6, MacOS X,
OpenBSD, MirBSD and NetBSD.


------------------------ REQUIREMENTS ------------------------


A couple of virtual hosts must be given:

- A shared virtual IP, which will be dynamically answered by one alive host.
Services that need high availability need to be assigned to that virtual IP.

- A real IP address for each host.

- A shared identifier for the virtual IP address, which is a number between 1
and 255.

- For each host : an advertisement time base and skew, which is the frequency
the host will tell the other one that it's still alive. By default, base is 1
and skew is 0, which basically means one advertisement a second. The protocol
is very light, a tiny packet every second won't have any noticeable impact on
your network.

- A shared password (that will never go plaintext to the network).

- A script to bring the virtual address up when a host becomes the master.

- Another script to bring the virtual address down when a host is no more the
master.


------------------------ USAGE ------------------------


The server will usually be installed as : /usr/local/sbin/ucarp
Everything is driven through command-line options.
In order to see the list of available options, try : /usr/local/sbin/ucarp -h

Better than a long technical discussion, here's a real-life setup example.

Your company has an internal mail relay whose IP address is 10.1.1.252. Every
user has configured his mail client with that host or IP address and the
service must always be up and running without reconfiguring mail clients in
case of a failure.

It's why you set up two mail servers hosts with an identical configuration.
Their real IP addresses are 10.1.1.1 and 10.1.1.2.
Let's see how to assign the same additionnal IP address (10.1.1.252) to both
servers, so that when one goes down, the other one goes up.

First, we will create a script that brings the virtual IP address up. Let's
save that file as /etc/vip-up.sh :

#! /bin/sh
/sbin/ip addr add 10.1.1.252/24 dev eth0

Now another script to bring it down, /etc/vip-down.sh :

#! /bin/sh
/sbin/ip addr del 10.1.1.252/24 dev eth0

Of course, anything can go in these scripts. For instance, you may want to add
routes, to add something to log files or to send mail. And last, but not
least, you can use a script that will connect to your switches and flush their
ARP cache. Some users reported that transitions were way faster when also
switching MAC addresses.
The interface name is passed as an argument to the called scripts, so feel
free to replace "eth0" with "$1" in the previous examples.

Don't forget to make those files executable :

chmod +x /etc/vip-up.sh /etc/vip-down.sh

Right. What we need now is an identifier for the virtual IP. Let's take "42".
And we also need a password. Let's take "love".

Now, on the first host (whoose real IP is 10.1.1.1), run :

/usr/local/sbin/ucarp -v 42 -p love -a 10.1.1.252 -s 10.1.1.1 &

On the second host, whose real IP is 10.1.1.2, run :

/usr/local/sbin/ucarp -v 42 -p love -a 10.1.1.252 -s 10.1.1.2 &

You should see that one of those hosts quickly becomes the master, and the
other one the backup. Related scripts are spawned on change.

Now unplug the master. After a few seconds, the other host becomes the new
master.

By changing the base (the -b switch) you can have a "preferred" master. The
lower the value is, the more likely it's going to be a master.

Please note that by default, and if everything's ok, a master will stay a
master as long as possible. If you want a "preferred" master to immediately
become a master even if another host is already the master:
- add the --preempt (or -P) switch to *all* hosts
- use a lower skew or a lower base for the "preferred" one.

When ucarp first runs, it starts as a backup and listens to the network to
determine if it should become the master. When it enters the backup state, it
normally runs the downscript. That can be useful to remove old temporary files
or clean up an interface that is in an unknown state. In some circumstances,
however, it is undesirable to run the downscript if the service was not
already up. In that case, use the --neutral (-n) switch for ucarp to not run
the downscript when it enters the backup state the first time. All changes
from the master state to the backup state after that will run the downscript.

--shutdown (-z) will run the downscript at exit, unless ucarp is already in
the backup state.

The "dead ratio" (--deadratio=...) knob basically changes how long a backup
server will wait for an unresponsive master before considering it as dead, and
becoming the new master. In the original protocol, the ratio is 3. This is
also the default when this command-line switch is missing.

Notices are sent both to stderr/stdout and to the syslog daemon (with the
"daemon" facility) by default. stderr/stdout are bypassed if the daemon is
started in background (--daemonize). Facilities can be changed with the
--syslog switch. Use --syslog=none to disable syslog logging, for instance if
prefer using something like multilog.


------------------------ TRANSLATIONS ------------------------


UCARP can speak your native language through gettext / libintl.
If you want to translate the software, have a look at the po/ directory.
Copy the ucarp.pot file to .po and use software like Kbabel
or Emacs to update the file.
Better use use your local charset than UTF-8.


------------------------ DOWNLOADING UCARP ------------------------


UCARP home page is: / .

UCARP mailing-list: /ml/


Thank you,

-Frank DENIS "Jedi/Sector One" .

ucarp 1.2 - Mar 27 2007

--interface= (-i ): bind interface
--srcip= (-s ): source (real) IP address of that host
--vhid= (-v ): virtual IP identifier (1-255)
--pass= (-p ): password
--preempt (-P): becomes a master as soon as possible
--neutral (-n): don't run downscript at start if backup
--addr= (-a ): virtual shared IP address
--help (-h): summary of command-line options
--advbase= (-b ): advertisement frequency
--advskew= (-k ): advertisement skew (0-255)
--upscript= (-u ): run to become a master
--downscript= (-d ): run to become a backup
--deadratio= (-r ): ratio to consider a host as dead
--shutdown (-z): call shutdown script at exit
--daemonize (-B): run in background
--facility= (-f): set syslog facility (default=daemon)

Sample usage:

Manage the 10.1.1.252 shared virtual address on interface eth0, with
1 as a virtual address idenfitier, mypassword as a password, and
10.1.1.1 as a real permanent address for this host.
Call /etc/vip-up.sh when the host becomes a master, and
/etc/vip-down.sh when the virtual IP address has to be disabled.

ucarp --interface=eth0 --srcip=10.1.1.1 --vhid=1 --pass=mypassword \
--addr=10.1.1.252 \
--upscript=/etc/vip-up.sh --downscript=/etc/vip-down.sh


Please report bugs to bugs@ucarp.org.
阅读(1581) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~