Edit mongod.conf to add replicate set
sudo vi /etc/mongod.conf
Add this following lines in mongod.conf
replication:
replSetName: rs0
oplogSizeMB: 1024
Then restart mongod by "sudo service mongod restart"
Check for mongo status if everything is fine
sudo service mongod status
if everything is OK you get this result otherwise please check/var/log/mongodb/mongod.log for any errors.
mongod start/running, process 5806
sudo vi /etc/mongod.conf
Add this following lines in mongod.conf
replication:
replSetName: rs0
oplogSizeMB: 1024
Then restart mongod by "sudo service mongod restart"
Check for mongo status if everything is fine
sudo service mongod status
if everything is OK you get this result otherwise please check/var/log/mongodb/mongod.log for any errors.
mongod start/running, process 5806
Now go to Shell prompt and type
>mongo
Then type
> use //To change your working DB
> rs.initiate()
{
"info2" : "no configuration explicitly specified -- making one",
"me" : "jamesnirmal:27017",
"ok" : 1
}
Now command prompt will changed to
rs0:PRIMARY>
Now type
rs0:PRIMARY> use local
rs0:PRIMARY> show collections
me
oplog.rs
startup_log
system.indexes
system.replset
MongoRestore:
Now go to Normal shell and create one folder called oplog
and type this following command to create mongo dump under oplog folder.
mongodump --port 27017 -d local -c oplog.rs --query '{"ts" : {$gte: Timestamp(1502285060, 1)}}' -o ./oplog/
Then type cd oplog/local/
mv oplog.rs.bson oplog.bson
rm oplog.rs.metadata.json //if exist
run this command to Destintion server all data will be updated automatically
mongorestore --port 27017 --oplogReplay ./oplog/local/
To verify your changes please type ;
db..find();
MongoRestore:
Now go to Normal shell and create one folder called oplog
and type this following command to create mongo dump under oplog folder.
mongodump --port 27017 -d local -c oplog.rs --query '{"ts" : {$gte: Timestamp(1502285060, 1)}}' -o ./oplog/
Then type cd oplog/local/
mv oplog.rs.bson oplog.bson
rm oplog.rs.metadata.json //if exist
run this command to Destintion server all data will be updated automatically
mongorestore --port 27017 --oplogReplay ./oplog/local/
To verify your changes please type ;
db.
Comments
Post a Comment