The replication process fails even if you start scratch from a new dbpath on the secondary.So the thing is to make some changes in the oplog. The size of the oplog must be set to a optimal value that so that it should be able to handle all application writes into it.
Increasing oplog size:
Shutdown the primary server
use admin
db.shutdownServer()
Start primary as standalone & run on different port say 37017
Login to mongo in port 37017
mongo --port 37017
Remove the old contents in local database
For safety have backop of old oplog before dropping
mongodump --db local --collection 'oplog.rs' --port 37017
Drop the old contents in local database
use local
db.oplog.rs.drop()
db.me.drop()
db.replset.election.drop()
db.replset.minvalid.drop()
db.startup_log.drop()
Replset collection cannot be dropped so remove it with required id :
db.system.replset.remove({ "_id" : "your_replsetname"})
Create a new oplog of required size say 50 GB
db.runCommand( { create: "oplog.rs", capped: true, size: (50 * 1024 * 1024 * 1024) } )
Also you can specify the oplog size in MB in mongod.conf file,say for 50 GB its 429496 MB
replication:
oplogSizeMB: 429496
Hope this Helps !!!
Edit:
As mentioned by Nicholas Tolley Cottrell in comments. In the MongoDB version 3.6 we can change oplog size in runtime without restart.
Check current oplog size
use local
db.oplog.rs.stats().maxSize
To change the oplog size to 10 GB
db.adminCommand({replSetResizeOplog: 1, size: 10000})