3.2. Configuration file

3.2.1. Configuration file format
3.2.2. Configuration file items
3.2.3. Configuration file location
3.2.4. Configuration file and LightDB major version upgrades

ltcluster and ltclusterd use a common configuration file, by default called ltcluster.conf (although any name can be used if explicitly specified). ltcluster.conf must contain a number of required parameters, including the database connection string for the local node and the location of its data directory; other values will be inferred from defaults if not explicitly supplied. See section required configuration file settings for more details.

3.2.1. Configuration file format

ltcluster.conf is a plain text file with one parameter/value combination per line.

Whitespace is insignificant (except within a quoted parameter value) and blank lines are ignored. Hash marks (#) designate the remainder of the line as a comment. Parameter values that are not simple identifiers or numbers should be single-quoted.

To embed a single quote in a parameter value, write either two quotes (preferred) or backslash-quote.

Example of a valid ltcluster.conf file:

# ltcluster.conf

node_id=1
node_name= node1
conninfo ='host=node1 dbname=ltcluster user=ltcluster connect_timeout=2'
data_directory = '/var/lib/pgsql/12/data'

Note

Beginning with ltcluster 5, configuration file parsing has been tightened up and now matches the way LightDB itself parses configuration files.

This means ltcluster.conf files used with earlier ltcluster versions may need slight modification before they can be used with ltcluster 5 and later.

The main change is that ltcluster requires most string values to be enclosed in single quotes. For example, this was previously valid:

conninfo=host=node1 user=ltcluster dbname=ltcluster connect_timeout=2

but must now be changed to:

conninfo='host=node1 user=ltcluster dbname=ltcluster connect_timeout=2'

3.2.1.1. Configuration file include directives

From ltcluster 5.2, the configuration file can contain the following include directives:

  • include: include the specified file, either as an absolute path or path relative to the current file
  • include_if_exists: include the specified file. The file is specified as an absolute path or path relative to the current file. However, if it does not exist, an error will not be raised.
  • include_dir: include files in the specified directory which have the .conf suffix. The directory is specified either as an absolute path or path relative to the current file

These behave in exactly the same way as the LightDB configuration file processing; see the LightDB documentation for additional details.

3.2.2. Configuration file items

The following sections document some sections of the configuration file:

For a full list of annotated configuration items, see the file ltcluster.conf.sample.

For ltclusterd-specific settings, see Chapter 11.

Note

The following parameters in the configuration file can be overridden with command line options:

  • -L/--log-level overrides log_level in ltcluster.conf
  • -b/--pg_bindir overrides pg_bindir in ltcluster.conf

3.2.3. Configuration file location

The configuration file will be searched for in the following locations:

  • a configuration file specified by the -f/--config-file command line option

  • a location specified by the package maintainer (if ltcluster as installed from a package and the package maintainer has specified the configuration file location)

  • ltcluster.conf in the local directory

  • /etc/ltcluster.conf

  • the directory reported by lt_config --sysconfdir

In examples provided in this documentation, it is assumed the configuration file is located at /etc/ltcluster.conf. If ltcluster is installed from a package, the configuration file will probably be located at another location specified by the packager.

Note that if a file is explicitly specified with -f/--config-file, an error will be raised if it is not found or not readable, and no attempt will be made to check default locations; this is to prevent ltcluster unexpectedly reading the wrong configuration file.

Note

If providing the configuration file location with -f/--config-file, avoid using a relative path, particularly when executing ltcluster primary register and ltcluster standby register, as ltcluster stores the configuration file location in the ltcluster metadata for use when ltcluster is executed remotely (e.g. during ltcluster standby switchover). ltcluster will attempt to convert the a relative path into an absolute one, but this may not be the same as the path you would explicitly provide (e.g. ./ltcluster.conf might be converted to /path/to/./ltcluster.conf, whereas you'd normally write /path/to/ltcluster.conf).

3.2.4. Configuration file and LightDB major version upgrades

When upgrading the LightDB cluster to a new major version, ltcluster.conf will probably needed to be updated.

Usually pg_bindir and data_directory will need to be modified, particularly if the default package locations are used, as these usually change.

It's also possible the location of ltcluster.conf itself will change (e.g. from /etc/ltcluster/11/ltcluster.conf to /etc/ltcluster/12/ltcluster.conf). This is stored as part of the ltcluster metadata and is used by ltcluster to execute ltcluster remotely (e.g. during a switchover operation).

If the content and/or location of ltcluster.conf has changed, the ltcluster metadata needs to be updated to reflect this. The ltcluster metadata can be updated on each node with: