2017-08-22 123 views
0

所以我試圖在Ubuntu虛擬機上安裝RocketChat和MongoDB。我已經配置好了一切正確,包括使用相應的IP地址:192.168.50.56(被註釋掉,因爲它應該是):連接Mongodb錯誤

# network interfaces 
net: 
    port: 27017 
    #bindIp: 192.168.50.56 


#processManagement: 

#security: 

#operationProfiling: 

#replication: 

replication: 
     oplogSizeMB; 
1 
     replSetName: rs0 

,當我嘗試連接時,我不斷收到此錯誤:

@RocketChat:/etc$ mongo 
MongoDB shell version v3.4.7 
connecting to: mongodb://127.0.0.1:27017 
2017-08-16T15:05:31.690-0400 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused 
2017-08-16T15:05:31.690-0400 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed : 
[email protected]/mongo/shell/mongo.js:237:13 
@(connect):1:6 
exception: connect failed 

回答

2

如果你想讓mongo監聽多個接口/ IP地址,你需要列出兩個IP地址。

# network interfaces 
net: 
    port: 27017 
    bindIp: 127.0.0.1,192.168.50.56 

replication: 
     oplogSizeMB: 1 
     replSetName: rs0 

該ip的可以用逗號分隔。

然後重新啓動mongodb