pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.(AWS에서는 SG로 보안처리 하고 있어서 편의상 모두 허용하기도 함)
#bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces. (주석으로 막으면 모든 IP에서 접속 가능. AWS에서는 SG로 보안처리 하고 있어서 편의상 모두 허용하기도 함)
#bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces. (주석으로 막으면 모든 IP에서 접속 가능. AWS에서는 SG로 보안처리 하고 있어서 편의상 모두 허용하기도 함)
replication:
replSetName: repl_set
#참고 : 몽고 replica 설정
primary가 될 서버에서 몽고 콘솔로 접속 : mongo
#Replica set 초기화
rs.initiate()
#Secondary 노드 추가
rs.add("secondary장비의 IP:27017")
#Arbiter 노드 추가
rs.add("arbiter장비IP:37017",arbiterOnly:true)
# 잘 저장되는지 테스트
use testdb
db.test_collection.insert({'msg':'test message'})
db.test_collection.find()
#Secondary에서는 아래 명령 실행 후 조회해 보면 됨
db.slaveOk(true)
#참고 - 1개 장비에 여러개의 몽고데몬을 실행시켜야할 경우
1개의 몽고DB를 설치하면 아래에 service 파일이 생성됨
/etc/systemd/system/multi-user.target.wants
해당 디렉토리의 mongod.service 심볼릭링크가 가리키는 파일(/usr/lib/systemd/system/mongod.service) 이 하나의 데몬 파일
/usr/lib/systemd/system/mongod.service 파일을 복사하여 한개 더 생성(ex. cp /usr/lib/systemd/system/mongod.service /usr/lib/systemd/system/mongod2.service)