카이도스의 Tech Blog

Mongodb Replica set 설치 - 7.0 - Failover 테스트 본문

DB

Mongodb Replica set 설치 - 7.0 - Failover 테스트

카이도스 2024. 2. 4. 14:25
728x90
반응형

2024.02.04 - [DB] - Mongodb Replica set 설치 - 7.0

 

Mongodb Replica set 설치 - 7.0

Mongodb 설치 - 7.0 # 사전작업 ## 호스트네임 변경 sudo hostnamectl set-hostname dev-mongo sudo hostnamectl set-hostname dev-mongo2 sudo hostnamectl set-hostname dev-mongo3 ## 디스크 작업 sudo su - lsblk fdisk /dev/sdb mkfs.xfs /dev/sdb1 mk

djdakf1234.tistory.com

2024.02.04 - [DB] - Mongodb Replica set 설치 - 7.0 - 복제 확인 간단 테스트

 

Mongodb Replica set 설치 - 7.0 - 복제 확인 간단 테스트

2024.02.04 - [분류 전체보기] - Mongodb Replica set 설치 - 7.0 - 복제 확인 간단 테스트 복제 확인 간단 테스트 IP1 # 접속 mongosh -u admin -p admin # db 확인 repl0 [direct: primary] test> show dbs admin 172.00 KiB config 212.00 K

djdakf1234.tistory.com

Failover 테스트

# IP1 리부팅 후 확인
repl0 [direct: primary] test> show dbs
sudo reboot


# 확인 (IP1 → IP2 으로 primary 변경 확인)
> rs.status()
....
  members: [
    {
      _id: 0,
      name: 'IP1:27017',
      health: 1,
      state: 2,
      stateStr: 'SECONDARY',
      uptime: 68,
      optime: { ts: Timestamp({ t: 1697765292, i: 1 }), t: Long("2") },
      optimeDurable: { ts: Timestamp({ t: 1697765292, i: 1 }), t: Long("2") },
      optimeDate: ISODate("2023-10-20T01:28:12.000Z"),
      optimeDurableDate: ISODate("2023-10-20T01:28:12.000Z"),
      lastAppliedWallTime: ISODate("2023-10-20T01:28:12.791Z"),
      lastDurableWallTime: ISODate("2023-10-20T01:28:12.791Z"),
      lastHeartbeat: ISODate("2023-10-20T01:28:22.129Z"),
      lastHeartbeatRecv: ISODate("2023-10-20T01:28:21.409Z"),
      pingMs: Long("0"),
      lastHeartbeatMessage: '',
      syncSourceHost: 'IP3:27017',
      syncSourceId: 2,
      infoMessage: '',
      configVersion: 6,
      configTerm: 2
    },
    {
      _id: 1,
      name: 'IP2:27017',
      health: 1,
      state: 1,
      stateStr: 'PRIMARY',
      uptime: 55116,
      optime: { ts: Timestamp({ t: 1697765292, i: 1 }), t: Long("2") },
      optimeDate: ISODate("2023-10-20T01:28:12.000Z"),
      lastAppliedWallTime: ISODate("2023-10-20T01:28:12.791Z"),
      lastDurableWallTime: ISODate("2023-10-20T01:28:12.791Z"),
      syncSourceHost: '',
      syncSourceId: -1,
      infoMessage: '',
      electionTime: Timestamp({ t: 1697765192, i: 1 }),
      electionDate: ISODate("2023-10-20T01:26:32.000Z"),
      configVersion: 6,
      configTerm: 2,
      self: true,
      lastHeartbeatMessage: ''
    },
    {
      _id: 2,
      name: 'IP3:27017',
      health: 1,
      state: 2,
      stateStr: 'SECONDARY',
      uptime: 54878,
      optime: { ts: Timestamp({ t: 1697765292, i: 1 }), t: Long("2") },
      optimeDurable: { ts: Timestamp({ t: 1697765292, i: 1 }), t: Long("2") },
      optimeDate: ISODate("2023-10-20T01:28:12.000Z"),
      optimeDurableDate: ISODate("2023-10-20T01:28:12.000Z"),
      lastAppliedWallTime: ISODate("2023-10-20T01:28:12.791Z"),
      lastDurableWallTime: ISODate("2023-10-20T01:28:12.791Z"),
      lastHeartbeat: ISODate("2023-10-20T01:28:20.790Z"),
      lastHeartbeatRecv: ISODate("2023-10-20T01:28:21.293Z"),
      pingMs: Long("0"),
      lastHeartbeatMessage: '',
      syncSourceHost: 'IP2:27017',
      syncSourceId: 1,
      infoMessage: '',
      configVersion: 6,
      configTerm: 2
    }
  ],
....
728x90
반응형

'DB' 카테고리의 다른 글

Mongodb - bakcup(cron)/백업 스크립트  (2) 2024.02.04
Mongodump, restore  (0) 2024.02.04
Mongodb Replica set 설치 - 7.0 - 복제 확인 간단 테스트  (0) 2024.02.04
Mongodb Replica set 설치 - 7.0  (0) 2024.02.04
Mongodb 설치 - 6.0  (0) 2024.02.04
Comments