构建 LVS-NAT 集群与 LVS-DR 集群指南
1. 配置 LVS 调度器
在配置 LVS 调度器时,我们需要借助之前编译安装的ipvsadm工具,来指导调度器如何将数据包转发至集群节点(即真实服务器)。有两种配置方式可供选择:
- 利用 LVS 发行版自带的配置脚本。具体使用方法可参考 LVS HOWTO 。
- 编写自定义脚本,以深入了解ipvsadm工具的使用。本文将采用此方法。
以下是/etc/init.d/lvs脚本的内容:
#!/bin/bash # # LVS script # # chkconfig: 2345 99 90 # description: LVS sample script # case "$1" in start) # Bring up the VIP (Normally this should be under Heartbeat's control.) /sbin/ifconfig eth0:1 209.100.100.3 netmask 255.255.255.0 up # Since this is the Director we must be # able to forward packets.10 echo 1 > /proc/sys/net/ipv4