Chinaunix首页 | 论坛 | 博客
  • 博客访问: 454985
  • 博文数量: 61
  • 博客积分: 507
  • 博客等级: 下士
  • 技术积分: 1185
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-20 00:19
文章分类

全部博文(61)

文章存档

2014年(13)

2013年(21)

2012年(27)

分类: 系统运维

2014-06-20 16:30:14

haproxy安装
wget
make TARGET=linux26 prefix=/usr/local/haproxy
make install

快起脚本放在/etc/init.d/下
[root@localhost gaoruijie]# cat haproxy.sh
# cat /usr/local/sbin/haproxy.sh  
#!/bin/bash
#haproxy command  
#ver:0.1bate
#20111129 by dongnan
 
#/usr/local/haproxy/sbin/haproxy  
#HA-Proxy version 1.4.18 2011/09/16
#Copyright 2000-2011 Willy Tarreau
#
#Usage : haproxy [-f ]* [ -vdVD ] [ -n ] [ -N ]
#        [ -p ] [ -m ]
#        -v displays version ; -vv shows known build options.
#        -d enters debug mode ; -db only disables background mode.
#        -V enters verbose mode (disables quiet mode)
#        -D goes daemon
#        -q quiet mode : don't display messages
#        -c check mode : only check config files and exit
#        -n sets the maximum total # of connections (2000)
#        -m limits the usable amount of memory (in MB)
#        -N sets the default, per-proxy maximum # of connections (2000)
#        -p writes pids of all children to this file
#        -de disables epoll() usage even when available
#        -ds disables speculative epoll() usage even when available
#        -dp disables poll() usage even when available
#        -sf/-st [pid ]* finishes/terminates old pids. Must be last arguments.
 
#variables
haproxy_dir=/usr/local/haproxy/
haproxy_conf=${haproxy_dir}haproxy.cfg
haproxy_pid=${haproxy_dir}logs/haproxy.pid
haproxy_cmd=${haproxy_dir}sbin/haproxy
#test variables
#file $haproxy_dir; file $haproxy_conf; file $haproxy_cmd; file $haproxy_pid
if [ "$#" -eq "0" ];then
    echo "usage: $0 {start|stop|restart}"
    exit 1
fi
 
if [ "$1" = "start" ];then
#echo $1
    $haproxy_cmd -f $haproxy_conf
elif [ "$1" = "stop" ];then
#echo $1
    kill `cat $haproxy_pid`
elif [ "$1" = "restart" ];then
#echo $1
    $haproxy_cmd -f $haproxy_conf -st `cat $haproxy_pid`
 
else
   echo "usage: $0 arguments only start and stop or restart !"
fi

haproxy.conf配置文件默认是没有的 所以需要手工创建
vi /usr/local/haproxy/haproxy.conf

global
        log 127.0.0.1   local0
        maxconn 4096
        chroot /usr/local/haproxy
        uid 501
        gid 501
        daemon
        nbproc 1
        pidfile /usr/local/haproxy/logs/haproxy.pid
        debug

defaults
        log     127.0.0.1       local3
        mode    http
        option httplog
        option httpclose
        option dontlognull
        option forwardfor
        option redispatch
        retries 2
        maxconn 2000
        balance roundrobin
        stats   uri     /haproxy-stats
        contimeout      5000
        clitimeout      50000
        srvtimeout      50000

listen web_proxy 192.168.4.6:1080
        #option httpchk HEAD /index.php  HTTP/1.0
        server web1_192.168.4.8  192.168.4.8:80 cookie app1inst1 check inter 2000 rise 2 fall 5
        server web2_192.168.4.7  192.168.4.7:80 cookie app1inst2 check inter 2000 rise 2 fall 5



service haproxy start

ps aux |grep haproxy








阅读(3398) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~