Haproxy 为 mysql 做负载均衡
tar zxvf haproxy-1.4..tar.gz
cd haproxy-1.4.
uname -r vim /etc/haproxy.cfg global
#日志
log 127.0.0.1 local0
maxconn
chroot /tmp
uid
gid daemon
nbproc
pidfile logs/haproxy.pid
#debug
#quiet
defaults
log 127.0.0.1 local3
mode http
#option httplog
#option httpclose
option dontlognull
#option forwardfor
option redispatch
retries
maxconn
contimeout
clitimeout
srvtimeout
balance roundrobin
bind-process
#监控状态页配置
listen stats
mode http
bind 0.0.0.0:
stats enable
stats uri /dbstat
stats realm Global\ statistics
#身份验证
stats auth admin:hello123 listen mysql_proxy
#代理端口
bind 0.0.0.0:
#模式 TCP
mode tcp
#调度算法
balance roundrobin
#mysql健康检查
option mysql-check
#健康检查加上check
server s1 192.168.1.42: weight check port inter 1s rise fall
server s3 192.168.1.43: weight check port inter 1s rise fall #启动服务
/usr/local/haproxy/sbin/haproxy -f /etc/haproxy.cfg
#杀掉服务
pkill haproxy #启动脚本
vim /etc/init.d/haproxy ========================================
#! /bin/sh
set -e PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/haproxy/sbin
PROGDIR=/usr/local/haproxy
PROGNAME=haproxy
DAEMON=$PROGDIR/sbin/$PROGNAME
CONFIG=/etc/haproxy.cfg
PIDFILE=$PROGDIR/logs/$PROGNAME.pid
DESC="HAProxy daemon"
SCRIPTNAME=/etc/init.d/$PROGNAME # Gracefully exit if the package has been removed.
test -x $DAEMON || exit start()
{
echo -n "Starting $DESC: $PROGNAME"
$DAEMON -f $CONFIG
echo "."
} stop()
{
echo -n "Stopping $DESC: $PROGNAME"
haproxy_pid=cat $PIDFILE
kill $haproxy_pid
echo "."
} restart()
{
echo -n "Restarting $DESC: $PROGNAME"
$DAEMON -f $CONFIG -p $PIDFILE -sf $(cat $PIDFILE)
echo "."
} case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart}" >&
exit
;;
esac exit
=================================================
chmod +x /etc/init.d/haproxy #启动服务
/etc/init.d/haproxy start
参考:
http://www.2cto.com/database/201412/357835.html
http://blog.sina.com.cn/s/blog_5f66526e0100om1x.html
Haproxy 为 mysql 做负载均衡的更多相关文章
- 用Haproxy给MySQL做负载均衡
1.安装 # wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.24.tar.gz # tar zcvf haproxy-1.4.24.t ...
- haproxy实现mysql slave负载均衡
简单画一个图: 一.服务器规划 192.168.116.132 (master) -->写操作 192.168.116.129 (slave1) -->读操作 192.168.116. ...
- Mysql的Haproxy反向代理和负载均衡
HaProxy提供高可用性.负载均衡以及基于TCP和HTTP应用的代理,支持虚拟主机,它是免费.快速并且可靠的一种解决方案.应用到Haproxy主要是因为他免费,并且基于TCP和HTTP的应用代理. ...
- 使用haproxy做负载均衡时保持客户端真实的IP
haproxy里添加设置项 option forwardfor option httpclose apache的日志格式修改 LogFormat "MY IP=%{X-Forwarded-F ...
- RabbitMQ3.6.3集群搭建+HAProxy1.6做负载均衡
目录 [TOC] 1.基本概念 1.1.RabbitMQ集群概述 通过 Erlang 的分布式特性(通过 magic cookie 认证节点)进行 RabbitMQ 集群,各 RabbitMQ 服 ...
- lvs(+keepalived)、haproxy(+heartbeat)、nginx 负载均衡的比较分析
目前使用比较多的就是标题中提到的这两者,其实lvs和haproxy都是实现的负载均衡的作用,keepalived和heartbeat都是提高高可用性的,避免单点故障.那么他们为什么这么搭配,而又有什么 ...
- RabbitMQ3.6.3集群搭建+HAProxy1.6做负载均衡
目录 目录 1.基本概念 1.1.RabbitMQ集群概述 1.2.软件负载均衡器HAProxy 2.RabbitMQ的配置步骤 2.1.安装 Erlang.RabbitMQ 2.2.修改 /etc/ ...
- (转载)Nginx/LVS/HAProxy三种主流负载均衡软件的对比
原地址:http://www.ha97.com/5646.html PS:Nginx/LVS/HAProxy是目前使用最广泛的三种负载均衡软件,本人都在多个项目中实施过,参考了一些资料,结合自己的一些 ...
- haproxy高可用、负载均衡集群
HAProxy提供高可用性.负载均衡以及基于TCP和HTTP应用的代理,支持虚拟主机,它是免费.快速并且可靠的一种解决方案.根据官方数据,其最高极限支持10G的并发.另外其支持从4层至7层的网络交换, ...
随机推荐
- 洛谷 P1705 爱与愁过火
P1705 爱与愁过火 题目背景 (本道题目隐藏了两首歌名,找找看哪~~~) <爱与愁的故事第一弹·heartache>第三章. 爱与愁大神说这是ta的伤心指数,只不过现在好很多了,翻译只 ...
- SQL 自增列清零方法
SQL Identity自增列清零方法1.使用DBCC控制台命令: dbcc checkident(表名,RESEED,0) 2.truncate table 也可将当前标识值清零 但当有外键等约束时 ...
- Linux中为XEN网桥绑定物理网卡
XEN虚拟机会默认将可以连通外网的网卡绑定到xenbr0上, 因此如果需要切换到其他物理网卡上时,需要自己配置脚本或执行命令. 1.添加脚本绑定 a.编写一个脚本,指定网卡与网桥绑定的关系 # vim ...
- webgoat 7.1 实战指南
WSASP中文文档参考链接: http://www.owasp.org.cn/owasp-project/2017-owasp-top-10 OWASP Top 10 2017中文版V1.3http: ...
- POJ 2227 FloodFill (priority_queue)
题意: 思路: 搞一个priority_queue 先把边界加进去 不断取最小的 向中间扩散 //By SiriusRen #include <queue> #include <cs ...
- ajax处理响应(三)
一旦脚本调用了send方法,浏览器就会在后台发送请求到浏览器.因为请求是在后台处理的,所以Ajax依靠事件来通知你这个请求的进度的进展情况,在上个随笔的里,使用handleResponse函数 ...
- POJ——T 2406 Power Strings
http://poj.org/problem?id=2406 Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 50627 ...
- ArcGIS Engine检索要素集、要素类和要素
转自原文 ArcGIS Engine检索要素集.要素类和要素 /// <summary> /// 获取所有要素集 /// </summary> /// <param na ...
- MySQL具体解释(13)------------事务
一. 什么是事务 事务就是一段sql 语句的批处理.可是这个批处理是一个atom(原子) .不可切割,要么都运行,要么回滚(rollback)都不运行. 二.为什么出现这样的技术 为什么要使用事务这个 ...
- 基本3D变换之World Transform, View Transform and Projection Transform
作者:i_dovelemon 来源:CSDN 日期:2014 / 9 / 28 主题:World Transform, View Transform , Projection Transform 引言 ...