Managing an Advanced Server Installation v10

Unless otherwise noted, the commands and paths noted in the following section assume that you have performed an installation using the native packages.

Starting and Stopping Advanced Server and Supporting Components

A service is a program that runs in the background and requires no user interaction (in fact, a service provides no user interface); a service can be configured to start at boot time, or manually on demand. Services are best controlled using the platform-specific operating system service control utility. Many of the Advanced Server supporting components are services.

The following table lists the names of the services that control Advanced Server and services that control Advanced Server supporting components:

Advanced Server Component NameLinux Service Name
Advanced Serveredb-as-10
Infinite Cacheedb-icache
pgAgentedb-pgagent-10
PgBounceredb-pgbouncer-1.7
pgPool-IIedb-pgpool-3.5
Slonyedb-slony-replication-10

Advanced Server's database server, and the services of Advanced Server's supporting components can be controlled at the command line or through operating system-specific graphical interfaces.

Controlling a Service on CentOS or RHEL 7.x

If your installation of Advanced Server resides on version 7.x of RHEL and CentOS, you must use the systemctl command to control the Advanced Server service and supporting components.

The systemctl command must be in your search path and must be invoked with superuser privileges. To use the command, open a command line, and enter:

systemctl <action> <service_name>

Where:

service_name specifies the name of the service.

action specifies the action taken by the service command. Specify:

  • start to start the service.
  • stop to stop the service.
  • restart to stop and then start the service.
  • status to discover the current status of the service.

Using pg_ctl to Control Advanced Server

You can use the pg_ctl utility to control an Advanced Server service from the command line on any platform. pg_ctl allows you to start, stop, or restart the Advanced Server database server, reload the configuration parameters, or display the status of a running server. To invoke the utility, assume the identity of the cluster owner, navigate into the home directory of Advanced Server, and issue the command:

./bin/pg_ctl -D <data_directory> <action>

data_directory is the location of the data controlled by the Advanced Server cluster.

action specifies the action taken by the pg_ctl utility. Specify:

  • start to start the service.
  • stop to stop the service.
  • restart to stop and then start the service.
  • reload sends the server a SIGHUP signal, reloading configuration parameters
  • status to discover the current status of the service.

For more information about using the pg_ctl utility, or the command line options available, see the official PostgreSQL Core Documentation available at:

https://www.postgresql.org/docs/10/static/app-pg-ctl.html

Choosing Between pg_ctl and the service Command

You can use the pg_ctl utility to manage the status of an Advanced Server cluster, but it is important to note that pg_ctl does not alert the operating system service controller to changes in the status of a server, so it is beneficial to use the service command whenever possible.

Note that when you invoke the installer with the --extract-only option, the installer does not create a service, it merely unpacks the server. If you have installed Advanced Server by invoking the installer with the --extract-only option, you must use the pg_ctl command to control the server.

Using the edbstart and edbstop Utilities

edbstart and edbstop functionality is supported only on Linux hosts that are running Advanced Server installations performed with the Interactive installer. RPM installations do not support edbstart and edbstop.

While the autostart scripts created during an Advanced Server installation control a single database cluster, the edbstart and edbstop utilities can control multiple database clusters on the same host, with a single configuration file.

The edbstart and edbstop utilities use a file named edbtab (described below) to determine which instances of Advanced Server should start when the operating system boots, and stop when the host is shut down.

Before using the edbstart or edbstop utilities, you should disable the Advanced Server autostart scripts. The commands that disable the scripts are platform specific;

  • On Fedora/Redhat:

    chkconfig --level 2345 edb-as-10 off
  • On Debian/Ubuntu:

    update-rc.d edb-as-10 disable

After stopping the Advanced Server service, use an editor to create a file named edbtab in the /etc directory; you can copy the sample file located in /opt/edb/as10/scripts/server/autostart.

Edit the edbtab file, specifying which Advanced Server clusters that the edbstart and edbstop programs will control, and indicating if the cluster should be automatically started and stopped.

Each edbtab file entry should take the form:

edb_home directory:edb_data_directory:N|Y

edb_home_directory

edb_home_directory specifies the home directory of the Advanced Server installation that the edbstart/edbstop utilities will control.

edb_data_directory

edb_data_directory specifies the data directory of the database cluster that the edbstart/edbstop utilities will control. edb_data_directory is the same as the value of $PGDATA for a specified cluster.

N|Y

Y specifies that edbstart and edbstop should control the service; N specifies that the user will control the service manually.

Include a separate entry in the edbtab file for each Advanced Server cluster that you wish to control with the edbstart and edbstop utilities.

After editing the edbtab file, copy the edb_autostart script to /etc/init.d. By default, the edb_autostart script is located in /opt/edb/as10/scripts/server/autostart.

Copy the edbstart and edbstop scripts to $EDBHOME. Make the scripts executable with the following command:

chmod +x edbstart
chmod +x edbstop
chmod +x edbstart edbstop /etc/init.d/edb_autostart

