码迷,mamicode.com
首页 > 其他好文 > 详细

haproxy rpm制做

时间:2017-07-06 20:49:49      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:front   超时   bsp   mkdir   admin   ref   设置   end   pclose   

 

 

[root@c01 tmp]# fpm -s dir -t rpm -v 1.7.7 -n haproxy --before-install /tmp/haproxy_before.sh --after-install /tmp/haproxy_after.sh --after-remove /tmp/haproxy_remove.sh -d ‘libaio‘ /apps/haproxy-1.7.7/ /etc/init.d/haproxy_sc 

 查看脚本:

[root@c01 tmp]# cat haproxy_before.sh 
#!/bin/bash
if [ ! -d /apps/haproxy-1.7.7 ];then
	mkdir -p /apps/haproxy-1.7.7
fi


[root@c01 tmp]# cat haproxy_after.sh 
#!/bin/bash
mkdir /apps/haproxy-1.7.7/conf
echo "
    global  
            log 127.0.0.1 local0 info #[err warning info debug] //日志位置  
            maxconn 4096  
            daemon #设置成后台运行  
            nbproc 1 #进程数量  
            pidfile /apps/haproxy-1.7.7/haproxy.pid  
      
    defaults  
            log     global  
            mode    http #默认模式  
            option  httplog #http日志格式  
            option  dontlognull  
            retries 3  #三次失败后认为服务器不可用  
            option  redispatch  #如果cookie写入了serverId而客户端不会刷新cookie,当serverId对应的服务器挂掉后,强制定向到其他健康的服务器  
            maxconn 2000 #当服务器负载很高的时候,自动结束掉当前队列处理比较久的链接默认的最大连接数  
            contimeout 5000 #连接超时  
            clitimeout 30000 #客户端超时  
            srvtimeout 30000 #服务器超时  
      
    frontend web_in  
            mode http  
            maxconn 1000  
            bind :80  
            acl is_a hdr_beg(host) -i www.espressos1.com  #判断域名是不是www.espressos1.com,是则给与a服务器集群服务  
            acl is_b hdr_beg(host) -i www.espressos2.com  #判断域名是不是www.espressos2.com,是则给与a服务器集群服务  
      
            use_backend a_server if is_a  
            use_backend b_server if is_b  
      
    backend a_server  
            mode http #http 模式  
            stats   uri  /haproxy  
            balance roundrobin  
            cookie  JSESSIONID prefix  
            stats   hide-version  
            option  httpclose  
            server web1 10.100.0.220:80 check  
            #server web2 128.1.2.5:80 check  
      
      
    backend b_server  
            mode http #http 模式  
            stats   uri  /haproxy  
            balance roundrobin  
            cookie  JSESSIONID prefix  
      
            stats   hide-version  
            option  httpclose  
            server web1 10.100.0.229:80  

">/apps/haproxy-1.7.7/conf/haproxy.conf.acl
echo "
global
        log 127.0.0.1 local0 info
        maxconn 51200
        user nobody
        group nobody
        daemon
        nbproc 1
        pidfile /var/run/haproxy.pid

defaults
        log global
        mode http
        option httplog
        option tcplog
        option httpclose
        option forwardfor except 127.0.0.0/8
        option redispatch
        option dontlognull
        retries 3
        timeout connect 10s
        timeout client 1m
        timeout server 1m
        timeout check 5s
        timeout http-request    10s
        timeout http-keep-alive 10s
    timeout queue           1m
        maxconn 10000
listen admin_stats
        bind 0.0.0.0:9001
        mode http
        stats refresh 30s
        stats uri /ha-stu
        stats realm welcome login\ Haproxy
        stats auth admin:admin@!
        stats hide-version
        stats admin if TRUE
#
listen mysql
    bind 0.0.0.0:3306
    mode tcp
#   balance roundrobin
    balance source
    server mysql-01 xxx.xxx.xxx.xxx:3306
#
listen mysql-ds
    bind 0.0.0.0:3307
    mode tcp
#   balance roudrobin
    balance source
    server mysql-02 xx.xxx.xxx.xxx:3306

">/apps/haproxy-1.7.7/conf/haproxy.conf.nomal

 

[root@c01 tmp]# cat haproxy_remove.sh 
#!/bin/bash
if [ -d /apps/haproxy-1.7.7 ];then
	rm -rf /apps/haproxy-1.7.7
fi

 

haproxy rpm制做

标签:front   超时   bsp   mkdir   admin   ref   设置   end   pclose   

原文地址:http://www.cnblogs.com/bass6/p/7127959.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!