Seesaw - 负载均衡系统


Apache
Linux
Google Go

软件简介

Seesaw 是 Google 开源的一个基于 Linux 的负载均衡系统。Seesaw
包含基本的负载均衡特性,同时支持一些高级的功能,诸如:anycast, Direct Server Return (DSR), 支持多个 VLANs
和集中式配置。同时其设计的宗旨是易于维护。

安装:

make install 成功运行后,应该会在 ${GOPATH}/bin 路径下生成一些 seesaw_ 前缀的二进制文件。把它们安装到合适的位置。

SEESAW_BIN="/usr/local/seesaw"
SEESAW_ETC="/etc/seesaw"
SEESAW_LOG="/var/log/seesaw"
INIT=`ps -p 1 -o comm=`
install -d "${SEESAW_BIN}" "${SEESAW_ETC}" "${SEESAW_LOG}"
install "${GOPATH}/bin/seesaw_cli" /usr/bin/seesaw
for component in {ecu,engine,ha,healthcheck,ncc,watchdog}; do
  install "${GOPATH}/bin/seesaw_${component}" "${SEESAW_BIN}"
done
if [ $INIT = "init" ]; then
  install "etc/init/seesaw_watchdog.conf" "/etc/init"
elif [ $INIT = "systemd" ]; then
  install "etc/systemd/system/seesaw_watchdog.service" "/etc/systemd/system"
  systemctl --system daemon-reload
fi
install "etc/seesaw/watchdog.cfg" "${SEESAW_ETC}"
# Enable CAP_NET_RAW for seesaw binaries that require raw sockets.
/sbin/setcap cap_net_raw+ep "${SEESAW_BIN}/seesaw_ha"
/sbin/setcap cap_net_raw+ep "${SEESAW_BIN}/seesaw_healthcheck"

setcap 二进制文件可以在 Debian/Ubuntu 上的 libcap2-bin 包找到。

配置:

这里可查看一份配置示例文件,一份最小的
seesaw.cfg 文件提供一下内容:

  • anycast_enabled - True if anycast should be enabled for this cluster.

  • name - The short name of this cluster.

  • node_ipv4 - The IPv4 address of this Seesaw node.

  • peer_ipv4 - The IPv4 address of our peer Seesaw node.

  • vip_ipv4 - The IPv4 address for this cluster VIP.

故障排除:

一个 Seesaw 应该有五个在看门狗下运行的组件——进程表显示的进程:

  • seesaw_ecu

  • seesaw_engine

  • seesaw_ha

  • seesaw_healthcheck

  • seesaw_ncc

  • seesaw_watchdog

所有 Seesaw v2 的组件除了由看门狗提供的日志,都拥有自己的日志。如果任何一个进程没有运行,请在 /var/log/seesaw (e.g.
seesaw_engine.{log,INFO}) 检查相应的日志。

需要注意的是,尽管该项目挂靠在 Google 名下,但并非 Google 官方产品,因此不会有官方支持,但源代码还是十分值得一部分开发者参考。