본문 바로가기
데이터베이스/MongoDB

MongoDB에 Replication을 설정해보자.

by leedonggeun 2022. 11. 28.

1. Replication 설정

[root@mongodb-01 ~]# mongosh --eval "printjson(rs.initiate())"

Current Mongosh Log ID: 638448e842b9e0f3852f4230
Connecting to:          mongodb://127.0.0.1:{port}/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.6.0
Using MongoDB:          6.0.3
Using Mongosh:          1.6.0

For mongosh info see: https://docs.mongodb.com/mongodb-shell/

------
   The server generated these startup warnings when booting
   2022-11-28T14:32:57.084+09:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
   2022-11-28T14:32:58.228+09:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
   2022-11-28T14:32:58.228+09:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never'
   2022-11-28T14:32:58.228+09:00: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. We suggest setting it to 'never'
   2022-11-28T14:32:58.228+09:00: vm.max_map_count is too low
------

------
   Enable MongoDB's free cloud-based monitoring service, which will then receive and display
   metrics about your deployment (disk utilization, CPU, operation statistics, etc).
   
   The monitoring data will be available on a MongoDB website with a unique URL accessible to you
   and anyone you share the URL with. MongoDB may use this information to make product
   improvements and to suggest MongoDB products and deployment options to you.
   
   To enable free monitoring, run the following command: db.enableFreeMonitoring()
   To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
------

{
  info2: 'no configuration specified. Using a default configuration for the set',
  me: '127.0.0.1:27017',
  ok: 1
}

아직은 레플리케이션을 사용하지 않기 때문에 1개의 서버만 설정되어있습니다.

2. Replication 확인

mongosh 명령어를 통해 mongoDB 접근 시 CLI에 Primary 노드임을 확인할 수 있습니다.

[root@mongodb-01 ~]# mongosh

Current Mongosh Log ID: 63844a4c79317a52c8fd71d2
Connecting to:          mongodb://127.0.0.1:{port}/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.6.0
Using MongoDB:          6.0.3
Using Mongosh:          1.6.0

For mongosh info see: https://docs.mongodb.com/mongodb-shell/

------
   The server generated these startup warnings when booting
   2022-11-28T14:32:57.084+09:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
   2022-11-28T14:32:58.228+09:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
   2022-11-28T14:32:58.228+09:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never'
   2022-11-28T14:32:58.228+09:00: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. We suggest setting it to 'never'
   2022-11-28T14:32:58.228+09:00: vm.max_map_count is too low
------

------
   Enable MongoDB's free cloud-based monitoring service, which will then receive and display
   metrics about your deployment (disk utilization, CPU, operation statistics, etc).
   
   The monitoring data will be available on a MongoDB website with a unique URL accessible to you
   and anyone you share the URL with. MongoDB may use this information to make product
   improvements and to suggest MongoDB products and deployment options to you.
   
   To enable free monitoring, run the following command: db.enableFreeMonitoring()
   To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
------

rs01 [direct: primary] test>

 

'데이터베이스 > MongoDB' 카테고리의 다른 글

MongoDB를 설치해 보자  (0) 2022.11.28

댓글