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