Docs Menu
Docs Home
/
MongoDB マニュアル
/ / / /

自己管理型コマンドライン オプションを YAML に変換する

mongodmongosは、 --outputConfigコマンドライン オプションを受け入れて、 mongod / mongosインスタンスで使用される構成を出力します。

このオプションを使用して、コマンドライン オプションを 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 --outputConfig

mongodは次の 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: requireTLS
outputConfig: true
processManagement:
fork: true
replication:
replSet: myShard
security:
clusterAuthMode: x509
sharding:
clusterRole: shardsvr
storage:
dbPath: /var/lib/mongodb
systemLog:
destination: file
path: /var/log/mongodb/mongod.log

構成ファイルを作成するには、生成されたコンテンツを ファイルにコピーし、YAML からoutputConfig設定を削除します。

コマンドライン オプションを使用する次の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 --outputConfig

mongosは次の 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: requireTLS
outputConfig: true
processManagement:
fork: true
security:
clusterAuthMode: x509
sharding:
configDB: myCSRS/cfg1.example.net:27019,cfg2.example.net:27019
systemLog:
destination: file
path: /var/log/mongodb/mongos.log

構成ファイルを作成するには、生成されたコンテンツを ファイルにコピーし、YAML からoutputConfig設定を削除します。

戻る

外部ソースの値