# Getting error while setting up mongodb replica set

**URL:** https://discourse.chef.io/t/getting-error-while-setting-up-mongodb-replica-set/7220
**Category:** Chef Infra (archive)
**Created:** [October 29, 2015, 6:20am UTC](https://discourse.chef.io/t/getting-error-while-setting-up-mongodb-replica-set/7220 "2015-10-29T06:20:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Chandan\_Maheshwari](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@Chandan\_Maheshwari](https://discourse.chef.io/u/Chandan_Maheshwari)
#### Post date: [October 29, 2015, 6:20am UTC](https://discourse.chef.io/t/getting-error-while-setting-up-mongodb-replica-set/7220/1 "2015-10-29T06:20:48Z")

</div>

Hi All,

I am using community mongodb cookbook and trying to setup replica using. As in the instructions i have given replica name and cluster name. But its failing,

1 It is trying to check mongo connection using Connection.new

connection = Mongo::Connection.new(‘localhost’, node[‘mongodb’][‘config’][‘port’], :op\_timeout =\> 60, :slave\_ok =\> true, :connect\_timeout =\> 60)  
connection.database\_names # check connection

And then trying to list databases.

Its failing here with error:

WARN: Could not connect to database: ‘local:27017’, reason: uninitialized constant Mongo::ConnectionFailure

We then used Client.new and somehow passed this.

2 Its now giving error as below:

ERROR: ruby\_block[config\_replicaset] (mongodb::replicaset line 225) had an error: NameError: uninitialized constant BSON::OrderedHash

Can someone point me here what i am missing here.

---

<div class="post-metadata">

### Author: ![Joseph\_Holsten](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/joseph_holsten/32/69_2.png) [@Joseph\_Holsten](https://discourse.chef.io/u/Joseph_Holsten)
#### Post date: [October 29, 2015, 7:30am UTC](https://discourse.chef.io/t/getting-error-while-setting-up-mongodb-replica-set/7220/2 "2015-10-29T07:30:31Z")

</div>

The maintainers of the mongodb cookbook no longer are responding to pull requests. Some of the users have moved our work to [http://x.josephholsten.com/track/click/30679653/github.com?p=eyJzIjoiMXBpWVBqSF92dlE5TExvVXg3bDdtSGZ3NWRBIiwidiI6MSwicCI6IntcInVcIjozMDY3OTY1MyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZ2l0aHViLmNvbVxcXC9jaGVmLWJyaWdhZGVcXFwvbW9uZ29kYi1jb29rYm9va1xcXC9cIixcImlkXCI6XCJiZWM0OGNiOGUyMzA0YTMyOTY2MWQxYzYzN2Y2MGEwZVwiLFwidXJsX2lkc1wiOltcImU5Y2U1NzQ2ZWNhZDdiY2U0YWRiMTc1MGIyNjE4ZDc2NTQ0ZGM5ZGRcIl19In0](http://x.josephholsten.com/track/click/30679653/github.com?p=eyJzIjoiMXBpWVBqSF92dlE5TExvVXg3bDdtSGZ3NWRBIiwidiI6MSwicCI6IntcInVcIjozMDY3OTY1MyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZ2l0aHViLmNvbVxcXC9jaGVmLWJyaWdhZGVcXFwvbW9uZ29kYi1jb29rYm9va1xcXC9cIixcImlkXCI6XCJiZWM0OGNiOGUyMzA0YTMyOTY2MWQxYzYzN2Y2MGEwZVwiLFwidXJsX2lkc1wiOltcImU5Y2U1NzQ2ZWNhZDdiY2U0YWRiMTc1MGIyNjE4ZDc2NTQ0ZGM5ZGRcIl19In0) [http://x.josephholsten.com/track/click/30679653/github.com?p=eyJzIjoiMXBpWVBqSF92dlE5TExvVXg3bDdtSGZ3NWRBIiwidiI6MSwicCI6IntcInVcIjozMDY3OTY1MyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZ2l0aHViLmNvbVxcXC9jaGVmLWJyaWdhZGVcXFwvbW9uZ29kYi1jb29rYm9va1xcXC9cIixcImlkXCI6XCJiZWM0OGNiOGUyMzA0YTMyOTY2MWQxYzYzN2Y2MGEwZVwiLFwidXJsX2lkc1wiOltcImU5Y2U1NzQ2ZWNhZDdiY2U0YWRiMTc1MGIyNjE4ZDc2NTQ0ZGM5ZGRcIl19In0](http://x.josephholsten.com/track/click/30679653/github.com?p=eyJzIjoiMXBpWVBqSF92dlE5TExvVXg3bDdtSGZ3NWRBIiwidiI6MSwicCI6IntcInVcIjozMDY3OTY1MyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZ2l0aHViLmNvbVxcXC9jaGVmLWJyaWdhZGVcXFwvbW9uZ29kYi1jb29rYm9va1xcXC9cIixcImlkXCI6XCJiZWM0OGNiOGUyMzA0YTMyOTY2MWQxYzYzN2Y2MGEwZVwiLFwidXJsX2lkc1wiOltcImU5Y2U1NzQ2ZWNhZDdiY2U0YWRiMTc1MGIyNjE4ZDc2NTQ0ZGM5ZGRcIl19In0). It’s descended from the edelight cookbook, so you probably can switch with no different configuration.

## Please let us know if you have any issues.

~j

---

<div class="post-metadata">

### Author: ![Chandan\_Maheshwari](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@Chandan\_Maheshwari](https://discourse.chef.io/u/Chandan_Maheshwari)
#### Post date: [October 29, 2015, 10:50am UTC](https://discourse.chef.io/t/getting-error-while-setting-up-mongodb-replica-set/7220/3 "2015-10-29T10:50:06Z")

</div>

After seeing the community cookbook and this cookbook, I found that :  
BSON::OrderedHash.new [not there for bson 3.x, which is the dependency of mongo gem]

Similarly :;

Mongo::Connection.new is not available now, and its

Mongo::Client.new

Can you tell me if this is been tested for replicaset recently

---

<div class="post-metadata">

### Author: ![Chandan\_Maheshwari](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@Chandan\_Maheshwari](https://discourse.chef.io/u/Chandan_Maheshwari)
#### Post date: [October 29, 2015, 10:56am UTC](https://discourse.chef.io/t/getting-error-while-setting-up-mongodb-replica-set/7220/4 "2015-10-29T10:56:19Z")

</div>

It fails at :

connection = Mongo::Connection.new(‘localhost’, node[‘mongodb’][‘config’][‘port’], :op\_timeout =\> 5, :slave\_ok =\> true)

replacing with works:  
connection = Mongo::Client.new([‘localhost:27017’], connect: :direct)

Any input
