一:安装haproxy

  1:解压   编译   安装

  tar zxf haproxy-1.7.9.tar.gz

cd  haproxy-1.7.9

uname -e

make TARGET=linux2.6 PREFIX=/usr/local/haproxy

make install PREFIX=/usr/local/haproxy

二:创建haproxy配置文件

mkdir /etc/haproxy

cd /etc/haproxy/

vi   haproxy.cfg

########################
global
    log 127.0.0.1 local0
    log 127.0.0.1 local1 notice
    maxconn 4096
    user www
    group www
    daemon
    nbproc 8

defaults
    log global
    mode tcp
    option tcplog
    option dontlognull
    retries 3
    option redispatch
    maxconn 2000
    timeout connect 50000
    timeout client 50000
    timeout server 50000

#Ha代理192.168.6.140 22端口
listen sshd
    bind 0.0.0.0:11000
    server 140_ssh 192.168.6.140:22 check inter 2000 rise 2 fall 5

#Ha代理http
listen 192.168.6.140_tomcat
    bind 0.0.0.0:11001
    mode http
    balance roundrobin
    server web1 192.168.6.140:8080 weight 1 maxconn 10000 check inter 3s rise 3 fall 3

# Ha代理redis

listen redis
    bind 0.0.0.0:9999
    balance leastconn
    mode tcp
    # redis 健康检查,确保只有master提供连接
    option tcp-check
    tcp-check connect
    tcp-check send PING\r\n
    tcp-check expect string +PONG
    tcp-check send info\ replication\r\n
    tcp-check expect string role:master
    tcp-check send QUIT\r\n
    tcp-check expect string +OK
    server redis01 127.0.0.1:6380 check port 6380 inter 5s fastinter 2s downinter 5s rise 3 fall 3
    server redis02 127.0.0.1:6381 check port 6381 inter 5s fastinter 2s downinter 5s rise 3 fall 3

# Ha web页面配置

listen status

bind *:10000
    mode http
    stats enable
    stats uri /status
    stats refresh 5s
    stats show-node
    stats show-legends
    stats hide-version
    bind-process 2

三:配置haproxy启动脚本

cp /haproxy-1.7.9/examples/haproxy.init /etc/init.d/haproxy
cp /usr/local/haproxy/sbin/haproxy /usr/sbin/
chmod a+x /etc/init.d/haproxy

四:启动haproxy服务

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

/etc/init.d/haproxy start

最新文章

  1. windows访问lnmp配置的虚拟域名
  2. oracle相关环境变量配置
  3. bootStrap-2
  4. 23讲 URL2
  5. spring + jdbc + extjs configuration
  6. Android.mk编译APK范例
  7. 第五节,python基本语法
  8. 团队第十次 # scrum meeting
  9. java各种集合的线程安全
  10. Python3 读写文件
  11. ASCII,unicode, utf8 ,big5 ,gb2312,gbk,gb18030等几种常用编码区别(转载)
  12. Java log4j
  13. C#发送QQ邮件
  14. .NET获取文件的MIME类型(Content Type)
  15. CentOS 安装 Redis (高可用)
  16. django signal
  17. iOS子线程操作检测版本更新,有新版本通知用户更新, CheckVersion
  18. Q806 写字符串需要的行数
  19. 实现Netty服务器与CocosCreate通信
  20. oracle数据库列的操作

热门文章

  1. SpringBoot 在IDEA中实现热部署(实用版)(引入)
  2. 微信小程序添加底部导航栏
  3. Linux tcpdump命令详解与Wireshark
  4. No module named 'winrandom'。
  5. cookie的使用以及cookie的跨域名获取
  6. nginx跨域设置&文件上传大小限制
  7. sys.argv的意义及用法
  8. linux运维、架构之路-K8s应用
  9. @Data注解使用后get set报错解决方法
  10. Java中SSM+Shiro系统登录验证码的实现方法