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 |
How do you see the connections used by mongos?
What is aggregation in mongodb?
When an object attribute is removed, is it deleted from the store?
Does amazon use mongodb?
Can mongodb store files?
How to create multiple collections in mongodb?
When was mongodb created?
What is the importance of covered query?
If you remove an object attribute, is it deleted from the database?
Is mongodb a documentdb?
Can I remove old files in the move chunk directory in mongodb?
What is bson in mongodb?
Oracle (3253)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)