What is a proper way of adding index to a replica set?

505 views
Skip to first unread message

Alex Paransky

unread,
May 10, 2012, 7:35:51 AM5/10/12
to mongod...@googlegroups.com
We were trying to add an index to a replica set of 3 servers. Using the background option was going to take 10 hours based on extrapolated total time based on % complete status updates. Without background option the index created in about 35 seconds but we had some requests that timed out in our app.

What would have been a better way of doing this? Should we have updated the replica set to remove one sever at a time and add index in that sever and then add it back to the replica set?

Thanks.

-AP_

idris

unread,
May 10, 2012, 2:08:43 PM5/10/12
to mongod...@googlegroups.com
Creating an index with a replica set is very well documented here: http://www.mongodb.org/display/DOCS/Building+indexes+with+replica+sets

Unfortunately, prior to version 2.1, you have to shut down each replica and build the index on it one replica a time.

Scott Hernandez

unread,
May 10, 2012, 8:55:53 PM5/10/12
to mongod...@googlegroups.com
Even with the new versions if you want to build in the foreground then
using the rolling upgrade approach of taking down secondaries and then
the primary to build them offline is still best. The new feature
simply allow background index building on secondaries which sounds
like it is not what Alex wants.

You do not want to reconfig the replica set as you process each node,
but simply take it down, create the index in non-replSet mode, and
then bring it back up.
> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/mongodb-user/-/bMNaeK2bAg8J.
>
> 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.
Reply all
Reply to author
Forward
0 new messages