Open the mongo.conf
file.
$ sudo nano /etc/mongo.conf
Uncomment the replication and add a replication set name.
replication:
replSetName: "replicaset-01"
Restart the mongodb server and login and initiate the replication.
$ sudo systemctl restart mongodb
$ mongo
> rs.initiate()