Skip to content

Instantly share code, notes, and snippets.

@mmcdaris
Created March 21, 2017 22:09
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mmcdaris/29cfe920c846ae6dd5c6eb354c9abdd2 to your computer and use it in GitHub Desktop.
Save mmcdaris/29cfe920c846ae6dd5c6eb354c9abdd2 to your computer and use it in GitHub Desktop.
Replicate from REDISTOGO to your local machine

example RTG_URL: redis://username:secretpasswordfromtheurl@lab.redistogo.com:9555/

Step 1: Start a local redis-server and redis-cli

$ redis-server
#in a new tab run:
$ redis-cli

Step 2: Check the initial DBSIZE (number of keys)

redis 127.0.0.1:6379> DBSIZE
(integer) 0

Step 3: Set the masterauth to the password in your RTG_URL

redis 127.0.0.1:6379> CONFIG SET masterauth secretpasswordfromtheurl
OK

Step 4: Set your local redis-server as the slave of the RTG instance

redis 127.0.0.1:6379> SLAVEOF lab.redistogo.com 9555
OK

Step 5: Check that replication has occurred and num of keys matches

redis 127.0.0.1:6379> DBSIZE
(integer) 2

Step 6: Run info to check the master link status is up and that the settings look correct

redis 127.0.0.1:6379> info
role:slave
master_host:lab.redistogo.com
master_port:9555
master_link_status:up
master_last_io_seconds_ago:1
master_sync_in_progress:0
db0:keys=2,expires=0

Step 7: To stop the replication run the following

redis 127.0.0.1:6379> SLAVEOF no one
OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment