简体   繁体   中英

Getting error message while replication database in mongodb windows

I am trying to replicate database in mongodb 4.0 in two different windows server. I followed all the steps of mongodb replication. While I was configuring the secondary database from primary through the below command

rsconf={_id:"myset", members:[{_id:0,host:"PrimaryServerIP:27017"},{_id:1,host:"SecondaryServerIP:27017"}]}

Then while I was reconfiguring the rsconf through

rs.reconfig(rsconf)

I was getting the below error message "Support for replication protocol version 0 was removed in MongoDB 4.0. Downgrade to MongoDB version 3.6 and upgrade your protocol version to 1 before upgrading your MongoDB version"

I tried to update the replication protocol by downgrading the MongoDB to 3.6 through the below command

rsconf = rs.conf()
rsconf.protocolVersion=1
rs.reconfig(rsconf)

But still getting the same error message. Is there any way to update the protocol version to 1 in mongodb 4.0.

Also I tried the same replication steps in mongodb 3.6 and it is working fine. Any help will be highly appreciated.

I had a similar issue and when I added protocolVersion to my new config it worked.

rsconf={
         _id:"myset", 
         protocolVersion: NumberLong(1),
         members:[{_id:0,host:"PrimaryServerIP:27017"},{_id:1,host:"SecondaryServerIP:27017"}]
       }

I was initially having this issue trying to reset my rs config to blank so I could start over; I actually did this in the mongo shell

 cfg = {
     "_id" : "rs0",
     "version" : 2,
     "protocolVersion" : NumberLong(1),
     "members" : [
         {
             "_id" : 0,
             "host" : "myhost:27017"
         }
     ]
 }

 rs.reconfig(cfg, {force:true})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM