简体   繁体   English

如何使Mongodb 27017端口在Ubuntu上可用

[英]How to make Mongodb 27017 port available on Ubuntu

After installing and starting mongodb on Google Ubuntu instance I can verify that 'mongodb' is running with: sudo systemctl status mongodb : 在Google Ubuntu实例上安装并启动mongodb之后,我可以验证“ mongodb”是否正在运行: sudo systemctl status mongodb

● mongodb.service - LSB: An object/document-oriented database
   Loaded: loaded (/etc/init.d/mongodb; generated; vendor preset: enabled)
   Active: active (running) since Mon 2017-02-27 19:41:17 UTC; 57min ago
     Docs: man:systemd-sysv-generator(8)
    Tasks: 13 (limit: 4915)
   Memory: 71.7M
      CPU: 14.520s
   CGroup: /system.slice/mongodb.service
           └─1914 /usr/bin/mongod --config /etc/mongodb.conf
Feb 27 19:41:15 instance-1 systemd[1]: Starting LSB: An object/document-oriented database...
Feb 27 19:41:16 instance-1 mongodb[1827]:  * Starting database mongodb
Feb 27 19:41:17 instance-1 mongodb[1827]:    ...done.
Feb 27 19:41:17 instance-1 systemd[1]: Started LSB: An object/document-oriented database.

It all looks good. 一切看起来不错。 But by some reason another application running on the same machine is not able to connect to the what-seems-to-be-running-properly mongodb . 但是由于某种原因,同一台计算机上运行的另一个应用程序无法连接到似乎正在正常运行的mongodb

Running nmap 127.0.0.1 returns: 运行nmap 127.0.0.1返回:

PORT    STATE SERVICE
22/tcp  open  ssh
631/tcp open  ipp

There is no mongodb's port # 27017 listed there as *open*. Interesting that the firewall is disabled. How can I assure the 没有mongodb's port # 27017 listed there as *open*. Interesting that the firewall is disabled. How can I assure the mongodb's port # 27017 listed there as *open*. Interesting that the firewall is disabled. How can I assure the mongodb's port # 27017 listed there as *open*. Interesting that the firewall is disabled. How can I assure the mongodb port 27017` is open and available to other applications? mongodb's port # 27017 listed there as *open*. Interesting that the firewall is disabled. How can I assure the mongodb port 27017`已打开并可供其他应用程序使用?

nmap scan all common port, mongodb use port 27017 by default which is not listed in default nmap default port scan. nmap扫描所有通用端口,默认情况下mongodb使用端口27017 (默认nmap默认端口扫描中未列出)。 On the other hand, you can specify the port manually : 另一方面,您可以手动指定端口:

nmap -p 27017  127.0.0.1

You will get : 你会得到 :

PORT      STATE SERVICE
27017/tcp open  unknown

If you see STATE close, this means mongodb is not running and then you should begin to worry about it 如果您看到STATE关闭,则表明mongodb没有运行,那么您应该开始担心它

Or as suggested by @Dimitri using netstat such as : 或者按照@Dimitri的建议使用netstat例如:

netstat -tulpn

which gives : 这使 :

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN      -               

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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