Tuesday, July 11, 2006

Postgresql Installation on Windows XP

March 18, 2004

Preliminary Work

Create a new Windows user account with password and ensure that it has administrative rights. This account will be the PostgreSQL Superuser account. Once the installation process terminated, this account can be deleted.

Log in under the new account.

Cygwin installation

For a first-time install, go to http://cygwin.com/ and click on the "Install or update now" icon.

Download and start the setup program.

The only choices you should have to make are:
that you want to install from the internet
where to install it on your machine (Root install Directory. e.g. C:\cygwin)
where to find the installation packages (Local Package Directory. e.g. C:\cygwin\install)
whether to use IE5, a direct connection, or a proxy to access the internet.
which download site you select

Please ensure that the following files(some of them not in the default list) are included in the download list:

PostgreSQL
cygwin
readline
libreadline
zlib
crypt
bzip2
cygrunsrv
cygutils
cygipc

Finally you can accept to create an icon on the desktop and to add an icon to the start menu.

Testing the Cygwin shell

Run the Cygwin bash shell and type the following commands:
cd /
Change to the root directory as defined during setup (C:\cygwin)

ls

Similar to the DOS 'DIR' command. Lists the content of the root directory. This root directory contents the following directories: bin, etc, home, lib, temp, tmp, usr, var..

Installing and starting CygIPC, the IPC-Manager

Using the windows file manager, copy cygipc-version.tar.bz2 from the local package directory (C:\cygwin\install/...\release\cygipc) into the root directory (C:\cygwin).

The ls command in the cygwin bash shell must confirm the presence of cygipc-version.tar.bz2

Unpack the archive by typing: bunzip2 -c /cygipc-version.tar.bz2 | tar xv

The directory /bin contains now the IPC-Manager ipc-daemon2.exe and a documentation has been installed into the directory /usr/share/doc/cygipc-version.

Test the IPC daemon by typing ipc-daemon2 & in the cygwin bash shell. The process number will be returned, eg. [1] 3480.

PostgreSQL initialisation

Do not forget to start the IPC-Manager before continuing!!

Type the following command in the cygwin bash shell: initdb -D /usr/share/postgresql/data -W

During the initialisation, you will be prompted for the superuser password. Enter the same password than for the windows account password.

The data directory will be created in /usr/share/postgresql/data.

Starting aund stopping the Database

Start the Database with: pg_ctl start -D /usr/share/postgresql/data -o "-i"
and stop it with: pg_ctl stop -D /usr/share/postgresql/data

Installing the IPC-Daemon as a Windows service

The IPC-daemon does not need to run during this step.

Run the Cygwin bash shell and type the following command:
cd /
ipc-daemon2 --install-as-service

After rebooting the system you can verify the presence of the new service called Cygwin IPC Daemon 2 (Control Panel -> Performance and Maintenance -> Administrative Tools -> Services)

Installing PostgreSQL as a Windows service

The IPC-Daemon must be started before continuing.

Run the Cygwin bash shell and type the following commands:
cd /
cygrunsrv --install postmaster --path /bin/postmaster --args "-D /usr/share/postgresql/data -i" --dep ipc-daemon2 --termsig INT --shutdown
Now the Database will be available at each Windows start.

After rebooting the system you can verify the presence of the new service called postmaster (Control Panel -> Performance and Maintenance -> Administrative Tools -> Services)

Post installation

Reboot your system, log in as user with administrative rights and delete the temporary account.

No comments: