How to find which nodes host a particular bucket/key?

Charlie Voiselle cvoiselle at basho.com
Tue Jan 13 12:14:49 EST 2015


You can use the following Erlang snippet in `riak attach`:

N=3,
{ok,Ring} = riak_core_ring_manager:get_my_ring(),
DocIdx = riak_core_util:chash_key({<<"my_bucket">>, <<"my_key">>}),
<<I:160/integer>> = DocIdx,
Preflist = riak_core_ring:preflist(DocIdx, Ring),
{Targets, Fallbacks} = lists:split(N, Preflist),
Targets.

Verify that `N` matches your clusters N-val. Change `my_bucket` and `my_key` as appropriate.  If all of your nodes are up and healthy, this will give you the primaries in the `Targets` variable and the fallback partitions in order of preference in `Fallbacks`.

Regards,
Charlie Voiselle
Basho Client Services


> On Jan 12, 2015, at 4:28 PM, Jay Doane <jay.s.doane at gmail.com> wrote:
> 
> Can anyone suggest how to determine the nodes on which a particular bucket/key are hosted in a cluster?
> 
> Thanks,
> Jay
> 
> 
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20150113/713750f3/attachment-0002.html>


More information about the riak-users mailing list