### redishappy
[![Build Status](https://travis-ci.org/mdevilliers/redishappy.svg?branch=master)](https://travis-ci.org/mdevilliers/redishappy)
[![Coverage Status](https://coveralls.io/repos/mdevilliers/redishappy/badge.png)](https://coveralls.io/r/mdevilliers/redishappy)
One method of providing a highly available Redis service is to deploy using [Redis Sentinel](http://redis.io/topics/sentinel).
Redis Sentinel monitors your Redis cluster and on detecting failure, promotes a slave to become the new master. RedisHappy provides a daemon to monitor for this promotion and to tell the outside world that this has happened.
Currently we support [HAProxy](http://www.haproxy.org/) with redishappy-haproxy and [Consul](https://www.consul.io/) with redishappy-consul.
Features
* Automatic discovery and healthchecking of Redis Sentinels.
* Extensible to support various service discovery mechanisims
* Developed in Golang, clean deployment with no additional dependencies.
* Read-only RestAPI.
* Syslog integration.
* RPM and Deb packages available.
* Support for Linux, Solaris and Windows
* [Puppet module available](https://github.com/lesaux/puppet-redishappy).
### Deployment
Redishappy ships in two forms redishappy-haproxy and redishappy-consul.
#### redishappy-haproxy
redishappy-haproxy updates HAProxy's configuration file on Redis master promotion and then reloads the HAProxy configuration file. The reload maintains current connections.
![redishappy_haproxy]( docs/redishappy-haproxy.png)
The redishappy daemon is installed on the same machine as HAProxy and runs with correct user rights to interact with HAProxy. Multiple instance of HAProxy/redishappy-haproxy can be deployed and operate seperatly.
#### redishappy-consul
redishappy-consul updates entries in a Consul instance on Redis master promotion.
![redishappy_consul]( docs/redishappy-consul.png)
### FAQ
Q. Why - I thought in the modern age Redis clients should be Sentinel aware? They should connect to the correct Redis instance on failover.
A. Some do, some don't. Some it seems to be an eternal 'work in progress'. Rather than fixing all of the clients we needed to work correctly with Sentinel, RedisHappy was built upon the fact that all of the clients I have tested are great at connecting to a single address.
Operations teams also need to support legacy applications and libraries - adding redishappy, Sentinels and HAProxy can help provide a HA enviroment for Redis backed applications.
Q. Why - This [article](http://blog.haproxy.com/2014/01/02/haproxy-advanced-redis-health-check/) suggests that HAProxy can healthcheck Redis instances quite fine by itself.
A. Yes. It can do. But not reliably... I'll explain.
Suppose we have this setup. R1 and R2 are redis instances, S1,S2,S3 are Sentinel instances, H1 and H2 are HAProxy instances.
<pre>
R1,R2
S1, S2, S3
H1, H2
</pre>
- Life is good - R1 and R2 are in a master slave configuration, H1 and H2 correctly identify R1 as the master
<pre>
R1 R2
M ---- S
^
|
---------
| |
H1 H2
</pre>
- Disaster! - R1 dies or is partitioned but don't fear R2 is now the "master". Day saved!
<pre>
* R2
M
^
|
---------
| |
H1 H2
</pre>
- Disaster! - R1 comes back online and announces itself as a "master". Both R1 and R2 are now accepting writes, as HAProxy's healthcheck identifies both as online.
<pre>
R1 R2
M M
^ ^
| |
---------
| |
H1 H2
</pre>
- R1 is made the "slave" of R2. Everything is ok now, except for the writes that R1 accepted which are lost forever.
<pre>
R1 R2
S ----- M
^
|
---------
| |
H1 H2
</pre>
When a Redis instance is started and stopped it initially announces itself as a "master". It will some time later be made a "slave" but in the meantime accept writes which will be lost when it is correctly made a slave.
RedisHappy attempts to avoid this failure mode by only presenting the correct server to HAProxy or any other service once it is confirmed as a "master". We assume clients will either block or fail until the master is online again.
### Building
Using Vagrant
The provided vagrant file creates a virtual machine with all of the dependancies to build redishappy, smoke test it, and build the deb and rpm packages.
```sh
vagrant up
```
The packages are automatically built to - $GOPATH/src/github.com/mdevilliers/redishappy/
The vagrant box also installs HAProxy, Docker and https://github.com/mdevilliers/docker-rediscluster for manual testing.
Download and build.
Install golang 1.4 +
```sh
go get github.com/mdevilliers/redishappy
cd $GOPATH/src/github.com/mdevilliers/redishappy
go get github.com/tools/godep
go get github.com/axw/gocov/gocov
go get github.com/mattn/goveralls
go get golang.org/x/tools/cmd/cover
go get golang.org/x/tools/cmd/goimports
godep restore
build/ci.sh
```
### Defaults
Installing using the deb and rpm packages will set the following defaults -
* Installs to `/usr/bin/redis-haproxy`
* Configuration to `/etc/redishappy-haproxy`
* Logs to file in `/var/log/redishappy-haproxy`
* Warnings, Errors go to syslog
### Configuration
Example configurations can be found in the main folders
* [HAProxy](main/redis-haproxy)
* [Consul](main/redis-consul)
Definitions for the elements
```js
{
// OPTIONAL - TCP Keep-Alive time (in seconds)
"SentinelTCPKeepAlive" : 0
// REQUIRED - needs to contain at least one logical cluster
"Clusters" :[
{
"Name" : "testing", // logical name of Redis cluster
"ExternalPort" : 6379 // port to expose for the cluster via HAProxy
}],
// REQUIRED - needs to contain the details of at least one cluster
// redishappy will discover additional sentinels as they come online
"Sentinels" : [
{"Host" : "172.17.42.1", "Port" : 26377}
],
// OPTIONAL for running redishappy-haproxy
"HAProxy" :
{
// REQUIRED - absolute path to the template file
"TemplatePath": "/var/redishappy/haproxy_template.cfg",
// REQUIRED - absolute path to HAProxy's config file
"OutputPath": "/etc/haproxy/haproxy.cfg",
// REQUIRED - command to run to reload the config file on changes
"ReloadCommand": "haproxy -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid)"
},
// OPTIONAL for running redishappy-consul
"Consul" : {
// REQUIRED - path to Consul instance
"Address" : "127.0.0.1:8500",
// REQUIRED - for each cluster in the main config there should be a defined service
"Services" : [
{
// REQUIRED - should match a name of a Cluster in the main config
"Cluster" : "testing",
// REQUIRED - logical name for the node
"Node" : "redis-1",
// REQUIRED - logical name for the data centre
"Datacenter": "dc1",
// REQUIRED - tags for the service
"tags" : [ "redis", "master", "anothertag"]
}
]
}
}
```
Or you can configure with the following environmental variables -
Environment Variable | Example | Notes
-----------------------------------|------------------|-----------------------------------
`REDISHAPPY_CLUSTERS` | clustername:6379 | multiple values can be ; seperated
`REDISHAPPY_SENTINELS` | ip_name:26377 | multiple values can be ; seperated
`REDISHAPPY_HAPROXY_TEMPLATE_PATH` | | string, see config file for example
`REDISHAPPY_HAPROXY_OUTPUT_PATH` | | string, see config file for example
`REDISHAPPY_HAPROXY_RELOAD_CMD` | | string, see config file for example
### API
RedisHappy provides a readonly API on port 8000. You can change the port by specifying a `PORT` environment variable. It is also possible to use a `BIND` [environment
没有合适的资源?快使用搜索试试~ 我知道了~
Redis Sentinel 高可用性守护进程.zip
共82个文件
go:52个
json:5个
txt:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 159 浏览量
2024-12-03
18:05:04
上传
评论
收藏 100KB ZIP 举报
温馨提示
重新快乐 提供高可用性 Redis 服务的一种方法是使用Redis Sentinel进行部署。Redis Sentinel 监控您的 Redis 集群,并在检测到故障时将某个从属节点提升为新的主节点。RedisHappy 提供了一个守护进程来监控此提升并告知外界此情况已发生。目前我们通过 redishappy-haproxy支持HAProxy ,通过 redishappy-consul 支持Consul。特征Redis Sentinels 的自动发现和健康检查。可扩展支持各种服务发现机制使用 Golang 开发,干净部署,无需任何额外依赖。只读 RestAPI。Syslog 集成。RPM 和 Deb 包可用。支持 Linux、Solaris 和 Windows木偶模块可用。部署Redishappy 有两种形式redishappy-haproxy 和 redishappy-consul。redishappy-haproxyredishappy-haproxy 在 Redis 主节点升级时更新 HAProxy 的配置文件,然后重新加载 H
资源推荐
资源详情
资源评论
收起资源包目录
Redis Sentinel 高可用性守护进程.zip (82个子文件)
.travis.yml 676B
标签.txt 40B
configuration
configuration_test.go 4KB
sanitycheck.go 1KB
configuration.go 5KB
sanitycheck_test.go 3KB
services
haproxy
client.go 1KB
template
writer_test.go 886B
writer.go 751B
logger
default.go 812B
log_windows.go 540B
log_solaris.go 116B
log_linux.go 751B
redis
sentinelclient.go 2KB
pubsubclient.go 1KB
redis.go 2KB
LICENSE 10KB
api
pingpong.go 161B
sentinel.go 475B
topology.go 337B
configuration.go 395B
readme.md 9KB
docs
redishappy-benchmark.md 10KB
redishappy-haproxy.png 25KB
redishappy-consul.png 24KB
build
configs
redis-haproxy
config.json 412B
haproxy_template.cfg 575B
ci.sh 1KB
rpm_init
redishappy-consul 2KB
redishappy-haproxy 2KB
release.sh 7KB
local-scripts
postrm-redishappy-haproxy 469B
preinstall-redishappy-haproxy 817B
postrm-redishappy-consul 472B
postinstall-redishappy-consul 95B
preinstall-redishappy-consul 812B
postinstall-redishappy-haproxy 293B
deb_upstart
redishappy-haproxy-service 381B
redishappy-consul-service 343B
types
sentinel.go 224B
consul.go 523B
sentinel_test.go 270B
flipper.go 1KB
flipper_test.go 3KB
cluster.go 117B
consul_test.go 696B
haproxy.go 200B
资源内容.txt 914B
sentinel
throttle.go 1KB
sentinels.go 4KB
manager.go 5KB
throttle_test.go 1KB
sentinels_test.go 4KB
manager_test.go 684B
monitor_test.go 4KB
monitor.go 5KB
manager_types.go 2KB
Godeps
Godeps.json 688B
Readme 136B
Vagrantfile 2KB
.gitignore 381B
main
noop
noop_flipperclient.go 618B
config.json 180B
main.go 1KB
redis-haproxy
haproxy_flipperclient.go 4KB
api.go 1KB
config.json 417B
haproxy_template.cfg 571B
sanity_checks.go 2KB
main.go 1KB
redis-consul
consul_flipperclient.go 2KB
config.json 497B
main.go 1KB
engine.go 2KB
util
stringify.go 236B
hash_test.go 660B
hash.go 443B
http.go 225B
schedule.go 133B
file_test.go 483B
file.go 316B
exec.go 201B
共 82 条
- 1
资源评论
徐浪老师
- 粉丝: 8529
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Ajax 控件和扩展程序
- 三冲头气液冲孔机sw19可编辑全套技术资料100%好用.zip
- springboot-时尚美妆电商网站(编号:27399134).zip
- Comsol锂离子电池析锂 锂枝晶生长相场模型 可以输出完整枝晶生长动画文件
- springboot-教育资源共享平台(编号:92629133).zip
- springboot-基于javaweb宿舍管理系统(编号:18018175).zip
- PCIE教程+PCIE协议+PCIE接口中文规范+初学者指南
- springboot-极速汽车美容与保养网站(编号:94086144).zip
- 2024《C语言程序设计》综合测验4-答案.mhtml
- springboot-大学生就业系统.zip
- 功率波动求1min和10min波动,滑动平均算法(ma)功率波动 1、根据滑动平均算法平抑功率波动,满足并网标准 2、求滑动后的1min最大波动 3、求滑动后10min最大波动 4、调动滑动窗
- 基于springboot的租房系统(编号:13824148).zip
- 三道压面机sw13可编辑全套技术资料100%好用.zip
- 基于SpringBoot的中老年人文化活动平台(编号:92110163)(1).zip
- 松下FP-X的模拟量控制,程序,用于空调冷冻泵的 用AFPX -TC2模拟量输入和AFPX-DA2模拟量输出控制 变频冷冻泵的转速 本程序可手动、自动控制,简便易懂,
- springboot-教务管理系统(编号:95134129).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功