Microsoft MVP성태의 닷넷 이야기
오류 유형: 517. docker에 설치한 MongoDB 서버로 연결이 안 되는 경우 [링크 복사], [링크+제목 복사],
조회: 11465
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

docker에 설치한 MongoDB 서버로 연결이 안 되는 경우

docker에 MongoDB를 설치한 경우,

C:\> docker pull mongo

// docker run -d -p 27017:27017/tcp --name mongodb_inst --rm -it mongo
// docker exec --name mongodb_inst /bin/bash

(저처럼) 무심코 ^^; 27017 포트로 연결을 시도하면 다음과 같은 오류 메시지를 보게 되는데요.

failed to connect to server [127.0.0.1:27017] on first connect
[MongoError: connect ECONNREFUSED 127.0.0.1:27017]

이유는, 포트 매핑이 어떻게 되어 있는지 확인해 보면 됩니다. ^^

C:\> docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                      NAMES
cf00331fdcbd        mongo:latest        "docker-entrypoint.s…"   3 minutes ago       Up 3 minutes        0.0.0.0:32768->27017/tcp   mongo




윈도우용의 압축 파일을 해제한 경우의 서비스 구동 방법

// 콘솔 실행 시 (대상이 되는 dbpath, 아래의 예에서는 d:\mongo\db 디렉터리를 미리 생성)
               (기본 dbpath는 mongodb가 설치된 드라이브의 "\data\db"이므로, 아래의 예에서는 d:\data\db" 디렉터리 생성 후 dbpath 옵션 없이 수행 가능)
d:\mongodb\bin> mongod --dbpath=d:\mongo\db --logpath=d:\mongo\log.txt

// 서비스 등록 시
d:\mongodb\bin> mongod --dbpath=d:\mongo\db --logpath=d:\mongo\log.txt --install

// 서비스 제거
d:\mongodb\bin> mongod --remove

mongo.exe 클라이언트 실행 후 기본 명령어
[데이터베이스 생성]
> use mydb
switched to db mydb

[컬렉션 생성]
> db.createCollection("users")
{ "ok" : 1 }

[컬렉션 확인]
> show collections
users

[문서 삽입]
> db.users.insert({name: "kevin" })
WriteResult({ "nInserted" : 1 })

> db.users.insert({name: "anders", age: 40})
WriteResult({ "nInserted" : 1 })

[문서 찾기]
> db.users.find()
{ "_id" : ObjectId("60f55e6772f24083840d4af6"), "name" : "kevin" }
{ "_id" : ObjectId("60f55ea172f24083840d4af7"), "name" : "anders", "age" : 40 }

// ObjectId: 문서 추가 시 _id 필드를 지정하지 않은 경우 default 값 체계
//           12바이트 - 타임스탬프(4바이트): 1970년 1월 1일 이후 초 단위로 시작한 값 (Sunday, 7 February 2106 06:28:16 GMT까지 표현할 수 있다고.)
//                     장비 식별자(3바이트), 프로세스 ID(2바이트), 카운터(3바이트)

[MongoDB 종료]
> use admin
switched to db admin
> db.shutdownServer()
server should be down...

// 공식 참조 문서
; https://docs.mongodb.com/manual/reference/

NoSQL 데이터베이스 타입
 - 데이터 모델 설계 방식
    1) 문서(Document) 모델: MongoDB,...
    2) 키-값(Key-value) 모델
    3) 칼럼(Column) 모델
    4) 그래프(Graph) 모델




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 12/21/2021]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 61  62  63  64  65  66  67  68  69  70  71  [72]  73  74  75  ...
NoWriterDateCnt.TitleFile(s)
11832정성태3/4/201910717오류 유형: 524. Visual Studio CMake - rsync: connection unexpectedly closed
11831정성태3/4/201910282오류 유형: 523. Visual Studio 2019 - 새 창으로 뜬 윈도우를 닫을 때 비정상 종료
11830정성태2/26/201910118오류 유형: 522. 이벤트 로그 - Error opening event log file State. Log will not be processed. Return code from OpenEventLog is 87.
11829정성태2/26/201911973개발 환경 구성: 430. 마이크로소프트의 CoreCLR 프로파일러 예제 빌드 방법 - 리눅스 환경 [1]
11828정성태2/26/201918354개발 환경 구성: 429. Component Services 관리자의 RuntimeBroker 설정이 2개 있는 경우 [8]
11827정성태2/26/201912298오류 유형: 521. Visual Studio - Could not start the 'rsync' command on the remote host, please install it using your system package manager.
11826정성태2/26/201912220오류 유형: 520. 우분투에 .NET Core SDK 설치 시 패키지 의존성 오류
11825정성태2/25/201917069개발 환경 구성: 428. Visual Studio 2019 - CMake를 이용한 리눅스 빌드 환경 설정 [1]
11824정성태2/25/201911827오류 유형: 519. The SNMP Service encountered an error while accessing the registry key SYSTEM\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration. [1]
11823정성태2/21/201913294오류 유형: 518. IIS 관리 콘솔이 뜨지 않는 문제
11822정성태2/20/201911465오류 유형: 517. docker에 설치한 MongoDB 서버로 연결이 안 되는 경우
11821정성태2/20/201911937오류 유형: 516. Visual Studio 2019 - This extension uses deprecated APIs and is at risk of not functioning in a future VS update. [1]
11820정성태2/20/201915045오류 유형: 515. 윈도우 10 1809 업데이트 후 "User Profiles Service" 1534 경고 발생
11819정성태2/20/201913717Windows: 158. 컴퓨터와 사용자의 SID(security identifier) 확인 방법
11818정성태2/20/201912639VS.NET IDE: 131. Visual Studio 2019 Preview의 닷넷 프로젝트 빌드가 20초 이상 걸리는 경우 [2]
11817정성태2/17/20199838오류 유형: 514. WinDbg Preview 실행 오류 - Error : DbgX.dll : WindowsDebugger.WindowsDebuggerException: Could not load dbgeng.dll
11816정성태2/17/201912312Windows: 157. 윈도우 스토어 앱(Microsoft Store App)을 명령행에서 직접 실행하는 방법
11815정성태2/14/201911233오류 유형: 513. Visual Studio 2019 - VSIX 설치 시 "The extension cannot be installed to this product due to prerequisites that cannot be resolved." 오류 발생
11814정성태2/12/20199989오류 유형: 512. VM(가상 머신)의 NT 서비스들이 자동 시작되지 않는 문제
11813정성태2/12/201911590.NET Framework: 809. C# - ("Save File Dialog" 등의) 대화 창에 확장 속성을 보이는 방법
11812정성태2/11/20199488오류 유형: 511. Windows Server 2003 VM 부팅 후 로그인 시점에 0xC0000005 BSOD 발생
11811정성태2/11/201913189오류 유형: 510. 서버 운영체제에 NVIDIA GeForce Experience 실행 시 wlanapi.dll 누락 문제
11810정성태2/11/201911264.NET Framework: 808. .NET Profiler - GAC 모듈에서 GAC 비-등록 모듈을 참조하는 경우의 문제
11809정성태2/11/201912725.NET Framework: 807. ClrMD를 이용해 메모리 덤프 파일로부터 특정 인스턴스를 참조하고 있는 소유자 확인
11808정성태2/8/201913849디버깅 기술: 123. windbg - 닷넷 응용 프로그램의 메모리 누수 분석
11807정성태1/29/201912200Windows: 156. 가상 디스크의 용량을 복구 파티션으로 인해 늘리지 못하는 경우 [4]
... 61  62  63  64  65  66  67  68  69  70  71  [72]  73  74  75  ...