1 Installation instructions for PostgreSQL 7.0.
3 If you haven't gotten the PostgreSQL distribution, get it from
4 ftp.postgresql.org, then unpack it:
6 gunzip postgresql-7.0.tar.gz
7 tar -xf postgresql-7.0.tar
8 mv postgresql-7.0 /usr/src
12 Building PostgreSQL requires GNU make. It will not work with other make
13 programs. On GNU/Linux systems GNU make is the default tool, on other
14 systems you may find that GNU make is installed under the name "gmake". We
15 will use that name from now on to indicate GNU make, no matter what name it
16 has on your system. To test for GNU make enter
20 If you need to get GNU make, you can find it at ftp://ftp.gnu.org.
22 Up to date information on supported platforms is at
23 http://www.postgresql.org/docs/admin/ports.htm. In general, most
24 Unix-compatible platforms with modern libraries should be able to run
25 PostgreSQL. In the doc subdirectory of the distribution are several
26 platform-specific FAQ and README documents you might wish to consult if you
29 Although the minimum required memory for running PostgreSQL can be as little
30 as 8MB, there are noticable speed improvements when expanding memory up to
31 96MB or beyond. The rule is you can never have too much memory.
33 Check that you have sufficient disk space. You will need about 30 Mbytes for
34 the source tree during compilation and about 5 Mbytes for the installation
35 directory. An empty database takes about 1 Mbyte, otherwise they take about
36 five times the amount of space that a flat text file with the same data
37 would take. If you run the regression tests you will temporarily need an
40 To check for disk space, use
44 Considering today's prices for hard disks, getting a large and fast hard
45 disk should probably be in your plans before putting a database into
49 Installation Procedure
51 PostgreSQL Installation
53 For a fresh install or upgrading from previous releases of PostgreSQL:
55 1. Create the PostgreSQL superuser account. This is the user the server
56 will run as. For production use you should create a separate,
57 unprivileged account (postgres is commonly used). If you do not have
58 root access or just want to play around, your own user account is
61 Running PostgreSQL as root, bin, or any other account with special
62 access rights is a security risk and therefore won't be allowed.
64 You need not do the building and installation itself under this account
65 (although you can). You will be told when you need to login as the
68 2. If you are not upgrading an existing system then skip to step 4.
70 You now need to back up your existing database. To dump your fairly
71 recent post-6.0 database installation, type
75 If you wish to preserve object id's (oids), then use the -o option when
76 running pg_dumpall. However, unless you have a special reason for doing
77 this (such as using OIDs as keys in tables), don't do it.
79 Make sure to use the pg_dumpall command from the version you are
80 currently running. However, do not use the pg_dumpall script from 6.0
81 or everything will be owned by the PostgreSQL super user. In that case
82 you should grab pg_dumpall from a later 6.x.x release. 7.0's pg_dumpall
83 will not work on older databases. If you are upgrading from a version
84 prior to Postgres95 v1.09 then you must back up your database, install
85 Postgres95 v1.09, restore your database, then back it up again.
88 You must make sure that your database is not updated in the middle of your
89 backup. If necessary, bring down postmaster, edit the permissions in file
90 /usr/local/pgsql/data/pg_hba.conf to allow only you on, then bring
92 3. If you are upgrading an existing system then kill the database server
95 ps ax | grep postmaster
99 ps -e | grep postmaster
101 (It depends on your system which one of these two works. No harm can be
102 done by typing the wrong one.) This should list the process numbers for
103 a number of processes, similar to this:
105 263 ? SW 0:00 (postmaster)
106 777 p1 S 0:00 grep postmaster
108 Type the following line, with pid replaced by the process id for
109 process postmaster (263 in the above case). (Do not use the id for the
110 process "grep postmaster".)
114 Tip: On systems which have PostgreSQL started at boot time,
115 there is probably a startup file which will accomplish the
116 same thing. For example, on a Redhat Linux system one might
119 /etc/rc.d/init.d/postgres.init stop
123 Also move the old directories out of the way. Type the following:
125 mv /usr/local/pgsql /usr/local/pgsql.old
127 or replace your particular paths.
129 4. Configure the source code for your system. It is this step at which you
130 can specify your actual installation path for the build process and
131 make choices about what gets installed. Change into the src
132 subdirectory and type:
136 followed by any options you might want to give it. For a first
137 installation you should be able to do fine without any. For a complete
138 list of options, type:
142 Some of the more commonly used ones are:
146 Selects a different base directory for the installation of
147 PostgreSQL. The default is /usr/local/pgsql.
151 If you want to use locales.
155 Allows the use of multibyte character encodings. This is primarily
156 for languages like Japanese, Korean, or Chinese.
160 Builds the Perl interface. Please note that the Perl interface
161 will be installed into the usual place for Perl modules (typically
162 under /usr/lib/perl), so you must have root access to use this
167 Builds the ODBC driver package.
171 Builds interface libraries and programs requiring Tcl/Tk,
172 including libpgtcl, pgtclsh, and pgtksh.
174 5. Compile the program. Type
178 The compilation process can take anywhere from 10 minutes to an hour.
179 Your milage will most certainly vary. Remember to use GNU make.
181 The last line displayed will hopefully be
183 All of PostgreSQL is successfully made. Ready to install.
185 6. Install the program. Type
189 7. Tell your system how to find the new shared libraries. How to do this
190 varies between platforms. What tends to work everywhere is to set the
191 environment variable LD_LIBRARY_PATH:
193 LD_LIBRARY_PATH=/usr/local/pgsql/lib
194 export LD_LIBRARY_PATH
196 on sh, ksh, bash, zsh or
198 setenv LD_LIBRARY_PATH /usr/local/pgsql/lib
200 on csh or tcsh. You might want to put this into a shell startup file
201 such as /etc/profile.
203 On some systems the following is the preferred method, but you must
204 have root access. Edit file /etc/ld.so.conf to add a line
208 Then run command /sbin/ldconfig.
210 If in doubt, refer to the manual pages of your system. If you later on
213 psql: error in loading shared libraries
214 libpq.so.2.1: cannot open shared object file: No such file or directory
216 then the above was necessary. Simply do this step then.
218 8. Create the database installation. To do this you must log in to your
219 PostgreSQL superuser account. It will not work as root.
221 mkdir /usr/local/pgsql/data
222 chown postgres /usr/local/pgsql/data
224 /usr/local/pgsql/initdb -D /usr/local/pgsql/data
226 The -D option specifies the location where the data will be stored. You
227 can use any path you want, it does not have to be under the
228 installation directory. Just make sure that the superuser account can
229 write to the directory (or create it) before starting initdb. (If you
230 have already been doing the installation up to now as the PostgreSQL
231 superuser, you may have to log in as root temporarily to create the
234 9. The previous step should have told you how to start up the database
237 /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
239 This will start the server in the foreground. To make it detach to the
240 background, use the -S.
242 10. If you are upgrading from an existing installation, dump your data back
245 /usr/local/pgsql/bin/psql -d template1 -f db.out
247 You also might want to copy over the old pg_hba.conf file and any other
248 files you might have had set up for authentication, such as password
251 This concludes the installation proper. To make your life more productive
252 and enjoyable you should look at the following optional steps and
255 * Life will be more convenient if you set up some enviroment variables.
256 First of all you probably want to include /usr/local/pgsql/bin (or
257 equivalent) into your PATH. To do this, add the following to your shell
258 startup file, such as ~/.bash_profile (or /etc/profile, if you want it
259 to affect every user):
261 PATH=$PATH:/usr/local/pgsql/bin
263 Furthermore, if you set PGDATA in the environment of the PostgreSQL
264 superuser, you can omit the -D for postmaster and initdb.
266 * You probably want to install the man and HTML documentation. Type
268 cd /usr/src/pgsql/postgresql-7.0/doc
271 This will install files under /usr/local/pgsql/doc and
272 /usr/local/pgsql/man. To enable your system to find the man
273 documentation, you need to add a line like the following to a shell
276 MANPATH=$MANPATH:/usr/local/pgsql/man
278 The documentation is also available in Postscript format. If you have a
279 Postscript printer, or have your machine already set up to accept
280 Postscript files using a print filter, then to print the User's Guide
283 cd /usr/local/pgsql/doc
284 gunzip -c user.ps.tz | lpr
286 Here is how you might do it if you have Ghostscript on your system and
287 are writing to a laserjet printer.
289 gunzip -c user.ps.gz | gs -sDEVICE=laserjet -r300 -q -dNOPAUSE -sOutputFile=- | lpr
291 Printer setups can vary wildly from system to system. If in doubt,
292 consult your manuals or your local expert.
294 The Adminstrator's Guide should probably be your first reading if you
295 are completely new to PostgreSQL, as it contains information about how
296 to set up database users and authentication.
298 * Usually, you will want to modify your computer so that it will
299 automatically start the database server whenever it boots. This is not
300 required; the PostgreSQL server can be run successfully from
301 non-privileged accounts without root intervention.
303 Different systems have different conventions for starting up daemons at
304 boot time, so you are advised to familiarize yourself with them. Most
305 systems have a file /etc/rc.local or /etc/rc.d/rc.local which is almost
306 certainly no bad place to put such a command. Whatever you do,
307 postmaster must be run by the PostgreSQL superuser (postgres) and not
308 by root or any other user. Therefore you probably always want to form
309 your command lines along the lines of su -c '...' postgres.
311 It might be advisable to keep a log of the server output. To start the
314 nohup su -c 'postmaster -D /usr/local/pgsql/data > server.log 2>&1' postgres &
316 Here are a few more operating system specific suggestions.
318 o Edit file rc.local on NetBSD or file rc2.d on SPARC Solaris 2.5.1
319 to contain the following single line:
321 su postgres -c "/usr/local/pgsql/bin/postmaster -S -D /usr/local/pgsql/data"
323 o In FreeBSD 2.2-RELEASE edit /usr/local/etc/rc.d/pgsql.sh to
324 contain the following lines and make it chmod 755 and chown
328 [ -x /usr/local/pgsql/bin/postmaster ] && {
329 su -l pgsql -c 'exec /usr/local/pgsql/bin/postmaster
330 -D/usr/local/pgsql/data
331 -S -o -F > /usr/local/pgsql/errlog' &
335 You may put the line breaks as shown above. The shell is smart
336 enough to keep parsing beyond end-of-line if there is an
337 expression unfinished. The exec saves one layer of shell under the
338 postmaster process so the parent is init.
340 o In RedHat Linux add a file /etc/rc.d/init.d/postgres.init which is
341 based on the example in contrib/linux/. Then make a softlink to
342 this file from /etc/rc.d/rc5.d/S98postgres.init.
344 * Run the regression tests. The regression tests are a test suite to
345 verify that PostgreSQL runs on your machine in the way the developers
346 expected it to. You should definitely do this before putting a server
347 into production use. The file
348 /usr/src/pgsql/postgresql-7.0/src/test/regress/README has detailed
349 instructions for running and interpreting the regression tests.
351 To start "playing around", set up the paths as explained above and start the
352 server. To create a database, type
360 to connect to that database. At the prompt you can enter SQL and start