<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>集群教程 — Redis 命令参考</title>
<link rel="stylesheet" href="../_static/pyramid.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '2.8',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="top" title="Redis 命令参考" href="../index.html" />
<link rel="next" title="Redis 集群规范" href="cluster-spec.html" />
<link rel="prev" title="Sentinel" href="sentinel.html" />
<!--[if lte IE 6]>
<link rel="stylesheet" href="../_static/ie6.css" type="text/css" media="screen" charset="utf-8" />
<![endif]-->
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="cluster-spec.html" title="Redis 集群规范"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="sentinel.html" title="Sentinel"
accesskey="P">previous</a> |</li>
<li><a href="../index.html">Redis 命令参考</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="cluster-tutorial">
<span id="id1"></span><h1>集群教程<a class="headerlink" href="#cluster-tutorial" title="Permalink to this headline">¶</a></h1>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">本文档翻译自 <a class="reference external" href="http://redis.io/topics/cluster-tutorial">http://redis.io/topics/cluster-tutorial</a> 。</p>
</div>
<p>本文档是 Redis 集群的入门教程,
从用户的角度介绍了设置、测试和操作集群的方法。</p>
<p>本教程不包含晦涩难懂的分布式概念,
也没有像 <a class="reference internal" href="cluster-spec.html#cluster-spec"><span>Redis 集群规范</span></a> 那样包含 Redis 集群的实现细节,
如果你打算深入地学习 Redis 集群的部署方法,
那么推荐你在阅读完这个教程之后,
再去看一看集群规范。</p>
<p><strong>Redis 集群目前仍处于 Alpha 测试版本</strong>,
如果在使用过程中发现任何问题,
请到 <a class="reference external" href="https://groups.google.com/forum/?fromgroups#!forum/redis-db">Redis 的邮件列表</a> 发贴,
或者到 <a class="reference external" href="https://github.com/antirez/redis">Redis 的 Github 页面</a> 报告错误。</p>
<div class="section" id="id2">
<h2>集群简介<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h2>
<p>Redis 集群是一个可以<strong>在多个 Redis 节点之间进行数据共享</strong>的设施(installation)。</p>
<p>Redis 集群不支持那些需要同时处理多个键的 Redis 命令,
因为执行这些命令需要在多个 Redis 节点之间移动数据,
并且在高负载的情况下,
这些命令将降低 Redis 集群的性能,
并导致不可预测的行为。</p>
<p>Redis 集群<strong>通过分区(partition)来提供一定程度的可用性</strong>(availability):
即使集群中有一部分节点失效或者无法进行通讯,
集群也可以继续处理命令请求。</p>
<p>Redis 集群提供了以下两个好处:</p>
<ul class="simple">
<li>将数据自动切分(split)到多个节点的能力。</li>
<li>当集群中的一部分节点失效或者无法进行通讯时,
仍然可以继续处理命令请求的能力。</li>
</ul>
</div>
<div class="section" id="id3">
<h2>Redis 集群数据共享<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h2>
<p>Redis 集群使用数据分片(sharding)而非一致性哈希(consistency hashing)来实现:
一个 Redis 集群包含 <code class="docutils literal"><span class="pre">16384</span></code> 个哈希槽(hash slot),
数据库中的每个键都属于这 <code class="docutils literal"><span class="pre">16384</span></code> 个哈希槽的其中一个,
集群使用公式 <code class="docutils literal"><span class="pre">CRC16(key)</span> <span class="pre">%</span> <span class="pre">16384</span></code> 来计算键 <code class="docutils literal"><span class="pre">key</span></code> 属于哪个槽,
其中 <code class="docutils literal"><span class="pre">CRC16(key)</span></code> 语句用于计算键 <code class="docutils literal"><span class="pre">key</span></code> 的 <a class="reference external" href="http://zh.wikipedia.org/wiki/%E5%BE%AA%E7%92%B0%E5%86%97%E9%A4%98%E6%A0%A1%E9%A9%97">CRC16 校验和</a> 。</p>
<p>集群中的每个节点负责处理一部分哈希槽。
举个例子,
一个集群可以有三个哈希槽,
其中:</p>
<ul class="simple">
<li>节点 A 负责处理 <code class="docutils literal"><span class="pre">0</span></code> 号至 <code class="docutils literal"><span class="pre">5500</span></code> 号哈希槽。</li>
<li>节点 B 负责处理 <code class="docutils literal"><span class="pre">5501</span></code> 号至 <code class="docutils literal"><span class="pre">11000</span></code> 号哈希槽。</li>
<li>节点 C 负责处理 <code class="docutils literal"><span class="pre">11001</span></code> 号至 <code class="docutils literal"><span class="pre">16384</span></code> 号哈希槽。</li>
</ul>
<p>这种将哈希槽分布到不同节点的做法使得用户可以很容易地向集群中添加或者删除节点。
比如说:</p>
<ul class="simple">
<li>如果用户将新节点 D 添加到集群中,
那么集群只需要将节点 A 、B 、 C 中的某些槽移动到节点 D 就可以了。</li>
<li>与此类似,
如果用户要从集群中移除节点 A ,
那么集群只需要将节点 A 中的所有哈希槽移动到节点 B 和节点 C ,
然后再移除空白(不包含任何哈希槽)的节点 A 就可以了。</li>
</ul>
<p>因为将一个哈希槽从一个节点移动到另一个节点不会造成节点阻塞,
所以无论是添加新节点还是移除已存在节点,
又或者改变某个节点包含的哈希槽数量,
都不会造成集群下线。</p>
</div>
<div class="section" id="id4">
<h2>Redis 集群中的主从复制<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h2>
<p>为了使得集群在一部分节点下线或者无法与集群的大多数(majority)节点进行通讯的情况下,
仍然可以正常运作,
Redis 集群对节点使用了主从复制功能:
集群中的每个节点都有 <code class="docutils literal"><span class="pre">1</span></code> 个至 <code class="docutils literal"><span class="pre">N</span></code> 个复制品(replica),
其中一个复制品为主节点(master),
而其余的 <code class="docutils literal"><span class="pre">N-1</span></code> 个复制品为从节点(slave)。</p>
<p>在之前列举的节点 A 、B 、C 的例子中,
如果节点 B 下线了,
那么集群将无法正常运行,
因为集群找不到节点来处理 <code class="docutils literal
没有合适的资源?快使用搜索试试~ 我知道了~
Redis离线网页版api
共256个文件
html:193个
png:19个
sample:9个
需积分: 12 16 下载量 17 浏览量
2018-07-31
09:42:49
上传
评论
收藏 17.97MB ZIP 举报
温馨提示
redis的离线网页版api文档,方便查看api函数,提高开发效率,值得收藏
资源推荐
资源详情
资源评论
收起资源包目录
Redis离线网页版api (256个子文件)
.buildinfo 234B
CNAME 14B
config 333B
basic.css 10KB
pyramid.css 6KB
epub.css 6KB
pygments.css 4KB
ie6.css 733B
description 73B
exclude 240B
gh-pages 203B
gh-pages 41B
ajax-loader.gif 673B
transparent.gif 49B
.gitignore 16B
HEAD 203B
HEAD 203B
HEAD 34B
HEAD 25B
cluster-tutorial.html 179KB
cluster-spec.html 163KB
sentinel.html 154KB
index.html 151KB
eval.html 147KB
persistence.html 141KB
notification.html 139KB
protocol.html 137KB
sort.html 136KB
info.html 136KB
scan.html 134KB
transaction.html 134KB
replication.html 130KB
pubsub.html 127KB
set.html 125KB
blpop.html 124KB
incr.html 124KB
rpoplpush.html 122KB
config_get.html 122KB
expire.html 122KB
pubsub.html 122KB
ltrim.html 122KB
slowlog.html 122KB
georadius.html 122KB
migrate.html 121KB
client_list.html 121KB
config_rewrite.html 121KB
bitcount.html 121KB
change_log.html 121KB
object.html 121KB
zrangebyscore.html 120KB
zrangebylex.html 120KB
bitop.html 120KB
zrange.html 120KB
setrange.html 120KB
srandmember.html 120KB
append.html 119KB
incrbyfloat.html 119KB
zunionstore.html 119KB
config_resetstat.html 119KB
README.html 119KB
restore.html 119KB
lrange.html 119KB
index.html 119KB
lrem.html 119KB
zadd.html 119KB
index.html 119KB
hincrbyfloat.html 119KB
move.html 118KB
brpoplpush.html 118KB
smove.html 118KB
keys.html 118KB
auth.html 118KB
getset.html 118KB
lpush.html 118KB
rpush.html 118KB
index.html 118KB
psubscribe.html 118KB
shutdown.html 118KB
script_kill.html 118KB
client_setname.html 118KB
linsert.html 118KB
msetnx.html 118KB
zrevrangebyscore.html 118KB
bgrewriteaof.html 118KB
lindex.html 118KB
zinterstore.html 118KB
hincrby.html 118KB
pfcount.html 118KB
zincrby.html 118KB
slaveof.html 118KB
getrange.html 118KB
zremrangebyrank.html 118KB
pfadd.html 118KB
geoadd.html 118KB
zrevrank.html 118KB
zrevrange.html 117KB
zrank.html 117KB
brpop.html 117KB
mset.html 117KB
zremrangebyscore.html 117KB
共 256 条
- 1
- 2
- 3
资源评论
sunshiwu1984
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- python-leetcode面试题解之第157题用Read4读取N个字符-题解.zip
- python-leetcode面试题解之第156题上下翻转二叉树-题解.zip
- python-leetcode面试题解之第155题最小栈-题解.zip
- python-leetcode面试题解之第153题寻找旋转排序数组中的最小值-题解.zip
- python-leetcode面试题解之第152题乘积最大子数组-题解.zip
- python-leetcode面试题解之第151题反转字符串中的单词-题解.zip
- python-leetcode面试题解之第150题逆波兰表达式求值-题解.zip
- python-leetcode面试题解之第149题直线上最多的点数-题解.zip
- python-leetcode面试题解之第148题排序链表-题解.zip
- python-leetcode面试题解之第147题对链表进行插入排序-题解.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功