加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

HAProxy advanced Redis health check---ref

发布时间:2020-12-16 04:45:12 所属栏目:安全 来源:网络整理
导读:http://blog.exceliance.fr/2014/01/02/haproxy-advanced-redis-health-check/ ? ? Introduction Redis ?is an opensource nosql database working on a key/value model.One interesting feature in? Redis ?is that it is able to write data to disk as w
</table>

The scenario is simple:??* 4 web application servers need to store and retrieve data to/from a?Redis?database??* one (better using 2)?HAProxy?servers which load-balance?redis?connections??* 2 (at least)?redis?servers in an active/standby mode with replication

Configuration

Below,is the HAProxy configuration for the

</td>
<td class="code">
<div class="container">
<div class="line number1 index0 alt2"><code class="plain plain">defaults REDIS


<div class="line number2 index1 alt1">
<code class="plain spaces">?<code class="plain plain">mode tcp

</td>

</tr></table>

The?HAProxy?health check sequence above allows to consider the?Redis?master server as UP in the farm and redirect connections to it.When the?Redis?master server fails,the remaining nodes elect a new one.?HAProxy?will detect it thanks to its health check sequence.

It does not require third party tools and make fail over transparent.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

http://blog.exceliance.fr/2014/01/02/haproxy-advanced-redis-health-check/

Introduction

Redis?is an opensource nosql database working on a key/value model.One interesting feature in?Redis?is that it is able to write data to disk as well as a master can synchronize many slaves.

HAProxy?can load-balance?Redis?servers with no issues at all.There is even a built-in health check for?redis?in?HAProxy.Unfortunately,there was no easy way for?HAProxy?to detect the status of a?redis?server: master or slave node. Hence people usually hacks this part of the architecture.

As written in the title of this post,we’ll learn today how to make a simple?Redisinfrastructure thanks to newest?HAProxy?advanced send/expect health checks.This feature is available in HAProxy 1.5-dev20 and above.

Purpose is to make the?redis?infrastructure as simple as possible and ease fail over for the web servers.?HAProxy?will have to detect which node is MASTER and route all the connection to it.

Redis high availability diagram with HAProxy

Below,an ascii art diagram of HAProxy load-balancing?Redis?servers:

</td>
<td class="code">
<div class="container">
<div class="line number1 index0 alt2"><code class="plain plain">+----+ +----+ +----+ +----+


<div class="line number2 index1 alt1"><code class="plain plain">| W1 | | W2 | | W3 | | W4 |?? Web application servers

<div class="line number3 index2 alt2"><code class="plain plain">+----+ +----+ +----+ +----+

<div class="line number4 index3 alt1">
<code class="plain spaces">?????<code class="plain plain">???? |?? |???? /

</td>

</tr>