7

快速搭建haproxy服务

 3 years ago
source link: https://www.wencst.com/archives/507
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

快速搭建haproxy服务

作者: wencst 分类: linux,Uncategorized,程序设计 发布时间: 2017-04-04 13:22 阅读: 2,501 次

操作系统:centos6.5

haproxy版本:haproxy-1.3.20

1.下载haproxy源码包并解压

#wget http://haproxy.1wt.eu/download/1.3/src/haproxy-1.3.20.tar.gz

#tar zxvf haproxy-1.3.20.tar.gz

#cd haproxy-1.3.20

#make TARGET=linux26 PREFIX=/new/work/haproxy

PREFIX是指定编译后的可执行文件路径

#make install PREFIX=/new/work/haproxy

将配置文件拷贝到可执行文件路径下

#cp examples/haproxy.cfg /new/work/haproxy/

3.修改配置文件

#cd /new/work/haproxy/

#vim /new/work/haproxy/haproxy.cfg

# this config needs haproxy-1.1.28 or haproxy-1.2.1

global
        log 127.0.0.1   local0
        log 127.0.0.1   local1 notice
        #log loghost    local0 info
        maxconn 4096
        chroot /new/work/haproxy/share/haproxy
        uid 99
        gid 99
        daemon
        #debug
        #quiet

defaults
        log     global
        mode    tcp
        option  tcplog
        option  dontlognull
        retries 3
        option redispatch
        maxconn 2000
        contimeout      5000
        clitimeout      50000
        srvtimeout      50000

listen  aaa.wencst.com 0.0.0.0:1234
#       bind 127.0.0.1:1234
        mode tcp
        balance roundrobin
        server  app1_1 192.168.0.6:1234 weight 3 check

配置文件按实际需要配置,这里展示为tcp协议的转发,listen可以配置根据域名转发,如果同样都是1234端口,可以根据不同的域名有不同的转发规则。

启动haproxy服务

#/new/work/haproxy/sbin/haproxy -f /new/work/haproxy/haproxy.cfg

如果文章对您有用,扫一下支付宝的红包,不胜感激!

欢迎加入QQ群进行技术交流:656897351(各种技术、招聘、兼职、培训欢迎加入)


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK