2.8. Clone the standby server

Create a ltcluster.conf file on the standby server. It must contain at least the same parameters as the primary's ltcluster.conf, but with the mandatory values node, node_name, conninfo (and possibly data_directory) adjusted accordingly, e.g.:

    node_id=2
    node_name='node2'
    conninfo='host=node2 user=ltcluster dbname=ltcluster connect_timeout=2'
    data_directory='/var/lib/lightdb/data'

Use the --dry-run option to check the standby can be cloned:

    $ ltcluster -h node1 -U ltcluster -d ltcluster -f /etc/ltcluster.conf standby clone --dry-run
    NOTICE: using provided configuration file "/etc/ltcluster.conf"
    NOTICE: destination directory "/var/lib/lightdb/data" provided
    INFO: connecting to source node
    NOTICE: checking for available walsenders on source node (2 required)
    INFO: sufficient walsenders available on source node (2 required)
    NOTICE: standby will attach to upstream node 1
    HINT: consider using the -c/--fast-checkpoint option
    INFO: all prerequisites for "standby clone" are met

If no problems are reported, the standby can then be cloned with:

    $ ltcluster -h node1 -U ltcluster -d ltcluster -f /etc/ltcluster.conf standby clone

    NOTICE: using configuration file "/etc/ltcluster.conf"
    NOTICE: destination directory "/var/lib/lightdb/data" provided
    INFO: connecting to source node
    NOTICE: checking for available walsenders on source node (2 required)
    INFO: sufficient walsenders available on source node (2 required)
    INFO: creating directory "/var/lib/lightdb/data"...
    NOTICE: starting backup (using lt_basebackup)...
    HINT: this may take some time; consider using the -c/--fast-checkpoint option
    INFO: executing:
      lt_basebackup -l "ltcluster base backup" -D /var/lib/lightdb/data -h node1 -U ltcluster -X stream
    NOTICE: standby clone (using lt_basebackup) complete
    NOTICE: you can now start your LightDB server
    HINT: for example: lt_ctl -D /var/lib/lightdb/data start
  

This has cloned the LightDB data directory files from the primary node1 using LightDB's lt_basebackup utility. A recovery.conf file containing the correct parameters to start streaming from this primary server will be created automatically.

Note

By default, any configuration files in the primary's data directory will be copied to the standby. Typically these will be lightdb.conf, lightdb.auto.conf, lt_hba.conf and lt_ident.conf. These may require modification before the standby is started.

Make any adjustments to the standby's LightDB configuration files now, then start the server.

For more details on ltcluster standby clone, see the command reference. A more detailed overview of cloning options is available in the administration manual.