0

I am trying to execute the below command

migrate x.x.x.x 6379 key destinationserver COPY

and I am getting the error

(error) ERR value is not an integer or out of range

Also these redis servers have authetication.. I am not sure how to provide it with this command

Any help would be appreciated.

Sourabh Roy
  • 159
  • 1
  • 18

1 Answers1

1

If you run help migrate in redis-cli, it gives you better information about how to use the MIGRATE command than the docs (which tell you how it works). Here's the output I get:

MIGRATE host port key| destination-db timeout [COPY] [REPLACE] [KEYS key]
  summary: Atomically transfer a key from a Redis instance to another one.
  since: 2.6.0
  group: generic

The destination-db here is referring to the database id within redis. By default, a redis system has 16 databases, numbers 0-15, so where you have destinationserver in your example, it should be the database id to put the data in. That's why you're getting the error, it needs to be an INT id of the database.

For AUTH, as long as your Redis version is 4.0.7 or higher, MIGRATE supports an AUTH keyword in the following form:

MIGRATE 127.0.0.2 6379 key 0 5000 AUTH my_password COPY

If you have Redis version 6.0.0 or higher, you can supply a username as well, though there's no information about this in the docs or in the output I have, but I'm not yet running version 6.

Adam Marshall
  • 6,369
  • 1
  • 29
  • 45
  • Thanks Adam.. This answer is helpful. So I cant use this query to migrate the data from one server to another. – Sourabh Roy Jan 26 '21 at 21:14
  • You can, you just need to specify the database id to use. If it’s a new redis server, 0 is a good default. – Adam Marshall Jan 26 '21 at 21:16
  • but where is the option to provide the 2nd instance information – Sourabh Roy Jan 26 '21 at 21:25
  • There isn't one because you can only run the migrate command from the "source" system. So you have to do a `redis-cli -h redis.example.com` (or run it from the source redis host itself). The command tells the local redis instance (whichever you're logged into) to migrate its data to the target you specify in the parameters to migrate. – Adam Marshall Jan 26 '21 at 21:44