## pg-setup

pg-setup — set up a new Postgres Pro Enterprise database cluster and manage the corresponding service

## Synopsis

`pg-setup` `initdb` [`initdb_options`]

`pg-setup` `find-free-port`

`pg-setup` `set-server-port `port``

`pg-setup` `service `service_option``

## Description

pg-setup is a shell script provided in the Postgres Pro Enterprise distribution to automate database cluster setup on Linux systems. This script is provided as part of the `postgrespro-ent-10-server` package. Once Postgres Pro Enterprise is installed, you can find pg-setup in the ``install-dir`/bin` directory, where `install-dir` is `/opt/pgpro/ent-10`.

pg-setup must be run as root, but performs database administration operations as user `postgres`. You can run this script with different options to:

- initialize the database cluster

- check for available ports and change the port used by Postgres Pro Enterprise server

- enable/disable automatic startup of Postgres Pro Enterprise service

- start, stop, or restart Postgres Pro Enterprise service

## Options

pg-setup accepts the following command-line arguments:

`initdb [`initdb_options`]`

  Initialize the database cluster on behalf of the `postgres` user.

  By default, the database cluster is initialized in the `/var/lib/pgpro/ent-10/data` directory, with checksums enabled, `auth-local` parameter set to `peer`, and `auth-host` parameter set to `md5`. Localization settings are inherited from the `LANG` environment variable for the current session. All the `LC_*` environment variables are ignored. Optionally, you can provide initdb options to customize the installation.

  ### Important

  With pg-setup, you cannot initialize the database cluster with checksums disabled or choose the data directory. If this is not what you expect, do not use pg-setup for cluster initialization and run initdb directly instead.

`find-free-port`

  Search for a free port on your system. This option is useful if you are going to install more than one server instance, or the default 5432 port is used by another program.

`set-server-port` `port`

  Specify the port number on which the server will listen for connections. Use this option to avoid conflicts if you are installing more than one server instance on the same system.

  Default: 5432

`service `service_option``

  Manage Postgres Pro Enterprise service using one of the following options:

  - `enable` — enable automatic service startup upon system restart.

  - `disable` — disable automatic service startup upon system restart.

  - `start` — start the service.

  - `stop` — stop the service.

  - `condrestart` — restart the service if it is running when pg-setup is invoked.

  - `status` — return the Postgres Pro Enterprise service status.

## Notes

If you are installing Postgres Pro Enterprise from the `postgrespro-ent-10` package, pg-setup is invoked automatically with the default settings. As a result, the database cluster is initialized and the default database is created in the `/var/lib/pgpro/ent-10/data` directory, Postgres Pro Enterprise service autostart is enabled, and the service is started.

If you are installing Postgres Pro Enterprise server directly from the `postgrespro-ent-10-server` package, you can run this script manually to initialize the database cluster or manage the Postgres Pro Enterprise service.

For details on binary installation specifics on Linux, see Section 17.1.