zoukankan      html  css  js  c++  java
  • haproxy+tomcat集群搭建

    web1和web2的部署可参考我之前的文章《Tomcat集群搭建》,这里就省去该过程了。
    #安装haproxy-1.4.17
    tar -zxf haproxy-1.4.17.tar.gz
    cd haproxy-1.4.17/
    make TARGET=linux26 PREFIX=/usr/local/haproxy
    make install PREFIX=/usr/local/haproxy
    
    #创建目录结构
    cd /usr/local/haproxy
    mkdir conf/
    mkdir logs/
    
    #修改haproxy配置
    vi conf/haproxy.cfg
    global
        log 127.0.0.1 local0
        maxconn 40960
        chroot /usr/local/haproxy
        uid 99
        gid 99
        daemon
        nbproc 1
        pidfile /usr/local/haproxy/logs/haproxy.pid
    
    defaults
        log global
        mode http
        option httplog
        option dontlognull
        retries 3
        option redispatch
        maxconn 20480
        contimeout 5000
        clitimeout 50000
        srvtimeout 50000
        
    listen web
        bind :80
        mode http
        balance roundrobin
        stats uri /haproxy-stats
        stats refresh 10s
        stats realm Haproxy statistics
        stats auth admin:admin
        option httpchk HEAD /index.html
        server web1 192.168.11.120:8080 weight 1 maxconn 10000 check inter 3s rise 3 fall 3
        server web2 192.168.11.121:9080 weight 1 maxconn 10000 check inter 3s rise 3 fall 3
    
    #日志输出配置,haproxy调用的是系统日志集中管理接口
    #比如,我这里是rsyslog,syslog或syslog-ng配置方法与此类似
    vi /etc/rsyslog.conf
    ModLoad imudp
    UDPServerRun 514
    local0.*        /var/log/haproxy.log
    
    #重启日志系统
    service rsyslog restart
    
    #启动web1、web2
    web1/bin/startup.sh
    web2/bin/startup.sh
    
    #启动haproxy
    /usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/conf/haproxy.cfg
    
    #测试,访问
    http:
    //localhost/haproxy-stats
    http://localhost/index.html
    http://192.168.11.120:8080/index.html
    http://192.168.11.121:9080/index.html
    等页面观察是否正常,可查看/var/log/haproxy.log观察日志输出情况。
  • 相关阅读:
    h5 喜帖
    h5 录音
    UglifyJS-- 对你的js做了什么
    SimpleCaptcha生成图片验证码内容为乱码
    Spring.profiles多环境配置最佳实践
    eclipse maven 导出项目依赖的jar包
    cygwin下切换到其他磁盘
    chrome 浏览器的插件权限有多大?
    windows系统tomcat日志输出至catalina.out配置说明
    Windows10远程报错:由于CredSSP加密Oracle修正
  • 原文地址:https://www.cnblogs.com/lichmama/p/4184869.html
Copyright © 2011-2022 走看看