]> granicus.if.org Git - postgresql/blob - INSTALL
Update for 7.0.2.
[postgresql] / INSTALL
1      Installation instructions for PostgreSQL 7.0.2.
2
3 If you haven't gotten the PostgreSQL distribution, get it from
4 ftp.postgresql.org, then unpack it:
5
6 > gunzip postgresql-7.0.2.tar.gz
7 > tar -xf postgresql-7.0.2.tar
8 > mv postgresql-7.0.2 /usr/src
9
10
11 Before you start
12
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
18
19 > gmake --version
20
21
22 If you need to get GNU make, you can find it at ftp://ftp.gnu.org.
23
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
29 are having trouble.
30
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.
34
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
40 extra 20MB.
41
42 To check for disk space, use
43
44 > df -k
45
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
48 production use.
49
50
51 Installation Procedure
52
53 PostgreSQL Installation
54
55 For a fresh install or upgrading from previous releases of PostgreSQL:
56
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
61      enough.
62
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.
66
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
69      database superuser.
70
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:
75
76      > ./configure
77
78
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:
82
83      > ./configure --help
84
85
86      Some of the more commonly used ones are:
87
88      --prefix=BASEDIR
89
90           Selects a different base directory for the installation of
91           PostgreSQL. The default is /usr/local/pgsql.
92
93      --enable-locale
94
95           If you want to use locales.
96
97      --enable-multibyte
98
99           Allows the use of multibyte character encodings. This is primarily
100           for languages like Japanese, Korean, or Chinese.
101
102      --with-perl
103
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.)
111
112      --with-odbc
113
114           Builds the ODBC driver package.
115
116      --with-tcl
117
118           Builds interface libraries and programs requiring Tcl/Tk,
119           including libpgtcl, pgtclsh, and pgtksh.
120
121   3. Compile the program. Type
122
123      > gmake
124
125
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.
128
129      The last line displayed will hopefully be
130
131      All of PostgreSQL is successfully made. Ready to install.
132
133
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.)
140
141   5. If you are not upgrading an existing system, skip to step 7.
142      If you are running 7.*, skip to step 6.
143
144      You now need to back up your existing database. To dump your 
145      database installation, type:
146
147      > pg_dumpall > db.out
148
149
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.
153
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
156      databases.
157
158                                         Caution
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
162       postmaster back up.
163
164       Rather than using pg_dumpall, pg_upgrade can often be used.
165
166   6. If you are upgrading an existing system, kill the database server
167      now. Type
168
169      > ps ax | grep postmaster
170
171
172      or
173
174      > ps -e | grep postmaster
175
176
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:
180
181        263  ?  SW   0:00 (postmaster)
182        777  p1 S    0:00 grep postmaster
183
184
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".)
188
189      > kill pid
190
191
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
195           find that
196
197           > /etc/rc.d/init.d/postgres.init stop
198
199
200           works.
201
202      If you used pg_dumpall, move the old directories out of the
203      way.  Type the following:
204
205      > mv /usr/local/pgsql /usr/local/pgsql.old
206
207
208      (substitute your particular paths).
209
210   7. Install the PostgreSQL executable files and libraries. Type
211
212      > gmake install
213
214
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
218      owned by root.
219
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:
223
224      > LD_LIBRARY_PATH=/usr/local/pgsql/lib
225      > export LD_LIBRARY_PATH
226
227
228      on sh, ksh, bash, zsh or
229
230      > setenv LD_LIBRARY_PATH /usr/local/pgsql/lib
231
232
233      on csh or tcsh. You might want to put this into a shell startup file
234      such as /etc/profile.
235
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
238
239      /usr/local/pgsql/lib
240
241
242      Then run command /sbin/ldconfig.
243
244      If in doubt, refer to the manual pages of your system. If you later on
245      get a message like
246
247      psql: error in loading shared libraries
248      libpq.so.2.1: cannot open shared object file: No such file or directory
249
250
251      then the above was necessary. Simply do this step then.
252
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
255      as root.
256
257      > mkdir /usr/local/pgsql/data
258      > chown postgres /usr/local/pgsql/data
259      > su - postgres
260      > /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
261
262
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.)
271
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
274
275      > /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
276
277
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
281      background is
282
283      > nohup /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data \
284          </dev/null >>server.log 2>>1 &
285
286
287  11. If you did a pg_dumpall, reload your data back in:
288
289      > /usr/local/pgsql/bin/psql -d template1 -f db.out
290
291
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
294      files.
295
296 This concludes the installation proper. To make your life more productive
297 and enjoyable you should look at the following optional steps and
298 suggestions:
299
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):
305
306      > PATH=$PATH:/usr/local/pgsql/bin
307
308
309      Furthermore, if you set PGDATA in the environment of the PostgreSQL
310      superuser, you can omit the -D for postmaster and initdb.
311
312    * You probably want to install the man and HTML documentation. Type
313
314      > cd /usr/src/pgsql/postgresql-7.0.2/doc
315      > gmake install
316
317
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
321      startup file:
322
323      > MANPATH=$MANPATH:/usr/local/pgsql/man
324
325
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
329      simply type
330
331      > cd /usr/local/pgsql/doc
332      > gunzip -c user.ps.tz | lpr
333
334
335      Here is how you might do it if you have Ghostscript on your system and
336      are writing to a laserjet printer.
337
338      > gunzip -c user.ps.gz \
339          | gs -sDEVICE=laserjet -r300 -q -dNOPAUSE -sOutputFile=- \
340          | lpr
341
342
343      Printer setups can vary wildly from system to system. If in doubt,
344      consult your manuals or your local expert.
345
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.
349
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.
354
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.
362
363      It might be advisable to keep a log of the server output. To start the
364      server that way try:
365
366      > nohup su -c 'postmaster -D /usr/local/pgsql/data > server.log 2>&1' postgres &
367
368
369      Here are a few more operating system specific suggestions.
370
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:
373
374           > su postgres -c "/usr/local/pgsql/bin/postmaster -S -D /usr/local/pgsql/data"
375
376
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
379           root:bin.
380
381           #!/bin/sh
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' &
386               echo -n ' pgsql'
387           }
388
389
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.
394
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.
398
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.
403
404 To start experimenting with Postgres, set up the paths as explained above
405 and start the server. To create a database, type
406
407 > createdb testdb
408
409
410 Then enter
411
412 > psql testdb
413
414
415 to connect to that database. At the prompt you can enter SQL commands and
416 start experimenting.