#Now you have to configure mongodb parameter inside /ect/mongod.conf file

# Change permission of mongod.conf file:
>sudo chmod 777 mongod.conf

#Edit parameters of mongod.conf file:
> vi /etc/mongod.conf
Change following parameters.
path : /log/mongod.log
dbPath : /data/db

Save the file and exit vi editor.
# Start mongodb service
> sudo mongod
It will give you output such as 'waiting for connection on port 27017', which means you have successfully installed mongodb on aws instance.
Now, connect to the MongoDB database using the mongo shell:
>mongo
# Follow the same procedure for all instances.
→ To start replication on instances ←
Make sure you have stopped all running mongod instances.
#Edit mongod.conf file
>vi /etc/mongod.conf
Enable replication and add replSetName and Remove bindIP under network interfaces.

Save the file and exit vi editor.
# Run below command to start instance as replica
>sudo mongod --config /etc/mongod.conf
It will give the below output.

** Follow the same procedure on all mongodb instance.
#Open mongo shell and type below command to initiate replication.
>rs.initiate({_id:”bdg-mongodb”,version:1,members:[{_id:0,host:”bdg-hdp-admin:27017”]}});
To check status:
>rs.status();
#Then add other members as below:
>rs.add(‘bdg-hdp-master:27017’);

Add all other members similarly.
#To add arbiter
Arbiters are mongod instances that are part of a replica set but they do not hold data. Arbiters participate in elections in order to break ties. If a replica set has an even number of members, then add an arbiter.
>rs.addArb(‘bdg-hdp-datanode2:27017’);
Again check status rs.status()

Your mongoDB cluster is up now. You can start working on your database.