-1

以下是控制台会话...

C:\Users\xxx>vmc tunnel myMongoDB
Getting tunnel connection info: OK

Service connection info:
  username : uuuu
  password : pppp
  name     : db
  url      : mongodb://uuuu:pppp@172.30.xx.xx:25200/db

Starting tunnel to myMongoDB on port 10000.
1: none
2: mongo
3: mongodump
4: mongorestore
Which client would you like to start?: 2
Launching 'mongo --host localhost --port 10000 -u uuuu -p pppp db'

MongoDB shell version: 2.0.6
connecting to: localhost:10000/db
> db.serverStatus()
{ "errmsg" : "need to login", "ok" : 0 }
>

我应该使用哪些凭据来登录(假设应该使用 db.auth)以消除错误“ {“errmsg”:“需要登录”,“ok”:0 } “。

当我在我的机器上的 micro CF 中运行相同的程序时,它工作正常并给了我预期的输出。

PS我正在尝试这个来了解我的应用程序上的当前连接,用node.js编写。尝试调试与数据库连接的一些问题。如果我可以使用任何其他替代方法,请也提出建议。

4

1 回答 1

1

this should work! Not sure why your tunnel isn't connecting, my immediate suggestion is to try another instance of MongoDB and see if the same error occurs.

If you are trying to inspect the bound services on you node.js app you should be able to inspect them in the VCAP_SERVICES environment variable. For example;

var http = require('http');
var util = require('util');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.write(util.inspect(process.env.VCAP_SERVICES));
  res.write("\n\n************\n\n");
  res.end(util.inspect(req.headers));

}).listen(3000);

This code is currently running at http://node-headers.cloudfoundry.com/ to serve as an example. However, mongodb connections for node.js applications should automatically configure to the bound service. If this does not work for you, then please do let me know.

于 2012-09-10T15:59:37.307 回答