使用Debian Lenny为一家小公司建立一个简单的高可用性Web服务器
本教程是针对Debian Lenny发行版编写的,并假设用户了解Linux的负载平衡以及一些基本技能,如果主机停止响应,则我们的两个负载平衡器由两台监视对方(心跳)的机器组成次要[备份]将采取主角色[备份 - >主]。
对于此设置,我们将需要3个IP地址,每个节点2个,主节点将使用的一个虚拟IP地址(主节点将捕获此IP)。 最后我们将安装Apache作为我们的Web服务器。
1.在两个节点上启用IPVS
IPVS(IP虚拟服务器):
lb01 / lb02
echo ip_vs_dh >> /etc/modules
echo ip_vs_ftp >> /etc/modules
echo ip_vs >> /etc/modules
echo ip_vs_lblc >> /etc/modules
echo ip_vs_lblcr >> /etc/modules
echo ip_vs_lc >> /etc/modules
echo ip_vs_nq >> /etc/modules
echo ip_vs_rr >> /etc/modules
echo ip_vs_sed >> /etc/modules
echo ip_vs_sh >> /etc/modules
echo ip_vs_wlc >> /etc/modules
echo ip_vs_wrr >> /etc/modules
modprobe ip_vs_dh
modprobe ip_vs_ftp
modprobe ip_vs
modprobe ip_vs_lblc
modprobe ip_vs_lblcr
modprobe ip_vs_lc
modprobe ip_vs_nq
modprobe ip_vs_rr
modprobe ip_vs_sed
modprobe ip_vs_sh
modprobe ip_vs_wlc
modprobe ip_vs_wrr
如果你收到错误,这意味着你没有使用debian lenny或者你已经重新编译了lenny原始内核。 内核必须用IPVS编译。
2.在负载平衡器上安装Ultra Monkey
要安装Ultra Monkey,请编辑/etc/apt/sources.list
并添加这两行(不要删除其他存储库):
lb01 / lb02
pico /etc/apt/sources.list
deb http://www.ultramonkey.org/download/latest/ sarge main
deb-src http://www.ultramonkey.org/download/latest sarge main
接下来我们这样做:
lb01 / lb02
apt-get update
如果你收到这个错误...
W: GPG error: http://www.ultramonkey.org sarge Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 03C0023E05410E97
W: You may want to run apt-get update to correct these problems
...有很少的解决方法,但这里是最值得信赖的工作!
创建一个名为: key.asc
的文件,并使用以下代码:
pico /home/key.asc
-----B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wAA CgkQA8ACPgVBDpfxKACeIfmJdm0wyb6FNyfP9/yYlSak1T8AoJjH/Pc+Uwq5T0kUEdcurSEm MZd1 =5NNR -----END PGP PUBLIC KEY BLOCK-----
运行以下命令来获取缺少的公钥...
gpg --import /home/key.asc
...并将密钥添加到密钥环...
apt-key add /root/.gnupg/pubring.gpg
...和问题..
apt-key update
... 然后...
apt-get update
回到教程 安装超猴子:
lb01 / lb02
apt-get install ultramonkey
dpkg-reconfigure ipvsadm
回答如下:
您要在启动时自动加载IPVS规则吗?
没有
选择一个守护进程方法。
没有
3.在负载平衡器上启用数据包转发
lb01 / lb02
pico /etc/sysctl.conf
取消注释以下行,以便负载平衡器能够路由流量:
# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1
之后运行:
lb01 / lb02
sysctl -p