haproxy1.7编译安装配置
#haproxy1.7编译安装配置
#高可用、负载均衡 使用
#haproxy1.7编译安装配置
#centos7 x86_64
#高可用、负载均衡 使用 #下载
#http://www.haproxy.org/download/1.7/src/haproxy-1.7.8.tar.gz
#cd /data/nfs/download
#yum install gcc gcc-c++ autoconf automake -y #安装haproxy
Hadir=/www/server/haproxy #安装目录
mkdir -p $Hadir
tar -axf haproxy-* && cd ./haproxy-*
make TARGET=linux2628 ARCH=x86_64 PREFIX=$Hadir
make install PREFIX=$Hadir
$Hadir/sbin/haproxy -v #增加用户
useradd -s /sbin/nologin -M haproxy
id haproxy #内核优化
# #NAT转发
# sed -i 's@net.ipv4.ip_forward = 0@net.ipv4.ip_forward = 1@g' /etc/sysctl.conf
# grep ip_forward /etc/sysctl.conf
echo "net.ipv4.ip_nonlocal_bind = 1" >>/etc/sysctl.conf #允许没监听IP时启动
sysctl -p #启动脚本配置
cp ./examples/haproxy.init $Hadir/haproxy
chmod $Hadir/haproxy
sed -i '/^BIN=/cBIN='$Hadir'/sbin/$BASENAME' $Hadir/haproxy
sed -i '/^CFG=/cCFG='$Hadir'/$BASENAME.cfg' $Hadir/haproxy #日志配置
sed -i 's/^#$ModLoad imudp/$ModLoad imudp/g' /etc/rsyslog.conf
sed -i 's/^#$UDPServerRun 514/$UDPServerRun 514/g' /etc/rsyslog.conf
echo 'local0.* /var/log/haproxy.log'>>/etc/rsyslog.conf #添加haproxy日志路径
systemctl restart rsyslog #生成配置文件
echo " ###########全局配置#########
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
daemon
#nbproc #进程数量
maxconn #最大连接数
user haproxy #运行用户
group haproxy #运行组
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
########默认配置############
defaults
log global
mode http #默认模式{ tcp|http|health }
option httplog #日志类别,采用httplog
option dontlognull #不记录健康检查日志信息
retries #2次连接失败不可用
option forwardfor #后端服务获得真实ip
option httpclose #请求完毕后主动关闭http通道
option abortonclose #服务器负载很高,自动结束比较久的链接
maxconn #最大连接数
timeout connect 5m #连接超时
timeout client 1m #客户端超时
timeout server 31m #服务器超时
timeout check 10s #心跳检测超时
balance roundrobin #负载均衡方式,轮询
########统计页面配置########
listen stats
bind 0.0.0.0:
mode http
option httplog
log 127.0.0.1 local0 err
stats refresh 30s
maxconn #最大连接数
stats uri /admin #状态页面 http//ip:1080/admin访问
stats realm Haproxy\ Statistics
stats auth admin:admin #用户和密码:admin
stats hide-version #隐藏版本信息
stats admin if TRUE #设置手工启动/禁用 ########设置haproxy 错误页面#####
#errorfile /opt/haproxy/errorfiles/.http
#errorfile /opt/haproxy/errorfiles/.http
#errorfile /opt/haproxy/errorfiles/.http
errorloc https://www.baidu.com/
#errorfile /opt/errorfiles/.http ########frontend前端配置##############
frontend http_main
bind *:
option forwardfor
acl web hdr(host) -i elven.win #acl规则,-i忽略大小写,访问*就触发web规则
use_backend web1 if web acl web_kvm path_beg -i /kvm
use_backend kvm if web_kvm default_backend web1 #不满足则响应的默认页面 ########backend后端配置##############
backend web1 #www1作用域 service haproxy restart
cookie SERVERID
balance roundrobin
option httpchk HEAD /index.html HTTP/1.0
server web1 192.168.20.81: weight check inter rise fall
server web2 192.168.18.12: weight check inter rise fall backend kvm
server kvm1 127.0.0.1: ">$Hadir/haproxy.cfg
chown -R haproxy:haproxy $Hadir/ #启动
/www/server/haproxy/haproxy start
netstat -antp|grep haproxy
ps -ef|grep haproxy #添加自启动
ln -sf /www/server/haproxy/haproxy /etc/init.d/haproxy
chkconfig --add haproxy
chkconfig haproxy on
chkconfig --list haproxy
service haproxy restart #查看监控
http://ip:1080/admin
#cat /var/log/haproxy.log ##启动报错 第 行:[: =: 期待一元表达式,[]里的变量用加上引号“”
#修改为如下:
[ "${NETWORKING}" = "no" ] && exit
haproxy1.7编译安装配置的更多相关文章
- azkaban编译安装配置文档
azkaban编译安装配置文档 参考官方文档: http://azkaban.github.io/azkaban/docs/latest/ azkaban的配置文件说明:http://azkaban. ...
- Visual Studio 2015编译安装配置QT5.5.1(含QTWEBKIT)
尽管QT5.5.1和VisualStudio 2015都已经发布很久了,但是QT项目组视乎不会为QT5.5.1专门发布预编译的QT5.5.1 for windows(2015)版本的,也不会专门发布V ...
- blfs(systemd版本)学习笔记-编译安装配置dhcpcd
我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! dhcpcd项目地址:http://www.linuxfromscratch.org/blfs/view/stable-syst ...
- blfs(systemv版本)学习笔记-编译安装配置dhcpcd
我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! dhcpcd项目地址:http://www.linuxfromscratch.org/blfs/view/8.3/basicne ...
- heartbeat 编译安装配置
一.heartbeat介绍 heartbeat是HA高可用集群的一个重要组件,heartbeat实现了资源转移和心跳信息传递.它的常用组合方式为heartbeat v1,heartbeat v2+cr ...
- cloudera impala编译 安装 配置 启动
无论是采用GDB调试impala或者尝试修改impala源码,前提都是需要本地环境编译impala,这篇文章详细的分享一下impala编译方法以及编译过程遇到的棘手的问题: 前言: impala官方的 ...
- CentOS 7.4下源码编译安装配置LAMP环境详解
CentOS 7.4搭建LAMP,LAMP:Linux.Apache.MySQL.PHP. 目录:第一部分 准备工作第二部分 安装Apache服务第三部分 安装MySQL服务第四部分 搭建PHP运行环 ...
- Linux下编译安装配置MariaDB数据库
说明:操作系统:CentOS 6.6 64位MariaDB版本:mariadb-5.5.33aMariaDB数据库存放目录:/data/mysql准备:一.配置防火墙,开启3306端口vi /etc ...
- 安装Hadoop系列 — eclipse plugin插件编译安装配置
[一].环境参数 eclipse-java-kepler-SR2-linux-gtk-x86_64.tar.gz //现在改为eclipse-jee-kepler-SR2-linux-gtk-x86_ ...
随机推荐
- Git相关操作四
1.克隆远程仓库 git clone remote_location clone_name remote_location为仓库地址,clone_name为要克隆到本地的仓库名称. 2.显示对应克隆地 ...
- LeetCode 342. Power of Four (4的次方)
Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example:Giv ...
- LeetCode 40. Combination Sum II (组合的和之二)
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in ...
- LeetCode 34. Search for a Range (找到一个范围)
Given an array of integers sorted in ascending order, find the starting and ending position of a giv ...
- myeclipse+tomcat中出现org.apache.juli.logging.LogFactory这样的错误[转]
将项目部署好后,启动tomcat后报错,java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory 报这个错说明你用的是t ...
- 使用bower init创建bower.json文件
使用bower init 可以快速创建bower.json文件 bower init 回答一系列问题后就可以了,其中大部分问题可以按enter跳过.
- hive1.2.2部署
1.解压hvie.tar,进入conf目录下,cp hive-default.xml.template hive-site.xml; 2.将hive下的新版本jline的JAR包拷贝到hadoop下: ...
- Paint the Grid Again (隐藏建图+优先队列+拓扑排序)
Leo has a grid with N × N cells. He wants to paint each cell with a specific color (either black or ...
- html5页面实现点击复制功能
在实际工作中,有时候会遇到这样的需求,页面上有一个链接,不需要选中链接内容,只需要点击复制按钮,就可以把链接内容复制到剪切板.这时候可以使用clipboard插件来实现.以下是一个简单的demo. 首 ...
- js判断对象还是数组
1.对于Javascript 1.8.5(ECMAScript 5),变量名字.isArray( )可以实现这个目的 var a=[]; var b={}; Array.isArray(a);//tr ...