Introduction to MongoDB
1.0 - draft
1.0 - draft
  • MongoDB
  • Getting Started
    • General
      • Database? Collection? Schema?
      • RDBMS? NoSQL?
      • Scale-Up ? Scale - out?
      • JavaScript Object Notation
    • MongoDB
      • 간략한 역사,
    • Manipulating Database
      • MongoShell
      • PyMongo
  • CRUD
    • General
      • Explain()
      • mongoimport
    • Create
      • Mongo Shell
      • PyMongo
      • Exercises
    • Read
      • Mongo Shell
      • PyMongo
      • Exercises
    • Update
      • Mongo Shell
      • PyMongo
      • Exercises
    • Delete
      • PyMongo
      • Exercises
    • Challenging Exercises
      • Exercise 1
  • Index with Geospatial & Text
    • Basic Index
      • Syntax
      • Exercises
    • Geospatial Index
      • Syntax
      • Exercises
    • Text Index
      • Syntax
      • Exercises
    • Challenge
  • Aggregate framework
    • Aggregate Framework
      • Basic
      • Exercises
  • Distributed
    • Replication
      • Setup
        • Configuration File
        • Running Servers
        • Initiation
        • Exercises
      • Concerns
        • Read Concern
        • Write Concern
        • Exercises
    • Sharding
      • Getting Started
      • Setup
  • MongoDB 4.0 Features
    • Multi-Document Transaction
      • Transaction?
      • Basic
      • Exercises
  • Administration
    • Untitled
Powered by GitBook
On this page

Was this helpful?

  1. Distributed
  2. Replication
  3. Setup

Initiation

MongoDB 인스턴스가 뜬 뒤 MongoShell 등을 통해 접속하여 initiate 해주어야 합니다.

mongod를 이용하여 instance를 시작해 준 뒤, 기존에 사용하던 방법과 유사하게 mongo shell에 접속하여 진행합니다.

기존에 mongo shell에 접속하는 방식과 같게, mongodb에 접속합니다. 다만, single machine에서 3대의 instance를 실행하였기 때문에, 그 중 하나의 node에 접속해 봅니다.

replication 의 경우 vote를 통해 어느 node가 primary가 될지 정하지만, 가장 처음에 initate할 때에는 대부분 본인이 처음 initiate 명령을 한 node가 primary로 동작하게 됩니다?

본 예제에서는 primary node로 사용할 30000 port를 가진 instance에 접속합니다. 아래와 같은 명령어를 통해 접속합니다.

$ mongo localhost:30000

Mongo shell에 접속한 뒤 아래와 같이 입력하여 replica set을 initiate 합니다.

> rs.initiate({
    "_id" : "replica-set",
    "members" :[
     { "_id" : 0, host : "127.0.0.1:30000"},
     { "_id" : 1, host : "127.0.0.1:30001"},
     { "_id" : 2, host : "127.0.0.1:30002"}
     ]})
> rs.status()
// TODO: a result of status() need to be documented.

아래에 pymongo를 통한 작업 또한 추가하면 좋을 것 같음.

PreviousRunning ServersNextExercises

Last updated 5 years ago

Was this helpful?