Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How do I start a replica set in mongodb?



How do I start a replica set in mongodb?..

Answer / Asmita Shri

To start a replica set in MongoDB, you need to configure the members of the set and then initiate it. Here's an example for three members:

1. Create the replica set configuration file (replset.conf) with the following content:

```
rs.initiate({
_id : 'myReplSet',
members: [
{_id: 0, host : 'localhost:27017'},
{_id: 1, host : 'localhost:27018'},
{_id: 2, host : 'localhost:27019'}
]
})
```

2. Start MongoDB with the configuration file:

```
mongod --replSet myReplSet --smallfiles --config replset.conf
```

3. Repeat step 2 for each member of the replica set.
4. Connect to any of the members and check the status of the replica set:

```javascript
rs.status()
```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More MongoDB Interview Questions

How do you see the connections used by mongos?

1 Answers  


What is aggregation in mongodb?

1 Answers  


When an object attribute is removed, is it deleted from the store?

1 Answers  


Does amazon use mongodb?

1 Answers  


Can mongodb store files?

1 Answers  


How to create multiple collections in mongodb?

1 Answers  


When was mongodb created?

1 Answers  


What is the importance of covered query?

1 Answers  


If you remove an object attribute, is it deleted from the database?

1 Answers  


Is mongodb a documentdb?

1 Answers  


Can I remove old files in the move chunk directory in mongodb?

1 Answers  


What is bson in mongodb?

1 Answers  


Categories