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包含--outputConfig命令行选项以生成相应的 YAML文件。
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命令行选项,以便为mongos实例生成相应的 YAML:
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设置。