mongod と mongos は、--outputConfig コマンドライン オプションを受け入れて、mongod または mongosインスタンスで使用される構成を出力します。
このオプションを使用して、コマンドライン オプションを YAML 構成に変換できます。
例
コマンドラインmongod オプションを YAML に変換する
コマンドライン オプションを使用する次のmongod呼び出しについて考えてみましょう。
mongod --shardsvr --replSet myShard --dbpath /var/lib/mongodb --bind_ip localhost,My-Example-Hostname --fork --logpath /var/log/mongodb/mongod.log --clusterAuthMode x509 --tlsMode requireTLS --tlsCAFile /path/to/my/CA/file --tlsCertificateKeyFile /path/to/my/certificate/file --tlsClusterFile /path/to/my/cluster/membership/file対応する YAML ファイルを生成するには、 --outputConfigコマンドライン オプションを含めます。
mongod --shardsvr --replSet myShard --dbpath /var/lib/mongodb --bind_ip localhost,My-Example-Hostname --fork --logpath /var/log/mongodb/mongod.log --clusterAuthMode x509 --tlsMode requireTLS --tlsCAFile /path/to/my/CA/file --tlsCertificateKeyFile /path/to/my/certificate/file --tlsClusterFile /path/to/my/cluster/membership/file --outputConfigmongodは次の YAML をstdoutに出力して終了します。
net: bindIp: localhost,My-Example-Hostname tls: CAFile: /path/to/my/CA/file certificateKeyFile: /path/to/my/certificate/file clusterFile: /path/to/my/cluster/membership/file mode: requireTLSoutputConfig: trueprocessManagement: fork: truereplication: replSet: myShardsecurity: clusterAuthMode: x509sharding: clusterRole: shardsvrstorage: dbPath: /var/lib/mongodbsystemLog: destination: file path: /var/log/mongodb/mongod.log構成ファイルを作成するには、生成されたコンテンツを ファイルにコピーし、YAML からoutputConfig設定を削除します。
コマンドラインmongos オプションを YAML に変換する
コマンドライン オプションを使用する次のmongos呼び出しについて考えてみましょう。
mongos --configdb myCSRS/cfg1.example.net:27019,cfg2.example.net:27019 --bind_ip localhost,My-Example-MONGOS-Hostname --fork --logpath /var/log/mongodb/mongos.log --clusterAuthMode x509 --tlsMode requireTLS --tlsCAFile /path/to/my/CA/file --tlsCertificateKeyFile /path/to/my/certificate/file --tlsClusterFile /path/to/my/cluster/membership/file--outputConfigこのオプションを指定して、 に対応する YAMLmongos を生成します。
mongos --configdb myCSRS/cfg1.example.net:27019,cfg2.example.net:27019 --bind_ip localhost,My-Example-MONGOS-Hostname --fork --logpath /var/log/mongodb/mongos.log --clusterAuthMode x509 --tlsMode requireTLS --tlsCAFile /path/to/my/CA/file --tlsCertificateKeyFile /path/to/my/certificate/file --tlsClusterFile /path/to/my/cluster/membership/file --outputConfigmongosは次の YAML をstdoutに出力して終了します。
net: bindIp: localhost,My-Example-MONGOS-Hostname tls: CAFile: /path/to/my/CA/file certificateKeyFile: /path/to/my/certificate/file clusterFile: /path/to/my/cluster/membership/file mode: requireTLSoutputConfig: trueprocessManagement: fork: truesecurity: clusterAuthMode: x509sharding: configDB: myCSRS/cfg1.example.net:27019,cfg2.example.net:27019systemLog: destination: file path: /var/log/mongodb/mongos.log構成ファイルを作成するには、生成されたコンテンツを ファイルにコピーし、YAML からoutputConfig設定を削除します。