# Heartbeat - Replica set내의 모든 노드들은 정해진 초마다 서로에게 Hearbeat를 보내서 상태를 확인
{
"member": [
{
"_id": 0,
"host": "localhost:5500",
"arbiterOnly": false,
"prioriy": 1
...
"votes": 1 # 투표권 0 or 1
}
# primary, secondary 서버에 port만 수정하여 동일하게 적용
... # Replca set 외 설정 생략
net:
port: 27017
bindIp: localhsot, {host name(domain or IP)}
security: # 커넥 실패 에러가 발생하는 경우에 설정 필요
authorization: "enabled"
clusterAuthMode: "keyFile"
keyFile: "{key file path}"
replication:
replSetName: "{name}"
mongod(mongo daemon) 실행
$sudo mongod --config /etc/mongod.conf --fork
or
systemctl start mongod
Primary node에서 mongo daemon 접속
mongo --port 27017 -u "admin" -p
Replica set 생성
rs.initiate( { _id: "rs0", members: [ {_id: 0, host: "primary:27017"}, {_id: 1, host: "secondary1:27018"}, {_id: 2, host: "secondary2:27019"} ] } )
Primary node에서 Replica set 생성 결과 확인
rs.status()