Thread: Batch file to force Postgresql to start after a crash

Batch file to force Postgresql to start after a crash

From
"Richard Sydney-Smith"
Date:
I have placed the following in a batchfile to force the postgres service to
start in the instance where
postgresql was incorrectly shut down.

del "c:\program files\postgresql\data\postmaster.pid"
net start "PostgreSQL Server"

Just ugly to have to tell a user to "press this when it doesn't work".

I am using W2000 sp3.

Have also included my notes to install  PgSQL731wina1.exe at the bottom.

best regards

Richard

----------------------------------------------------------------------------
---------------

Setting up the Postgres Server ( version PgSQL731wina1.exe)
==============================================

Presently the only version for windows is an Alpha test copy.
While it operates well the installation is not yet point and click!

a) Log into your computer as "Administrator".
        #    Note : No other user account / name works properly.    #

b) Run the file PgSQL731wina1.exe
            Accept all default settings.
            Type in your "Administrator" password when requested.
                    - It is one of the last tasks so be patient.

c) The postgres server installs to :

             c:\Program Files\Postgresql

  Subdirectories include:

  /bin    - all programs
  /data  - root location for databases
             also contains the server configuration files
             which determine the resources available to the
             server

d) Use the windows notepad to edit /data/postgresql.conf to read:

    ....
        tcpip_socket = true
        port = 5432
        #
        # Shared Memory Size
        #
        shared_buffers = 5120                       # 2*max_connections, min
16, typically 8KB each
        max_fsm_relations = 300                   # min 10, fsm is free
space map, ~40 bytes
        max_fsm_pages = 5000                     # min 1000, fsm is free
space map, ~6 bytes
        max_locks_per_transaction = 64        # min 10
        wal_buffers = 100                              # min 4, typically
8KB each
        #
        # Non-shared Memory Sizes
        #
        sort_mem = 8192                     # min 64, size in KB
        vacuum_mem = 16384             # min 1024, size in KB
    ......

e) Goto your mycomputer icon and right click and then left click on
properties. Click on the tab "advanced" and then on the button
"Environmental Variables"

Add the following:

         PGDATA     c:\Program Files\Postgresql\data
         PGHOME     c:\Program Files\Postgresql
         PGHOST      localhost

f) To start the server make a short cut to /bin/pgsqlstart.bat

g) To stop the server /bin/pgsqlstop.bat

**** Make sure the server is properly shut down before halting your
computer.****

h) If the server is improperly stopped then there will be a file

            c:\Program Files\Postgresql\data\postmaster.pid

that needs to be deleted before a new instance of the server can start.

use the command :

            del c:\Program Files\Postgresql\data\postmaster.pid

or open your windows explorer and delete it that way.

Alternatively the commands can be placed in a batch file:

            del "c:\program files\postgresql\data\postmaster.pid"
            net start "PostgreSQL Server"