postmaster Command in Linux



The postmaster in Linux is the PostgreSQL multiuser database server process responsible for managing client connections, requests, and database processes. It manages multiple database connections, starting a separate process for each one. It controls server communication and handles one database cluster at a time, requiring a specific data directory location to run.

Table of Contents

Here is a comprehensive guide to the options available with the postmaster command −

Note: In PostgreSQL 7.1, the postmaster was effectively merged with postgres. Since then, postgres has been the primary executable used to start the PostgreSQL server.

Syntax of postmaster Command

The syntax of the postmaster command in Linux is as follows −

postmaster [options]

The [options] field in the above command is used to specify the options to modify the command’s output. Commonly used options are mentioned in the next section.

postmaster Command Options

The options for the postmaster command are listed below −

Option Description
-A 0|1 Enables run-time assertion checks for debugging. Default is on if enabled during compilation. (Obsolete in postgres)
-B nbuffers Sets the number of shared buffers (default 64 buffers, each 8 kB).
-c name=value Sets a named run-time parameter. Multiple parameters can be set.
-d debug-level Sets the debug level (1 to 5). Higher values provide more output.
-D datadir Specifies the file system location of the data directory.
-F Disables fsync calls for performance but risks data corruption in case of a crash. (Obsolete in postgres)
--fsync=true Opposite of -F. Enables fsync for data integrity.
-h hostname Specifies the IP host name or address for client connections (default is all addresses).
-i Allows client connections via TCP/IP. Corresponds to setting tcpip_socket=true.
--tcpip-socket=false Opposite of -i. Disables TCP/IP connections. (Obsolete in postgres)
-k directory Specifies the directory for Unix-domain socket connections. Default is /tmp.
-l Enables secure SSL connections. Requires the -i option and SSL-enabled compilation.
-N max-connections Sets the maximum number of client connections. Default is 32.
-o extra-options Passes additional command-line options to all server processes.
-p port Specifies the TCP/IP port or Unix socket extension for connections (default 5432).
-S Starts the postmaster in silent mode (no logging). Not recommended for troubleshooting.
--silent-mode=false Opposite of -S. Enables logging output.
--name=value Sets a named run-time parameter. Shorter form of -c.
-n Prevents reinitialization of shared data structures for debugging purposes.
-s Stops all other server processes for manual core dumps without terminating them.

Examples postmaster Command in Linux

This section covers how to use the postmaster command in Linux with examples −

Starting the postmaster Server

To start the postmaster server in the background, use the following command −

nohup postmaster > logfile 2 > &1 < /dev/null &

To start with a specific port, use the command given below −

postmaster -p 1120

Checking Assertions on Run Time

To check assertions on run time, use -A option −

postmaster -A 1

The above command enables the run-time assertion checks for debugging.

Setting the Number of Shared Buffers

Use the -B option with the postmaster command to set the number of shared buffers. For example, the following command sets the number of shared buffers to 128, with each buffer being 8 kB −

postmaster -B 128

Setting the Run Time Parameters

To set the run-time parameters, use the -c option with the name of the parameter and its value −

postmaster -c max_connections=80

Similarly, to set multiple parameters, use the -c option in the following way −

postmaster -c shared_buffers=256MB -c work_mem=16MB

Setting the Data Directory

The data directory in PostgreSQL is a critical directory where the database stores all of its essential data files, configuration files, and logs. It contains the database cluster and is the primary location where PostgreSQL stores its data. To set the data directory, use the -D option −

postmaster -D /var/lib/postgresql/data

Disabling fsync Calls

To disable fsync calls to improve performance at the risk of data corruption in case of a system crash, use the -F option −

postmaster -F

Enabling TCP/IP Connections

To allow clients to connect via TCP/IP connections, use the -i option −

postmaster -i

Setting Client Connection Number

The default number of client connections is 32. To set the maximum number of client connections, use the -N option −

postmaster -N 100

Alternative to postmaster Command

In PostgreSQL, postmaster is the old name for the main PostgreSQL server process. However, the name postmaster has been replaced by postgres in more recent versions of PostgreSQL. The postgres command is not just an alternative but the current and only correct method for starting PostgreSQL in recent versions.

postmaster Command in Linux1

In modern versions of PostgreSQL, the server is started with the postgres command instead of postmaster. It behaves the same as the postmaster but uses a newer name.

To verify whether it is installed or not, check its version using the -V option:

postgres -V
postmaster Command in Linux2

To start the server, use the following command:

nohup postgres >logfile 2 > &1 < /dev/null &
postmaster Command in Linux3

To specify the data directory, use the following command:

postgres -D /var/lib/postgresql/data

Similarly, to specify the run-time parameters, use the -c option in the same way as it is used for postmaster:

postgres -c work_mem=1234

Note that the postgres command uses the same set of options as the postmaster.

Lastly, to display the usage help of the postgres command, use the –help option:

postgres --help

Conclusion

The postmaster in Linux is an essential process for managing PostgreSQL database connections and server processes. It controls various functions like client connections, database operations, and the data directory.

Although the postmaster command was once the primary way to interact with PostgreSQL servers, it has been replaced by the postgres command in newer versions of PostgreSQL. Despite the name change, the functionality remains the same, with postgres offering similar options for configuration and server management.

Advertisements