CentOS 7.2 编译安装Haproxy-1.7.4

前端之家收集整理的这篇文章主要介绍了CentOS 7.2 编译安装Haproxy-1.7.4前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


@H_403_2@

  1. 环境设置@H_403_2@

    yum groupinstall -y "Development tools"@H_403_2@

  2. 解压haproxy1.7.4@H_403_2@

    tar -zxf haproxy-1.7.4.tar.gz -C /usr/local/@H_403_2@

  3. 编译安装haproxy@H_403_2@

    cdhaproxy-1.7.4@H_403_2@

    make TARGET=linux26 ARCH=X86_64 PREFIX=/usr/local/haproxy@H_403_2@

    make install PREFIX=/usr/local/haproxy@H_403_2@

  4. 创建haproxy启动脚本@H_403_2@

    vi /etc/init.d/haproxy@H_403_2@


    @H_403_2@


    @H_403_2@

#!/bin/sh@H_403_2@

#@H_403_2@

# chkconfig: - 85 15@H_403_2@

# description: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited \@H_403_2@

# for high availability environments.@H_403_2@

# processname: haproxy@H_403_2@

# config: /etc/haproxy/haproxy.cfg@H_403_2@

# pidfile: /var/run/haproxy.pid@H_403_2@

# Script Author: Simon Matter <simon.matter@invoca.ch>@H_403_2@

# Version: 2004060600@H_403_2@

# Source function library.@H_403_2@

if [ -f /etc/init.d/functions ]; then@H_403_2@

. /etc/init.d/functions@H_403_2@

elif [ -f /etc/rc.d/init.d/functions ] ; then@H_403_2@

. /etc/rc.d/init.d/functions@H_403_2@

else@H_403_2@

exit 0@H_403_2@

fi@H_403_2@

# Source networking configuration.@H_403_2@

. /etc/sysconfig/network@H_403_2@

# Check that networking is up.@H_403_2@

[ "${NETWORKING}" = "no" ] && exit 0@H_403_2@

# This is our service name@H_403_2@

BASENAME=`basename $0`@H_403_2@

if [ -L $0 ]; then@H_403_2@

BASENAME=`find $0 -name $BASENAME -printf %l`@H_403_2@

BASENAME=`basename $BASENAME`@H_403_2@

fi@H_403_2@

BIN=/usr/local/haproxy/sbin/haproxy@H_403_2@

CFG=/usr/local/haproxy/haproxy.cfg@H_403_2@

[ -f $CFG ] || exit 1@H_403_2@

PIDFILE=/var/run/$BASENAME.pid@H_403_2@

LOCKFILE=/var/lock/subsys/$BASENAME@H_403_2@

RETVAL=0@H_403_2@

start() {@H_403_2@

quiet_check@H_403_2@

if [ $? -ne 0 ]; then@H_403_2@

echo "Errors found in configuration file,check it with '$BASENAME check'."@H_403_2@

return 1@H_403_2@

fi@H_403_2@

echo -n "Starting $BASENAME: "@H_403_2@

daemon $BIN -D -f $CFG -p $PIDFILE@H_403_2@

RETVAL=$?@H_403_2@

echo@H_403_2@

[ $RETVAL -eq 0 ] && touch $LOCKFILE@H_403_2@

return $RETVAL@H_403_2@

}@H_403_2@

stop() {@H_403_2@

echo -n "Shutting down $BASENAME: "@H_403_2@

killproc $BASENAME -USR1@H_403_2@

RETVAL=$?@H_403_2@

echo@H_403_2@

[ $RETVAL -eq 0 ] && rm -f $LOCKFILE@H_403_2@

[ $RETVAL -eq 0 ] && rm -f $PIDFILE@H_403_2@

return $RETVAL@H_403_2@

}@H_403_2@

restart() {@H_403_2@

quiet_check@H_403_2@

if [ $? -ne 0 ]; then@H_403_2@

echo "Errors found in configuration file,check it with '$BASENAME check'."@H_403_2@

return 1@H_403_2@

fi@H_403_2@

5. 创建haproxy配置文件@H_403_2@

vi /usr/local/haproxy/haproxy.cfg@H_403_2@

#@H_403_2@

# demo config for Proxy mode@H_403_2@

#@H_403_2@

global@H_403_2@

log 127.0.0.1 local0 info #[err warning info debug]@H_403_2@

maxconn 4096@H_403_2@

daemon@H_403_2@

nbproc 1@H_403_2@

defaults@H_403_2@

mode http@H_403_2@

option httplog@H_403_2@

retries 3@H_403_2@

option redispatch@H_403_2@

option abortonclose@H_403_2@

maxconn 4096@H_403_2@

contimeout 5000@H_403_2@

clitimeout 30000@H_403_2@

srvtimeout 30000@H_403_2@

timeout check 2000@H_403_2@

frontend httpfrontend@H_403_2@

bind 0.0.0.0:80@H_403_2@

option httplog@H_403_2@

log 127.0.0.1 local2 info@H_403_2@


@H_403_2@

chkconfig --add haproxy
@H_403_2@

chkconfig --level 2345 haproxy on
@H_403_2@


@H_403_2@

6. chmod 755 /etc/init.d/haproxy@H_403_2@

systemctl start haproxy
@H_403_2@

7. 检查80,10050的端口是否打开@H_403_2@

ss -tnl@H_403_2@

猜你在找的CentOS相关文章