developer tip

MongoDB를 처음 사용하는 경우 mongo 명령을 실행할 수 없습니다.

optionbox 2020. 9. 2. 17:42
반응형

MongoDB를 처음 사용하는 경우 mongo 명령을 실행할 수 없습니다.


MongoDB를 실행하려고했습니다.

   E:\mongo\bin>mongod
    mongod --help for help and startup options
    Sun Nov 06 18:48:37
    Sun Nov 06 18:48:37 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
    Sun Nov 06 18:48:37
    Sun Nov 06 18:48:37 [initandlisten] MongoDB starting : pid=7108 port=27017 dbpath=/data/db 32-bit host=pykhmer-PC
    Sun Nov 06 18:48:37 [initandlisten]
    Sun Nov 06 18:48:37 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
    Sun Nov 06 18:48:37 [initandlisten] **       see http://blog.mongodb.org/post/137788967/32-bit-limitations
    Sun Nov 06 18:48:37 [initandlisten] **       with --journal, the limit is lower
    Sun Nov 06 18:48:37 [initandlisten]
    Sun Nov 06 18:48:37 [initandlisten] db version v2.0.1, pdfile version 4.5
    Sun Nov 06 18:48:37 [initandlisten] git version: 3a5cf0e2134a830d38d2d1aae7e88cac31bdd684
    Sun Nov 06 18:48:37 [initandlisten] build info: windows (5, 1, 2600, 2, 'Service Pack 3') BOOST_LIB_VERSION=1_42
    Sun Nov 06 18:48:37 [initandlisten] options: {}
    Sun Nov 06 18:48:37 [initandlisten] exception in initAndListen: 10296 dbpath (/data/db) does not exist, terminating
    Sun Nov 06 18:48:37 dbexit:
    Sun Nov 06 18:48:37 [initandlisten] shutdown: going to close listening sockets...
    Sun Nov 06 18:48:37 [initandlisten] shutdown: going to flush diaglog...
    Sun Nov 06 18:48:37 [initandlisten] shutdown: going to close sockets...
    Sun Nov 06 18:48:37 [initandlisten] shutdown: waiting for fs preallocator...
    Sun Nov 06 18:48:37 [initandlisten] shutdown: closing all files...
    Sun Nov 06 18:48:37 [initandlisten] closeAllFiles() finished
    Sun Nov 06 18:48:37 dbexit: really exiting now

E:\mongo\bin>mongo
MongoDB shell version: 2.0.1
connecting to: test
Sun Nov 06 18:48:42 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed

E:\mongo>ls
GNU-AGPL-3.0  README  THIRD-PARTY-NOTICES  bin  data

http://www.mongodb.org/display/DOCS/Quickstart+Windows를 보고 지침을 따랐습니다. 누구든지 MongoDB를 실행하는 데 어떤 문제가 있는지 말해 줄 수 있습니까 (Windows 7을 사용하고 있습니다)?


나는 당신의 로그 출력이 그것을 명확하게 설명한다고 생각합니다.

exception in initAndListen: 10296 dbpath (/data/db) does not exist, terminating

이 디렉토리를 간단히 만들거나 구성 파일 내에서 구성 값으로 정의한 다음 mongod -f C:\path\to\your\mongodb.conf.


MongoDB를 설치 한 후 수동으로 데이터 폴더를 만들어야합니다.

기본적으로 MongoDB는 / data / db에 데이터를 저장합니다. 
하지만 자동으로 해당 디렉토리를 생성하지는 않습니다. 그것을 만들려면 다음을 수행하십시오.

$ sudo mkdir -p / 데이터 / db /
$ sudo chown`id -u` / data / db

MongoDB에 다른 데이터 디렉토리를 사용하도록 지시 할 수도 있습니다.
--dbpath 옵션을 사용합니다.

자세한 정보는 MongoDB 위키 페이지로 이동하십시오.


이와 같이 명시 적으로 데이터베이스 경로를 지정하고 문제가 해결되는지 확인하십시오.

mongod --dbpath data/db

mongod --dbpath "c://data/db"

위의 코드를 실행하면 서버가 시작됩니다.


들어 윈도우 7

mongod.exe\data\db 에 대한 dbpath 설정으로 대체 경로를 지정할 수 있습니다 .

다음 예에서와 같이 :

c:\mongodb\bin\mongod.exe --dbpath c:\mongodb\data\db

또는

구성 파일을 통해 dbpath를 설정할 수 있습니다 .


데이터베이스 데이터 파일에 대한 경로가 있는지 확인하십시오.;) :

Sun Nov 06 18:48:37 [initandlisten] initAndListen 예외 : 10296 dbpath (/ data / db) does not exist , terminating


이것은 나를 위해 일했습니다 (적용되는 경우 잠금 파일도 표시됨).

first>youridhere@ubuntu:/var/lib/mongodb$ sudo service mongodb start 
then >youridhere@ubuntu:/var/lib/mongodb$ sudo rm mongod.lock*

몇 번의 시도 후에 이것은 Windows 7 환경 에서 나를 위해 작동합니다 . :

Initially directory to which you have copied all MongDB sources has such view:

bsondump.exe
mongo.exe
mongod.exe
mongod.pdb
mongodump.exe
mongoexport.exe
mongofiles.exe
mongoimport.exe
mongooplog.exe
mongoperf.exe
mongorestore.exe
mongos.exe
mongos.pdb
mongostat.exe
mongotop.exe

All you need is to add data directory and db directory nested( data/db ) Final view should look like this:

data
bsondump.exe
mongo.exe
mongod.exe
mongod.pdb
mongodump.exe
mongoexport.exe
mongofiles.exe
mongoimport.exe
mongooplog.exe
mongoperf.exe
mongorestore.exe
mongos.exe
mongos.pdb
mongostat.exe
mongotop.exe

Than simply type in directory where MongoDB sources and data/db dirs exist this command:

C:\my_mongo_dir\bin>mongod --dbpath .\data\db

Also check if you have installed the Mongo as a windows service and if its running. That's also important. There might port conflict because of that.


Create the data/db directory in your main (windows) partition:

C:\> mkdir \data
C:\> mkdir \data\db

and then go to your mongo_directory/bin and run mongod.exe:

C:\> cd \my_mongo_dir\bin

C:\my_mongo_dir\bin> mongod

DON't CLOSE THIS WINDOW

Now in a different command prompt window run Mongo:

C:\> cd \my_mongo_dir\bin
C:\my_mongo_dir\bin> mongo

(REMEMBER YOU HAVE TO KEEP THAT OTHER WINDOW OPEN)

This solved the problem for me.


create folder structure data/db in the working directory and then starting up mongodb using "mongod --dbpath data/db" works just fine


You should create a startup.bat if you're using Windows, much more convenient:

C:\mongodb\mongodb-win32-x86_64-eiditon\bin\mongod.exe --dbpath C:\mongodb\data

And just dbclick startup.bat and mongodb will run using C:\mongodb\data as its data folder.


You just need to create directory in C:. as C:\data\db\

Now just start mongoDB:

C:\Users\gi.gupta>"c:\Program Files\MongoDB\Server\3.2\bin\mongod.exe"
2016-05-03T10:49:30.412+0530 I CONTROL  [main] Hotfix KB2731284 or later update is not installed, will zero-out data files
2016-05-03T10:49:30.414+0530 I CONTROL  [initandlisten] MongoDB starting : pid=7904 port=27017 dbpath=C:\data\db\ 64-bit host=GLTPM-W036
2016-05-03T10:49:30.414+0530 I CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2016-05-03T10:49:30.414+0530 I CONTROL  [initandlisten] db version v3.2.6
2016-05-03T10:49:30.414+0530 I CONTROL  [initandlisten] git version: 05552b562c7a0b3143a729aaa0838e558dc49b25
2016-05-03T10:49:30.414+0530 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1p-fips 9 Jul 2015
2016-05-03T10:49:30.414+0530 I CONTROL  [initandlisten] allocator: tcmalloc
2016-05-03T10:49:30.414+0530 I CONTROL  [initandlisten] modules: none
2016-05-03T10:49:30.414+0530 I CONTROL  [initandlisten] build environment:
2016-05-03T10:49:30.414+0530 I CONTROL  [initandlisten]     distmod: 2008plus-ssl
2016-05-03T10:49:30.414+0530 I CONTROL  [initandlisten]     distarch: x86_64
2016-05-03T10:49:30.414+0530 I CONTROL  [initandlisten]     target_arch: x86_64
2016-05-03T10:49:30.414+0530 I CONTROL  [initandlisten] options: {}
2016-05-03T10:49:30.427+0530 I -        [initandlisten] Detected data files in C:\data\db\ created by the 'wiredTiger' storage engine, so setting the active storage engine to
2016-05-03T10:49:30.429+0530 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(f
chive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-05-03T10:49:30.998+0530 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-05-03T10:49:30.998+0530 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory 'C:/data/db/diagnostic.data'
2016-05-03T10:49:31.000+0530 I NETWORK  [initandlisten] waiting for connections on port 27017
2016-05-03T10:49:40.766+0530 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:57504 #1 (1 connection now open)

It will then run as service in background.


If you're using Windows 7/ 7+.

Here is something you can try.

Check if the installation is proper in CONTROL PANEL of your computer.

Now goto the directory and where you've install the MongoDB. Ideally, it would be in

C:\Program Files\MongoDB\Server\3.6\bin

Then either in the command prompt or in the IDE's terminal. Navigate to the above path ( Ideally your save file) and type

mongod --dbpath

It should work alright!


The very simplest approach given by mongo README help file

RUNNING

For command line options invoke:

$ ./mongod --help

To run a single server database:

$ sudo mkdir -p /data/db
$ ./mongod
$
$ # The mongo javascript shell connects to localhost and test database by default:
$ ./mongo
> help

If you are working with windows, go to your directory where you have mongo.exe

use the following commands, (I am sharing mine)

C:\Program Files\MongoDB\Server\3.6\bin>mkdir \data

C:\Program Files\MongoDB\Server\3.6\bin>mkdir \data\db

C:\Program Files\MongoDB\Server\3.6\bin>mongod ## this will start your mongoDB server

Now you need to run another CMD prompt and go to the directory where you have mongo and just run it

C:\Program Files\MongoDB\Server\3.6\bin>mongo ## this will start your mongoDB client

Hope it helped :)

If it doesn't work, run CMD as an administrator

참고URL : https://stackoverflow.com/questions/8029064/new-to-mongodb-can-not-run-command-mongo

반응형