mongod shell没有启动,data/db不存在

 谢淑萍066347 发布于 2023-02-08 16:51

当我开始mongod trowed错误.问题是什么?

root@cs12867:~# mongod
mongod --help for help and startup options
Sun Dec 22 15:37:44.081 [initandlisten] MongoDB starting : pid=18415 port=27017 dbpath=/data/db/ 64-bit host=cs12867
Sun Dec 22 15:37:44.081 [initandlisten] db version v2.4.6
Sun Dec 22 15:37:44.081 [initandlisten] git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673
Sun Dec 22 15:37:44.081 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Sun Dec 22 15:37:44.081 [initandlisten] allocator: tcmalloc
Sun Dec 22 15:37:44.081 [initandlisten] options: {}
Sun Dec 22 15:37:44.081 [initandlisten] exception in initAndListen: 10296
*********************************************************************
 ERROR: dbpath (/data/db/) does not exist.
 Create this directory or give existing directory in --dbpath.
 See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
Sun Dec 22 15:37:44.081 dbexit:
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to close listening sockets...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to flush diaglog...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to close sockets...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: waiting for fs preallocator...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: lock for final commit...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: final commit...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: closing all files...
Sun Dec 22 15:37:44.081 [initandlisten] closeAllFiles() finished
Sun Dec 22 15:37:44.081 dbexit: really exiting now

我设定--dbpath:

root@cs12867:~# mongod --dbpath /var/lib/mongodb/data/db
Sun Dec 22 15:29:25.121 [initandlisten] MongoDB starting : pid=17739 port=27017 dbpath=/var/lib/mongodb/data/db 64-bit host=cs12867
Sun Dec 22 15:29:25.121 [initandlisten] db version v2.4.6
Sun Dec 22 15:29:25.121 [initandlisten] git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673
Sun Dec 22 15:29:25.121 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Sun Dec 22 15:29:25.121 [initandlisten] allocator: tcmalloc
Sun Dec 22 15:29:25.121 [initandlisten] options: { dbpath: "/var/lib/mongodb/data/db" }
Sun Dec 22 15:29:25.121 [initandlisten]
Sun Dec 22 15:29:25.121 [initandlisten] ** WARNING: Readahead for /var/lib/mongodb/data/db is set to 2048KB
Sun Dec 22 15:29:25.121 [initandlisten] **          We suggest setting it to 256KB (512 sectors) or less
Sun Dec 22 15:29:25.121 [initandlisten] **          http://dochub.mongodb.org/core/readahead
Sun Dec 22 15:29:25.123 [initandlisten] journal dir=/var/lib/mongodb/data/db/journal
Sun Dec 22 15:29:25.123 [initandlisten] recover : no journal files present, no recovery needed
Sun Dec 22 15:29:25.134 [initandlisten] waiting for connections on port 27017
Sun Dec 22 15:29:25.134 [websvr] admin web console waiting for connections on port 28017
Sun Dec 22 15:29:26.179 [initandlisten] connection accepted from 127.0.0.1:37164 #1 (1 connection now open)
Sun Dec 22 15:29:26.179 [FileAllocator] allocating new datafile /var/lib/mongodb/data/db/Tester.ns, filling with zeroes...
Sun Dec 22 15:29:26.179 [FileAllocator] creating directory /var/lib/mongodb/data/db/_tmp
Sun Dec 22 15:29:26.181 [FileAllocator] done allocating datafile /var/lib/mongodb/data/db/Tester.ns, size: 16MB,  took 0 secs
Sun Dec 22 15:29:26.181 [FileAllocator] allocating new datafile /var/lib/mongodb/data/db/Tester.0, filling with zeroes...
Sun Dec 22 15:29:26.181 [FileAllocator] done allocating datafile /var/lib/mongodb/data/db/Tester.0, size: 64MB,  took 0 secs
Sun Dec 22 15:29:26.182 [FileAllocator] allocating new datafile /var/lib/mongodb/data/db/Tester.1, filling with zeroes...
Sun Dec 22 15:29:26.182 [FileAllocator] done allocating datafile /var/lib/mongodb/data/db/Tester.1, size: 128MB,  took 0 secs
Sun Dec 22 15:29:26.184 [conn1] build index Tester.user { _id: 1 }
Sun Dec 22 15:29:26.184 [conn1] build index done.  scanned 0 total records. 0 secs
Sun Dec 22 15:29:26.184 [conn1] end connection 127.0.0.1:37164 (0 connections now open)
Sun Dec 22 15:29:26.192 [initandlisten] connection accepted from 127.0.0.1:37165 #2 (1 connection now open)
Sun Dec 22 15:29:26.732 [initandlisten] connection accepted from 127.0.0.1:37166 #3 (2 connections now open)
Sun Dec 22 15:29:26.733 [conn3] end connection 127.0.0.1:37166 (1 connection now open)
Sun Dec 22 15:29:26.740 [initandlisten] connection accepted from 127.0.0.1:37167 #4 (2 connections now open)
Sun Dec 22 15:29:26.740 [conn4] end connection 127.0.0.1:37167 (1 connection now open)
Sun Dec 22 15:29:26.834 [initandlisten] connection accepted from 127.0.0.1:37168 #5 (2 connections now open)
Sun Dec 22 15:29:26.835 [conn5] end connection 127.0.0.1:37168 (1 connection now open)
Sun Dec 22 15:29:26.843 [initandlisten] connection accepted from 127.0.0.1:37169 #6 (2 connections now open)
Sun Dec 22 15:29:27.252 [initandlisten] connection accepted from 127.0.0.1:37170 #7 (3 connections now open)
Sun Dec 22 15:29:27.253 [conn7] end connection 127.0.0.1:37170 (2 connections now open)
Sun Dec 22 15:29:27.304 [initandlisten] connection accepted from 127.0.0.1:37171 #8 (3 connections now open)
Sun Dec 22 15:29:27.304 [conn8] end connection 127.0.0.1:37171 (2 connections now open)
Sun Dec 22 15:29:28.332 [initandlisten] connection accepted from 127.0.0.1:37173 #9 (3 connections now open)
Sun Dec 22 15:29:28.333 [conn9] end connection 127.0.0.1:37173 (2 connections now open)
Sun Dec 22 15:29:28.352 [initandlisten] connection accepted from 127.0.0.1:37174 #10 (3 connections now open)
Sun Dec 22 15:29:28.842 [conn10] end connection 127.0.0.1:37174 (2 connections now open)
Sun Dec 22 15:29:28.862 [initandlisten] connection accepted from 127.0.0.1:37176 #11 (3 connections now open)
Sun Dec 22 15:29:28.863 [conn11] end connection 127.0.0.1:37176 (2 connections now open)
Sun Dec 22 15:29:30.362 [initandlisten] connection accepted from 127.0.0.1:37178 #12 (3 connections now open)
Sun Dec 22 15:29:30.363 [initandlisten] connection accepted from 127.0.0.1:37179 #13 (4 connections now open)
Sun Dec 22 15:29:30.364 [conn13] end connection 127.0.0.1:37179 (3 connections now open)
Sun Dec 22 15:37:36.523 [signalProcessingThread] shutdown: closing all files...
Sun Dec 22 15:37:36.523 [signalProcessingThread] closeAllFiles() finished
Sun Dec 22 15:37:36.523 [signalProcessingThread] journalCleanup...
Sun Dec 22 15:37:36.523 [signalProcessingThread] removeJournalFiles
Sun Dec 22 15:37:36.525 [signalProcessingThread] shutdown: removing fs lock...
Sun Dec 22 15:37:36.525 dbexit: really exiting now

