首页 > 解决方案 > 无法连接到我在 AWS 上运行的 Mongo 服务器。节点进程未启动,但 Mongod 日志看起来不错

问题描述

当我启动我的 mongod 服务器时,它运行得非常好。我打开了所有连接来尝试解决这个问题,所以不要介意警告。当我尝试运行我的节点进程时,它通过其公共 IP 连接到我的服务器(我有那个设置,所以我也可以从家里连接到我的数据库)。但是,我的节点进程实际上从未启动,但 mongo 服务器显示

[conn1] received client metadata from Censored IP: 46534 conn1: {
    driver: {
        name: "nodejs",
        version: "3.1.10"
    },
    os: {
        type: "Linux",
        name: "linux",
        architecture: "x64",
        version: "4.15.0-1031-aws"
    },
    platform: "Node.js v11.4.0, LE, mongodb-core: 3.1.9"
}
我的mongo配置是:
# 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# bindIpAll: true# how the process runs
processManagement:
    timeZoneInfo: /usr/share / zoneinfo

# security: #authorization: enabled# operationProfiling:

    #replication:

    #sharding:

    ##Enterprise - Only Options:

    #auditLog:

    #snmp:
我使用mongoose连接,之前只遇到过一次,暂时修复了,但不知道为什么我的node进程连接不上mongod服务器并正常启动。蒙古日志:
2019 - 01 - 09 T16: 35: 59.390 + 0000 I STORAGE[initandlisten] WiredTiger message[1547051759: 390412][3431: 0x7f79c7a83a40], txn - recover: Recovering log 25 through 26
2019 - 01 - 09 T16: 35: 59.442 + 0000 I STORAGE[initandlisten] WiredTiger message[1547051759: 442748][3431: 0x7f79c7a83a40], txn - recover: Recovering log 26 through 26
2019 - 01 - 09 T16: 35: 59.486 + 0000 I STORAGE[initandlisten] WiredTiger message[1547051759: 486445][3431: 0x7f79c7a83a40], txn - recover: Set global recovery timestamp: 0
2019 - 01 - 09 T16: 35: 59.530 + 0000 I RECOVERY[initandlisten] WiredTiger recoveryTimestamp.Ts: Timestamp(0, 0)
2019 - 01 - 09 T16: 35: 59.547 + 0000 I CONTROL[initandlisten]
2019 - 01 - 09 T16: 35: 59.547 + 0000 I CONTROL[initandlisten] ** WARNING: Access control is not enabled
for the database.
2019 - 01 - 09 T16: 35: 59.547 + 0000 I CONTROL[initandlisten] ** Read and write access to data and configuration is unrestricted.
2019 - 01 - 09 T16: 35: 59.547 + 0000 I CONTROL[initandlisten]
2019 - 01 - 09 T16: 35: 59.584 + 0000 I FTDC[initandlisten] Initializing full - time diagnostic data capture with directory '/var/lib/mongodb/diagnostic.data'
2019 - 01 - 09 T16: 35: 59.585 + 0000 I NETWORK[initandlisten] waiting
for connections on port 27017
2019 - 01 - 09 T16: 36: 10.088 + 0000 I NETWORK[listener] connection accepted from Censored IP: 46534 #1 (1 connection now open)
2019-01-09T16:36:10.095+0000 I NETWORK  [conn1] received client metadata from Censored IP:46534 conn1: { driver: { name: "nodejs", version: "3.1.10" }, os: { type: "Linux", name: "linux", architecture: "x64", version: "4.15.0-1031-aws" }, platform: "Node.js v11.4.0, LE, mongodb-core: 3.1.9" }

如果有人知道出了什么问题,请告诉我!

const mongoose = require('mongoose')

mongoose.connect(process.env.MONGO_URL, {
  useNewUrlParser: true
})
我的 .env 是:
MONGO_URL=mongodb://censoredip:27017/theseus

标签: javascriptnode.jsmongodb

解决方案


我解决了我的问题!我四处试验,发现它与 Mongo 无关。我实际上没有执行任何操作,并且某个功能一定已经消失或被意外删除。很抱歉给您带来麻烦,感谢拉维!


推荐阅读