Centos 7 安装 Haproxy
【环境】
Centos 7.2
Web1:192.168.136.170
web2:192.168.136.166
Haproxy:192.168.136.173
【web服务器1、2】
安装Nginx(可参考YUM快速搭建LNMP)两台Web服务器都需要安装Nginx
为了方便区分web服务器,我们编辑下首页
web1:
- echo 'This is web 1' > /usr/share/nginx/html/index.html
- systemctl restart nginx
web2:
- echo 'This is web 1' > /usr/share/nginx/html/index.html
- systemctl restart nginx
【Haproxy服务器】
yum -y install haproxy
编辑haproxy配置文件
vim /etc/haproxy/haproxy.cfg
(下列红色的#部分,是需要注释的,最下方的是web服务器的地址,如有多个节点,就继续添加)
- #---------------------------------------------------------------------
- # Example configuration for a possible web application. See the
- # full configuration options online.
- #
- # http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
- #
- #---------------------------------------------------------------------
- #---------------------------------------------------------------------
- # Global settings
- #---------------------------------------------------------------------
- global
- # to have these messages end up in /var/log/haproxy.log you will
- # need to:
- #
- # ) configure syslog to accept network log events. This is done
- # by adding the '-r' option to the SYSLOGD_OPTIONS in
- # /etc/sysconfig/syslog
- #
- # ) configure local2 events to go to the /var/log/haproxy.log
- # file. A line like the following can be added to
- # /etc/sysconfig/syslog
- #
- # local2.* /var/log/haproxy.log
- #
- log 127.0.0.1 local2
- # chroot /var/lib/haproxy
- pidfile /var/run/haproxy.pid
- maxconn
- user haproxy
- group haproxy
- daemon
- # turn on stats unix socket
- stats socket /var/lib/haproxy/stats
- #---------------------------------------------------------------------
- # common defaults that all the 'listen' and 'backend' sections will
- # use if not designated in their block
- #---------------------------------------------------------------------
- defaults
- mode http
- log global
- option httplog
- option dontlognull
- option http-server-close
- option forwardfor except 127.0.0.0/
- # option redispatch
- retries
- timeout http-request 10s
- timeout queue 1m
- timeout connect 10s
- timeout client 1m
- timeout server 1m
- timeout http-keep-alive 10s
- timeout check 10s
- maxconn
- #---------------------------------------------------------------------
- # main frontend which proxys to the backends
- #---------------------------------------------------------------------
- frontend main *:
- acl url_static path_beg -i /static /images /javascript /stylesheets
- acl url_static path_end -i .jpg .gif .png .css .js
- use_backend static if url_static
- default_backend app
- #---------------------------------------------------------------------
- # static backend for serving up images, stylesheets and such
- #---------------------------------------------------------------------
- backend static
- balance roundrobin
- server static 127.0.0.1: check
- #---------------------------------------------------------------------
- # round robin balancing between the various backends
- #---------------------------------------------------------------------
- backend app
- balance roundrobin
- server app1 127.0.0.1: check
- server app2 127.0.0.1: check
- server app3 127.0.0.1: check
- server app4 127.0.0.1: check
- listen webcluster 0.0.0.0:
- option httpchk GET /index.html
- option persist
- balance roundrobin
- server inst1 192.168.136.170 check inter 2000 fall 3
- server inst2 192.168.136.166 check inter 2000 fall 3
然后访问haproxy地址,查看是否会对两台web服务器进行轮询访问。
Centos 7 安装 Haproxy的更多相关文章
- Centos 编译安装Haproxy
一.环境介绍 1.Centos6 2. haproxy-1.4.25.tar.gz 二.安装 $ curl -O http://haproxy.1wt.eu/download/1.4/src/hapr ...
- CentOS6.5 安装HAProxy 1.5.20
[在CentOS下安装haproxy] sudo yum install haproxy 编辑配置文件 vim /etc/haproxy/haproxy.cfg #------------------ ...
- centos 7 下安装haproxy
1 haproxy 下载 从如下目录下载haproxy:http://www.haproxy.org/download/1.7/src/haproxy-1.7.1.tar.gz 2 haproxy 安 ...
- 安装haproxy和haproxy命令
HaProxy系列文章:http://www.cnblogs.com/f-ck-need-u/p/7576137.html 1.安装haproxy CentOS自带了haproxy,但可能版本比较老. ...
- NoSql1 在Linux(CentOS)上安装memcached及使用
前言: 今天是初五,生活基本要从过年的节奏中回归到正常的生活了,所以想想也该想想与工作有关的事情了.我之前在工作中会经常使用memcached和redis,但是自己一直没有时间系统的好好看 ...
- 在Ubuntu|CentOS上安装Shutter截图工具及快捷键设置
简介 Shutter前身叫GScrot,它是一款相当棒的截图软件. 通过Shutter,你可以截取包括选定区域.全屏幕.窗口.窗口内的控件甚至网页的图像.通过内置的强大插件机制,你可以在截图后,对图像 ...
- CentOS下安装hadoop
CentOS下安装hadoop 用户配置 添加用户 adduser hadoop passwd hadoop 权限配置 chmod u+w /etc/sudoers vi /etc/sudoers 在 ...
- CentOS下安装使用start-stop-daemon
CentOS下安装使用start-stop-daemon 在centos下下了个自启动的服务器脚本 执行的时候发现找不到start-stop-daemon命令 好吧 执行手动编译一下 加上这个命令 w ...
- CentOS 7 安装 Docker
CentOS 7 安装 Docker 这里介绍 ContOS 7 的安装 docker V1.2+,包括阿里云加速 docker 镜像下载的设置,这对提升使用 docker 体验至关重要.其他系统安装 ...
随机推荐
- Hibernate持久化,生命周期
一 .生命周期 1.1 . 说明 持久化类就是我们所说的实体类,实体类(持久化类)对象是有状态的. 为什么实体类对象会有状态? 答:由于HIbernate框架是一个先映射,后操作的框架.所谓的状 ...
- k8s安装ingress
1. 环境准备 安装nginx-ingress-controller和backend cd /etc/yum.repos.d/mainfests 下载镜像的脚本 vi ingressnginx.sh ...
- Spring Cloud Alibaba学习笔记(6) - Sentinel使用总结
使用Sentinel API Sentinel主要有三个核心Api: SphU:定义资源,让资源收到监控,保护资源 SphU 包含了 try-catch 风格的 API.用这种方式,当资源发生了限流之 ...
- win7用驱动精灵安装了bcm94352ac蓝牙驱动后还是不能用蓝牙的解决方法
驱动精灵安装了驱动后,设备管理器处显示Bluetooth USB,但是没法用蓝牙,找不到蓝牙图标,后来在华硕官方下载了win7的Broadcom 蓝牙驱动程序装上之后就好了
- elementUI表单验证
elementUI表单验证非常方便,我们直奔主题: <template> <el-form ref="orderForm" :model="orderF ...
- 1+X证书学习日志——盒模型
## padding的作用: 控制子元素和父元素之间的位置关系 padding设置方法: ...
- 有用的vscode快捷键大全+自定义快捷键
VS Code是前端的一个比较好用的代码编辑器,但是我们不能老是局限于鼠标操作呀,有时候很不方便,所以呢,快捷键大全来啦,有的可能会和你们电脑自带的快捷键冲突呢,这时候,你自己设置一下就好了呀 一.v ...
- Android studio如何连接三星手机
打开Android studio,选择Trouble Shoot device connections: 这个菜单项会自动扫描本地已经用USB线连接的设备: 已经成功扫描出了我的Galaxy C7 P ...
- 删除MRP单据
select *into newtable from a_mplist 把a_mplist的表中的数据复制到newtable表中结构也是一样的 insert into newtable select ...
- Date与String的相互转换
构造函数 日期:new Date();//获取当前日期,精确到毫秒. 日期:new Date(long date);//即1970 年 1 月 1 日 00:00:00 GMT(Greenwich M ...