In this post you will see how to run a Mongo DB server with replica set.
For this, we will use mongodb community that you can install from your therminal.
First, create a folder to store your data, like:
mkdir /data/mongodb/db0
Then, start your server with this command.
mongod --port 27017 --dbpath /data/mongodb/db0 --replSet rs0 --bind_ip localhost
After first start, you will need to start the replica set.
Open your SGBD (you can use Mongosh) and run this command:
rs.initiate()
Now, you can restar your server to apply all changes:
Run netstat -vanp tcp | grep 27017
in your therminal to get PID application, and kill then.
kill -9 81094
(modify 81094 to your PID)
Then, run
mongod --port 27017 --dbpath /data/mongodb/db0 --replSet rs0 --bind_ip localhost
That's It!
Top comments (0)