zoukankan      html  css  js  c++  java
  • haproxy—TCP负载均衡

    1.下载haproxy最新版本 http://www.haproxy.org/download/1.5/src/haproxy-1.5.12.tar.gz

    2.haproxy的安装

    mkdir –p /usr/local/haproxy/logs/ 也就是创建这个文件夹/usr/local/haproxy/logs/

    make TARGET=linux26 PREFIX=/usr/local/haproxy make install PREFIX=/usr/local/haproxy

    3.执行下面的命令

    [root@Template-Redhat54 haproxy-1.4.20]# install -d /usr/local/sbin

    [root@Template-Redhat54 haproxy-1.4.20]# install haproxy /usr/local/sbin

    [root@Template-Redhat54 haproxy-1.4.20]# install -d /usr/local/share/man/man1

    [root@Template-Redhat54 haproxy-1.4.20]# install -m 644 doc/haproxy.1 /usr/local/share/man/man1

    [root@Template-Redhat54 haproxy-1.4.20]# install -d /usr/local/doc/haproxy

    [root@Template-Redhat54 haproxy-1.4.20]# for x in configuration architecture haproxy-en haproxy-fr; do > install -m 644 doc/$x.txt /usr/local/doc/haproxy ; > done

    4.检查安装结果:

    [root@Template-Redhat54 haproxy-1.4.20]# haproxy

    看到类似下面的内容证明安装好了

    HA-Proxy version 1.4.20 2012/03/10

    Copyright 2000-2012 Willy Tarreau <w@1wt.eu>

    Usage : haproxy [-f <cfgfile>]* [ -vdVD ] [ -n <maxconn> ] [ -N <maxpconn> ] [ -p <pidfile> ] [ -m <max megs> ]

    -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.

    5.拷贝haproxy.cfg文件到usr/local/haproxy下。

    haproxy.cfg内容如下:

    ==============================================================

    global

    maxconn 51200

    chroot /usr/local/haproxy

    uid 99

    gid 99

    daemon

    #quiet

    nbproc 1

    pidfile /usr/local/haproxy/logs/haproxy.pid

    defaults

    mode http

    #retries 2

    option redispatch

    option abortonclose

    timeout connect 5000ms

    timeout client 30000ms

    timeout server 30000ms

    #timeout check 2000

    log 127.0.0.1 local0 err#[err warning info debug]

    balance roundrobin

    # option httplog

    # option httpclose

    # option dontlognull

    # option forwardfor

    listen admin_stats

    bind 0.0.0.0:7777

    option httplog

    stats refresh 30s

    stats uri /stats

    stats realm Haproxy Manager

    stats auth admin:admin

    #stats hide-version

    listen test1

    bind :63005

    mode tcp

    server t1 127.0.0.1:9797

    server t2 10.30.90.111:9797

    ==============================================================

    开启haproxy命令

    /usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg

    停止haproxy

    # killall haproxy

  • 相关阅读:
    好用的辅助工具
    摆脱单体架构黑洞>>>>走向微服务的乐园
    什么是 jQuery 事件
    WebDriver一些常见问题的解决方法【转】
    IE浏览器相关的问题及解决方案[转]
    fix org.openqa.selenium.NoSuchWindowException when find element on ie11.
    BI案例:BI在连锁零售业应用(ZT)【转】
    SQL 基础语法(创建表空间、用户、并授予权限、数据的增删改查) --(学习笔记)[转]
    创建数据库和表的SQL语句【转】
    T-sql语句中GO的作用及语法【转】
  • 原文地址:https://www.cnblogs.com/xzlive/p/14010120.html
Copyright © 2011-2022 走看看