Comments (3)
你好,关于你的两个问题,解答如下。
其一:
客户端向 slave 发送什么命令,要由程序来决定,如果程序向一个 slave 发送了写命令,那么这个写命令将被拒绝,因此程序有责任将正确的命令发送给正确的服务器 —— 将写命令发送给 master ,将读命令发送给 slave ,而这些目前需要使用程序手动去做。
有一些数据库也支持只读 slave ,但是它们的 slave 可以在接到写命令时,自动把客户端引导至 master ,并让客户端重新发送命令(这好像被称为“读写分离”特性?),而不会像 Redis 的 slave 那样,直接返回错误,不过我用过的 Ruby 和 Python 客户端都不支持这种特性,至于其他客户端是否支持,我不太清楚。
其二:
官网说的是对的, Redis 目前的主从复制没办法保持强制一致性:当你向 master 发送一条写命令之后, master 会向 slave 发送相同的写命令,而这条写命令在发送的过程中可能会有一段时间延迟,这段延迟时间之内, master 和 slave 的数据并不是完全一致的。
为了规避这一缺陷,如果你需要执行一个写然后读(write-and-read)操作,那么为了确保数据的正确性,你应该直接写和读 master ,而不要写 master ,然后读 slave ,因为这可能会引起问题。
Redis 的官网有提到将来可能会支持强一致性, Redis 的 github repo 上面也相关的实验性质的 branch 存在,有兴趣的话可以找找看。
huangz
from redis.
看到了,谢谢!
from redis.
:)
from redis.
Related Issues (20)
- sentinel 文档的更新
- Using Redis as an LRU cache
- 补齐 HyperLogLog 文档的翻译
- 添加许可证
- RESTORE命令变化 HOT 2
- 各个文档的标题改动
- 将命令名改为驼峰写法?
- 关于积压空间的创建和写入问题 HOT 1
- 修复原来使用的 Sphinx Tag
- 添加 HSTRLEN 命令的文档翻译
- 3.0 更新计划 HOT 1
- 有打算添加3.0的文档么? HOT 1
- 作者啥时候出个MD版本的呢?
- 有PDF版本么?
- 关于info命令latest_fork_usec解释的疑问
- 关于replication的疑问
- Redis 集群 master和slave数据同步问题
- List 中 LSET 命令中出现错别字
- redisdoc.com 域名过期啦???博主看下?? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redis.