gpt4 book ai didi

mongodb - 蒙戈无法连接

转载 作者:行者123 更新时间:2023-12-03 03:12:30 24 4
gpt4 key购买 nike

我在 Azure VPS 上运行 Ubuntu 15。我安装了 MongoDB 并启动并运行良好。然后,我停止了 mongod 服务,并更改了 mongod.conf 中的数据库路径和日志路径,以指向我在附加磁盘上创建的目录:

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

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

我重新启动了整个 VPS 以确保新更改生效。现在,当我输入 mongo 时,我收到以下错误:

2016-02-05T14:49:41.004+0000 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2016-02-05T14:49:41.018+0000 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:224:14
@(connect):1:6

如果我撤消更改并使用原始的 loglib 位置,它就会起作用。我可以做什么来确保使用新位置?

编辑

保留旧日志位置并尝试上述步骤后,我在日志中得到以下内容:

2016-02-05T15:19:47.049+0000 I CONTROL  [main] ***** SERVER RESTARTED *****
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] MongoDB starting : pid=1158 port=27017 dbpath=/datadrive/lib/mongodb 64-bit host=CLIENTPROJECTS
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] db version v3.2.1
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] git version: a14d55980c2cdc565d4704a7e3ad37e4e535c1b2
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2d 9 Jul 2015
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] modules: none
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] build environment:
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] distmod: ubuntu1404
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] distarch: x86_64
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] target_arch: x86_64
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/datadrive/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2016-02-05T15:19:47.693+0000 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /datadrive/lib/mongodb/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
2016-02-05T15:19:47.693+0000 I CONTROL [initandlisten] dbexit: rc: 100

最佳答案

首先你可以检查 mongod 是否启动:sudo lsof -i | grep 27017,然后检查日志 /datadrive/log/mongodb/mongod.log 中的内容。

编辑:

停止 mongod 的所有实例(ps aux | grep mongod 应该显示没有任何运行),删除锁定文件 rm/datadrive/lib/mongodb/mongod.lock,以及重新启动服务。

编辑2:

配置中的目录 /datadrive/lib/mongodb//datadrive/log/mongodb/ 应该存在并且属于 mongodb 用户。默认情况下它是 mongodb:mongodb,并在 /etc/init.d/mongodb 中定义为 DAEMONUSER

关于mongodb - 蒙戈无法连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35227054/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com