LVS 的几个脚本 挺有用的 配置HA的时候可以看看

1.VS/NAT
echo "1" > /proc/sys/net/ipv4/ip_forward                   //打开IP转发
ipvsadm –C                                        //清除现有Ipvs规则
ipvsadm -A -t 202.114.216.177:80 -s rr             //使用轮叫调度算法
ipvsadm -a -t 202.114.216.177:80 -r 192.168.88.10:80 -m -w 1  //添加RS1服务器的调度
ipvsadm -a -t 202.114.216.177:80 -r 192.168.88.20:80 -m -w 1   //如上
ipvsadm -a -t 202.114.216.177:80 -r 192.168.88.30:80 -m -w 1   //如上


2,VS/DR

LVS:
ifconfig eth0:0 202.114.216.177 broadcast 202.114.216.177 netmask 255.255.255.255 up
route add -host 202.114.216.177 dev eth0:0
ipvsadm -A -t 202.114.216.177:80 -s rr         //使用轮叫调度算法
ipvsadm -a -t 202.114.216.177:80 -r 202.114.216.231 -g  //添加RS1服务器的调度
ipvsadm -a -t 202.114.216.177:80 -r 202.114.216.232 -g   //同上
ipvsadm -a -t 202.114.216.177:80 -r 202.114.216.233 -g   //同上
ipvsadm
chmod 777 /etc/init.d/vip.sh                    //修改权限

RS
ifconfig lo:0 202.114.216.177  broadcast 202.114.216.177 netmask 255.255.255.255 up
route add -host 202.114.216.177 dev lo:0           //添路主机路由
echo "1" > /proc/sys/net/ipv4/conf/lo/arp_ignore    //关闭ARP广播请求
echo "2" > /proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" > /proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" > /proc/sys/net/ipv4/conf/all/arp_announce
sysctl  –p                                 //立即让配置在内核中生效
chmod 777 /etc/init.d/lvs.sh                //修改权限

3.VS/TUNE

LVS
ifconfig tunl0 202.114.216.177 broadcast 202.114.216.177 netmask 255.255.255.255 up
route add -host 202.114.216.177 dev tunl0
ipvsadm -A -t 202.114.216.177:80 -s rr          //使用轮叫调度算法
ipvsadm -a -t 202.114.216.177:80 -r 202.114.216.231 -i   //添加RS1服务器的调度
ipvsadm -a -t 202.114.216.177:80 -r 202.114.216.232 -i   //如上
ipvsadm -a -t 202.114.216.177:80 -r 202.114.216.233 -i   //如上
ipvsadm
chmod 777 /etc/init.d/vip.sh                          //修改权限
RS
ifconfig tunl0 202.114.216.177 broadcast 202.114.216.177 netmask 255.255.255.255 up
route add -host 202.114.216.177 dev tunl0                 //添路主机路由
echo "1" > /proc/sys/net/ipv4/conf/lo/arp_ignore    //关闭ARP广播请求
echo "2" > /proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" > /proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" > /proc/sys/net/ipv4/conf/all/arp_announce
sysctl  –p                               //立即让配置在内核中生效
chmod 777 /etc/init.d/lvs.sh                   //修改权限


--------------------我是分界线--------------------------------------
RAID 5
mdadm -Cv /dev/md0 -l5 -n3 /dev/sd[bcd] -x1 /dev/sde  //利用三块磁盘sdb ,sdc,sdd创建名称为md0设备的RAID5级别的磁盘阵列,另外sde为热备份盘
mkfs.ext3 /dev/md0      //以ext3的文件系统格式化md0设备
mdadm -D /dev/md0      //查看RAID5阵列的磁盘状态


你可能感兴趣的:(LVS)