安装haproxy和haproxy命令,安装haproxy命令
本文目录:
1.安装haproxy
2.haproxy命令
1.安装haproxy
CentOS自带了haproxy,但可能版本比较老。可以在IUS源上找到最新稳定版的haproxy。
cat </etc/yum.repos.d/ius.repo
[ius]
name=iusrepo
baseurl=https://mirrors.tuna.tsinghua.edu.cn/ius/stable/CentOS/$releasever/\$basearch
gpgcheck=0
enable=1
eof
yum -y install haproxy17u
以下是编译安装haproxy-1.7.10的过程。
编译安装haproxy时,可以借助于pcre环境,该环境下编译时借助正则表达式分析编译速度会快很多,但是没有该环境也可以安装。
yum -y install pcre pcre-devel
tar xf haproxy-1.7.10.tar.gz
cd haproxy-1.7.10
make TARGET=linux2628 ARCH=x86_64 PREFIX=/usr/local/haproxy USE_PCRE=1
make install PREFIX=/usr/local/haproxy
make时需要使用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 5.7 and above
- aix51 for AIX 5.1
- aix52 for AIX 5.2
- cygwin for Cygwin
- haiku for Haiku
- generic for any other OS or version.
- custom to manually adjust every setting
使用ARCH指定架构,不过ARCH选项可省。使用USE_PCRE=1表示使用PCRE环境编译,加快编译速度。
编译安装完成后,只有3个目录:doc、share和sbin,sbin里面只有一个haproxy的主程序haproxy。为了方便管理haproxy服务,可以从yum安装的haproxy中复制/etc/init.d/haproxy。
2.haproxy命令
常用的几个:
# 检查配置文件语法
haproxy -c -f /etc/haproxy/haproxy.cfg
# 以daemon模式启动,以systemd管理的daemon模式启动
haproxy -D -f /etc/haproxy/haproxy.cfg [-p /var/run/haproxy.pid]
haproxy -Ds -f /etc/haproxy/haproxy.cfg [-p /var/run/haproxy.pid]
# 启动调试功能,将显示所有连接和处理信息在屏幕
haproxy -d -f /etc/haproxy/haproxy.cfg
# restart。需要使用st选项指定pid列表
haproxy -f /etc/haproxy.cfg [-p /var/run/haproxy.pid] -st `cat /var/run/haproxy.pid`
# graceful restart,即reload。需要使用sf选项指定pid列表
haproxy -f /etc/haproxy.cfg [-p /var/run/haproxy.pid] -sf `cat /var/run/haproxy.pid`
# 显示haproxy编译和启动信息
haproxy -vv
回到Linux系列文章大纲:http://www.cnblogs.com/f-ck-need-u/p/7048359.html
回到网站架构系列文章大纲:http://www.cnblogs.com/f-ck-need-u/p/7576137.html
回到数据库系列文章大纲:http://www.cnblogs.com/f-ck-need-u/p/7586194.html
转载请注明出处:http://www.cnblogs.com/f-ck-need-u/p/8546010.html
注:若您觉得这篇文章还不错请点击右下角推荐,您的支持能激发作者更大的写作热情,非常感谢!
http://www.dengb.com/Linuxjc/1310080.htmlwww.dengb.comtruehttp://www.dengb.com/Linuxjc/1310080.htmlTechArticle安装haproxy和haproxy命令,安装haproxy命令 本文目录: 1.安装haproxy 2.haproxy命令 1.安装haproxy CentOS自带了haproxy,但可能版本比较老。可以在IUS源...