haproxy安装配置
来源:互联网 发布:优化csgo的显卡驱动 编辑:程序博客网 时间:2024/06/18 16:24
HAProxy实现了一种事件驱动,单一进程模型,此模型支持非常大的并发连接数。多进程或多线程模型受内存限制 、系统调度器限制以及无处不在的锁限制,很少能处理数千并发连接。事件驱动模型因为在有更好的资源和时间管理的用户空间(User-Space) 实现所有这些任务,所以没有这些问题。此模型的弊端是,在多核系统上,这些程序通常扩展性较差。这就是为什么他们必须进行优化以 使每个CPU时间片(Cycle)做更多的工作。
1、Haproxy下载地址http://download.csdn.net/detail/learner198461/9627517
2、解压 tar -zxvf haproxy.tar.gz cd haproxy目录,执行make TARGET=generic ARCH=x86_64(这里可以指定内核版本,内核版本用uname -a查看,如果不确定内核版本对应命令参数,可以用默认。),ARCH指定CPU体系。make 之后,执行安装 make install PERFIX=/usr/local/haproxy
3、编译带ssl make TARGET=generic ARCH=x86_64 USE_OPENSSL=1(确认以及安装openssl)
编译ssl静态库
$ export STATICLIBSSL=/tmp/staticlibssl
$ ./config --prefix=$STATICLIBSSL no-shared
$ make && make install_sw
4、创建配置文件 mkdir /usr/local/haproxy/conf mkdir /usr/local/haproxy/run 从examples拷贝配置
5、配置日志 local0.* /var/log/haproxy.log 重启服务rsylog
6、可以启动haproxy服务了 命令:haproxy -f /etc/haproxy/haproxy.cfg
haproxy -f /etc/haproxy/haproxy.cfg -sf `cat /var/run/haproxy.pid`
配置文件内容参考
###########全局配置#########
global
daemon
nbproc 1
pidfile /var/run/haproxy.pid
########默认配置############
defaults
mode http #默认的模式mode { tcp|http|health },tcp是4层,http是7层,health只会返回OK
retries 2 #两次连接失败就认为是服务器不可用,也可以通过后面设置
option redispatch #当serverId对应的服务器挂掉后,强制定向到其他健康的服务器
option abortonclose #当服务器负载很高的时候,自动结束掉当前队列处理比较久的链接
maxconn 4096 #默认的最大连接数
timeout connect 5000ms #连接超时
timeout client 30000ms #客户端超时
timeout server 30000ms #服务器超时
#timeout check 2000 #=心跳检测超时
log 127.0.0.1 local0 err #[err warning info debug]
########统计页面配置########
listen admin_stats
bind 0.0.0.0:1080 #监听端口
mode http #http的7层模式
option httplog #采用http日志格式
#log 127.0.0.1 local0 err
maxconn 10
stats refresh 30s #统计页面自动刷新时间
stats uri /stats #统计页面url
stats realm XingCloud\ Haproxy #统计页面密码框上提示文本
stats auth admin:admin #统计页面用户名和密码设置
stats hide-version #隐藏统计页面上HAProxy的版本信息
########test1配置#################
listen test1
bind 0.0.0.0:90
mode tcp
#maxconn 4086
#log 127.0.0.1 local0 debug
server s1 10.18.138.201:80
server s2 10.18.102.190:80
server s3 10.18.102.189:80
server s4 10.18.102.188:80
server s5 10.18.102.187:80
########frontend配置##############
########test2配置#################
listen test2
bind 0.0.0.0:91
mode tcp
#maxconn 4086
#log 127.0.0.1 local0 debug
server s1 10.18.138.130:80 weight 1
server s2 10.18.138.201:8080 weight 6
########frontend配置##############
附(TARGET)
- linux22 for Linux 2.2
- linux24 for Linux 2.4 and above (default)
- linux24e for Linux 2.4 with support for a working epoll (> 0.21)
- linux26 for Linux 2.6 and above
- linux2628 for Linux 2.6.28, 3.x, and above (enables splice and tproxy)
- solaris for Solaris 8 or 10 (others untested)
- freebsd for FreeBSD 5 to 10 (others untested)
- netbsd for NetBSD
- osx for Mac OS/X
- openbsd for OpenBSD 3.1 and above
- aix51 for AIX 5.1
- aix52 for AIX 5.2
- cygwin for Cygwin
- generic for any other OS or version.
- custom to manually adjust every setting
附(arch)
i386,i486,i586,i686,x86_6
- haproxy安装与配置
- haproxy安装与配置
- Haproxy安装配置
- Haproxy安装和配置
- Haproxy安装与配置
- haproxy安装与配置
- Haproxy+keepalived安装配置
- haproxy 安装和配置
- Haproxy 安装 配置
- haproxy安装配置
- Haproxy安装及配置
- haproxy安装配置介绍
- HAProxy 安装与配置
- Haproxy安装与配置
- haproxy 安装配置
- haproxy安装配置
- HAProxy安装及配置
- haproxy安装配置
- 防止ViewPager中的Fragment被销毁的方法,更加流畅
- ListView控件中item中实现的Button的点击事件
- HTML5 User Interaction(描述页面内容交互工作的新方式)
- 前端小特效
- 分布式与集群的区别
- haproxy安装配置
- 函数指针
- leetcode——Kth Largest Element in an Array
- Android打造通用标题栏——让你的App统一标题栏风格
- mfc 对话框 listbox control
- 过客--茫然了,梳理一下20160911
- hdu5875(思维题)
- Volley框架你想知道的秘密
- 使用rxjava实现imager loader,自定义缓存规则,