无法使用Windows7上的mongo shell连接到Linux上的远程mongo数据库

时间:2014-06-30 23:59:26

标签: linux mongodb

我知道有非常相似的问题,但我已经尝试了所有的解决方案,没有成功。 我在Windows7机器上安装了mongo,以及Linux机器。没有花哨的配置,只是默认配置。我可以启动mongod进程,然后使用mongo shell我可以连接到127.0.0.1两者都没有任何问题。

然而,当我尝试从Windows机器连接到Linux时,没有运气。 我试过了

mongo --host xxx.xxx.xxx.xxx --verbose

(当然使用xxx.xxx.xxx.xxx的ip地址)并获得了

MongoDB shell version: 2.6.0
connecting to: xxx.xxx.xxx.xxx:27017/test
2014-06-30T19:35:35.081-0400 creating new connection to:xxx.xxx.xxx.xxx:27017
2014-06-30T19:35:35.085-0400 [ConnectBG] BackgroundJob starting: ConnectBG
2014-06-30T19:35:56.091-0400 Error: couldn't connect to server xxx.xxx.xxx.xxx:27017
(xxx.xxx.xxx.xxx), connection attempt failed at src/mongo/shell/mongo.js:148
2014-06-30T19:35:56.092-0400 User Assertion: 12513:connect failed
exception: connect failed

我甚至尝试使用

在Linux机器上启动mongod
mongod --bind_ip 0.0.0.0 -v

(注意,我没有使用mongodb.conf文件,但我甚至尝试创建一个没有bind_ip行,但结果相同)并且这些尝试都没有解决我的问题

我可以使用putty从Windows连接到Linux机器,我可以ping它等等。 我读了其他问题,但没有找到解决方案。我是新手,这是我的第一次,所以我可能忽略了一些基本的东西,感谢任何帮助。

命令netstat -a | Linux机器上的grep 27017给了我

tcp        0      0 *:27017                     *:*                         LISTEN
unix  2      [ ACC ]     STREAM     LISTENING     226111 /tmp/mongodb-27017.sock

我不知道这是否正确或是否暗示某个问题。

为了完整,命令

./mongod --bind_ip 0.0.0.0 -v
Linux机器上的

启动mongod进程给了我:

warning: bind_ip of 0.0.0.0 is unnecessary; listens on all ips by default
2014-06-30T16:50:12.194-0700 [DataFileSync] BackgroundJob starting: DataFileSync
2014-06-30T16:50:12.194-0700 shardKeyTest passed
2014-06-30T16:50:12.194-0700 isInRangeTest passed
2014-06-30T16:50:12.194-0700 shardObjTest passed
2014-06-30T16:50:12.195-0700 [initandlisten] MongoDB starting : pid=28755 port=27017  
dbpath=/data/db 64-bit host=five9-sac-1
2014-06-30T16:50:12.195-0700 [initandlisten] db version v2.6.3
2014-06-30T16:50:12.195-0700 [initandlisten] git version:
255f67a66f9603c59380b2a389e386910bbb52cb
2014-06-30T16:50:12.195-0700 [initandlisten] build info: Linux build12.nj1.10gen.cc 
2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_          64    
BOOST_LIB_VERSION=1_49
2014-06-30T16:50:12.195-0700 [initandlisten] allocator: tcmalloc
2014-06-30T16:50:12.195-0700 [initandlisten] options: { net: { bindIp: "0.0.0.0" },   
systemLog: { verbosity: 1 } }
2014-06-30T16:50:12.226-0700 [initandlisten] flushing directory /data/db
2014-06-30T16:50:12.246-0700 [initandlisten] journal dir=/data/db/journal
2014-06-30T16:50:12.246-0700 [initandlisten] recover : no journal files present, no
recovery needed
2014-06-30T16:50:12.246-0700 [initandlisten] flushing directory /data/db/journal
2014-06-30T16:50:12.274-0700 [initandlisten] flushing directory /data/db/journal
2014-06-30T16:50:12.292-0700 [initandlisten] opening db:  local
2014-06-30T16:50:12.293-0700 [initandlisten] enter repairDatabases (to check pdfile  
version #)
2014-06-30T16:50:12.293-0700 [initandlisten]    local
2014-06-30T16:50:12.295-0700 [initandlisten]    test
2014-06-30T16:50:12.295-0700 [initandlisten] opening db:  test
2014-06-30T16:50:12.296-0700 [initandlisten] done repairDatabases
2014-06-30T16:50:12.296-0700 [initandlisten] opening db:  admin
2014-06-30T16:50:12.296-0700 [initandlisten] query admin.system.roles planSummary: EOF 
ntoreturn:0 ntoskip:0 keyUpdates:0 numYields:0 locks(micros) W          :93 r:49 
nreturned:0 reslen:20 0ms
2014-06-30T16:50:12.296-0700 [TTLMonitor] BackgroundJob starting: TTLMonitor
2014-06-30T16:50:12.296-0700 [ClientCursorMonitor] BackgroundJob starting:  
ClientCursorMonitor
2014-06-30T16:50:12.296-0700 [initandlisten] fd limit hard:4096 soft:1024 max conn: 819
2014-06-30T16:50:12.296-0700 [IndexRebuilder] BackgroundJob starting: IndexRebuilder
2014-06-30T16:50:12.296-0700 [PeriodicTaskRunner] BackgroundJob starting: 
PeriodicTaskRunner
2014-06-30T16:50:12.297-0700 [IndexRebuilder] opening db:  local
2014-06-30T16:50:12.297-0700 [initandlisten] create collection local.startup_log { 
size: 10485760, capped: true }
2014-06-30T16:50:12.297-0700 [initandlisten] command local.$cmd command: create { 
create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0   
numYields:0  reslen:75 0ms
2014-06-30T16:50:12.298-0700 [initandlisten] insert local.startup_log ninserted:1 
keyUpdates:0 numYields:0  0ms
2014-06-30T16:50:12.298-0700 [initandlisten] waiting for connections on port 27017
2014-06-30T16:50:12.303-0700 [IndexRebuilder] opening db:  test
2014-06-30T16:50:12.308-0700 [IndexRebuilder] checking complete

尝试从Windows连接到mongo shell时无法再输出。 我很乐意运行任何其他命令并发布结果。

0 个答案:

没有答案