In this recipe, we are going to discuss how to start a PostgreSQL cluster. After using initdb to initialize a data directory, you will see a message that provides a command we can use to start using PostgreSQL; that is, pg_ctl. pg_ctl is a utility used to manage the start, stop, and promotion/failover of PostgreSQL. In this recipe, we will learn how a PostgreSQL cluster can be started using pg_ctl.
Getting ready
To use pg_ctl to start PostgreSQL, we must have an already existing or a newly initialized data directory. Please take a look at the previous recipe to see the steps involved in initialization.
If there is an already existing PostgreSQL cluster running on port 5432 (default), we must set the port to a different value in postgresql.conf or the postgresql.auto.conf file corresponding to the new data directory.
Make sure to set the PATH variable to the following (can be added to .bash_profile) so that you can use the pg_ctl utility without...