ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
一)yum安装haproxy 在centos7.3上haproxy版本为:Version : 1.5.18 [root@proxy01 ~]# yum -y install haproxy 查看目录结构 [root@proxy01 ~]# rpm -ql haproxy /etc/haproxy/haproxy.cfg /etc/logrotate.d/haproxy /etc/sysconfig/haproxy /usr/bin/iprange /usr/lib/systemd/system/haproxy.service 启动脚本: [root@proxy01 ~]# vim /usr/lib/systemd/system/haproxy.service [Unit] Description=HAProxy Load Balancer After=syslog.target network.target [Service] EnvironmentFile=/etc/sysconfig/haproxy ExecStart=/usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid $OPTIONS ExecReload=/bin/kill -USR2 $MAINPID KillMode=mixed [Install] WantedBy=multi-user.target 二)编译安装haproxy1.7.10 [root@proxy02 haproxy-1.7.10]# yum -y install pcre-devel zlib-devel openssl-devel [root@proxy02 src]# wget http://soft.51yuki.cn/haproxy-1.7.10.tar.gz [root@proxy02 src]# tar xf haproxy-1.7.10.tar.gz && cd haproxy-1.7.10 [root@proxy02 haproxy]# make TARGET=linux2628 USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 ARCH=x86_644 && make install PREFIX=/usr/local/haproxy 创建目录存放配置文件 [root@proxy02 haproxy]# mkdir /etc/haproxy 编写一个配置文件 ~~~ global log 127.0.0.1 local2 chroot /usr/local/haproxy pidfile /usr/local/haproxy/haproxy.pid maxconn 100000 daemon nbproc 1 defaults option http-keep-alive maxconn 100000 mode http log global option httplog timeout http-request 10s timeout queue 1m timeout connect 10s timeout client 1m timeout server 1m timeout http-keep-alive 10s timeout check 10s ######################################################### listen status mode http bind *:8888 stats enable stats hide-version stats uri /haproxy-status stats auth haproxy:saltstack stats admin if TRUE stats realm Haproxy\ Statistics #stats scope . #--------------------------------------------------------------------- # main frontend which proxys to the backends #--------------------------------------------------------------------- #frontend main *:5000 # acl url_static path_beg -i /static /images /javascript /stylesheets # acl url_static path_end -i .jpg .gif .png .css .js # # use_backend static if url_static # default_backend app #--------------------------------------------------------------------- ###################################################################### frontend frontend_www_example_com bind 10.2.11.170:80 mode http option httplog log global default_backend backend_www_example_com ####################################################### backend backend_www_example_com option forwardfor header X-REAL-IP option httpchk HEAD / HTTP/1.0 balance roundrobin server web01.51yuki.cn 10.2.11.207:8080 check inter 2000 rise 30 fall 15 server web02.51yuki.cn 10.2.11.206:8080 check inter 2000 rise 30 fall 15 ~~~ 启动脚本: [root@proxy02 haproxy]# cp /usr/local/src/haproxy-1.7.10/examples/haproxy.init /etc/init.d/haproxy 修改脚本 BIN=/usr/local/haproxy/sbin/$BASENAME