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

Configuration File

MongoDB Instance를 실행하기 위해서 이에 맞는 적절한 Configuration File이 작성되어 있어야 한다. 본 절에서는 이와 관련된 내용을 다룬다.

아래의 내용은 각 replica 서버를 위한 configuration file의 내용이다. 각각의 primary, secondary-1, secondary-2에 따라서 내용이 달라야 하므로 file 아래 설명에 맞게 각각의 line을 수정하길 바란다.

/path/to/mongodb/replica-set/primary/mongod.conf
# Database 저장 파일의 path와 journaling 여부를 기
storage:
  dbPath: /path/to/mongodb/replica-set/primary/dbpath/
  journal:
    enabled: true

# Log file이 어디에 저장될지 및 이에 관련된 세팅
systemLog:
  destination: file
  logAppend: true
  path: /path/to/mongodb/replica-set/primary/mongo.log

# Network와 관련된 설정이다. ip binding을 어떻게 할 것인지, port number는 무엇인지 설정한다.
net:
  port: 30000
  bindIp: 127.0.0.1

# Replication과 관련된 세팅이다. replica set의 이름을 기입한다.
replication:
  replSetName: replica-set

각 Replication node마다 위와 같은 방식으로 세팅파일을 기록한 뒤 Mongo Instance를 실행하여야 한다. 위에서 언급한 바와 같이, 수정이 필요한 line은 3, 11, 15번째 줄로 각각 다음과 같이 세팅해주면 된다.

  • primary

    • dbpath: /path/to/mongodb/replica-set/primary/dbpath/

    • path: /path/to/mongodb/replica-set/primary/mongo.log

    • port: 30000

  • secondary-1

    • dbpath: /path/to/mongodb/replica-set/secondary-1/dbpath/

    • path: /path/to/mongodb/replica-set/secondary-1/mongo.log

    • port: 30001

  • secondary-2

    • dbpath: /path/to/mongodb/replica-set/secondary-2/dbpath/

    • path: /path/to/mongodb/replica-set/secondary-2/mongo.log

    • port: 30002

PreviousSetupNextRunning Servers

Last updated 5 years ago

Was this helpful?