命令切换linux ha,安装haproxy和haproxy命令,安装haproxy命令

安装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源...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值