puppet-mongodb icon indicating copy to clipboard operation
puppet-mongodb copied to clipboard

Mongo 3.6 : Could not evaluate: Can't connect to any member of replicaset rsmain

Open Dharmender-Singh opened this issue 7 years ago • 8 comments

Hi,

We are trying to setup the replication using this module but getting following error :

Notice: /Stage[main]/Mongodb::Replset/Mongodb_replset[rsmain]/ensure: created Warning: Can't connect to replicaset member 192.168.33.5:8080. Warning: Can't connect to replicaset member 192.168.33.6:8080. Warning: Can't connect to replicaset member 192.168.33.7:8080. Error: /Stage[main]/Mongodb::Replset/Mongodb_replset[rsmain]: Could not evaluate: Can't connect to any member of replicaset rsmain.

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 5.3.2
  • Ruby: 2..0.0
  • Distribution: Centos 7.4.1708 (Core)
  • Module version: 2.1.2

How to reproduce (e.g Puppet code you use)

  1. Create three AWS EC2 instances with port 8080 open
  2. Set the replication configuration : class { 'mongodb::server': auth => false, verbose => true, port => $port, dbpath => $dbpath, logpath => $logpath, service_ensure => stopped, replset => 'rsmain', replset_config => { 'rsmain' => { ensure => present, members => ['192.168.33.5:8080', '192.168.33.6:8080', '192.168.33.7:8080'] } } }
  3. Execute Puppet Apply

What are you seeing

Error: /Stage[main]/Mongodb::Replset/Mongodb_replset[rsmain]: Could not evaluate: Can't connect to any member of replicaset rsmain.

What behaviour did you expect instead

Replication should work

Output log

Please refer to the attached file for debug log Error_Log.txt

Any additional information you'd like to impart

Dharmender-Singh avatar May 30 '18 15:05 Dharmender-Singh

This issue will probably be fixed with this PR: https://github.com/voxpupuli/puppet-mongodb/pull/446

I will try to get it merged (lost sight of this for a while)

EDIT: in hindsight, I'm not sure this is entirely related sorry, you seem to be getting a slightly different error.

TomRitserveldt avatar Jun 05 '18 05:06 TomRitserveldt

Thanks @TomRitserveldt .

This issue is now resolved after changing or removing following line : service_ensure => stopped to service_ensure => running

But I am facing different problems now with replication:

  1. If auth == true, then I am getting following Error : Error: Failed to apply catalog: Could not evaluate MongoDB shell command: load('/root/.mongorc.js'); printjson(db.getMongo().getDBs())

I think, there is already a bug for this : https://github.com/voxpupuli/puppet-mongodb/issues/437

  1. If auth == false, If we do following steps : a) Set auth == false b) Setup the replication c) Enable Authorisation in conf file d) Restart the Mongo Service

Then the replication is working on the First Node but when you will run the code on Second Node then it's failed when it's trying to fetch the replication info from the first node.

Error : {"operationTime"=>1528300824, "ok"=>0, "errmsg"=>"not authorized on admin to execute command { replSetGetStatus: 1.0, $clusterTime: { clusterTime: 1528300824, signature: { hash: 0, keyId: 6563998673095622657 } }, $db: \"admin\" }", "code"=>13, "codeName"=>"Unauthorized", "$clusterTime"=>{"clusterTime"=>1528300824, "signature"=>{"hash"=>0, "keyId"=>"6563998673095622657"}}}

Is there any way to set the replication with the Auth enabled ?

Dharmender-Singh avatar Jun 06 '18 16:06 Dharmender-Singh

@Dharmender-Singh The error you're getting with auth = false IS related to my PR above, the replica nodes need to run the command to check the db's created with slaveOk(). I haven't tried to setup the cluster with auth enabled as we dont do direct cluster access for users other than the applications(per database) themselves.

TomRitserveldt avatar Jun 07 '18 04:06 TomRitserveldt

Thanks @TomRitserveldt . Will wait for merging your PR..

Dharmender-Singh avatar Jun 07 '18 08:06 Dharmender-Singh

Hi there, now would be a good time to merge those PS's

zez3 avatar Apr 30 '19 16:04 zez3

btw. it's also valid for clusters with no authentication. @TomRitserveldt

zez3 avatar Apr 30 '19 16:04 zez3

Just curious what the timeframe on this getting resolved is. I am trying to set up a replica set with auth set to true and it fails

Error: /Stage[main]/Mongodb::Replset/Mongodb_replset[main]: Could not evaluate: Can't connect to any member of replicaset rsmain.

rachalsolutions avatar Oct 03 '19 03:10 rachalsolutions

Hey there, any news about this ?

spuyet avatar Mar 18 '20 14:03 spuyet