找到了一个暂时的解决方案 con=Mongo::ReplSetConnection.new(["host1:14000", "host2:14000", "host3:14000"]) con.add_auth("databasename","user","passwd") con.apply_saved_authentication()