负载均衡集群的方式设定和脚本

负载复制#!/bin/bash # Open IP Forwarding echo 1 > /proc/sys/net/ipv4/ip_forward # To make the load balancer forward the masquerading packets iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -d 0.0.0.0/0 -o eth0 -j MASQUERADE ipvsadm -C # Choose the Weighted Round Robing ipvsadm -A -t 10.0.0.1:80 -s wrr # Set Real Server ipvsadm -a -t 10.0.0.1:80 -r 192.168.0.1:873 -m -w 2 ipvsadm -a -t 10.0.0.1:80 -r 192.168.0.2:873 -m -w 3 ipvsadm 1.2.3.4.5.6.7.8.9.10.11.12.