我正在做一些实验来了解 Riak。这是我发现的一些有趣的东西:
n_val
我有一个包含 2 个节点的集群和一个包含2个节点的存储桶类型
[root@co-riak002 ~]# riak-admin ring-status
================================== Claimant ===================================
Claimant: 'riak@10.172.48.68'
Status: up
Ring Ready: true
============================== Ownership Handoff ==============================
No pending changes.
============================== Unreachable Nodes ==============================
All nodes are up and reachable
[root@co-riak002 ~]# riak-admin bucket-type create testBucket '{"props":{"n_val":2}}'
testBucket created
[root@co-riak002 ~]# riak-admin bucket-type activate testBucket
testBucket has been activated
然后我在里面写了一些东西:
[root@co-riak002 ~]# curl -XPUT -d '{"bar":"foo"}' -H "Content-Type: application/json" http://localhost:8098/types/testBucket/buckets/stuff/keys/hello?w=2&returnbody=true
[1] 10890
[root@co-riak002 ~]#
[1]+ Done curl -XPUT -d '{"bar":"foo"}' -H "Content-Type: application/json" http://localhost:8098/types/testBucket/buckets/stuff/keys/hello?w=2
r=2
现在我可以用和很好地阅读它pr=2
:
[root@co-riak002 ~]# curl http://localhost:8098/types/testBucket/buckets/stuff/keys/hello?r=2
{"bar":"foo"}
[root@co-riak002 ~]# curl http://localhost:8098/types/testBucket/buckets/stuff/keys/hello?pr=2
{"bar":"foo"}
在我杀死了一个节点后,r=2
仍然可以正常读取,但不能pr=2
[root@co-riak002 ~]# riak-admin ring-status
================================== Claimant ===================================
Claimant: 'riak@10.172.48.68'
Status: up
Ring Ready: true
============================== Ownership Handoff ==============================
No pending changes.
============================== Unreachable Nodes ==============================
The following nodes are unreachable: ['riak@10.172.48.66']
与r=2
:
[root@co-riak002 ~]# curl http://localhost:8098/types/testBucket/buckets/stuff/keys/hello?r=2
{"bar":"foo"}
与pr=2
:
[root@co-riak002 ~]# curl http://localhost:8098/types/testBucket/buckets/stuff/keys/hello?pr=2
PR-value unsatisfied: 1/2
我很困惑 -r
读取操作中使用的仲裁数不应该意味着在返回数据之前需要同意的副本/物理节点的数量吗?为什么它在这种情况下不起作用?pr
当它应该意味着vnodes的数量时,为什么在这种情况下工作?
我对这个空间很陌生。非常感谢任何指针。