简体   繁体   中英

Mongo DB 2.0.1 issue

I have an issue with MongoDB version 2.0.1. I have installed it on an Ubuntu machine that is 32 bit. I am able to connect to it through the command prompt, but not able to connect to it through Java code. This same code used to work with the older MongoDB version. I get the following exception.

    Caused by: com.mongodb.MongoInternalException: DBPort.findOne failed
       at com.mongodb.DBPort.findOne(DBPort.java:153)
       at com.mongodb.DBPort.runCommand(DBPort.java:159)
       at com.mongodb.DBTCPConnector.testMaster(DBTCPConnector.java:369)
       at com.mongodb.Mongo.<init>(Mongo.java:140)
       at
com..bean.MongoCollectionPoolBean.init(MongoCollectionPoolBean.java:
42)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
57)
       at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
43)
       at java.lang.reflect.Method.invoke(Method.java:616)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:
1544)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:
1485)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:
1417)
       ... 24 more
        Caused by: java.io.IOException: couldn't connect to
    [domU-12-31-39-0B-26-01/67.265.65.132:27017]
    bc:java.net.ConnectException: Connection timed out
           at com.mongodb.DBPort._open(DBPort.java:205)
           at com.mongodb.DBPort.go(DBPort.java:85)
           at com.mongodb.DBPort.findOne(DBPort.java:145)
           ... 35 more

When I try to reproduce the same problem with my local system (Mac Lion 64 bit) it works fine. When I see the server logs here is what i see on my local system:

[clientcursormon] mem (MB) res:14 virt:2434 mapped:0

and on Ubuntu (where it is not working)

[clientcursormon] mem (MB) res:14 virt:86 mapped:0

if your application is connecting to mongodb on the same box, then use 127.0.0.1 so that it doesnt break when your amazon instance change IP addresses. In general it is better to use a hostname that you point to an IP via /etc/hosts or dns. If this still does not work make sure you can do "telnet localhost 27017" from the local terminal. If it cannot connect then either mongodb is not running on that port, or you have a firewall.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM