programing

MongoDB를 서비스로 시작할 수 없습니다.

nasanasas 2020. 11. 19. 21:35
반응형

MongoDB를 서비스로 시작할 수 없습니다.


저는 몇 달 동안 MongoDB 용으로 개발해 왔으며 Windows 7 Enterprise 컴퓨터에 서비스로 설치하고 싶습니다. 다음은 서비스를 생성하기 위해 실행 한 명령입니다.

"D:\Milvia Systems\Development\MongoDB\mongod.exe" --logpath "D:\Milvia Systems\Development\MongoDB\logs\DBLog.log" --logappend --dbpath "D:\Milvia Systems\Development\MongoDB\db" -vvv --reinstall

그러나 net start "MongoDB"또는 서비스 제어판을 사용할 때마다 다음 오류가 발생합니다.

오류 1053 : 서비스가 시작 또는 제어 요청에 적시에 응답하지 않았습니다.

환경 : Windows 7 Enterprise 64 비트 MongoDB : 1.6.3 pdfile 버전 4.5


실제 문제를보기 위해 로깅을 확인 했습니까?

Mongo 설치를 c:\mongodb.

c:\mongodb\logsc:\mongodb\data\db디렉터리를 만듭니다 .

그런 다음 c:\mongodb\bin디렉터리를 검색하고 다음을 실행하여 서비스를 제거합니다 (설치 한 경우!).

mongod --remove

그런 다음 로그 및 데이터 디렉토리를 지정하여 서비스를 설치하십시오.

mongod --logpath c:\mongodb\logs\mongo.log --dbpath c:\mongodb\data\db --directoryperdb --install

그런 다음 서비스를 시작하는 데 문제가있는 경우 지정된 로그 파일에서 이유를 확인해야합니다.

여기에 더 많은 정보가 있습니다 .


데이터 디렉토리 또는 로그 디렉토리에 대한 절대 파일 경로를 지정하지 않은 경우 동일한 Windows 오류가 발생하지만 로그 파일은 표시되지 않습니다.

등록 된 서비스 인수를 수정하기 위해 Webiyo푸시 된 "Windows 7에 MongoDB 서비스 설치" 의 정보를 사용했습니다 .

  1. MongoDB를 다운로드하고 C : \ 드라이브에 압축을 풉니 다.
  2. "C : \ mongodb165"디렉토리 아래에 "data"및 "logs"하위 디렉토리를 추가합니다.
  3. "C : \ mongodb165 \ logs \ mongolog.txt"에 로그 파일 이름 "mongolog.txt"를 추가하십시오.
  4. 디렉토리를 "C : \ mongodb165 \ bin"으로 변경하십시오.
  5. 다음 명령을 실행하십시오.

    mongod --install --rest –master –logpath=C:\mongodb165\logs\mongolog.txt
    
  6. 레지스트리 편집기 (regedit.exe)를 열고 HKEY_LOCAL_MACHINE → SYSTEM → CurrentControlSet → 서비스로 이동합니다.

  7. MongoDB 키를 찾아 "ImagePath"값을 다음과 같이 설정하십시오.

    C:\mongodb165\bin\mongod --service  --rest  --master  --logpath=C:\mongodb165\logs\mongolog.txt  --dbpath=C:\mongodb165\data
    
  8. 변경 사항을 레지스트리에 저장하고 레지스트리 편집기를 종료합니다.

  9. ComponentServices를 열고 "서비스 (로컬)"를 클릭 한 다음 MongoDB 서비스를 찾으십시오. 시작하세요.
  10. URL http : // localhost : 28017 / 에서 MongoDB가 통계를 반환하는지 확인합니다.

내 Windows 7 컴퓨터에서 동일한 문제가 발생했습니다. 설치를 위해 MongoDB 문서의 지시를 따랐지만 "C : \"에 있지 않으면 "net start MongoDB"를 실행할 수 없습니다. 위에서 언급 한 Webiyo 링크에 포함 된 지침을 따르기 위해 돌아가서 MongoDB를 다시 설치하고 싶지 않았습니다 . 문서에 따라 MongoDB를 이미 설치했고 프로젝트 디렉토리가있는 곳에서 "net start MongoDB"를 실행할 수 있기를 원하는 경우 :

HKEY_LOCAL_MACHINE> SYSTEM> CurrentControlSet> 서비스> MongoDB로 이동하십시오.

이름 열에서 ImagePath를 두 번 클릭하십시오.

다음 ImagePath에 붙여 넣으십시오 (필요에 맞게 폴더 디렉토리 및 이름 편집).

C:\mongodb\bin\mongod.exe --service  --rest  --master  --logpath=C:\mongodb\log\mongolog.txt  --dbpath=C:\mongodb\data\db --config C:\mongodb\mongod.cfg

이 ImagePath 값을 직접 복사하고 "data"폴더가 C : \ 대신 mongodb 디렉토리에있는 경우 "mongod.cfg"파일에 다음 행을 추가하십시오. dbpath=C:\mongodb\data\db

이 작업을 수행 한 후 "net stop MongoDB"를 실행하면 "시스템 오류 109가 발생했습니다. 파이프가 종료되었습니다."라는 메시지가 표시됩니다. 당신도 그것을 볼 수 있습니다. 이 메시지는 jira.mongodb.org 에서 철저히 논의되었습니다 .

전체 토론을 앞뒤로 읽는 시간을 절약하기 위해 Tad Marshalls 게시물은이 문제를 요약합니다.

"... 2.1.0에서 잘 작동했습니다. 나중에 변경하면 다시 깨졌습니다.하지만 예, 현재 코드에서이 오류 메시지가 표시됩니다.

설명은 mongod.exe가 "net stop mongodb"로 인해 우리를 호출 할 때 Windows 서비스 제어 관리자에 의해 생성 된 콜백 스레드에서 종료되고 이로 인해 콜백 스레드를 생성하는 데 사용 된 RPC 파이프가 중단된다는 것입니다. 이를 방지하기 위해 종료 로직을 ​​재구성해야합니다.

오류 메시지는이 문제의 유일한 실제 효과입니다. 명령을 종료하고 깨끗하게 Windows 서비스 제어 관리자에게 중지되었음을 알립니다. 그러나 "net"명령은 예상대로 RPC 호출에서 돌아 오지 않았기 때문에 오류 메시지를 표시합니다. "


이 명령을 실행했습니다.

C:\MongoDB\Server\3.4\bin>net start MongoDB

그리고이 메시지를 받았습니다.

서비스가 제어 기능에 응답하지 않습니다. NET HELPMSG 2186을 입력하면 더 많은 도움말을 볼 수 있습니다.

몇 번의 시행 착오 끝에 튜토리얼을 따를파일 이름을 mongod.conf 로 지정하라고 요청 했지만 명령이 mongod.cfg 를 참조하려고한다는 것을 알았습니다 .

이름을 수정하고 명령을 다시 실행하자마자

C:\MongoDB\Server\3.4\bin>sc.exe delete MongoDB
[SC] DeleteService SUCCESS

C:\MongoDB\Server\3.4\bin>sc.exe create MongoDB binPath= "\"C:\MongoDB\Server\3.4\bin\mongod.exe\" --service --config=\"C:\MongoDB\Server\3.4\mongod.cfg\"" DisplayName= "MongoDB" start= "auto"
[SC] CreateService SUCCESS

C:\MongoDB\Server\3.4\bin>net start MongoDB
The MongoDB service is starting....
The MongoDB service was started successfully.

서비스가 정상적으로 실행되기 시작했습니다.


Windows Server 2012에서 동일한 문제가 발생할 수있는 다른 사용자에게 :

Windows Server 2012의 Mongo 3.0.3에서 방금 동일한 문제가 발생했습니다. 저는 시스템 관리자가 아니므로 sc.exe에서 변경된 사항을 모릅니다. 나는 사용해야한다

sc.exe create MongoDB binPath= "C:\mongodb\bin\mongod.exe --service --config=C:\mongodb\mongod.cfg" DisplayName= "MongoDB" start= "auto"

웹 사이트에있는 것과 비교하여 바이너리 및 구성 파일 경로 모두에 대해 \ "\"가 없습니다.


다음은 Windows 7에 mongoDB를 설치하기 위해 수행 한 단계입니다.

  1. mongodb 사이트-> https://www.mongodb.com/download-center?jmp=nav#community 에서 .msi 파일을 다운로드 하고 실행합니다.

  2. mondoDb를 다운로드 할 때마다 (일반적으로 c 드라이브 Program Files 폴더에 있음) 해당 폴더로 이동하고 동일한 폴더의 bin 폴더가있는 위치에 데이터 폴더로그 폴더를 만듭니다.

3. 데이터 폴더 안에 db 폴더를 만듭니다.

구조는 다음과 같습니다.

  1. 이제 관리자 권한으로 명령 프롬프트를 엽니 다.

  2. 파일 경로를 변경하고 bin 폴더를 입력하십시오. (이 경우 c> program files> MongoDB> bin>)

  3. 다음 명령을 입력하십시오. mongod --directoryperdb --dbpath "C : / Program Files \ MongoDB \ data"--logpath "C : \ Program Files \ MongoDB \ log \ mongo.log"--logappend --rest- 설치

  4. 이것은 로그 경로와 데이터베이스 경로를 설정합니다. 마지막으로 net start MongoDB를 실행합니다 . 도움이 되었기를 바랍니다.


내 mongod.cfg 파일에는 다음 두 줄이 있습니다.

#snmp:
mp:

왜 거기에 mp :가 있는지 모르겠습니다. 하지만 수동으로 이미지 경로를 실행하면

C:\mongodb\bin\mongod.exe --config "C:\mongodb\bin\mongod.cfg" --service

...에서

Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MongoDB

나는 얻었다

c:\mongodb\bin>mongod /?C:\mongodb\bin\mongod.exe --config "C:\mongodb\bin\mongod.cfg" --service
Unrecognized option: mp
try 'mongod --help' for more information

그래서 주석을 달았고 아무 문제없이 서비스가 시작되었습니다.


들어 MongoDB를 3.0 , 당신은 설정 파일에 다음을 설정해야합니다.

logpath=E:\mongoDBdata\log\mongoDB.log
dbpath=E:\mongoDBdata\db

로그 경로는 폴더가 아닌 파일로 끝나야합니다.


mongod.cfg 파일에 탭이 있는지 확인하십시오. 탭을 제거하면 해결되었습니다!


MongoDB 3.6.0에서 다음 작업

다음 폴더가 있는지 확인하십시오.

  • C : \ mongodb \ data
  • C : \ mongodb \ data \ db

그런 다음 필요한 것은 다음 명령입니다.

  • mongod --directoryperdb -dbpath C : \ mongodb \ data \ db --logpath C : \ mongodb \ log \ mongo.log --logappend --service --install
  • 순 시작 MongoDB
  • 몽고

이것이 실패 할 수있는 또 다른 방법은 서비스를 실행하는 계정에 데이터 디렉터리에 대한 쓰기 권한이없는 경우입니다.

이 경우 서비스는 잠금 파일을 생성 할 수 없습니다.

mongod 서비스는이 상황에서 잘못 작동하고 프로세스를 시작하는 루프에 들어가 처리되지 않은 예외, 충돌 등이 즉시 발생합니다. 프로세스가 시작될 때마다 로그 파일이 다시 생성되므로 원하는 경우 빠르게 가져와야합니다. 오류를 확인하십시오.

Windows 서비스의 기본 사용자는 localhost \ system입니다. 따라서 수정은이 사용자가 db 디렉토리에 쓸 수 있는지 확인하거나 가능한 다른 사용자로 서비스를 시작하는 것입니다.


버전 2.6 이상에서는 mongo.cfg가 가리키는 / data / db / 및 / log / 폴더를 만들어야합니다. MongoDB는 자체적으로 그렇게하지 않으며 서비스로 실행될 때 응답으로 해당 오류를 발생시킵니다.


전체 mongod 항목을 입력하기 전에 오른쪽 클릭에서 "관리자 권한으로 실행"권한으로 명령 줄을 열어야합니다.


디버그에 30 분을 보낸 후 ... 드디어 "rest"속성 앞에 대시 하나가 있음을 발견했습니다.

mongodb as service


명령 줄에서 로컬로 mongod.exe를 실행 해보십시오. 여기서 예외가 발생하여 mongod가 호출하여 문제를 해결할 수 있습니다. 제 경우에는 로컬 디스크의 여유 공간이 작기 때문에 디렉토리 위치를 변경하고 Mongocofig 파일을 변경하면 이제 정상적으로 실행됩니다.


서비스 세부 정보를 보면 서비스를 시작하는 명령이 다음과 같은 것을 알 수 있습니다.

"C:\Program Files\MongoDB\bin\mongod" --config  C:\Program Files\MongoDB\mongod.cfg  --service 

MongoDB 팀 "--config옵션 을 추가하는 것을 잊었습니다 . 따라서 레지스트리를 편집하여 수정하면 작동합니다.


Windows 8.1에서 동일한 문제가 발생했습니다.

나를 위해 일한 해결책은 구성 파일 경로를 올바르게 지정하는 것입니다.

HKEY_LOCAL_MACHINE > SYSTEM > CurrentControlSet > services > MongoDB > imagePath값으로 이동 하는 것은 다음과 같습니다.

"C:\Program Files\MongoDB 2.6 Standard\bin\mongod.exe" --config mongod.cfg --service

그런 다음 실제 경로와 일치하도록 구성 파일 경로를 수정했습니다.

"C:\Program Files\MongoDB 2.6 Standard\bin\mongod.exe" --config "d:\mongodb\mongod.cfg" --service

Remember to create the database before starting the service

C:\>"C:\Program Files\MongoDB\Server\3.2\bin\mongod.exe" --dbpath d:\MONGODB\DB
2016-10-13T18:18:23.135+0200 I CONTROL  [main] Hotfix KB2731284 or later update is installed, no need to zero-out data files
2016-10-13T18:18:23.147+0200 I CONTROL  [initandlisten] MongoDB starting : pid=4024 port=27017 dbpath=d:\MONGODB\DB 64-bit host=mongosvr
2016-10-13T18:18:23.148+0200 I CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2016-10-13T18:18:23.149+0200 I CONTROL  [initandlisten] db version v3.2.8
2016-10-13T18:18:23.149+0200 I CONTROL  [initandlisten] git version: ed70e33130c977bda0024c125b56d159573dbaf0
2016-10-13T18:18:23.150+0200 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1p-fips 9 Jul 2015
2016-10-13T18:18:23.151+0200 I CONTROL  [initandlisten] allocator: tcmalloc
2016-10-13T18:18:23.151+0200 I CONTROL  [initandlisten] modules: none
2016-10-13T18:18:23.152+0200 I CONTROL  [initandlisten] build environment:
2016-10-13T18:18:23.152+0200 I CONTROL  [initandlisten]     distmod: 2008plus-ssl
2016-10-13T18:18:23.153+0200 I CONTROL  [initandlisten]     distarch: x86_64
2016-10-13T18:18:23.153+0200 I CONTROL  [initandlisten]     target_arch: x86_64
2016-10-13T18:18:23.154+0200 I CONTROL  [initandlisten] options: { storage: { dbPath: "d:\MONGODB\DB" } }
2016-10-13T18:18:23.166+0200 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=8G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-10-13T18:18:23.722+0200 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-10-13T18:18:23.723+0200 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory 'd:/MONGODB/DB/diagnostic.data'
2016-10-13T18:18:23.895+0200 I NETWORK  [initandlisten] waiting for connections on port 27017

Then you can stop the process Control-C

2016-10-13T18:18:44.787+0200 I CONTROL  [thread1] Ctrl-C signal
2016-10-13T18:18:44.788+0200 I CONTROL  [consoleTerminate] got CTRL_C_EVENT, will terminate after current cmd ends
2016-10-13T18:18:44.789+0200 I FTDC     [consoleTerminate] Shutting down full-time diagnostic data capture
2016-10-13T18:18:44.792+0200 I CONTROL  [consoleTerminate] now exiting
2016-10-13T18:18:44.792+0200 I NETWORK  [consoleTerminate] shutdown: going to close listening sockets...
2016-10-13T18:18:44.793+0200 I NETWORK  [consoleTerminate] closing listening socket: 380
2016-10-13T18:18:44.793+0200 I NETWORK  [consoleTerminate] shutdown: going to flush diaglog...
2016-10-13T18:18:44.793+0200 I NETWORK  [consoleTerminate] shutdown: going to close sockets...
2016-10-13T18:18:44.795+0200 I STORAGE  [consoleTerminate] WiredTigerKVEngine shutting down
2016-10-13T18:18:45.116+0200 I STORAGE  [consoleTerminate] shutdown: removing fs lock...
2016-10-13T18:18:45.117+0200 I CONTROL  [consoleTerminate] dbexit:  rc: 12

Now your database is prepared and you can start the service using

C:\>net start MongoDB
The MongoDB service is starting.
The MongoDB service was started successfully.

Check if a process instance of mongod is already running. If yes, this service will not start because C:\data\db\mongod.lock will be used by it.

And to start MongoDB as a service, this file shall be not used by any process.


For me, the issue was the wrong directory. Make sure you copy paste the directory from your file explorer and not assume the directory specified on the docs page correct.


If you receive the error:

the service name is invalid

when running net start mongodb, you will need to run the following command from Step 4 of Manually Create a Windows Service for MongoDB Community Editition:

sc.exe create MongoDB binPath= "\"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe\" --service --config=\"C:\Program Files\MongoDB\Server\3.4\mongod.cfg\"" DisplayName= "MongoDB" start= "auto"

I had made few changes in the Config start-up file, which caused this issue. When I looked in the "mongo.log" file, it said

"Cannot start server. Detected data files in E:\Mongo\data\db created by storage engine 'wiredTiger'. The configured storage engine is 'mmapv1'., terminating"

Resetting the storage engine back to 'wiredTiger' resolved the issue for me. Hope this helps others.


I started following a tutorial on a blog that required MongoDB. It had instructions on downloading and configuring the service. But for some reason the command for starting the Windows service in that tutorial wasn’t working. So I went to the MongoDB docs and tried running this command as listed in the mongodb.org-

The command for strting mongodb service- sc.exe create MongoDB binPath= "\"C:\MongoDB\bin\mongod.exe\" --service --config=\"C:\MongoDB\bin\mongodb\mongod.cfg\"" DisplayName= "MongoDB" start= "auto"

I got this message: [SC] CreateService SUCCESS

Then I ran this one: net start MongoDB

And got this message:

The service is not responding to the control function.

More help is available by typing NET HELPMSG 2186.

I create a file named 'mongod.cfg' in the 'C:\MongoDB\bin\mongodb\' As soon as I added that file and re-ran the command- 'net start MongoDB', the service started running fine.

Hope this helps.


Well, in my case, I was running low disk space on my drive where I have my MongoDB data files. I checked MongoDB logs file which stated the following

2015-11-11T21:53:54.717+0500 E JOURNAL [initandlisten] Insufficient free space for journal files 2015-11-11T21:53:54.717+0500 I JOURNAL [initandlisten] Please make at least 3379MB available in C:\wamp\bin\mongodb\data\db\journal or use --smallfiles

All I had to do is clean up some space and fire up the service again.. Worked for me. So All you have to is check your logs file and deal with the problem accordingly.

참고URL : https://stackoverflow.com/questions/4661670/cannot-start-mongodb-as-a-service

반응형