1 Installation instructions for PostgreSQL 7.0.2.
3 If you haven't gotten the PostgreSQL distribution, get it from
4 ftp.postgresql.org, then unpack it:
6 > gunzip postgresql-7.0.2.tar.gz
7 > tar -xf postgresql-7.0.2.tar
8 > mv postgresql-7.0.2 /usr/src
13 Building PostgreSQL requires GNU make. It will not work with other make
14 programs. On GNU/Linux systems GNU make is the default tool, on other
15 systems you may find that GNU make is installed under the name gmake. We
16 will use that name from now on to indicate GNU make, no matter what name it
17 has on your system. To test for GNU make enter
22 If you need to get GNU make, you can find it at ftp://ftp.gnu.org.
24 Up to date information on supported platforms is at
25 http://www.postgresql.org/docs/admin/ports.htm. In general, most
26 Unix-compatible platforms with modern libraries should be able to run
27 PostgreSQL. In the doc subdirectory of the distribution are several
28 platform-specific FAQ and README documents you might wish to consult if you
31 Although the minimum required memory for running PostgreSQL can be as little
32 as 8MB, there are noticeable speed improvements when expanding memory up to
33 96MB or beyond. The rule is you can never have too much memory.
35 Check that you have sufficient disk space. You will need about 30 Mbytes for
36 the source tree during compilation and about 5 Mbytes for the installation
37 directory. An empty database takes about 1 Mbyte, otherwise they take about
38 five times the amount of space that a flat text file with the same data
39 would take. If you run the regression tests you will temporarily need an
42 To check for disk space, use
46 Considering today's prices for hard disks, getting a large and fast hard
47 disk should probably be in your plans before putting a database into
51 Installation Procedure
53 PostgreSQL Installation
55 For a fresh install or upgrading from previous releases of PostgreSQL:
57 1. Create the PostgreSQL superuser account. This is the user the server
58 will run as. For production use you should create a separate,
59 unprivileged account (postgres is commonly used). If you do not have
60 root access or just want to play around, your own user account is
63 Running PostgreSQL as root, bin, or any other account with special
64 access rights is a security risk; don't do it. The postmaster will in
65 fact refuse to start as root.
67 You need not do the building and installation itself under this account
68 (although you can). You will be told when you need to login as the
71 2. Configure the source code for your system. It is this step at which you
72 can specify your actual installation path for the build process and
73 make choices about what gets installed. Change into the src
74 subdirectory and type:
79 followed by any options you might want to give it. For a first
80 installation you should be able to do fine without any. For a complete
81 list of options, type:
86 Some of the more commonly used ones are:
90 Selects a different base directory for the installation of
91 PostgreSQL. The default is /usr/local/pgsql.
95 If you want to use locales.
99 Allows the use of multibyte character encodings. This is primarily
100 for languages like Japanese, Korean, or Chinese.
104 Builds the Perl interface and plperl extension language. Please
105 note that the Perl interface needs to be installed into the usual
106 place for Perl modules (typically under /usr/lib/perl), so you
107 must have root access to perform the installation step. (It is
108 often easiest to leave out --with-perl initially, and then build
109 and install the Perl interface after completing the installation
110 of PostgreSQL itself.)
114 Builds the ODBC driver package.
118 Builds interface libraries and programs requiring Tcl/Tk,
119 including libpgtcl, pgtclsh, and pgtksh.
121 3. Compile the program. Type
126 The compilation process can take anywhere from 10 minutes to an hour.
127 Your mileage will most certainly vary. Remember to use GNU make.
129 The last line displayed will hopefully be
131 All of PostgreSQL is successfully made. Ready to install.
134 4. If you want to test the newly built server before you install it, you
135 can run the regression tests at this point. The regression tests are a
136 test suite to verify that PostgreSQL runs on your machine in the way
137 the developers expected it to. For detailed instructions see Regression
138 Test. (Be sure to use the "parallel regress test" method, since the
139 sequential method only works with an already-installed server.)
141 5. If you are not upgrading an existing system, skip to step 7.
142 If you are running 7.*, skip to step 6.
144 You now need to back up your existing database. To dump your
145 database installation, type:
147 > pg_dumpall > db.out
150 If you wish to preserve object id's (oids), then use the -o option when
151 running pg_dumpall. However, unless you have a special reason for doing
152 this (such as using OIDs as keys in tables), don't do it.
154 Make sure to use the pg_dumpall command from the version you are
155 currently running. 7.0.2's pg_dumpall should not be used on older
159 You must make sure that your database is not updated in the middle of your
160 backup. If necessary, bring down postmaster, edit the permissions in file
161 /usr/local/pgsql/data/pg_hba.conf to allow only you on, then bring
164 Rather than using pg_dumpall, pg_upgrade can often be used.
166 6. If you are upgrading an existing system, kill the database server
169 > ps ax | grep postmaster
174 > ps -e | grep postmaster
177 (It depends on your system which one of these two works. No harm can be
178 done by typing the wrong one.) This should list the process numbers for
179 a number of processes, similar to this:
181 263 ? SW 0:00 (postmaster)
182 777 p1 S 0:00 grep postmaster
185 Type the following line, with pid replaced by the process id for
186 process postmaster (263 in the above case). (Do not use the id for the
187 process "grep postmaster".)
192 Tip: On systems which have PostgreSQL started at boot time,
193 there is probably a startup file that will accomplish the
194 same thing. For example, on a Redhat Linux system one might
197 > /etc/rc.d/init.d/postgres.init stop
202 If you used pg_dumpall, move the old directories out of the
203 way. Type the following:
205 > mv /usr/local/pgsql /usr/local/pgsql.old
208 (substitute your particular paths).
210 7. Install the PostgreSQL executable files and libraries. Type
215 You should do this step as the user that you want the installed
216 executables to be owned by. This does not have to be the same as the
217 database superuser; some people prefer to have the installed files be
220 8. If necessary, tell your system how to find the new shared libraries.
221 How to do this varies between platforms. The most widely usable method
222 is to set the environment variable LD_LIBRARY_PATH:
224 > LD_LIBRARY_PATH=/usr/local/pgsql/lib
225 > export LD_LIBRARY_PATH
228 on sh, ksh, bash, zsh or
230 > setenv LD_LIBRARY_PATH /usr/local/pgsql/lib
233 on csh or tcsh. You might want to put this into a shell startup file
234 such as /etc/profile.
236 On some systems the following is the preferred method, but you must
237 have root access. Edit file /etc/ld.so.conf to add a line
242 Then run command /sbin/ldconfig.
244 If in doubt, refer to the manual pages of your system. If you later on
247 psql: error in loading shared libraries
248 libpq.so.2.1: cannot open shared object file: No such file or directory
251 then the above was necessary. Simply do this step then.
253 9. Create the database installation (the working data files). To do this
254 you must log in to your PostgreSQL superuser account. It will not work
257 > mkdir /usr/local/pgsql/data
258 > chown postgres /usr/local/pgsql/data
260 > /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
263 The -D option specifies the location where the data will be stored. You
264 can use any path you want, it does not have to be under the
265 installation directory. Just make sure that the superuser account can
266 write to the directory (or create it, if it doesn't already exist)
267 before starting initdb. (If you have already been doing the
268 installation up to now as the PostgreSQL superuser, you may have to log
269 in as root temporarily to create the data directory underneath a
270 root-owned directory.)
272 10. The previous step should have told you how to start up the database
273 server. Do so now. The command should look something like
275 > /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
278 This will start the server in the foreground. To make it detach to the
279 background, you can use the -S option, but then you won't see any log
280 messages the server produces. A better way to put the server in the
283 > nohup /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data \
284 </dev/null >>server.log 2>>1 &
287 11. If you did a pg_dumpall, reload your data back in:
289 > /usr/local/pgsql/bin/psql -d template1 -f db.out
292 You also might want to copy over the old pg_hba.conf file and any other
293 files you might have had set up for authentication, such as password
296 This concludes the installation proper. To make your life more productive
297 and enjoyable you should look at the following optional steps and
300 * Life will be more convenient if you set up some environment variables.
301 First of all you probably want to include /usr/local/pgsql/bin (or
302 equivalent) into your PATH. To do this, add the following to your shell
303 startup file, such as ~/.bash_profile (or /etc/profile, if you want it
304 to affect every user):
306 > PATH=$PATH:/usr/local/pgsql/bin
309 Furthermore, if you set PGDATA in the environment of the PostgreSQL
310 superuser, you can omit the -D for postmaster and initdb.
312 * You probably want to install the man and HTML documentation. Type
314 > cd /usr/src/pgsql/postgresql-7.0.2/doc
318 This will install files under /usr/local/pgsql/doc and
319 /usr/local/pgsql/man. To enable your system to find the man
320 documentation, you need to add a line like the following to a shell
323 > MANPATH=$MANPATH:/usr/local/pgsql/man
326 The documentation is also available in Postscript format. If you have a
327 Postscript printer, or have your machine already set up to accept
328 Postscript files using a print filter, then to print the User's Guide
331 > cd /usr/local/pgsql/doc
332 > gunzip -c user.ps.tz | lpr
335 Here is how you might do it if you have Ghostscript on your system and
336 are writing to a laserjet printer.
338 > gunzip -c user.ps.gz \
339 | gs -sDEVICE=laserjet -r300 -q -dNOPAUSE -sOutputFile=- \
343 Printer setups can vary wildly from system to system. If in doubt,
344 consult your manuals or your local expert.
346 The Adminstrator's Guide should probably be your first reading if you
347 are completely new to PostgreSQL, as it contains information about how
348 to set up database users and authentication.
350 * Usually, you will want to modify your computer so that it will
351 automatically start the database server whenever it boots. This is not
352 required; the PostgreSQL server can be run successfully from
353 non-privileged accounts without root intervention.
355 Different systems have different conventions for starting up daemons at
356 boot time, so you are advised to familiarize yourself with them. Most
357 systems have a file /etc/rc.local or /etc/rc.d/rc.local which is almost
358 certainly no bad place to put such a command. Whatever you do,
359 postmaster must be run by the PostgreSQL superuser (postgres) and not
360 by root or any other user. Therefore you probably always want to form
361 your command lines along the lines of su -c '...' postgres.
363 It might be advisable to keep a log of the server output. To start the
366 > nohup su -c 'postmaster -D /usr/local/pgsql/data > server.log 2>&1' postgres &
369 Here are a few more operating system specific suggestions.
371 o Edit file rc.local on NetBSD or file rc2.d on SPARC Solaris 2.5.1
372 to contain the following single line:
374 > su postgres -c "/usr/local/pgsql/bin/postmaster -S -D /usr/local/pgsql/data"
377 o In FreeBSD 2.2-RELEASE edit /usr/local/etc/rc.d/pgsql.sh to
378 contain the following lines and make it chmod 755 and chown
382 [ -x /usr/local/pgsql/bin/postmaster ] && {
383 su -l pgsql -c 'exec /usr/local/pgsql/bin/postmaster
384 -D/usr/local/pgsql/data
385 -S -o -F > /usr/local/pgsql/errlog' &
390 You may put the line breaks as shown above. The shell is smart
391 enough to keep parsing beyond end-of-line if there is an
392 expression unfinished. The exec saves one layer of shell under the
393 postmaster process so the parent is init.
395 o In RedHat Linux add a file /etc/rc.d/init.d/postgres.init which is
396 based on the example in contrib/linux/. Then make a softlink to
397 this file from /etc/rc.d/rc5.d/S98postgres.init.
399 * Run the regression tests against the installed server (using the
400 sequential test method). If you didn't run the tests before
401 installation, you should definitely do it now. For detailed
402 instructions see Regression Test.
404 To start experimenting with Postgres, set up the paths as explained above
405 and start the server. To create a database, type
415 to connect to that database. At the prompt you can enter SQL commands and