我在使用mongoskin并使用cluster mongo数据库的服务器上使用Nodejs。我正在使用EC2 bitnami来构建所有服务器。从应用程序日志中,我打印出数据库连接字符串,如下所示(请忽略IP地址,我只是把乱码值)
mongodb://username:password@22.344.345.444:27017,username:password@44.55.665.44:27017,username:password@23.543.345.345:27017/mydb?replicaSet=myDBReplicaCluster
我非常惊讶它始终连接到“admin”数据库。它没有连接到连接字符串中定义的“mydb”数据库。我已经尝试了一切但无法理解问题。以下是所有细节 使用的节点模块:
"dependencies": {
"express": "4.9.8",
"body-parser": "1.9.0",
"connect-busboy": "0.0.2",
"cookie-parser": "1.3.3",
"express-session": "1.9.0",
"passport": "0.2.1",
"passport-local": "1.0.0",
"connect-flash": "0.1.1",
"connect-mongoskin": "*",
"morgan": "1.4.0",
"ejs": "1.0.0",
"bcrypt-nodejs": "0.0.3",
"mongodb": "1.4.19",
"mongoskin": "1.4.4",
"string": "2.2.0",
"unzip": "0.1.11",
"node-fs":"0.1.7",
"xml2js":"0.4.4",
"log4js":"0.6.21",
"helmet":"0.5.2",
"csurf":"1.6.3",
"underscore":"1.7.0",
"validator":"3.22.2",
"elasticsearch":"*"
},
"devDependencies": {
"grunt": "0.4.5",
"chai": "1.9.2",
"mocha": "1.21.5",
"karma": "0.12.24",
"grunt-contrib-copy": "0.7.0",
"grunt-contrib-clean": "0.6.0",
"grunt-contrib-uglify": "0.6.0",
"grunt-contrib-jshint": "0.10.0",
"grunt-simple-mocha": "0.4.0",
"grunt-exec": "0.4.6",
"karma-script-launcher": "0.1.0",
"karma-chrome-launcher": "0.1.5",
"karma-firefox-launcher": "0.1.3",
"karma-ie-launcher": "0.1.5",
"karma-jasmine": "0.1.5",
"karma-phantomjs-launcher": "0.1.4",
"karma-story-reporter": "0.2.2",
"grunt-karma": "0.9.0",
"grunt-cli": "0.1.13",
"karma-sauce-launcher": "0.2.10",
"phantomjs": "1.9.11",
"karma-ng-html2js-preprocessor": "0.1.1",
"node-inspector": "0.7.4",
"protractor": "*",
"grunt-protractor-runner": "1.1.4",
"grunt-contrib-htmlmin": "0.3.0",
"grunt-bump": "0.0.16",
"node-gyp":"*",
"grunt-sass":"*",
"frisby":"*",
"jasmine-node":"*",
"grunt-jasmine-node":"*",
"grunt-contrib-watch":"*"
}
请帮忙。
答案 0 :(得分:0)
你不应该有用户名&密码重复;正确的格式应该是:
import foo
try:
foo.bar() # in this case throws BarException
except foo.BarException:
pass