# mongod_config.conf - Configuration for Config Server Replica Set members
storage:
dbPath: /data/db
systemLog:
destination: file
path: /var/log/mongodb/mongod.log
logAppend: true
net:
port: 27017
bindIp: 0.0.0.0
tls:
mode: requireTLS
certificateKeyFile: /etc/ssl/mongodb/mongodb_sharded.pem
CAFile: /etc/ssl/mongodb/ca_sharded.pem
security:
authorization: enabled
clusterAuthMode: x509
replication:
replSetName: configRS
sharding:
clusterRole: configsvr
Config Server 설정(mongod_config.conf)과 매우 유사하지만, 샤드 서버의 역할에 맞게 replication.replSetName과 sharding.clusterRole 부분이 다릅니다.
# mongod_shard.conf - Configuration for Shard Server Replica Set members
storage:
dbPath: /data/db
systemLog:
destination: file
path: /var/log/mongodb/mongod.log
logAppend: true
net:
port: 27017
bindIp: 0.0.0.0
tls:
mode: requireTLS
certificateKeyFile: /etc/ssl/mongodb/mongodb_sharded.pem
CAFile: /etc/ssl/mongodb/ca_sharded.pem
security:
authorization: enabled
clusterAuthMode: x509
replication:
replSetName: shard1RS
sharding:
clusterRole: shardsvr
shard1-a:
image: mongo:latest
hostname: shard1-a
container_name: shard1-a
# ... 다른 설정들 ...
volumes:
- ./mongod_shard_no_clusterRole.conf:/etc/mongod.conf # 이 파일 사용
command: ["mongod", "--config", "/etc/mongod.conf", "--shardsvr"] # <<-- 여기에 `--shardsvr` 옵션이 명시적으로 들어갑니다.
# ... 나머지 설정들 ...
나머지 storage, systemLog, net, security, tls 설정은 Config Server와 동일하게 적용됩니다. 모든 샤드 클러스터 구성 요소가 동일한 TLS 인증서(mongodb_sharded.pem, ca_sharded.pem)와 보안 설정을 공유하도록 합니다.
mongod_shard.conf 파일 1개로 shard1-a, shard1-b, shard1-c 세 멤버 모두에게 동일하게 사용됩니다.
# mongos.conf - Configuration for Mongos Router
systemLog:
destination: file
path: /var/log/mongodb/mongos.log
logAppend: true
net:
port: 27017
bindIp: 0.0.0.0
tls:
mode: requireTLS
certificateKeyFile: /etc/ssl/mongodb/mongodb_sharded.pem
CAFile: /etc/ssl/mongodb/ca_sharded.pem
security:
clusterAuthMode: x509
sharding:
configDB: configRS/config1:27017,config2:27017,config3:27017
<ConfigServerReplSetName>/<ConfigHost1>:<ContainerInternalPort>,<ConfigHost2>:<ContainerInternalPort>,<ConfigHost3>:<ContainerInternalPort>mongos.conf 파일도 마찬가지로 1개로 mongos1과 mongos2 두 Mongos 라우터 컨테이너에 동일하게 사용될 것입니다.
주의) YAML 파일의 들여쓰기(Indentation) 오류 : YAML 파일은 들여쓰기에 매우 민감합니다. 한 칸이라도 들여쓰기가 잘못되면 파서가 옵션을 올바르게 인식하지 못할 수 있습니다.