1

This is only for initial Redis setup. Obviously, on production systems, a dump of the entire multi-machine database would be difficult to sort through.

I'd accept an answer in any language, although I prefer Python.

A simple Redis CLI command for this would work, too.

Nathan Basanese
  • 8,475
  • 10
  • 37
  • 66

2 Answers2

3

Redis implements clustering using sentinel.

Read more on sentinel - http://redis.io/topics/sentinel

Connect to the redis instance using redis-cli -h hostname -p port from terminal.

Run KEYS * command to get all the keys on that Redis instance.

KEYS command takes regex as the argument (* for all).

If you are trying to access it from code .. there are various modules available. I have tried using node-redis, for Node Js.

However on production I don't recommend you to use KEYS command as it takes a considerable time for millions on keys, rather use SCAN command to scan a number of keys its syntax is SCAN CURSOR MATCH match COUNT count.. eg SCAN 0 MATCH * COUNT 10000..initially the cursor is taken as 0 as the iteration for further keys is stopped when the cursor returned is 0.

Ali
  • 427
  • 1
  • 4
  • 14
  • // , Ah, so I must do this on each instance, one by one, rather than a whole cluster all at once, as I had hoped for. – Nathan Basanese Dec 08 '15 at 01:56
  • 1
    Yes to get a dump of all keys you need to connect to each instance and execute keys or scan command.... However if u just want to know the number of keys in redis instance for redis 2.6 and above, lua is supported, you can get number of wildcard keys like this `eval "return #redis.call('keys', 'prefix-*')" 0` – Ali Dec 08 '15 at 03:04
1
from redis import StrictRedis
red = StrictRedis(host='127.0.0.1')
all_keys=red.keys("*")
Ali Nikneshan
  • 3,500
  • 27
  • 39