先解决lua环境,(因为centos自带的版本不符合haproxy要求的最低版本(5.3)先安装Lua依赖的包

[root@slave-master lua-5.3.5]# yum install  vim iotop bc gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl  openssl-devel zip unzip zlib-devel  net-tools lrzsz tree ntpdate telnet lsof tcpdump wget libevent libevent-devel bc  systemd-devel bash-completion traceroute -y
[root@slave-master lua-5.3.5]# yum install libtermcap-devel ncurses-devel libevent-devel readline-devel -y

下载lua并编译安装

[root@slave-master haproxy-2.0.4]# cd /usr/local/src/
[root@slave-master src]# tar xf lua-5.3.5.tar.gz
[root@slave-master src]# cd lua-5.3.5
[root@slave-master lua-5.3.5]# make linux test
[root@slave-master lua-5.3.5]# src/lua -v
Lua 5.3.5  Copyright (C) 1994-2018 Lua.org, PUC-Rio

下载haproxy并编译安装

[root@slave-master src]# tar xf haproxy-2.0.4.tar.gz -C /usr/local/
[root@slave-master src]# cd /usr/local/haproxy
[root@slave-master haproxy-2.0.4]# make ARCH=x86_64 TARGET=linux-glibc USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 USE_SYSTEMD=1 USE_CPU_AFFINITY=1 USE_LUA=1 LUA_INC=/usr/local/src/lua-5.3.5/src/ LUA_LIB=/usr/local/src/lua-5.3.5/src/ PREFIX=/usr/local/haproxy
[root@slave-master haproxy-2.0.4]# make install PREFIX=/usr/local/haproxy
[root@slave-master haproxy-2.0.4]# cp haproxy /usr/sbin/

准备启动脚本

[root@slave-master haproxy]# vim /usr/lib/systemd/system/haproxy.service
[Unit]
Description=HAProxy Load Balancer
After=syslog.target network.target
[Service]
ExecStartPre=/usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -c -q
ExecStart=/usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /var/lib/haproxy/haproxy.pid
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
WantedBy=multi-user.target

准备配置文件

[root@slave-master haproxy]# mkdir /etc/haproxy/
[root@slave-master haproxy]# vim /etc/haproxy/haproxy.cfg
global
maxconn 100000
chroot /usr/local/haproxy
stats socket /var/lib/haproxy/haproxy.sock mode 600 level admin
uid 99
gid 99
daemon
#nbproc 4
#cpu-map 1 0
#cpu-map 2 1
#cpu-map 3 2
#cpu-map 4 3
pidfile /var/lib/haproxy/haproxy.pid
log 127.0.0.1 local3 info defaults
option http-keep-alive
option forwardfor
maxconn 100000
mode http
timeout connect 300000ms
timeout client 300000ms
timeout server 300000ms listen stats
mode http
bind 0.0.0.0:9999
stats enable
log global
stats uri /haproxy-status
stats auth haadmin:q1w2e3r4ys listen web_port
bind 192.168.37.33:80
mode http
log global
server web1 127.0.0.1:8080 check inter 3000 fall 2 rise 5

启动服务

[root@slave-master src]# mkdir /var/lib/haproxy
[root@slave-master src]# chown 99.99 /var/lib/haproxy/ -R
[root@slave-master haproxy]# systemctl start haproxy

编译安装haproxy2.0的更多相关文章

  1. 源码编译安装MySQL8.0

    源码编译安装MySQL8.0 0.前期准备条件 查看linux的版本 [root@mysql etc]# cat /etc/redhat-release CentOS Linux release 7. ...

  2. centos6.5下编译安装mariadb-10.0.20

    源码编译安装mariadb-10.0.20.tar.gz 一.安装cmake编译工具 跨平台编译器 # yum install -y gcc* # yum install -y cmake 解决依赖关 ...

  3. centos7下编译安装php-7.0.15(PHP-FPM)

    centos7下编译安装php-7.0.15(PHP-FPM) 一.下载php7源码包 http://php.net/downloads.php 如:php-7.0.15.tar.gz 二.安装所需依 ...

  4. centos6编译安装zabbix3.0和中文支持整理文档

    编者按: 最近公司部分业务迁移机房,为了更方便的监控管理主机资源,决定上线zabbix监控平台.运维人员使用2.4版本的进行部署,个人在业余时间尝鲜,使用zabbix3.0进行部署,整理文档如下,仅供 ...

  5. Linux Centos7.2 编译安装PHP7.0.2

    操作环境: 1.系统:Centos7.2 2.服务:Nginx 1.下载PHP7.0.2的安装包解压,编译,安装: $ cd /usr/src/ $ wget http://cn2.php.net/d ...

  6. centos7.6下编译安装zabbix4.0.10长期支持版

    一.安装数据库,这里使用的是percona-server5..24版本 配置如下 [root@zabbix4_clone:~]# cat /etc/my.cnf # Example MySQL con ...

  7. CentOS7下编译安装redis-5.0.9

    CentOS7下编译安装redis-5.0.9 本文地址http://yangjianyong.cn/?p=171转载无需经过作者本人授权 下载redis #code start wget https ...

  8. Linux下编译安装Vim8.0

    什么是Vim? Vim 是经典的 UNIX 编辑器 Vi 的深度改良版本.它增加了许多功能,包括:多级撤销.格式高亮.命令行历史.在线帮助.拼写检查.文件名补完.块操作.脚本支持,等等.除了字符界面版 ...

  9. Centos6.5下编译安装ACE6.0

    ACE在Linux下的编译安装步骤(CentOS6.5 64Bit) Linux平台安装(CentOS6.5 64bit) 1, 下载ACE软件包,上传至Linux服务器(假设目录为/opt/ace, ...

随机推荐

  1. python调试出现报错:SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xb0 in position 9: invalid start byte

    原因:如图,代码里字符串里加上汉字就会报相关错误: 解决办法:开头加上 #-*-coding:GBK -*-   即可解决

  2. vue脚手架配置代理

    vue.config.js配置具体代理规则 module.exports = { devServer: { proxy: { '/api1': { // 匹配所有以 '/api1'开头的请求路径 ta ...

  3. node获取请求我的客户端的地址

    node获取请求我的客户端的地址 const http = require('http'); //创建 Server const server = http.createServer() // 监听r ...

  4. IDEA 设置Java项目使用的JDK版本 最全篇

    1. File -> Project Setting -> Project : 2. File ->Project Setting -> Modules 3. File -&g ...

  5. Django笔记&教程 1-1 一 新建项目

    Django 自学笔记兼学习教程第1章第1节--一 新建项目 点击查看教程总目录 1- 命令行新建Django项目 新建项目命令(project_name处为项目名) django-admin sta ...

  6. go微服务框架Kratos笔记(一)入门教程

    kratos简介 Kratos 一套轻量级 Go 微服务框架,包含大量微服务相关功能及工具 本文基于kratos v2.0.3,windows平台,其他系统平台均可借鉴参考 环境搭建 Golang开发 ...

  7. Windows11下的快捷键(win10通用,部分win11独有的不通用)

    给大家介绍一下win11下我常用的几个快捷键,在微软官方的文档里面都可以查到,官网链接 https://support.microsoft.com/zh-cn/windows/windows-%E7% ...

  8. nginx 支持websocket

    nginx 反向代理websocket nginx配置 请求地址及路径:ws://x.x.x.x/web/springws/websocket.ws 解析 map 指令 上面 nginx.conf 配 ...

  9. Linux驱动实践:你知道【字符设备驱动程序】的两种写法吗?

    作 者:道哥,10+年嵌入式开发老兵,专注于:C/C++.嵌入式.Linux. 关注下方公众号,回复[书籍],获取 Linux.嵌入式领域经典书籍:回复[PDF],获取所有原创文章( PDF 格式). ...

  10. python实现图像直方图

    目录: (一)直方图的使用 正文: (一)直方图的使用 1 from matplotlib import pyplot as plt 2 def plot_demo(image): 3 print(i ...