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层的网络交换, ...
随机推荐
- 时间格式化函数strftime
#include <time.h> #include <stdio.h> #include <string.h> int main() { char ti ...
- OpenCASCADE Extended Data Exchange - XDE
OpenCASCADE Extended Data Exchange - XDE eryar@163.com Abstract. OpenCASCADE Data Exchange allows de ...
- Unity3D:粒子系统Particle System
1. GameObject → Create Other → Particle System. 2. 选中 Particle System,可看到下列屬性: 3.Particle System: ...
- C语言利用 void 类型指针实现面向对象类概念与抽象
不使用C++时,很多C语言新手可能认为C语言缺乏了面向对象和抽象性,事实上,C语言通过某种组合方式,可以间接性的实现面对对象和抽象. 不过多态和继承这种实现,就有点小麻烦,但是依然可以实现. 核心: ...
- 用select标签实现跳转
用select标签实现跳转 一.用select标签实现跳转JavaScript代码 我们经常有遇到需要用select标签跳转到新网页的情况,dw生成的代码太复杂,那么有没有精简的代码得以实现呢?经过仔 ...
- private SortedDictionary<string, object> Dic_values = new SortedDictionary<string, object>();
private SortedDictionary<string, object> Dic_values = new SortedDictionary<string, object&g ...
- 51Nod 迷宫问题(最短路+权值)(模板)
你来到一个迷宫前.该迷宫由若干个房间组成,每个房间都有一个得分,第一次进入这个房间,你就可以得到这个分数.还有若干双向道路连结这些房间,你沿着这些道路从一个房间走到另外一个房间需要一些时间.游戏规定了 ...
- AIX lsof 命令
1.查看某端口运行情况 如查看22端口运行情况 # lsof –i:22 # lsof –i:22 –r ----每隔15秒显示22端口的监听情况. 2.查看活动的连接 如:查看ip地址为19 ...
- SASS常用方法
cnpm install --save-dev sass-loader //sass-loader依赖于node-sass cnpm install --save-dev node-sass //实现 ...
- Linux硬件信息查看
more /proc/cpuinfo more /proc/meminfo more /proc/*info lspci 查看主板信息等cat /proc/cpuinfo CPU信息cat /proc ...