2015-01-02 5 views
0

로컬 컴퓨터에 mongo가 설치되어 있습니다. 내가 mongod을 실행하여 데이터베이스를 시작할 때 나는 (즉 매우 일반적이고,이 사이트는 해결 방법에 대한 해결책을 가지고)이 오류가 발생했습니다 : 나는 /my/curent/directory/data/db에서 내 개발 환경에서 디렉토리를 생성 $ mongod --dbpath /my/curent/directory/data/db 다시 몽고를 시작 MongoDB - 이전 데이터에 대한 액세스를 제공하는 dbach

$ mongod 
mongod --help for help and startup options 
2015-01-01T22:31:17.350-0600 [initandlisten] MongoDB starting : pid=2835 port=27017 dbpath=/data/db 64-bit host=hermes 
2015-01-01T22:31:17.351-0600 [initandlisten] db version v2.6.4 
2015-01-01T22:31:17.351-0600 [initandlisten] git version: nogitversion 
2015-01-01T22:31:17.351-0600 [initandlisten] build info: Darwin minimavericks.local 13.3.0 Darwin Kernel Version 13.3.0: Tue Jun 3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49 
2015-01-01T22:31:17.351-0600 [initandlisten] allocator: tcmalloc 
2015-01-01T22:31:17.351-0600 [initandlisten] options: {} 
2015-01-01T22:31:17.351-0600 [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 
2015-01-01T22:31:17.351-0600 [initandlisten] dbexit: 
2015-01-01T22:31:17.351-0600 [initandlisten] shutdown: going to close listening sockets... 
2015-01-01T22:31:17.351-0600 [initandlisten] shutdown: going to flush diaglog... 
2015-01-01T22:31:17.351-0600 [initandlisten] shutdown: going to close sockets... 
2015-01-01T22:31:17.351-0600 [initandlisten] shutdown: waiting for fs preallocator... 
2015-01-01T22:31:17.351-0600 [initandlisten] shutdown: lock for final commit... 
2015-01-01T22:31:17.351-0600 [initandlisten] shutdown: final commit... 
2015-01-01T22:31:17.351-0600 [initandlisten] shutdown: closing all files... 
2015-01-01T22:31:17.352-0600 [initandlisten] closeAllFiles() finished 
2015-01-01T22:31:17.355-0600 [initandlisten] dbexit: really exiting now 

, 이번에 생성하는 :

2015-01-01T22:32:31.282-0600 [initandlisten] options: { storage: { dbPath: "./data/db" } } 
2015-01-01T22:32:31.319-0600 [initandlisten] journal dir=./data/db/journal 
2015-01-01T22:32:31.320-0600 [initandlisten] recover : no journal files present, no recovery needed 
2015-01-01T22:32:31.383-0600 [FileAllocator] allocating new datafile ./data/db/local.ns, filling with zeroes... 
2015-01-01T22:32:31.383-0600 [FileAllocator] creating directory ./data/db/_tmp 
2015-01-01T22:32:31.482-0600 [FileAllocator] done allocating datafile ./data/db/local.ns, size: 16MB, took 0.098 secs 
2015-01-01T22:32:31.842-0600 [FileAllocator] allocating new datafile ./data/db/local.0, filling with zeroes... 
2015-01-01T22:32:32.756-0600 [FileAllocator] done allocating datafile ./data/db/local.0, size: 64MB, took 0.914 secs 
2015-01-01T22:32:33.215-0600 [initandlisten] build index on: local.startup_log properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "local.startup_log" } 
2015-01-01T22:32:33.216-0600 [initandlisten]  added index to empty collection 
2015-01-01T22:32:33.216-0600 [initandlisten] command local.$cmd command: create { create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0 numYields:0 reslen:37 1852ms 
2015-01-01T22:32:33.216-0600 [initandlisten] waiting for connections on port 27017 
2015-01-01T22:33:31.402-0600 [clientcursormon] mem (MB) res:33 virt:2635 
2015-01-01T22:33:31.402-0600 [clientcursormon] mapped (incl journal view):160 
2015-01-01T22:33:31.402-0600 [clientcursormon] connections:0 

그것은 굉장하다. mongo 쉘을 사용하면이 디렉토리에서 작업하고있는 콜렉션에 액세스 할 수 있지만 show dbs을 사용하여 몇 주 전부터 (이 디렉토리가없는 경우) 다른 모든 데이터베이스를 볼 수 있습니다. --dbpath 옵션은 데이터가 저장된 위치를 격리하지 않을 경우 어떤 용도로 사용됩니까? 뭔가 이상한 일이 여기 있습니까?

+0

mongo 셸을 통해 이전 데이터에 액세스합니까? –

+0

'--dbpath' 디렉토리를 확인하십시오. 거기에 이전 데이터 파일이 있습니까? MongoDB는 마술처럼 오래된 데이터를 찾지 않을 것이므로, 새로운 디렉토리라고 말하면 (또는 당신이 생각하는 디렉토리에서 MongoDB를 가리키고 있지 않다는) 오인이라고 생각합니다. – wdberkeley

+0

이전 데이터는'mongo' 쉘을 통해 볼 수 있지만,'mongod'를 로깅하면 어떤 연결도 표시되지 않습니다. – Jared

답변

0

MongoDB는 모든 데이터를 저장하려면 data directory이 필요합니다. MongoDB의 기본 데이터 디렉토리 경로는 \data\db입니다.

대체 dbpath를 사용하려면 구성 파일에서 경로 (예 : C:\Program Files\MongoDB\mongod.cfg)를 지정하거나 명령 줄에서 --dbpath 옵션을 지정하십시오. 그런 다음 C 드라이브에서 data\db 폴더를 만들고 창을 사용하는 경우

보다 약 MongoDB Installation


읽어보십시오.

데이터 용으로 고유 한 디렉토리를 사용하는 경우 폴더의 전체 경로을 --dbpath 인수 값으로 전달하십시오.

+0

이전과 다른 디렉토리를 변경 했더라도 여전히 컴퓨터의 모든 데이터를 제공합니까? 이 디렉토리는 한 시간 전에 존재하지 않았지만 이제는이 디렉토리를 통해 모든 데이터를 사용할 수 있습니다. – Jared

+0

mongod.cfg 파일 수정 – Braj

관련 문제