• haproxy rpm制做


    [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
    
  • 相关阅读:
    spring ApplicationListener接口
    spring提供的几个常用可实现的接口
    dubbo源码解析(三) DubboInvoker
    Java生日计算年龄工具
    css实现右尖括号样式
    微信小程序支付开发之申请退款
    微信小程序picker组件
    java 获取用户ip
    spring boot 添加拦截器的简单实例(springBoot 2.x版本,添加拦截器,静态资源不可访问解决方法)
    JVM 组成以及各部分作用
  • 原文地址:https://www.cnblogs.com/bass6/p/7127959.html
Copyright © 2020-2023  润新知