我以为论坛中的其他讨论会解决这个问题,但尽管我非常仔细地遵循了说明,但到目前为止,我的所有尝试都失败了
我正在尝试将mongodb设置为在nodejs服务器的后端工作。我修改了sudo nano/etc/mongod.conf文件:
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
# how the process runs
processManagement:
fork: true
timeZoneInfo: /usr/share/zoneinfo
#security:
authorization: enabled
#operationProfiling:
#replication:
replSetName: volatize0
setParameter:
enableLocalhostAuthBypass: false
然后是:
sudo systemctl start mongod
然后执行:
>sudo netstat -tnlp
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 1888/mongod
tcp 0 0 127.0.0.1:27019 0.0.0.0:* LISTEN 4895/mongod
我仍然无法通过node.js连接到服务器它拒绝连接。
你能告诉我如何让mongodb除了监听localhost之外还监听静态ip吗?
感谢
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 1888/mongod
这意味着您的绑定ip为127.0.0.1。您的配置文件不是服务器期望的位置,它在正确的位置,但服务器没有配置为查找它,或者它的格式不正确。
或者,一切都是正确的,但在更改配置文件后还没有重新启动服务器。