因此,mongodb 在我的 ubuntu 设备上可以正常工作,然后我重新安装了 Apache2 并安装了 mysql/php 和一些其他小工具,Mongo 停止工作。当我输入mongo
:
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
我查看了我的 mongodb 日志:
2018-12-19T21:29:21.316+0300 I CONTROL [initandlisten] MongoDB starting : pid=10656 port=60 dbpath=/var/lib/mongodb 64-bit host=vitsuji-N501VW
2018-12-19T21:29:21.316+0300 I CONTROL [initandlisten] db version v4.0.3
2018-12-19T21:29:21.316+0300 I CONTROL [initandlisten] git version: 7ea530946fa7880364d88c8d8b6026bbc9ffa48c
2018-12-19T21:29:21.316+0300 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1 11 Sep 2018
2018-12-19T21:29:21.316+0300 I CONTROL [initandlisten] allocator: tcmalloc
2018-12-19T21:29:21.316+0300 I CONTROL [initandlisten] modules: enterprise
2018-12-19T21:29:21.316+0300 I CONTROL [initandlisten] build environment:
2018-12-19T21:29:21.316+0300 I CONTROL [initandlisten] distmod: ubuntu1804
2018-12-19T21:29:21.316+0300 I CONTROL [initandlisten] distarch: x86_64
2018-12-19T21:29:21.316+0300 I CONTROL [initandlisten] target_arch: x86_64
2018-12-19T21:29:21.316+0300 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1, 172.31.29.201", port: 60 }, processManagement: { timeZoneInfo: "/usr/share/zoneinfo" }, security: { authorization: "enabled" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log", quiet: true } }
2018-12-19T21:29:21.316+0300 E STORAGE [initandlisten] Failed to set up listener: SocketException: Permission denied
2018-12-19T21:29:21.316+0300 I CONTROL [initandlisten] now exiting
2018-12-19T21:29:21.316+0300 I CONTROL [initandlisten] shutting down with code:48
我的 mongodb.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: 127.0.0.1, 10.168.0.73
#127.0.0.1, 10.168.0.73
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
security:
authorization: "enabled"
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
端口 27017、37970 上没有运行任何进程。如果有人知道发生了什么,那将会很有帮助。