Question

I'm working on integrating ElasticSearch with my symfony2 application using MongoDB doctrine.
In this tutorial it says that I need to convert my standalone instance into a Replicate set
Basically the concept is as follow: the application interrogates MongoDB primary server for data, and the search features needs to interrogate the secondary server for search. My replicate set config is as follow :

{
    "_id" : "rs0",
    "version" : 1,
    "members" : [
            {
                    "_id" : 0,
                    "host" : "localhost:27017"
            }
    ]

} I think this is Primary server, My question is do I need to create another server? if yes how can I create the second replicate server ?
Tanks a lot!

Was it helpful?

Solution

As per the tutorial you linked, in order for the ElasticSearch River to work you need to have your MongoDB configured as a replica set. In a replica set configuration, each node has an operation log (oplog) which is a log of all of the operations (inserts, updates, deletes) that have been applied. The oplog can be read using a tailable cursor in order to enable features such as the ElasticSearch River or MMS Backup.

My question is do I need to create another server?

Technically, a replica set can be configured as a single node (which you have done). The recommended best practice is to have a replica set with a minimum of three nodes (a primary, a secondary, and an arbiter OR a primary and two secondaries) which will provide additional benefits of high availability and data redundancy. For more information, see the Replica Set Introduction in the MongoDB manual.

the search features needs to interrogate the secondary server for search.

By default, MongoDB drivers direct all write & read requests to the primary which provides strong consistency for reading data. If you read from a secondary, the data is eventually consistent. This means that if there is any replication lag from the primary to the secondary, you may read older data from the secondary.

It is usually not recommended to perform queries on a secondary. In your scenario, if both machines are used at capacity and you either experience a failure or need to bring a machine down, then you will not have enough resources to serve the applications and perform the searches. You should plan in having your primary having enough resources to perform both functions.

As for migrating your standalone server to a replica set, you can follow the steps described in the tutorial: Convert a Standalone to a Replica Set.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top