mongodb, replicates and error: { “$err” : “not master and slaveOk=false”, “code” : 13435 }

前端 未结 8 1455
遥遥无期
遥遥无期 2020-11-30 17:24

I tried mongo replica sets for the first time.

I am using ubuntu on ec2 and I booted up three instances. I used the private IP address of each of the instances. I p

8条回答
  •  遥遥无期
    2020-11-30 17:45

    THIS IS JUST A NOTE FOR ANYONE DEALING WITH THIS PROBLEM USING THE RUBY DRIVER

    I had this same problem when using the Ruby Gem.

    To set slaveOk in Ruby, you just pass it as an argument when you create the client like this:

    mongo_client = MongoClient.new("localhost", 27017, { slave_ok: true })
    

    https://github.com/mongodb/mongo-ruby-driver/wiki/Tutorial#making-a-connection

    mongo_client = MongoClient.new # (optional host/port args)
    

    Notice that 'args' is the third optional argument.

提交回复
热议问题