Skip to content

Instantly share code, notes, and snippets.

@ivaravko
Created July 16, 2015 13:02
Show Gist options
  • Save ivaravko/351405f96974422e6c7e to your computer and use it in GitHub Desktop.
Save ivaravko/351405f96974422e6c7e to your computer and use it in GitHub Desktop.
mongo replica set connection
connection = Mongo::MongoReplicaSetClient.new(
["replica.host.ru:27022", "master.host.ru:27022"], read: :secondary_preferred, logger: Rails.logger
)
db = connection.db('admin')
db.authenticate('reader', 'somepassword')
$MONGO = connection.db('test')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment