Skip to content

yankov/redis-migrator

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Redis-migrator

Redis-migrator is a tool to redistribute keys in your redis cluster when its topography has changed.

##How it works

Say you are using Redis::Distributed to distribute your writes and reads across different redis nodes. Redis::Distributed uses consitent hashing algorithm to determine where a command will go. If you changed configuration of your cluster, for example, changed a hostname or added a new node then routes for some of the keys will change too. If you try to read such a key - you won't get a data from its old node.

Redis-migrator takes a list of nodes for your old cluster and list of nodes for your new cluster and determines for which keys routes were changed. Then it moves those keys to new nodes.

##Install
gem install redis_migrator

##Usage
require 'redis_migrator'

# a list of redis-urls for an old cluster
old_redis_hosts = ["redis://host1.com:6379", "redis://host2.com:6379"]

# a list of redis-urls for a new cluster
new_redis_hosts = ["redis://host1.com:6379", "redis://host2.com:6379", "redis://host3.com:6379"]

migrator = Redis::Migrator.new(old_redis_hosts, new_redis_hosts)
migrator.run

##Requirements

  • ruby 1.9 or jruby (with --1.9 flag)
  • redis >=2.4.14 (only on machine where migrator will be running)

##Contributing

# First fork the project.
# Then bundle
bundle

# and make sure tests pass
bundle exec rspec spec

# Add features and profit.
# Send a pull request back to the original repository.

##TODO

  • Error handling

About

Redis-migrator is a tool to redistribute keys in your redis cluster when its topography has changed.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages