before to continue actually replying your question, there are much
better ways to handle your use case, especially the following:
1) Start a new instance of Redis.
2) Make the new instance a clone of your production instance using:
SLAVEOF <host> <port>
3) When the replication finished cloning the instance (you can see
that from the logs of the slave), turn the new instance into a slave
with: SLAVEOF NO ONE.
4) At this point manipulate the slave instance as you wish.
5) When you are ready finally either switch the client configuration
to use the new instance, or, use replication again (SLAVEOF and so
forth) in order to clone the new data into the old instance. But this
will cause some downtime, so switching the instance is the way to go
IMHO.
make sure to do a backup of your most recent RDB file before doing all
that. Even if you are using AOF persistency you can easily create an
RDB backup calling the BGSAVE command.
Note that while you alter the data on the new instance all the changes
arriving on the old instance are not replicated since we disconnected
the two instances with SLAVEOF NO ONE. But this also happened in your
scenario with two databases.
Now if you still want to clone the database 0 into 1 please reply here
and I'll tell you the (not trivial) way to do this efficiently, that
basically involves rewriting an AOF log, concatenating two copies of
it but with the second copy having the SELECT command altered to
select DB 1.
Cheers,
Salvatore
> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
>
>
--
Salvatore 'antirez' Sanfilippo
open source developer - VMware
http://invece.org
"We are what we repeatedly do. Excellence, therefore, is not an act,
but a habit." -- Aristotele
Salvatore of course means "disable slaving and turn the slave into a
stand-alone master."
> 4) At this point manipulate the slave instance as you wish.
> 5) When you are ready finally either switch the client configuration
> to use the new instance, or, use replication again (SLAVEOF and so
> forth) in order to clone the new data into the old instance. But this
> will cause some downtime, so switching the instance is the way to go
> IMHO.
>
> make sure to do a backup of your most recent RDB file before doing all
> that. Even if you are using AOF persistency you can easily create an
> RDB backup calling the BGSAVE command.
>
> Note that while you alter the data on the new instance all the changes
> arriving on the old instance are not replicated since we disconnected
> the two instances with SLAVEOF NO ONE. But this also happened in your
> scenario with two databases.
Also note that even when you have a slave of the master, while writes
to the master will replicate to the slave, writes to the slave will
not replicate to the master.
Regards,
- Josiah
Regards,
- Josiah
thanks for sharing this, maybe we need rdb-check utility smarter than
it is and able to do this kind of magics?
Like merging DBs, splitting DBs, and possibly even looking for
specific keys and dump it.
Cheers,
Salvatore