然后再说:

root@cs12867:~# mongod
mongod --help for help and startup options
Sun Dec 22 15:37:44.081 [initandlisten] MongoDB starting : pid=18415 port=27017 dbpath=/data/db/ 64-bit host=cs12867
Sun Dec 22 15:37:44.081 [initandlisten] db version v2.4.6
Sun Dec 22 15:37:44.081 [initandlisten] git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673
Sun Dec 22 15:37:44.081 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Sun Dec 22 15:37:44.081 [initandlisten] allocator: tcmalloc
Sun Dec 22 15:37:44.081 [initandlisten] options: {}
Sun Dec 22 15:37:44.081 [initandlisten] exception in initAndListen: 10296
*********************************************************************
 ERROR: dbpath (/data/db/) does not exist.
 Create this directory or give existing directory in --dbpath.
 See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
Sun Dec 22 15:37:44.081 dbexit:
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to close listening sockets...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to flush diaglog...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to close sockets...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: waiting for fs preallocator...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: lock for final commit...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: final commit...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: closing all files...
Sun Dec 22 15:37:44.081 [initandlisten] closeAllFiles() finished
Sun Dec 22 15:37:44.081 dbexit: really exiting now

4J41.. 16

mongodb的默认数据库路径是/data/db/.

所以当你跑:

mongod

MongoDB检查/ data/db /是否存在以及用户是否可以访问它.在您的情况下,没有这样的目录,因此错误.

但是,您可以使用mongod的--dbpath参数覆盖默认数据库路径(或使用配置文件).

mongod --dbpath /var/lib/mongodb/data/db

在这种情况下,而不是检查/ data/db/mongoDB检查/ var/lib/mongodb/data/db.在您的情况下,您拥有指定的目录,并且您可以访问它,因此它会运行.

这样做不会启动mongo shell.要启动shell,请如上所述首先启动mongod并使其保持运行状态.然后在另一个终端执行

mongo

这将启动mongo shell.

1 个回答
  • mongodb的默认数据库路径是/data/db/.

    所以当你跑:

    mongod
    

    MongoDB检查/ data/db /是否存在以及用户是否可以访问它.在您的情况下,没有这样的目录,因此错误.

    但是,您可以使用mongod的--dbpath参数覆盖默认数据库路径(或使用配置文件).

    mongod --dbpath /var/lib/mongodb/data/db
    

    在这种情况下,而不是检查/ data/db/mongoDB检查/ var/lib/mongodb/data/db.在您的情况下,您拥有指定的目录,并且您可以访问它,因此它会运行.

    这样做不会启动mongo shell.要启动shell,请如上所述首先启动mongod并使其保持运行状态.然后在另一个终端执行

    mongo
    

    这将启动mongo shell.

    2023-02-08 16:56 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有