4.1. Introduction To Configuring

4.1.1. Configuration files

By default, CouchDB reads configuration files from the following locations,in the following order:

  • etc/default.ini
  • etc/default.d/*.ini
  • etc/local.ini
  • etc/local.d/*.ini
    All paths are specified relative to the CouchDB installation directory:/opt/couchdb recommended on UNIX-like systems, C:\CouchDB recommendedon Windows systems, and a combination of two directories on macOS:Applications/Apache CouchDB.app/Contents/Resources/couchdbx-core/etc forthe default.ini and default.d directories, and/Users/youruser/Library/Application Support/CouchDB2/etc/couchdb forthe local.ini and local.d directories.

Settings in successive documents override the settings in earlier entries.For example, setting the httpd/bind_address parameter inlocal.ini would override any setting in default.ini.

Warning

The default.ini file may be overwritten during an upgrade orre-installation, so localised changes should be made to the local.inifile or files within the local.d directory.

The configuration file chain may be changed by setting the ERL_FLAGSenvironment variable:

  1. export ERL_FLAGS="-couch_ini /path/to/my/default.ini /path/to/my/local.ini"

or by placing the -couch_ini .. flag directly in the etc/vm.args file.Passing -couch_ini .. as a command-line argument when launching couchdbis the same as setting the ERL_FLAGS environment variable.

Warning

The environment variable/command-line flag overrides any -couch_inioption specified in the etc/vm.args file. And, BOTH of theseoptions completely override CouchDB from searching in the defaultlocations. Use these options only when necessary, and be sure to trackthe contents of etc/default.ini, which may change in future releases.

If there is a need to use different vm.args or sys.config files, forexample, in different locations to the ones provided by CouchDB, or you don’twant to edit the original files, the default locations may be changed bysetting the COUCHDB_ARGS_FILE or COUCHDB_SYSCONFIG_FILE environmentvariables:

  1. export COUCHDB_ARGS_FILE="/path/to/my/vm.args"
  2. export COUCHDB_SYSCONFIG_FILE="/path/to/my/sys.config"

4.1.2. Parameter names and values

All parameter names are case-sensitive. Every parameter takes a value of oneof five types: boolean, integer, string, tuple and proplist.Boolean values can be written as true or false.

Parameters with value type of tuple or proplist are following the Erlangrequirement for style and naming.

4.1.3. Setting parameters via the configuration file

The common way to set some parameters is to edit the local.ini file(location explained above).

For example:

  1. ; This is a comment
  2. [section]
  3. param = value ; inline comments are allowed

Each configuration file line may contains section definition, parameter_specification, empty (space and newline characters only) or _commented line.You can set up inline commentaries for sections or parameters.

The section defines group of parameters that are belongs to some specificCouchDB subsystem. For instance, httpd section holds not only HTTPserver parameters, but also others that directly interacts with it.

The parameter specification contains two parts divided by the equal sign(=): the parameter name on the left side and the parameter value on theright one. The leading and following whitespace for = is an optional toimprove configuration readability.

Note

In case when you’d like to remove some parameter from the default.ini_without modifying that file, you may override in _local.ini, but withoutany value:

  1. [compactions]
  2. _default =

This could be read as: “remove the _default parameter from thecompactions section if it was ever set before”.

The semicolon (;) signals the start of a comment. Everything after thischaracter is ignored by CouchDB.

After editing the configuration file, CouchDB should be restarted to applyany changes.

4.1.4. Setting parameters via the HTTP API

Alternatively, configuration parameters can be set via theHTTP API. This API allows changing CouchDB configurationon-the-fly without requiring a server restart:

  1. curl -X PUT http://localhost:5984/_node/<name@host>/_config/uuids/algorithm -d '"random"'

The old parameter’s value is returned in the response:

  1. "sequential"

You should be careful changing configuration via the HTTP API since it’spossible to make CouchDB unreachable, for example, by changing thehttpd/bind_address:

  1. curl -X PUT http://localhost:5984/_node/<name@host>/_config/httpd/bind_address -d '"10.10.0.128"'

If you make a typo or the specified IP address is not available from yournetwork, CouchDB will be unreachable. The only way to resolve this will beto remote into the server, correct the config file, and restart CouchDB. Toprotect yourself against such accidents you may set thehttpd/config_whitelist of permitted configuration parameters forupdates via the HTTP API. Once this option is set, further changes tonon-whitelisted parameters must take place via the configuration file, and inmost cases, will also require a server restart before taking effect.

4.1.5. Configuring the local node

While the HTTP API allows configuring all nodes in thecluster, as a convenience, you can use the literal string _local in placeof the node name, to interact with the local node’s configuration. Forexample:

  1. curl -X PUT http://localhost:5984/_node/_local/_config/uuids/algorithm -d '"random"'

原文: http://docs.couchdb.org/en/stable/config/intro.html