To properly manage the PostgreSQL database cluster the PostgreSQL Recovery Kit requires the postmaster process to be running with the port argument: “-p port”. The port is required to create a PostgreSQL resource hierarchy and for monitoring once the hierarchy is created. To view the current argument list for the postmaster process see the postmaster.opts file located in the data directory for PostgreSQL database cluster. The following is an example of the contents of this file:

C:/Program Files/PostgreSQL/9.6/bin/postgres.exe “-D” “E:\PGSQL1” “-p” “5432”

In this example the postmaster process is running with the port argument. If the postmaster process is not running with the port argument it will need to be added via one of the two methods listed below:

  • Adding the port argument to an existing Windows Service Instance
  • Adding the port argument to a non-Windows Service Instance

Adding the port argument to an existing Windows Service Instance

If the PostgreSQL database cluster to be protected by the PostgreSQL recovery kit is running via a Windows Service, such as the postgresql-x64-9.6 service created by the initial install of the PostgreSQL software v9.6, then the startup command line for the service will need to be modified. This can be done via the following steps:

  1. Stop the existing PostgreSQL database cluster instance. This can be done using several different methods:

    1. Use the Windows Service Interface (services.msc) and select to stop the service.

    2. Use the command line utility “sc”, e.g. sc stop service name.

    3. Use the command “net”, e.g net stop service_name.

  1. Modify the startup command line for the service. This can be done via the command line using the “sc” utility or by editing the startup command line in the registry. Note: The startup command line for the PostgreSQL service uses the pg_ctl.exe utility. To pass arguments to the postmaster process from the pg_ctl utility requires the use of the “-o” argument. The “-o” argument takes a quoted list of postmaster startup options such as the “-p port” as used in the modifications shown below.

    To edit the startup command line using the “sc” command line utility follow these steps. This example uses the postgresql-x64-9.6 service:

    1. Retrieve the binPath (startup command line) for the service, e.g “sc qc postgresql-x64-9.6” it will return something like the following (for this example only the output line with the startup command line is shown):

      BINARY_PATH_NAME : “C:\Program Files\PostgreSQL\9.6\bin\pg_ctl.exe” runservice -N “postgresql-x64-9.6” -D “E:\PGSQL1” –w

    2. Update the binPath. Note: There is a space after the “=” for the binPath argument and the value must be in double quotes therefore it requires escaping the imbedded double quotes.

      sc config postgresql-x64-9.6 binPath= “\“C:\Program Files\PostgreSQL\9.6\bin\pg_ctl.exe\” runservice -N \“postgresql-x64-9.6\” -D \“E:\PGSQL1\” –w –o \”-p 5432\” “

To edit the startup command line in registry requires the use of a registry edit tool such as regedit.

a. Using regedit find the service ImagePath registry value: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\postgresql-x86-9.6\ImagePath

b. Modify the ImagePath value by adding the port argument at the end of the existing command line: -o “-p 5432”

  1. Restart the existing PostgreSQL database cluster instance. This can be done using several different methods:

    1. Use the Windows Service Interface (services.msc) and select to start the service.

    2. Use the command line utility “sc”, e.g. sc start service_name.

    3. Use the command “net”, e.g net start service_name.

  1. Verify the postmaster process is running with port argument by checking the postmaster.opts file as described above.

Adding the port argument to a non- Windows Service Instance

If a Windows Service does not exist for the PostgreSQL database cluster then stopping and restarting the PostgreSQL database cluster via the PostgreSQL utility pg_ctl.exe will be required. This can be done via the following steps:

  1. Stop the PostgreSQL database cluster.

pg_ctl stop –D F:\PGSQL2

  1. Start the PostgreSQL database cluster.

pg_ctl start –D F:\PGSQL2 –w –o “-p 5433”

  1. Verify the postmaster process is running with port argument by checking the postmaster.opts file as described above.

フィードバック

お役に立ちましたか?

はい いいえ
お役に立ちましたか
理由をお聞かせください
フィードバックありがとうございました

このトピックへフィードバック

送信