diff options
-rw-r--r-- | src/mongo/db/SConscript | 5 | ||||
-rw-r--r-- | src/mongo/db/mongod_options.cpp | 374 | ||||
-rw-r--r-- | src/mongo/db/mongod_options.h | 5 | ||||
-rw-r--r-- | src/mongo/db/mongod_options_general.h | 64 | ||||
-rw-r--r-- | src/mongo/db/mongod_options_general.idl | 103 | ||||
-rw-r--r-- | src/mongo/db/mongod_options_legacy.idl | 72 | ||||
-rw-r--r-- | src/mongo/db/mongod_options_replication.h | 47 | ||||
-rw-r--r-- | src/mongo/db/mongod_options_replication.idl | 84 | ||||
-rw-r--r-- | src/mongo/db/mongod_options_sharding.h | 51 | ||||
-rw-r--r-- | src/mongo/db/mongod_options_sharding.idl | 86 | ||||
-rw-r--r-- | src/mongo/db/mongod_options_storage.idl | 95 | ||||
-rw-r--r-- | src/mongo/db/storage/storage_options.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/storage/storage_options.h | 2 |
13 files changed, 635 insertions, 354 deletions
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript index 628a13edd48..5764d4f13bb 100644 --- a/src/mongo/db/SConscript +++ b/src/mongo/db/SConscript @@ -510,6 +510,11 @@ env.Library( target="mongod_options", source=[ "mongod_options.cpp", + env.Idlc('mongod_options_general.idl')[0], + env.Idlc('mongod_options_legacy.idl')[0], + env.Idlc('mongod_options_replication.idl')[0], + env.Idlc('mongod_options_sharding.idl')[0], + env.Idlc('mongod_options_storage.idl')[0], ], LIBDEPS=[ 'repl/repl_settings', diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp index fb51b8af4a8..8a174df4c9b 100644 --- a/src/mongo/db/mongod_options.cpp +++ b/src/mongo/db/mongod_options.cpp @@ -41,6 +41,11 @@ #include "mongo/bson/util/builder.h" #include "mongo/config.h" #include "mongo/db/global_settings.h" +#include "mongo/db/mongod_options_general_gen.h" +#include "mongo/db/mongod_options_legacy_gen.h" +#include "mongo/db/mongod_options_replication_gen.h" +#include "mongo/db/mongod_options_sharding_gen.h" +#include "mongo/db/mongod_options_storage_gen.h" #include "mongo/db/repl/repl_settings.h" #include "mongo/db/server_options.h" #include "mongo/db/server_options_base.h" @@ -56,331 +61,32 @@ namespace mongo { using std::endl; -Status addMongodOptions(moe::OptionSection* options) { - Status ret = addGeneralServerOptions(options); - if (!ret.isOK()) { - return ret; - } - - moe::OptionSection general_options("General options"); - moe::OptionSection rs_options("Replica set options"); - moe::OptionSection replication_options("Replication options"); - moe::OptionSection sharding_options("Sharding options"); - moe::OptionSection storage_options("Storage options"); - - // Authentication Options - - // Way to enable or disable auth on command line and in Legacy config file - general_options.addOptionChaining("auth", "auth", moe::Switch, "run with security") - .setSources(moe::SourceAllLegacy) - .incompatibleWith("noauth"); - - // IP Whitelisting Options - general_options - .addOptionChaining("security.clusterIpSourceWhitelist", - "clusterIpSourceWhitelist", - moe::StringVector, - "Network CIDR specification of permitted origin for `__system` access.") - .composing(); - - - // Way to enable or disable auth in JSON Config - general_options - .addOptionChaining( - "security.authorization", - "", - moe::String, - "How the database behaves with respect to authorization of clients. " - "Options are \"disabled\", which means that authorization checks are not " - "performed, and \"enabled\" which means that a client cannot perform actions it is " - "not authorized to do.") - .setSources(moe::SourceYAMLConfig) - .format("(:?disabled)|(:?enabled)", "(disabled/enabled)"); - - // setParameter parameters that we want as config file options - // TODO: Actually read these into our environment. Currently they have no effect - general_options.addOptionChaining("security.authSchemaVersion", "", moe::String, "TODO") - .setSources(moe::SourceYAMLConfig); - - general_options.addOptionChaining("security.enableLocalhostAuthBypass", "", moe::String, "TODO") - .setSources(moe::SourceYAMLConfig); - - // Diagnostic Options - - general_options.addOptionChaining("profile", "profile", moe::Int, "0=off 1=slow, 2=all") - .setSources(moe::SourceAllLegacy); - - general_options - .addOptionChaining("operationProfiling.mode", "", moe::String, "(off/slowOp/all)") - .setSources(moe::SourceYAMLConfig) - .format("(:?off)|(:?slowOp)|(:?all)", "(off/slowOp/all)"); - - general_options - .addOptionChaining( - "cpu", "cpu", moe::Switch, "periodically show cpu and iowait utilization") - .setSources(moe::SourceAllLegacy); - - general_options - .addOptionChaining( - "sysinfo", "sysinfo", moe::Switch, "print some diagnostic system information") - .setSources(moe::SourceAllLegacy); - - // Storage Options - - storage_options.addOptionChaining( - "storage.engine", - "storageEngine", - moe::String, - "what storage engine to use - defaults to wiredTiger if no data files present"); +std::string storageDBPathDescription() { + StringBuilder sb; + sb << "Directory for datafiles - defaults to " << storageGlobalParams.kDefaultDbPath; #ifdef _WIN32 boost::filesystem::path currentPath = boost::filesystem::current_path(); - std::string defaultPath = currentPath.root_name().string() + storageGlobalParams.kDefaultDbPath; - storage_options.addOptionChaining("storage.dbPath", - "dbpath", - moe::String, - std::string("directory for datafiles - defaults to ") + - storageGlobalParams.kDefaultDbPath + " which is " + - defaultPath + " based on the current working drive"); - -#else - storage_options.addOptionChaining("storage.dbPath", - "dbpath", - moe::String, - std::string("directory for datafiles - defaults to ") + - storageGlobalParams.kDefaultDbPath); - + sb << " which is " << currentPath.root_name().string() << storageGlobalParams.kDefaultDbPath + << " based on the current working drive"; #endif - storage_options.addOptionChaining("storage.directoryPerDB", - "directoryperdb", - moe::Switch, - "each database will be stored in a separate directory"); - - storage_options - .addOptionChaining("storage.queryableBackupMode", - "queryableBackupMode", - moe::Switch, - "enable read-only mode - if true the server will not accept writes.") - .setSources(moe::SourceAll) - .hidden(); - - storage_options - .addOptionChaining("storage.groupCollections", - "groupCollections", - moe::Switch, - "group collections - if true the storage engine may group " - "collections within a database into a shared record store.") - .hidden(); - - storage_options - .addOptionChaining("storage.syncPeriodSecs", - "syncdelay", - moe::Double, - "seconds between disk syncs (0=never, but not recommended)") - .setDefault(moe::Value(60.0)); - - // Upgrade and repair are disallowed in JSON configs since they trigger very heavyweight - // actions rather than specify configuration data - storage_options.addOptionChaining("upgrade", "upgrade", moe::Switch, "upgrade db if needed") - .setSources(moe::SourceAllLegacy); - - storage_options.addOptionChaining("repair", "repair", moe::Switch, "run repair on all dbs") - .setSources(moe::SourceAllLegacy); - - // Javascript Options - - general_options - .addOptionChaining("noscripting", "noscripting", moe::Switch, "disable scripting engine") - .setSources(moe::SourceAllLegacy); - - general_options - .addOptionChaining( - "security.javascriptEnabled", "", moe::Bool, "Enable javascript execution") - .setSources(moe::SourceYAMLConfig); - - // Query Options - - general_options - .addOptionChaining("notablescan", "notablescan", moe::Switch, "do not allow table scans") - .setSources(moe::SourceAllLegacy); - - // Journaling Options - - // Way to enable or disable journaling on command line and in Legacy config file - storage_options.addOptionChaining("journal", "journal", moe::Switch, "enable journaling") - .setSources(moe::SourceAllLegacy); - - storage_options - .addOptionChaining("nojournal", - "nojournal", - moe::Switch, - "disable journaling (journaling is on by default for 64 bit)") - .setSources(moe::SourceAllLegacy); - - storage_options.addOptionChaining("dur", "dur", moe::Switch, "enable journaling") - .hidden() - .setSources(moe::SourceAllLegacy); - - storage_options.addOptionChaining("nodur", "nodur", moe::Switch, "disable journaling") - .hidden() - .setSources(moe::SourceAllLegacy); - - // Way to enable or disable journaling in JSON Config - general_options.addOptionChaining("storage.journal.enabled", "", moe::Bool, "enable journaling") - .setSources(moe::SourceYAMLConfig); - -#if defined(__linux__) - general_options.addOptionChaining( - "shutdown", "shutdown", moe::Switch, "kill a running server (for init scripts)"); -#endif + return sb.str(); +} - // Replication Options - - replication_options.addOptionChaining( - "replication.oplogSizeMB", - "oplogSize", - moe::Int, - "size to use (in MB) for replication op log. default is 5% of disk space " - "(i.e. large is good)"); - - rs_options - .addOptionChaining("replication.replSet", - "replSet", - moe::String, - "arg is <setname>[/<optionalseedhostlist>]") - .setSources(moe::SourceAllLegacy); - - rs_options.addOptionChaining("replication.replSetName", "", moe::String, "arg is <setname>") - .setSources(moe::SourceYAMLConfig) - .format("[^/]+", "[replica set name with no \"/\"]"); - - // `enableMajorityReadConcern` is enabled by default starting in 3.6. - rs_options - .addOptionChaining("replication.enableMajorityReadConcern", - "enableMajorityReadConcern", - moe::Bool, - "enables majority readConcern") - .setDefault(moe::Value(true)) - .setImplicit(moe::Value(true)); - - replication_options.addOptionChaining( - "master", "master", moe::Switch, "Master/slave replication no longer supported"); - - replication_options.addOptionChaining( - "slave", "slave", moe::Switch, "Master/slave replication no longer supported"); - - // Sharding Options - - sharding_options - .addOptionChaining("configsvr", - "configsvr", - moe::Switch, - "declare this is a config db of a cluster; default port 27019; " - "default dir /data/configdb") - .setSources(moe::SourceAllLegacy) - .incompatibleWith("shardsvr") - .incompatibleWith("nojournal"); - - sharding_options - .addOptionChaining("shardsvr", - "shardsvr", - moe::Switch, - "declare this is a shard db of a cluster; default port 27018") - .setSources(moe::SourceAllLegacy) - .incompatibleWith("configsvr"); - - sharding_options - .addOptionChaining( - "sharding.clusterRole", - "", - moe::String, - "Choose what role this mongod has in a sharded cluster. Possible values are:\n" - " \"configsvr\": Start this node as a config server. Starts on port 27019 by " - "default." - " \"shardsvr\": Start this node as a shard server. Starts on port 27018 by " - "default.") - .setSources(moe::SourceYAMLConfig) - .format("(:?configsvr)|(:?shardsvr)", "(configsvr/shardsvr)"); - - sharding_options - .addOptionChaining( - "sharding._overrideShardIdentity", - "", - moe::String, - "overrides the shardIdentity document settings stored in the local storage with " - "a MongoDB Extended JSON document in string format") - .setSources(moe::SourceYAMLConfig) - .incompatibleWith("configsvr") - .requires("storage.queryableBackupMode"); - - sharding_options - .addOptionChaining("noMoveParanoia", - "noMoveParanoia", - moe::Switch, - "turn off paranoid saving of data for the moveChunk command; default") - .hidden() - .setSources(moe::SourceAllLegacy) - .incompatibleWith("moveParanoia"); - - sharding_options - .addOptionChaining("moveParanoia", - "moveParanoia", - moe::Switch, - "turn on paranoid saving of data during the moveChunk command " - "(used for internal system diagnostics)") - .hidden() - .setSources(moe::SourceAllLegacy) - .incompatibleWith("noMoveParanoia"); - - sharding_options - .addOptionChaining("sharding.archiveMovedChunks", - "", - moe::Bool, - "config file option to turn on paranoid saving of data during the " - "moveChunk command (used for internal system diagnostics)") - .hidden() - .setSources(moe::SourceYAMLConfig); - - - options->addSection(general_options).transitional_ignore(); - options->addSection(replication_options).transitional_ignore(); - options->addSection(rs_options).transitional_ignore(); - options->addSection(sharding_options).transitional_ignore(); - options->addSection(storage_options).transitional_ignore(); - - // The following are legacy options that are disallowed in the JSON config file - - // This is a deprecated option that we are supporting for backwards compatibility - // The first value for this option can be either 'dbpath' or 'run'. - // If it is 'dbpath', mongod prints the dbpath and exits. Any extra values are ignored. - // If it is 'run', mongod runs normally. Providing extra values is an error. - options->addOptionChaining("command", "command", moe::StringVector, "command") - .hidden() - .positional(1, 3) - .setSources(moe::SourceAllLegacy); - - options - ->addOptionChaining("cacheSize", "cacheSize", moe::Long, "cache size (in MB) for rec store") - .hidden() - .setSources(moe::SourceAllLegacy); - - // deprecated pairing command line options - options->addOptionChaining("pairwith", "pairwith", moe::Switch, "DEPRECATED") - .hidden() - .setSources(moe::SourceAllLegacy); - - options->addOptionChaining("arbiter", "arbiter", moe::Switch, "DEPRECATED") - .hidden() - .setSources(moe::SourceAllLegacy); - - options->addOptionChaining("opIdMem", "opIdMem", moe::Switch, "DEPRECATED") - .hidden() - .setSources(moe::SourceAllLegacy); +Status addMongodOptions(moe::OptionSection* options) try { + uassertStatusOK(addGeneralServerOptions(options)); + uassertStatusOK(addMongodGeneralOptions(options)); + uassertStatusOK(addMongodReplicationOptions(options)); + uassertStatusOK(addMongodShardingOptions(options)); + uassertStatusOK(addMongodStorageOptions(options)); + uassertStatusOK(addMongodLegacyOptions(options)); return Status::OK(); +} catch (const AssertionException& ex) { + return ex.toStatus(); } void printMongodHelp(const moe::OptionSection& options) { @@ -434,8 +140,7 @@ Status validateMongodOptions(const moe::Environment& params) { return ret; } - if ((params.count("nodur") || params.count("nojournal")) && - (params.count("dur") || params.count("journal"))) { + if (params.count("nojournal") && params.count("storage.journal.enabled")) { return Status(ErrorCodes::BadValue, "Can't specify both --journal and --nojournal options."); } @@ -484,19 +189,6 @@ Status canonicalizeMongodOptions(moe::Environment* params) { return ret; } - // "storage.journal.enabled" comes from the config file, so override it if any of "journal", - // "nojournal", "dur", and "nodur" are set, since those come from the command line. - if (params->count("journal")) { - Status ret = - params->set("storage.journal.enabled", moe::Value((*params)["journal"].as<bool>())); - if (!ret.isOK()) { - return ret; - } - ret = params->remove("journal"); - if (!ret.isOK()) { - return ret; - } - } if (params->count("nojournal")) { Status ret = params->set("storage.journal.enabled", moe::Value(!(*params)["nojournal"].as<bool>())); @@ -508,28 +200,6 @@ Status canonicalizeMongodOptions(moe::Environment* params) { return ret; } } - if (params->count("dur")) { - Status ret = - params->set("storage.journal.enabled", moe::Value((*params)["dur"].as<bool>())); - if (!ret.isOK()) { - return ret; - } - ret = params->remove("dur"); - if (!ret.isOK()) { - return ret; - } - } - if (params->count("nodur")) { - Status ret = - params->set("storage.journal.enabled", moe::Value(!(*params)["nodur"].as<bool>())); - if (!ret.isOK()) { - return ret; - } - ret = params->remove("nodur"); - if (!ret.isOK()) { - return ret; - } - } // "security.authorization" comes from the config file, so override it if "auth" is // set since those come from the command line. diff --git a/src/mongo/db/mongod_options.h b/src/mongo/db/mongod_options.h index 5bf467ce2d7..f1e56500a30 100644 --- a/src/mongo/db/mongod_options.h +++ b/src/mongo/db/mongod_options.h @@ -80,4 +80,9 @@ Status canonicalizeMongodOptions(moe::Environment* params); StatusWith<repl::ReplSettings> parseMongodReplicationOptions(const moe::Environment& params); Status storeMongodOptions(const moe::Environment& params); + +/** + * Help test user for storage.dbPath config option. + */ +std::string storageDBPathDescription(); } diff --git a/src/mongo/db/mongod_options_general.h b/src/mongo/db/mongod_options_general.h new file mode 100644 index 00000000000..2959904f5c8 --- /dev/null +++ b/src/mongo/db/mongod_options_general.h @@ -0,0 +1,64 @@ + +/** + * Copyright (C) 2019-present MongoDB, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * <http://www.mongodb.com/licensing/server-side-public-license>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the Server Side Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#pragma once + +#include <string> + +#include "mongo/base/status.h" + +namespace mongo { + +inline Status validateSecurityAuthorizationSetting(const std::string& value) { + constexpr auto kEnabled = "enabled"_sd; + constexpr auto kDisabled = "disabled"_sd; + + if (!kEnabled.equalCaseInsensitive(value) && !kDisabled.equalCaseInsensitive(value)) { + return {ErrorCodes::BadValue, + "security.authorization expects either 'enabled' or 'disabled'"}; + } + + return Status::OK(); +} + +inline Status validateOperationProfilingModeSetting(const std::string& value) { + constexpr auto kOff = "off"_sd; + constexpr auto kSlowOp = "slowOp"_sd; + constexpr auto kAll = "all"_sd; + + if (!kOff.equalCaseInsensitive(value) && !kSlowOp.equalCaseInsensitive(value) && + !kAll.equalCaseInsensitive(value)) { + return {ErrorCodes::BadValue, "operationProfiling.mode expects 'off', 'slowOp', or 'all'"}; + } + + return Status::OK(); +} + +} // namespace mongo diff --git a/src/mongo/db/mongod_options_general.idl b/src/mongo/db/mongod_options_general.idl new file mode 100644 index 00000000000..302c601f1c4 --- /dev/null +++ b/src/mongo/db/mongod_options_general.idl @@ -0,0 +1,103 @@ +# Copyright (C) 2019-present MongoDB, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the Server Side Public License, version 1, +# as published by MongoDB, Inc. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# Server Side Public License for more details. +# +# You should have received a copy of the Server Side Public License +# along with this program. If not, see +# <http://www.mongodb.com/licensing/server-side-public-license>. +# +# As a special exception, the copyright holders give permission to link the +# code of portions of this program with the OpenSSL library under certain +# conditions as described in each individual source file and distribute +# linked combinations including the program with the OpenSSL library. You +# must comply with the Server Side Public License in all respects for +# all of the code used other than as permitted herein. If you modify file(s) +# with this exception, you may extend this exception to your version of the +# file(s), but you are not obligated to do so. If you do not wish to do so, +# delete this exception statement from your version. If you delete this +# exception statement from all source files in the program, then also delete +# it in the license file. +# + +global: + cpp_namespace: "mongo" + cpp_includes: + - "mongo/db/mongod_options_general.h" + configs: + section: 'General options' + initializer: + register: addMongodGeneralOptions + +configs: + auth: + description: 'Run with security' + arg_vartype: Switch + source: [ cli, ini ] + conflicts: noauth + 'security.clusterIpSourceWhitelist': + description: 'Network CIDR specification of permitted origin for `__system` access' + short_name: clusterIpSourceWhitelist + arg_vartype: StringVector + source: [ cli, ini, yaml ] + duplicate_behavior: append + 'security.authorization': + description: >- + How the database behaves with respect to authorization of clients. + Options are "disabled", which means that authorization checks are not + performed, and "enabled" which means that a client cannot perform actions it is + not authorized to do. + arg_vartype: String + source: yaml + validator: + callback: validateSecurityAuthorizationSetting + 'security.authSchemaVersion': + description: 'TODO' + arg_vartype: String + source: yaml + 'security.enableLocalhostAuthBypass': + description: 'TODO' + arg_vartype: String + source: yaml + profile: + description: '0=off 1=slow, 2=all' + arg_vartype: Int + source: [ cli, ini ] + 'operationProfiling.mode': + description: '(off/slowOp/all)' + arg_vartype: String + source: yaml + validator: + callback: validateOperationProfilingModeSetting + cpu: + description: 'Periodically show cpu and iowait utilization' + arg_vartype: Switch + source: [ cli, ini ] + sysinfo: + description: 'Print some diagnostic system information' + arg_vartype: Switch + source: [ cli, ini ] + noscripting: + description: 'Disable scripting engine' + arg_vartype: Switch + source: [ cli, ini ] + 'security.javascriptEnabled': + description: 'Enable javascript execution' + arg_vartype: Bool + source: yaml + notablescan: + description: 'Do not allow table scans' + arg_vartype: Switch + source: [ cli, ini ] + shutdown: + description: 'Kill a running server (for init scripts)' + arg_vartype: Switch + source: [ cli, ini ] + condition: + preprocessor: 'defined(__linux__)' diff --git a/src/mongo/db/mongod_options_legacy.idl b/src/mongo/db/mongod_options_legacy.idl new file mode 100644 index 00000000000..02c7c02f1e9 --- /dev/null +++ b/src/mongo/db/mongod_options_legacy.idl @@ -0,0 +1,72 @@ +# Copyright (C) 2019-present MongoDB, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the Server Side Public License, version 1, +# as published by MongoDB, Inc. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# Server Side Public License for more details. +# +# You should have received a copy of the Server Side Public License +# along with this program. If not, see +# <http://www.mongodb.com/licensing/server-side-public-license>. +# +# As a special exception, the copyright holders give permission to link the +# code of portions of this program with the OpenSSL library under certain +# conditions as described in each individual source file and distribute +# linked combinations including the program with the OpenSSL library. You +# must comply with the Server Side Public License in all respects for +# all of the code used other than as permitted herein. If you modify file(s) +# with this exception, you may extend this exception to your version of the +# file(s), but you are not obligated to do so. If you do not wish to do so, +# delete this exception statement from your version. If you delete this +# exception statement from all source files in the program, then also delete +# it in the license file. +# + +global: + cpp_namespace: "mongo" + configs: + source: [ cli, ini ] + initializer: + register: addMongodLegacyOptions + +configs: + # + # The following are legacy options that are disallowed in the JSON config file + # + + # This is a deprecated option that we are supporting for backwards compatibility + # The first value for this option can be either 'dbpath' or 'run'. + # If it is 'dbpath', mongod prints the dbpath and exits. Any extra values are ignored. + # If it is 'run', mongod runs normally. Providing extra values is an error. + command: + description: Command + arg_vartype: StringVector + hidden: true + positional: 1-3 + cacheSize: + description: 'Cache size (in MB) for rec store' + arg_vartype: Long + hidden: true + + # + # The following are deprecated and unusable options. + # Specifying them will result in a startup error. + # + + pairwith: + description: DEPRECATED + arg_vartype: Switch + hidden: true + arbiter: + description: DEPRECATED + arg_vartype: Switch + hidden: true + opIdMem: + description: DEPRECATED + arg_vartype: Switch + hidden: true + diff --git a/src/mongo/db/mongod_options_replication.h b/src/mongo/db/mongod_options_replication.h new file mode 100644 index 00000000000..f39ab8d9fdc --- /dev/null +++ b/src/mongo/db/mongod_options_replication.h @@ -0,0 +1,47 @@ + +/** + * Copyright (C) 2019-present MongoDB, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * <http://www.mongodb.com/licensing/server-side-public-license>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the Server Side Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#pragma once + +#include <string> + +#include "mongo/base/status.h" + +namespace mongo { + +inline Status validateReplicaSetNameSetting(const std::string& value) { + if (value.find('/') != std::string::npos) { + return {ErrorCodes::BadValue, "replication.replSetName must not contain a '/' character"}; + } + + return Status::OK(); +} + +} // namespace mongo diff --git a/src/mongo/db/mongod_options_replication.idl b/src/mongo/db/mongod_options_replication.idl new file mode 100644 index 00000000000..bc0cdc562bb --- /dev/null +++ b/src/mongo/db/mongod_options_replication.idl @@ -0,0 +1,84 @@ +# Copyright (C) 2019-present MongoDB, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the Server Side Public License, version 1, +# as published by MongoDB, Inc. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# Server Side Public License for more details. +# +# You should have received a copy of the Server Side Public License +# along with this program. If not, see +# <http://www.mongodb.com/licensing/server-side-public-license>. +# +# As a special exception, the copyright holders give permission to link the +# code of portions of this program with the OpenSSL library under certain +# conditions as described in each individual source file and distribute +# linked combinations including the program with the OpenSSL library. You +# must comply with the Server Side Public License in all respects for +# all of the code used other than as permitted herein. If you modify file(s) +# with this exception, you may extend this exception to your version of the +# file(s), but you are not obligated to do so. If you do not wish to do so, +# delete this exception statement from your version. If you delete this +# exception statement from all source files in the program, then also delete +# it in the license file. +# + +global: + cpp_namespace: "mongo" + cpp_includes: + - "mongo/db/mongod_options_replication.h" + configs: + source: [ yaml, cli, ini ] + initializer: + register: addMongodReplicationOptions + +configs: + # + # Replication options + # + 'replication.oplogSizeMB': + section: 'Replication options' + description: 'Size to use (in MB) for replication op log. default is 5% of disk space (i.e. large is good)' + short_name: oplogSize + arg_vartype: Int + master: + section: 'Replication options' + description: 'Master/slave replication no longer supported' + arg_vartype: Switch + source: [ cli, ini ] + hidden: true + slave: + section: 'Replication options' + description: 'Master/slave replication no longer supported' + arg_vartype: Switch + source: [ cli, ini ] + hidden: true + + # + # Replica set options + # + + 'replication.replSet': + section: 'Replica set options' + description: 'arg is <setname>[/<optionalseedhostlist>]' + short_name: replSet + arg_vartype: String + source: [ cli, ini ] + 'replication.replSetName': + section: 'Replica set options' + description: 'arg is <setname>' + arg_vartype: String + source: yaml + validator: + callback: validateReplicaSetNameSetting + 'replication.enableMajorityReadConcern': + section: 'Replica set options' + description: 'Enables majority readConcern' + short_name: enableMajorityReadConcern + arg_vartype: Bool + default: true + implicit: true + diff --git a/src/mongo/db/mongod_options_sharding.h b/src/mongo/db/mongod_options_sharding.h new file mode 100644 index 00000000000..10d7183a629 --- /dev/null +++ b/src/mongo/db/mongod_options_sharding.h @@ -0,0 +1,51 @@ + +/** + * Copyright (C) 2019-present MongoDB, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * <http://www.mongodb.com/licensing/server-side-public-license>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the Server Side Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#pragma once + +#include <string> + +#include "mongo/base/status.h" + +namespace mongo { + +inline Status validateShardingClusterRoleSetting(const std::string& value) { + constexpr auto kConfigSvr = "configsvr"_sd; + constexpr auto kShardSvr = "shardsvr"_sd; + + if (!kConfigSvr.equalCaseInsensitive(value) && !kShardSvr.equalCaseInsensitive(value)) { + return {ErrorCodes::BadValue, + "sharding.clusterRole must be one of 'configsvr' or 'shardsvr'"}; + } + + return Status::OK(); +} + +} // namespace mongo diff --git a/src/mongo/db/mongod_options_sharding.idl b/src/mongo/db/mongod_options_sharding.idl new file mode 100644 index 00000000000..f8da615ed84 --- /dev/null +++ b/src/mongo/db/mongod_options_sharding.idl @@ -0,0 +1,86 @@ +# Copyright (C) 2019-present MongoDB, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the Server Side Public License, version 1, +# as published by MongoDB, Inc. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# Server Side Public License for more details. +# +# You should have received a copy of the Server Side Public License +# along with this program. If not, see +# <http://www.mongodb.com/licensing/server-side-public-license>. +# +# As a special exception, the copyright holders give permission to link the +# code of portions of this program with the OpenSSL library under certain +# conditions as described in each individual source file and distribute +# linked combinations including the program with the OpenSSL library. You +# must comply with the Server Side Public License in all respects for +# all of the code used other than as permitted herein. If you modify file(s) +# with this exception, you may extend this exception to your version of the +# file(s), but you are not obligated to do so. If you do not wish to do so, +# delete this exception statement from your version. If you delete this +# exception statement from all source files in the program, then also delete +# it in the license file. +# + +global: + cpp_namespace: "mongo" + cpp_includes: + - "mongo/db/mongod_options_sharding.h" + configs: + section: 'Sharding options' + initializer: + register: addMongodShardingOptions + +configs: + configsvr: + description: 'Declare this is a config db of a cluster; default port 27019; default dir /data/configdb' + arg_vartype: Switch + source: [ cli, ini ] + conflicts: [ shardsvr, nojournal ] + shardsvr: + description: 'Declare this is a shard db of a cluster; default port 27018' + arg_vartype: Switch + source: [ cli, ini ] + conflicts: configsvr + 'sharding.clusterRole': + description: >- + Choose what role this mongod has in a sharded cluster. Possible values are: + "configsvr": Start this node as a config server. Starts on port 27019 by default. + "shardsvr": Start this node as a shard server. Starts on port 27018 by default. + arg_vartype: String + source: yaml + validator: + callback: validateShardingClusterRoleSetting + 'sharding._overrideShardIdentity': + description: >- + Overrides the shardIdentity document settings stored in the local storage with + a MongoDB Extended JSON document in string format. + arg_vartype: String + source: yaml + conflicts: configsvr + requires: 'storage.queryableBackupMode' + noMoveParanoia: + description: 'Turn off paranoid saving of data for the moveChunk command; default' + arg_vartype: Switch + source: [ cli, ini ] + conflicts: moveParanoia + hidden: true + moveParanoia: + description: >- + Turn on paranoid saving of data during the moveChunk command + (used for internal system diagnostics) + arg_vartype: Switch + source: [ cli, ini ] + conflicts: noMoveParanoia + hidden: true + 'sharding.archiveMovedChunks': + description: >- + Config file option to turn on paranoid saving of data during the + moveChunk command (used for internal system diagnostics) + arg_vartype: Bool + source: yaml + hidden: true diff --git a/src/mongo/db/mongod_options_storage.idl b/src/mongo/db/mongod_options_storage.idl new file mode 100644 index 00000000000..222eb750516 --- /dev/null +++ b/src/mongo/db/mongod_options_storage.idl @@ -0,0 +1,95 @@ +# Copyright (C) 2019-present MongoDB, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the Server Side Public License, version 1, +# as published by MongoDB, Inc. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# Server Side Public License for more details. +# +# You should have received a copy of the Server Side Public License +# along with this program. If not, see +# <http://www.mongodb.com/licensing/server-side-public-license>. +# +# As a special exception, the copyright holders give permission to link the +# code of portions of this program with the OpenSSL library under certain +# conditions as described in each individual source file and distribute +# linked combinations including the program with the OpenSSL library. You +# must comply with the Server Side Public License in all respects for +# all of the code used other than as permitted herein. If you modify file(s) +# with this exception, you may extend this exception to your version of the +# file(s), but you are not obligated to do so. If you do not wish to do so, +# delete this exception statement from your version. If you delete this +# exception statement from all source files in the program, then also delete +# it in the license file. +# + +global: + cpp_namespace: "mongo" + cpp_includes: + - "mongo/db/mongod_options.h" + - "mongo/db/storage/storage_options.h" + configs: + section: 'Storage options' + source: [ yaml, cli, ini ] + initializer: + register: addMongodStorageOptions + +configs: + 'storage.engine': + description: 'What storage engine to use - defaults to wiredTiger if no data files present' + short_name: storageEngine + arg_vartype: String + + 'storage.dbPath': + description: + expr: 'storageDBPathDescription()' + is_constexpr: false + short_name: dbpath + arg_vartype: String + + 'storage.directoryPerDB': + description: 'Each database will be stored in a separate directory' + short_name: directoryperdb + arg_vartype: Switch + 'storage.queryableBackupMode': + description: 'Enable read-only mode - if true the server will not accept writes' + short_name: queryableBackupMode + arg_vartype: Switch + hidden: true + 'storage.groupCollections': + description: >- + Group collections - if true the storage engine may group + collections within a database into a shared record store + short_name: groupCollections + arg_vartype: Switch + hidden: true + 'storage.syncPeriodSecs': + description: 'Seconds between disk syncs (0=never, but not recommended)' + short_name: syncdelay + arg_vartype: Double + default: 60.0 + validator: + gte: 0.0 + lte: { expr: 'StorageGlobalParams::kMaxSyncdelaySecs' } + upgrade: + description: 'Upgrade db if needed' + arg_vartype: Switch + source: [ cli, ini ] + repair: + description: 'Run repair on all dbs' + arg_vartype: Switch + source: [ cli, ini ] + 'storage.journal.enabled': + description: 'Enable journaling' + short_name: journal + deprecated_short_name: dur + arg_vartype: Switch + nojournal: + description: 'Disable journaling (journaling is on by default for 64 bit)' + deprecated_short_name: nodur + arg_vartype: Switch + source: [ cli, ini ] + diff --git a/src/mongo/db/storage/storage_options.cpp b/src/mongo/db/storage/storage_options.cpp index e46a1096dc3..c91f12eee02 100644 --- a/src/mongo/db/storage/storage_options.cpp +++ b/src/mongo/db/storage/storage_options.cpp @@ -72,7 +72,6 @@ const char* StorageGlobalParams::kDefaultConfigDbPath = "/data/configdb"; #endif const int StorageGlobalParams::kMaxJournalCommitIntervalMs = 500; -const double StorageGlobalParams::kMaxSyncdelaySecs = 9.0 * 1000.0 * 1000.0; namespace { /** diff --git a/src/mongo/db/storage/storage_options.h b/src/mongo/db/storage/storage_options.h index 6b109e25904..cc77ecad564 100644 --- a/src/mongo/db/storage/storage_options.h +++ b/src/mongo/db/storage/storage_options.h @@ -95,7 +95,7 @@ struct StorageGlobalParams { // via an fsync operation. // Do not set this value on production systems. // In almost every situation, you should use the default setting. - static const double kMaxSyncdelaySecs; + static constexpr double kMaxSyncdelaySecs = 9.0 * 1000.0 * 1000.0; AtomicDouble syncdelay; // seconds between fsyncs // --queryableBackupMode |