Microsoft MVP성태의 닷넷 이야기
오류 유형: 517. docker에 설치한 MongoDB 서버로 연결이 안 되는 경우 [링크 복사], [링크+제목 복사],
조회: 20540
글쓴 사람
정성태 (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

비밀번호

댓글 작성자
 




... 151  [152]  153  154  155  156  157  158  159  160  161  162  163  164  165  ...
NoWriterDateCnt.TitleFile(s)
1285정성태5/16/201234533.NET Framework: 318. gacutil.exe로 어셈블리 등록 시 시스템 변경 사항파일 다운로드1
1284정성태5/15/201226956오류 유형: 155. Windows Phone 연결 상태에서 DRIVER POWER STATE FAILURE 블루 스크린 뜨는 현상
1283정성태5/12/201234603.NET Framework: 317. C# 관점에서의 Observer 패턴 구현 [1]파일 다운로드1
1282정성태5/12/201227343Phone: 6. Windows Phone 7 Silverlight에서 Google Map 사용하는 방법 [3]파일 다운로드1
1281정성태5/9/201234373.NET Framework: 316. WPF/Silverlight의 그래픽 단위와 Anti-aliasing 처리를 이해하자 [1]파일 다운로드1
1280정성태5/9/201227508오류 유형: 154. Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, ...'.
1279정성태5/9/201226276.NET Framework: 315. 해당 DLL이 Managed인지 / Unmanaged인지 확인하는 방법 [1]파일 다운로드1
1278정성태5/8/201227656오류 유형: 153. Visual Studio 디버깅 - Unable to break execution. This process is not currently executing the type of code that you selected to debug.
1277정성태5/8/201232611오류 유형: 152. cmd.exe - The system cannot write to the specified device. [2]
1276정성태4/28/201224476Phone: 5. 모든 Marketplace에 윈폰 앱을 등록하는 방법 [1]
1275정성태4/28/201228073개발 환경 구성: 150. 프로세스 실행으로 잠긴 파일이지만, 이름은 변경가능하다는 사실! 아셨나요? [7]
1274정성태4/17/201222733Phone: 4. "Holiday Calendar" 윈폰 응용 프로그램 등록
1273정성태4/6/201226163Phone: 3. 윈도우 폰을 위한 Holiyday Calendar 앱 개발파일 다운로드1
1272정성태4/5/201227283오류 유형: 151. ASP.NET - EcbGetUnicodeServerVariables 코드에서 System.AccessViolationException 예외 발생
1271정성태4/3/201229785Math: 6. 동전을 여러 더미로 나누는 경우의 수 세기 [1]
1270정성태3/29/201224282오류 유형: 150. Visual Studio 2010 원격 디버깅 오류 - Kerberos authentication failed
1269정성태3/27/201238244오류 유형: 149. ODP.NET 오류 - The provider is not compatible with the version of Oracle client
1268정성태3/27/201234512오류 유형: 148. WCF svc 호출 시 HTTP Error 404.17 - Not Found [1]
1267정성태3/16/201232679.NET Framework: 314. C++의 inline asm 사용을 .NET으로 포팅하는 방법 [1]파일 다운로드1
1266정성태3/14/201235789개발 환경 구성: 149. RAID 1 구성 시 하드 디스크 장애 발생 해결에 대한 경험담
1265정성태3/13/201226027VC++: 61. 아이태니엄(IA64: Itanium) 에서 겪은 C++ 포인터 연산 문제 [2]
1264정성태3/10/201245600.NET Framework: 313. WELL512 난수 발생 알고리즘 - C# [5]파일 다운로드1
1263정성태3/9/201224244개발 환경 구성: 148. tinyget 사용법
1262정성태3/8/201245105개발 환경 구성: 147. .keystore 파일에 저장된 개인키 추출 방법과 인증기관으로부터 온 공개키를 합친 pfx 파일 만드는 방법 [1]
1261정성태3/7/201225686Phone: 2. 개발자용 윈도우 폰 7 기기 등록하는 방법
1260정성태3/6/201225778Phone: 1. 윈도폰 7 개발자 (회사) 등록하는 방법 [3]
... 151  [152]  153  154  155  156  157  158  159  160  161  162  163  164  165  ...