pg-setup
pg-setup — создать кластер баз данных Postgres Pro и управлять соответствующей службой
Синтаксис
pg-setup initdb [параметры_initdb]
pg-setup find-free-port
pg-setup set-server-port порт
pg-setup set параметр значение
pg-setup service параметр_service
pg-setup tune конфигурация
Описание
Программа pg-setup представляет собой скрипт оболочки, включённый в дистрибутив Postgres Pro и предназначенный для автоматизации установки кластера баз данных в системах Linux. Этот скрипт входит в состав пакета postgrespro-ent-11-server. После установки Postgres Pro вы можете найти pg-setup в каталоге , где каталог-инсталляции/binкаталог-инсталляции обозначает путь /opt/pgpro/ent-11.
Программу pg-setup нужно запускать от имени root, но она выполняет административные операции с базой данных под именем пользователя postgres. Запуская её с разными параметрами, вы можете:
инициализировать кластер баз данных
настроить кластер БД для определённого продукта Postgres Pro
проверить доступные порты и изменить порт, который будет использоваться сервером Postgres Pro
включить/отключить автоматический запуск службы Postgres Pro
запустить, остановить или перезапустить службу Postgres Pro
Параметры
pg-setup принимает следующие аргументы командной строки:
initdb [--tune=конфигурация] [параметры_initdb]Инициализировать кластер баз данных от имени пользователя
postgres.По умолчанию кластер баз данных инициализируется в каталоге
/var/lib/pgpro/ent-11/dataи настраивается для продукта Postgres Pro; в этом кластере будут включены контрольные суммы, параметрauth-localбудет иметь значениеpeer, аauth-host— значениеmd5. Параметры локализации наследуются из переменной окруженияLANG, определённой в текущем сеансе. Все переменные окруженияLC_*при этом игнорируются. Вы можете также передать параметры initdb для дополнительной настройки инсталляции.Если база данных по умолчанию создаётся с помощью pg-setup, путь к каталогу данных сохраняется в файле
/etc/default/postgrespro-enterprise-11, чтобы все последующие команды pg-setup, а также все команды, управляющие службой Postgres Pro, воздействовали именно на эту базу данных. Управлять несколькими базами данных с помощью pg-setup нельзя.Параметр
--tuneустанавливает заданную конфигурацию для кластера баз данных. Предопределены следующие значенияконфигурации(их доступность зависит от редакции Postgres Pro):1c,stdилиent. Значение1сдопускается для любого продукта. По умолчанию выбирается конфигурация, определяемая устанавливаемой редакцией Postgres Pro Enterprise. Если вы укажете какое-либо другое, не предопределённое, значение, кластер будет использовать стандартную конфигурацию.В случае, если в вашей системе будут работать несколько серверов БД и/или приложений, может потребоваться изменить настроенную конфигурацию, так как pg-setup выбирает параметры конфигурации в зависимости от характеристик оборудования, полагая, что система будет использоваться только одним сервером БД.
find-free-portНайти свободный порт в системе. Это может быть полезно, если вы планируете устанавливать несколько экземпляров серверов, либо стандартный порт 5432 уже используется другой программой.
set-server-portпортЗадать номер порта, на котором сервер будет принимать соединения. Воспользуйтесь этой командой, чтобы избежать конфликтов, если вы устанавливаете в одной системе более одного сервера.
По умолчанию: 5432
setимязначениеУстановить для заданного параметра конфигурации указанное
значениев файлеpostgresql.conf. Если этот параметр ранее был определён командойALTER SYSTEM, его предыдущее значение удаляется из файлаpostgresql.auto.conf.serviceпараметр_serviceУправление службой Postgres Pro с помощью следующих команд:
enable— включить автоматический запуск службы при перезагрузке системы.disable— отключить автоматический запуск службы при перезагрузке системы.start— запустить службу.stop— остановить службу.condrestart— перезапустить службу, если она работает в момент вызова pg-setup.status— возвращает статус службы Postgres Pro.
Замечания
Если вы устанавливаете Postgres Pro из пакета postgrespro-ent-11, pg-setup вызывается автоматически с параметрами по умолчанию. В результате создаётся кластер баз данных и база по умолчанию в каталоге /var/lib/pgpro/ent-11/data, настраивается автозапуск службы Postgres Pro и служба запускается.
Если вы устанавливаете сервер Postgres Pro непосредственно из пакета postgrespro-ent-11-server, вы можете запустить этот скрипт вручную для инициализации кластера баз данных или управления службой Postgres Pro.
Установка из двоичных пакетов в Linux подробно описана в Разделе 17.1.
pg-setup
pg-setup — set up a new Postgres Pro 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 set parameter value
pg-setup service service_option
pg-setup tune conf
Description
pg-setup is a shell script provided in the Postgres Pro distribution to automate database cluster setup on Linux systems. This script is provided as part of the postgrespro-ent-11-server package. Once Postgres Pro is installed, you can find pg-setup in the directory, where install-dir/bininstall-dir is /opt/pgpro/ent-11.
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
configure the database cluster for a specific Postgres Pro product
check for available ports and change the port used by Postgres Pro server
enable/disable automatic startup of Postgres Pro service
start, stop, or restart Postgres Pro service
Options
pg-setup accepts the following command-line arguments:
initdb [--tune=conf] [initdb_options]Initialize the database cluster on behalf of the
postgresuser.By default, the database cluster, configured for your Postgres Pro distribution, is initialized in the
/var/lib/pgpro/ent-11/datadirectory, with checksums enabled,auth-localparameter set topeer, andauth-hostparameter set tomd5. Localization settings are inherited from theLANGenvironment variable for the current session. All theLC_*environment variables are ignored. Optionally, you can provide initdb options to customize the installation.If the default database is created using pg-setup, the path to its data directory is stored in the
/etc/default/postgrespro-enterprise-11file, so all the subsequent pg-setup commands, as well as any commands that manage Postgres Pro service, affect this database only. You cannot manage several databases using pg-setup.The
--tuneoption sets the specified configuration for the database cluster. Predefined values ofconfdepend on the Postgres Pro edition and can be1c,stdorent. The value of1ccan be specified for any product. By default, the database cluster is configured for your Postgres Pro Enterprise edition. If you provide a value different from any predefined, the cluster will get non-customized configuration settings.For systems where more than one database server and/or application will run, you may need to adjust the configuration since pg-setup chooses the configuration settings depending on hardware characteristics, assuming that the system will use only one database server.
find-free-portSearch 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-portportSpecify 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
setnamevalueSet the specified configuration parameter to the provided
valuein thepostgresql.conffile. If this parameter has been already defined by theALTER SYSTEMcommand, its previous value is removed from thepostgresql.auto.conffile.serviceservice_optionManage Postgres Pro 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 service status.
Notes
If you are installing Postgres Pro from the postgrespro-ent-11 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-11/data directory, Postgres Pro service autostart is enabled, and the service is started.
If you are installing Postgres Pro server directly from the postgrespro-ent-11-server package, you can run this script manually to initialize the database cluster or manage the Postgres Pro service.
For details on binary installation specifics on Linux, see Section 17.1.