1.说明:该脚本仅适用于Linux操作系统2.使用方法: 在该脚本同级目录下要创建一个名字叫做 haproxy 的文件
haproxy 文件内容如下
1 global 2 log 127.0.0.1 local2 3 daemon 4 maxconn 256 5 log 127.0.0.1 local2 info 6 defaults 7 log global 8 mode http 9 timeout connect 5000ms 10 timeout client 50000ms 11 timeout server 50000ms 12 option dontlognull 13 14 listen stats :8888 15 stats enable 16 stats uri /admin 17 stats auth admin:1234 18 19 frontend oldboy.org 20 bind 0.0.0.0:80 21 option httplog 22 option httpclose 23 option forwardfor 24 log global 25 acl www hdr_reg(host) -i www.oldboy.org 26 use_backend www.oldboy.org if www 27 28 backend www.oldboy.org 29 server 100.1.7.1 100.1.7.9 weight 20 maxconn 3000 30 server 100.1.7.2 100.1.7.9 weight 20 maxconn 3000 31 server 100.1.7.3 100.1.7.9 weight 20 maxconn 3000
3. haproxy平台管理脚本内容如下
1 # -*- coding:utf-8 -*- 2 import os,sys,time 3 file1 = "haproxy" 4 file2 = "haproxy" 5 list1=[] 6 list= [] 7 list2=[] 8 list3 = [] 9 list4 = [] 10 print "