openbsd-ports/databases/postgresql/files
espie 594099de65 Patches to fix dynamic libraries, especially on ppc which understands
only major/minor.

Add DYNLIBDIR where needed.

Some style issues.

From peter@, brad@ and peter_e@gmx.net
2001-04-23 21:58:44 +00:00
..
md5 Upgrade to postgresql 7.1. ok'd espie@ 2001-04-21 18:25:42 +00:00
README.OpenBSD Patches to fix dynamic libraries, especially on ppc which understands 2001-04-23 21:58:44 +00:00

Using PostgreSQL in an OpenBSD environment:
-------------------------------------------

If you are installing PostgreSQL for the first time, the following
steps are required:

1. Create the PostgreSQL user and group:

	# useradd -c "PostgreSQL Admin User" -g =uid -m -d /var/postgresql \
		-s /bin/sh postgresql

2. su to the postgresql account and initialize the database:

       # su - postgresql
       $ mkdir /var/postgresql/data
       $ initdb -D /var/postgresql/data

If you are upgrading PostgreSQL then you may have a `pgsql' user.
It is suggested that you follow the steps in

	!!PREFIX!!/share/doc/postgresql/INSTALL

for more information on how to upgrade your existing databases. See
also `Special notes for OpenBSD port' below. Replace references to
the `postgresql' user below with `pgsql' or whatever other user you
have selected to be the database administration account.

Auto Start and Stop
-------------------

If you wish to start PostgreSQL automatically during system startup,
add the following lines to /etc/rc.local:

if [ -x !!PREFIX!!/bin/pg_ctl ]; then
	su -l postgresql -c "!!PREFIX!!/bin/pg_ctl start \
		-D /var/postgresql/data -l /var/postgresql/logfile"
	echo -n ' postgresql'
fi

To automatically shutdown the database as part of the system shutdown, 
add the following lines to /etc/rc.shutdown:

if [ -f /var/postgresql/data/postmaster.pid ]; then
	su -l postgresql -c "!!PREFIX!!/bin/pg_ctl stop -m fast \
		-D /var/postgresql/data"
	rm -f /var/portgresql/data/postmaster.pid
fi

Network Connections and Tuning
------------------------------

To allow connections over TCP (and other options) edit the file:

	/var/postgresql/data/postgresql.conf

and also edit the pg_hba.conf (in the same directory) making the
appropriate changes to allow connection from your network.

Please note that OpenBSD port of PostgreSQL requires a kernel
compiled with SYSVSEM and SYSVSHM options for proper operation.
The GENERIC kernel has these settings but the default sizes are not
really large enough for a database with more than a handful of
connections and should have at least the following:

option          SEMMNI=256
option          SEMMNS=2048

To serve a large number of connections (>250), you may also need
to increase the maximum shared memory segment size, on the i386
try:

option		SHMMAXPGS=4096		# default on i386 is 2048 = 8Mb
					# other archs may vary

These numbers should be tweaked depending on system use.

The ulimit settings can also be a problem.  The following can be
added for the postgresql user in the /etc/login.conf file:

	postgresql:\
		:maxproc-max=256:\
		:maxproc-cur=256:\
		:openfiles-cur=768:\
		:datasize-max=256M:\
		:datasize-cur=64M:\
		:stacksize-cur=4M:

For more than about 250 connections, these numbers should be
increased. Please report any changes and experiences to the package
maintainers so that we can update this file for future versions.