2016-02-11 228 views
2

我無法通過任何GUI連接到MongoDB。但MongoDB正在運行,因爲我可以使用shell來順利管理DM。無法遠程連接MongoDB

這裏是日誌

2016-02-11T05:58:44.033+0000 I CONTROL [initandlisten] MongoDB starting : 

pid=2559 port=27017 dbpath=/var/lib/mongo 64-bit host=ip-172-31-30-5 
2016-02-11T05:58:44.033+0000 I CONTROL [initandlisten] db version v3.2.1 
2016-02-11T05:58:44.033+0000 I CONTROL [initandlisten] git version: a14d55980c2cdc565d4704a7e3ad37e4e535c1b2 
2016-02-11T05:58:44.033+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.0-fips 29 Mar 2010 
2016-02-11T05:58:44.033+0000 I CONTROL [initandlisten] allocator: tcmalloc 
2016-02-11T05:58:44.033+0000 I CONTROL [initandlisten] modules: none 
2016-02-11T05:58:44.033+0000 I CONTROL [initandlisten] build environment: 
2016-02-11T05:58:44.033+0000 I CONTROL [initandlisten]  distmod: amazon 
2016-02-11T05:58:44.033+0000 I CONTROL [initandlisten]  distarch: x86_64 
2016-02-11T05:58:44.033+0000 I CONTROL [initandlisten]  target_arch: x86_64 
2016-02-11T05:58:44.033+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { port: 27017 }, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath: "/var/lib/mongo", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } } 
2016-02-11T05:58:44.053+0000 I -  [initandlisten] Detected data files in /var/lib/mongo created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'. 
2016-02-11T05:58:44.053+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0), 
2016-02-11T05:58:44.291+0000 I CONTROL [initandlisten] 
2016-02-11T05:58:44.291+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 
2016-02-11T05:58:44.291+0000 I CONTROL [initandlisten] **  We suggest setting it to 'never' 
2016-02-11T05:58:44.291+0000 I CONTROL [initandlisten] 
2016-02-11T05:58:44.293+0000 I FTDC  [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongo/diagnostic.data' 
2016-02-11T05:58:44.293+0000 I NETWORK [initandlisten] waiting for connections on port 27017 
2016-02-11T05:58:44.295+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker 

mongd.conf

# mongod.conf 

# for documentation of all options, see: 
# http://docs.mongodb.org/manual/reference/configuration-options/ 

# where to write logging data. 
systemLog: 
    destination: file 
    logAppend: true 
    path: /var/log/mongodb/mongod.log 

# Where and how to store data. 
storage: 
    dbPath: /var/lib/mongo 
    journal: 
    enabled: true 
# engine: 
# mmapv1: 
# wiredTiger: 

# how the process runs 
processManagement: 
    fork: true # fork and run in background 
    pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile 

# network interfaces 
net: 
    port: 27017 
# bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces. 


#security: 

#operationProfiling: 

#replication: 

#sharding: 

## Enterprise-Only Options 

#auditLog: 

#snmp: 

我看到了一些類似的問題也有一些解決方案建議發表意見線# bindIp: 127.0.0.1並刪除/var/lib/mongodb/mongod.lock。我的設置有問題嗎?

回答

0

可能有多種原因導致您無法遠程連接到正在運行的MongoDB實例。我在這裏列出了幾個原因:

  1. 服務器的防火牆(上您的MongoDB實例正在運行)如果你正在使用亞馬遜EC2實例,可能會從外部IP
  2. 會阻止所有傳入的請求,防火牆是不夠的。你需要通過亞馬遜控制檯
  3. 端口27017可能不是在服務器上打開連接到打開的端口和IP(使用不同的端口檢查,以覈實像https://www.site24x7.com/port-test.html
  4. 的連接可能會得到由於TCP下降超時
  5. 嘗試設置bindIp0.0.0.0(參考:mongodb.conf bind_ip = 127.0.0.1 does not work but 0.0.0.0 works & MongoDB bind_ip won't work unless set to 0.0.0.0
+1

太感謝你了,第三個是我的問題 –