Last active
August 29, 2015 14:15
-
-
Save clupprich/887d9836fca3a8f19c88 to your computer and use it in GitHub Desktop.
mongo-replica-test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2.2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'mongo', '1.11.1' | |
gem 'mongo_ha', '1.11.1' | |
gem 'bson_ext' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GEM | |
remote: https://rubygems.org/ | |
specs: | |
bson (1.11.1) | |
bson_ext (1.11.1) | |
bson (~> 1.11.1) | |
mongo (1.11.1) | |
bson (= 1.11.1) | |
mongo_ha (1.11.1) | |
mongo (~> 1.11.0) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
bson_ext | |
mongo (= 1.11.1) | |
mongo_ha (= 1.11.1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir -p data/mongo1 | |
mongod --port 27001 --smallfiles --oplogSize 50 --replSet test --dbpath data/mongo1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir -p data/mongo2 | |
mongod --port 27002 --smallfiles --oplogSize 50 --replSet test --dbpath data/mongo2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'bundler/setup' | |
require 'mongo' | |
require 'mongo_ha' | |
require 'logger' | |
nodes = ['localhost:27001', 'localhost:27002'] | |
options = { | |
read: :secondary_preferred, | |
pool_size: 100, | |
pool_timeout: 10, | |
connect_timeout: 5, | |
reconnect_attempts: 53, | |
reconnect_retry_seconds: 0.1, | |
reconnect_retry_multiplier: 2, | |
reconnect_max_retry_seconds: 5, | |
logger: Logger.new(STDOUT) | |
} | |
client = Mongo::MongoReplicaSetClient.new(nodes, options) | |
db = client['mongo-replica-test'] | |
until true == false | |
db.collection('tests').insert({ timestamp: Time.now }) | |
sleep 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment