require 'mongo' START_PORT = 27017 N = 4 N.times do |n| system("rm -rf /data/rs#{n}") system("mkdir -p /data/rs#{n}") system("mongod --replSet replica-set-foo --logpath '#{n}.log' --dbpath /data/rs#{n} --port #{START_PORT + n} --fork") end con =<