Enable the edb_autostart service with the commands:

chkconfig --level 2345 edb_autostart on
chkconfig --add edb_autostart

For the service to take effect, you must restart your system.

Manually Controlling the Server with edbstart and edbstop

You can use edbstart and edbstop at the command line to manually control all of the clusters specified in the edbtab file, or to control an individual cluster. Call edbstart without an argument to start all of the clusters listed within the edbtab file; invoke edbstop without an argument to stop all of the clusters listed in the edbtab file. You can control an individual cluster by specifying the cluster's data directory as an argument. The following command starts a cluster:

edbstart /opt/edb/as10/data

While the following command stops a cluster:

edbstop /opt/edb/as10/data

Configuring Component Services to AutoStart at System Reboot

After installing, configuring, and starting the services of Advanced Server supporting components on a Linux system, you must manually configure your system to autostart the service when your system reboots. To configure a service to autostart on a Linux system, open a command line, assume superuser privileges, and enter the following command.

On a Redhat-compatible Linux system, enter:

/sbin/chkconfig <service_name> on

On a Debian-compatible Linux system, use the command:

/usr/sbin/update-rc.d service_name enable

Where service_name specifies the name of the service.

Setting Advanced Server Environment Variables

The script sets the environment variables for your current shell session; when your shell session ends, the environment variables are destroyed. You may wish to invoke pgplus_env or pg_env from your system-wide shell startup script, so that environment variables are automatically defined for each shell session.

The pgplus_env script is created during the Advanced Server installation process and reflects the choices made during installation. To invoke the script, open a command line and enter:

source /opt/edb/as10/pgplus_env.sh

As the pgplus_env.sh script executes, it sets the following environment variables:

export PATH=/opt/edb/as10/bin:$PATH
export EDBHOME=/opt/edb/as10
export PGDATA=/opt/edb/as10/data
export PGDATABASE=edb
# export PGUSER=enterprisedb
export PGPORT=5444
export PGLOCALEDIR=/opt/edb/as10/share/locale

If you have used an installer created by EnterpriseDB to install PostgreSQL, the pg_env script performs the same function. To invoke the pg_env script, open a command line, and enter:

source /opt/PostgreSQL/10/pg_env.sh

As the pg_env.sh script executes, it sets the following environment variables:

PATH=/home/opt/PostgreSQL/10/bin:$PATH
PGDATA=/home/opt/PostgreSQL/10/data
PGDATABASE=postgres
PGUSER=postgres
PGPORT=5432
PGLOCALEDIR=/home/opt/PostgreSQL/10/share/locale
MANPATH=$MANPATH:/home/opt/PostgreSQL/10/share/man

Connecting to Advanced Server with psql

psql is a command line client application that allows you to execute SQL commands and view the results. To open the edb-psql client, the client must be in your search path. The executable resides in the bin directory, under your Advanced Server installation.

/opt/edb/as10/bin/psql

Use the following command and command options to start the psql client:

psql -d edb -U enterprisedb

Where:

-d specifies the database to which psql will connect.

-U specifies the identity of the database user that will be used for the session.

Note
  • To update configuration files in Linux, navigate through the EDB Postgres menu selection on the Applications menu to the Advanced Server 10 menu; use the Expert Configuration menu to select the configuration file that you would like to edit.
  • If you have performed an installation with the interactive installer, you can access the psql client through the Applications menu. Navigate through the EDB Postgres menu to the Advanced Server 10 menu; then, navigate through the Run SQL Command Line menu, selecting EDB-PSQL. When the Terminal window opens, provide connection information for your session.

For more information about using the command line client, see the PostgreSQL Core Documentation at:

https://www.postgresql.org/docs/10/static/app-psql.html

Connecting to Advanced Server with the pgAdmin 4 Client

pgAdmin 4 provides an interactive graphical interface that you can use to manage your database and database objects. Easy-to-use dialogs and online help simplify tasks such as object creation, role management, and granting or revoking privileges. The tabbed browser panel provides quick access to information about the object currently selected in the pgAdmin tree control.

To open pgAdmin, use the Applications menu to access the EDB Postgres menu; navigate through the Advanced Server 10 menu to select pgAdmin. The client opens in your default browser.

The pgAdmin 4 client Dashboard

Fig. 1: The pgAdmin 4 client Dashboard

To connect to the Advanced Server database server, expand the Servers node of the Browser tree control, and right click on the EDB Postgres Advanced Server node. When the context menu opens, select Connect Server. The Connect to Server dialog opens.

The Connect to Server dialog

Fig. 2: The Connect to Server dialog

Provide the password associated with the database superuser in the Password field, and click OK to connect.

Connecting to an Advanced Server database

Fig. 3: Connecting to an Advanced Server database

When the client connects, you can use the Browser tree control to retrieve information about existing database objects, or to create new objects. For more information about using the pgAdmin client, use the Help drop-down menu to access the online help files.