Adding indexes without blocking using master-slave

4 views
Skip to first unread message

douggreen

unread,
Jan 8, 2010, 3:20:10 PM1/8/10
to mongodb-user
If i add indexes to the slave, wait for the slave to catch up and
become current, then restart and switch so the slave becomes the
master, will the new indexes propogate back to the old master [now the
slave]?

Eliot Horowitz

unread,
Jan 8, 2010, 3:47:32 PM1/8/10
to mongod...@googlegroups.com
The problem with that is you can't add an index to a slave... Are you
worries about how long it will take to build the index

On Jan 8, 2010, at 4:20 PM, douggreen <douggreen...@gmail.com>
wrote:

> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en
> .
>
>

douggreen

unread,
Jan 8, 2010, 5:24:17 PM1/8/10
to mongodb-user
Bummer, yes our concern is that adding these indexes takes about an
hour, and we try very hard for no downtime.

On Jan 8, 3:47 pm, Eliot Horowitz <eliothorow...@gmail.com> wrote:
> The problem with that is you can't add an index to a slave...  Are you  
> worries about how long it will take to build the index
>

> On Jan 8, 2010, at 4:20 PM, douggreen <douggreenconsult...@gmail.com>  

douggreen

unread,
Jan 9, 2010, 9:41:43 AM1/9/10
to mongodb-user
The goal is to upgrade mongo to 1.2.1. I can't do this without
creating some indexes that are needed by our application, because in
my testing, once I upgraded to 1.2.1 without having these indexes,
mongo crashed several times, but once I created the indexes it stopped
crashing. Rather than debug why it crashes without the indexes, I
decided that we need the index, and that we just need to add them.

Here's the new idea, a little like the old one:

1. We currently have a master-slave setup, running on two different
machines, both are on 1.1.3, let's call the master mongo1 and the
slave mongo2
2. Shutdown mongo2
3. Create a copy/backup
4. Restart mongo2 as a standalone instance, without being the slave
5. Drop all indexes on mongo2, because we have some we don't need,
and we're missing others
6. Repair database on mongo2
7. Create new indexes on mongo2
8. Stop mongo2 as a standalone instance, and restart as slave
*** mongo1 is still running 1.1.3
*** mongo2 is now running 1.2.1 with different indexes
*** any problems here?
9. Let mongo2 catch up from being down for 8 hours (total time for
4-8 in testing)
10. Shutdown mongo1
*** I'll look for some sync command to force it to sync before
shutting down, and to shutdown cleanly
11. Shutdown mongo2 making sure it is fully sync'd
12. Copy files from mongo2 to mongo1 (in testing the db went from 77G
to 45G)
13. Restart mongo1 with 1.2.1 using new db just copied over
14. Restart mongo2 in replication mode

Eliot Horowitz

unread,
Jan 9, 2010, 9:52:23 AM1/9/10
to mongod...@googlegroups.com
I think that will work but haven't tested that exactly. Why are doing
the repair?

Also, can you give any info on the crash? Even the log file might be
helpful to us

On Jan 9, 2010, at 3:41 PM, douggreen <douggreen...@gmail.com>
wrote:

douggreen

unread,
Jan 9, 2010, 7:29:40 PM1/9/10
to mongodb-user
I would of expected to reclaim a lot of disk space after just dropping
the indexes, but nothing was released. So I tried the repairDatabase.

On Jan 9, 9:52 am, Eliot Horowitz <eliothorow...@gmail.com> wrote:
> I think that will work but haven't tested that exactly. Why are doing  
> the repair?
>
> Also, can you give any info on the crash?  Even the log file might be  
> helpful to us
>

> On Jan 9, 2010, at 3:41 PM, douggreen <douggreenconsult...@gmail.com>  

Eliot Horowitz

unread,
Jan 9, 2010, 2:40:42 PM1/9/10
to mongod...@googlegroups.com
Ah. Ok. We never release disk space. Just store it and reuse it

On Jan 10, 2010, at 1:29 AM, douggreen <douggreen...@gmail.com>
wrote:

Reply all
Reply to author
Forward
0 new messages