]> granicus.if.org Git - postgresql/blob - doc/src/sgml/install.sgml
Document configure's --with-maxbackends switch.
[postgresql] / doc / src / sgml / install.sgml
1 <Chapter Id="install">
2 <Title>Installation</Title>
3
4 <Abstract>
5 <Para>
6 Complete installation instructions for 
7 <ProductName>Postgres</ProductName> v6.4.
8 </Para>
9 </Abstract>
10
11 <Para>
12 Before installing <ProductName>Postgres</ProductName>, you may wish to visit
13 <ULink url="http://www.postgresql.org">www.postgresql.org</ULink>
14 for up to date information, patches, etc.
15 </Para>
16
17 <Para>
18 These installation instructions assume:
19
20 <ItemizedList Mark="bullet" Spacing="compact">
21 <ListItem>
22 <Para>
23 Commands are Unix-compatible. See note below.
24 </Para>
25 </ListItem>
26 <ListItem>
27 <Para>
28 Defaults are used except where noted.
29 </Para>
30 </ListItem>
31 <ListItem>
32 <Para>
33 User <literal>postgres</literal> is the <ProductName>Postgres</ProductName> superuser.
34 </Para>
35 </ListItem>
36 <ListItem>
37 <Para>
38 The source path is <filename>/usr/src/pgsql</filename> (other paths are possible).
39 </Para>
40 </ListItem>
41 <ListItem>
42 <Para>
43 The runtime path is <filename>/usr/local/pgsql</filename> (other paths are possible).
44 </Para>
45 </ListItem>
46 </ItemizedList>
47 </para>
48 <Para>
49 Commands were tested on RedHat Linux version 4.2 using the tcsh shell.
50 Except where noted, they will probably work on most systems. Commands
51 like <command>ps</command> and <command>tar</command> may vary wildly 
52 between platforms on what options you should use.
53 <Emphasis>Use common sense</Emphasis> before typing in these commands.
54 </Para>
55
56 <Para>
57 Our Makefiles require GNU <Application>make</Application> (called
58 <Quote>gmake</Quote> in this document).  They will <Emphasis>not</Emphasis>
59 work with non-GNU <Application>make</Application> programs.  If you
60 have GNU <Application>make</Application> installed under the name 
61 <Quote>make</Quote> instead of <Quote>gmake</Quote>, then you will use the
62 command <command>make</command> instead. That's OK, but
63 you need to have the GNU form of <Application>make</Application> to succeed with
64 an installation.
65 </Para>
66
67 <Sect1>
68 <Title>Requirements to Run <ProductName>Postgres</ProductName></Title>
69
70 <Para>
71 Up to date information on supported platforms is at
72 <ulink url="http://www.postgresql.org/docs/admin/install.htm">
73 http://www.postgresql.org/docs/admin/install.htm</ulink>.
74
75  In general, most Unix-compatible
76 platforms with modern libraries should be able to run <ProductName>Postgres</ProductName>.
77 </para>
78 <para>
79 Although the minimum required memory for running <ProductName>Postgres</ProductName>
80 is as little as 8MB, there are noticable improvements in runtimes for the regression
81 tests when expanding memory up to 96MB on a relatively fast dual-processor system
82 running X-Windows.
83 The rule is you can never have too much memory.
84 </para>
85 <Para>
86 Check that you have sufficient disk space.  You will need about
87       30 Mbytes for <filename>/usr/src/pgsql</filename>, 
88 about 5 Mbytes for <filename>/usr/local/pgsql</filename>
89       (excluding your database) and 1 Mbyte for an empty database.
90       The database will temporarily grow to about 20 Mbytes during the
91       regression tests.  You will also need about 3 Mbytes for the
92       distribution tar file.
93 </Para>
94
95 <Para>
96       We therefore recommend that during installation and testing you
97       have well over 20 Mbytes free under <filename>/usr/local</filename> and another 25 Mbytes
98       free on the disk partition containing your database.  Once you
99       delete the source files, tar file and regression database, you
100       will need 2 Mbytes for <filename>/usr/local/pgsql</filename>, 1 Mbyte for the empty
101       database, plus about five times the space you would require to
102       store your database data in a flat file.
103 </Para>
104
105 <Para>
106       To check for disk space, use 
107 <programlisting>
108 $ df -k
109 </programlisting>
110 </para>
111 </Sect1>
112
113 <Sect1>
114 <Title>Installation Procedure</Title>
115
116 <Procedure>
117 <Title><ProductName>Postgres</ProductName> Installation</Title>
118
119 <Para>
120 For a fresh install or upgrading from previous releases of
121 <ProductName>Postgres</ProductName>:
122 </Para>
123
124 <Step Performance="required">
125 <Para>
126 Read any last minute information and platform specific porting
127      notes.  There are some platform specific notes at the end of this
128      file for Ultrix4.x, Linux, BSD/OS and NeXT.  There are other
129      files in directory <FileName>/usr/src/pgsql/doc</FileName>, including files FAQ-Irix
130      and FAQ-Linux.  Also look in directory
131 <ULink url="ftp://ftp.postgresql.org/pub">ftp://ftp.postgresql.org/pub</ULink>.
132      If there is a file called INSTALL in this directory then this
133      file will contain the latest installation information.
134 </Para>
135
136 <Para>
137      Please note that a "tested" platform in the list given earlier
138      simply means that someone went to the effort at some point of making
139      sure that a <ProductName>Postgres</ProductName> distribution would compile and run on this
140      platform without modifying the code.  Since the current developers
141      will not have access to all of these platforms, some of them may not
142      compile cleanly and pass the regression tests in the current
143      release due to minor problems.  Any such known problems and their
144      solutions will be posted in 
145 <ULink url="ftp://ftp.postgresql.org/pub/INSTALL">ftp://ftp.postgresql.org/pub/INSTALL</ULink>.
146 </Para>
147 </Step>
148
149 <Step Performance="optional">
150 <Para>
151 Create the <ProductName>Postgres</ProductName> superuser account
152 (<literal>postgres</literal> is commonly used) if it does not already exist.
153 </para>
154 <para>
155 The owner of the Postgres files can be any unprivileged user account.
156 It <emphasis>must not</emphasis> be <literal>root</literal>, <literal>bin</literal>,
157 or any other account with special access rights, as that would create a security risk.
158 </para>
159 </Step>
160
161 <Step Performance="required">
162 <Para>
163 Log in to the <ProductName>Postgres</ProductName> superuser account. Most of the
164 remaining steps in the installation will happen in this account.
165 </para>
166 </step>
167 <Step Performance="required">
168 <Para>
169 Ftp file 
170 <ulink url="ftp://ftp.postgresql.org/pub/postgresql-v6.4.tar.gz">
171  <filename>ftp://ftp.postgresql.org/pub/postgresql-v6.4.tar.gz</filename></ulink>
172  from the Internet.  Store it in your home directory.
173 </Para>
174 </Step>
175
176 <Step Performance="required">
177 <Para>
178 Some platforms use <application>flex</application>.  
179 If your system uses <application>flex</application> then make sure
180      you have a good version.  To check, type 
181 <programlisting>
182 $ flex --version
183 </programlisting>
184
185 </Para>
186
187 <Para>
188      If the <application>flex</application> command is not found then you probably do not need it.
189      If the version is 2.5.2 or 2.5.4 or greater then you are okay.  If it
190      is 2.5.3 or before 2.5.2 then you will have to upgrade <application>flex</application>.  You may
191      get it at 
192 <ulink url="ftp://prep.ai.mit.edu/pub/gnu/flex-2.5.4.tar.gz">ftp://prep.ai.mit.edu/pub/gnu/flex-2.5.4.tar.gz</ulink>.
193 </Para>
194
195 <Para>
196      If you need <application>flex</application> and don't have it or have the wrong version, then
197      you will be told so when you attempt to compile the program.  Feel
198      free to skip this step if you aren't sure you need it.  If you do
199      need it then you will be told to install/upgrade <application>flex</application> when you try to
200      compile <productname>Postgres</productname>.
201 </Para>
202
203 <Para>
204 You may want to do the entire <application>flex</application> installation from
205 the root account, though that is not absolutely necessary.
206 Assuming that you want the installation to place files in the usual default
207 areas, type the following:
208 <ProgramListing>
209 $ su -
210 $ cd /usr/local/src
211 ftp prep.ai.mit.edu
212 ftp> cd /pub/gnu/
213 ftp> binary
214 ftp> get flex-2.5.4.tar.gz
215 ftp> quit
216 $ gunzip -c flex-2.5.4.tar.gz | tar xvf -
217 $ cd flex-2.5.4
218 $ configure --prefix=/usr
219 $ gmake
220 $ gmake check
221 # You must be root when typing the next line:
222 $ gmake install
223 $ cd /usr/local/src
224 $ rm -rf flex-2.5.4
225 </ProgramListing>
226 </Para>
227
228 <Para>
229      This will update files <filename>/usr/man/man1/flex.1</filename>,
230  <filename>/usr/bin/flex</filename>,
231      <filename>/usr/lib/libfl.a</filename>,
232  <filename>/usr/include/FlexLexer.h</filename> and will add a link
233      <filename>/usr/bin/flex++</filename> which points to flex.
234 </Para>
235 </Step>
236
237 <Step Performance="required">
238 <Para>
239 If you are not upgrading an existing system then skip to 
240 <xref linkend="newdirs">.
241 If you are upgrading an existing system then back up your database.
242      For alpha- and beta-level releases, the database format is liable
243      to change, often every few weeks, with no notice besides a quick comment
244      in the HACKERS mailing list.  Full releases always require a dump/reload
245      from previous releases.  It is therefore a bad idea to skip this
246      step.  
247 </para>
248 <tip>
249 <para>
250 Do not use the <application>pg_dumpall</application> 
251 script from v6.0 or everything
252      will be owned by the <ProductName>Postgres</ProductName> super user.
253 </para>
254 </tip>
255
256 <para>
257 To dump your fairly recent post-v6.0 database installation, type
258
259 <programlisting>
260 $ pg_dumpall -z > db.out
261 </programlisting>
262 </para>
263 <para>
264 To use the latest <application>pg_dumpall</application> script on your
265 existing older database before upgrading <productname>Postgres</productname>,
266 pull the most recent version of <application>pg_dumpall</application>
267 from the new distribution:
268
269 <ProgramListing>
270 $ cd
271 $ gunzip -c postgresql-v6.4.tar.gz \
272     | tar xvf - src/bin/pg_dump/pg_dumpall
273 $ chmod a+x src/bin/pg_dump/pg_dumpall
274 $ src/bin/pg_dump/pg_dumpall -z > db.out
275 $ rm -rf src
276 </ProgramListing>
277 </Para>
278
279 <Para>
280      If you wish to preserve object id's (oids), then use the -o
281      option when running <application>pg_dumpall</application>.  
282 However, unless you have a
283      special reason for doing this (such as using OIDs as keys
284 in tables), don't do it.
285 </Para>
286
287 <Para>
288      If the <application>pg_dumpall</application> command
289  seems to take a long time and you think
290      it might have died, then, from another terminal, type
291 <programlisting>
292 $ ls -l db.out
293 </programlisting>
294      several times to see if the size of the file is growing.
295 </Para>
296
297 <Para>
298      Please note that if you are upgrading from a version prior to
299      <ProductName>Postgres95</ProductName> v1.09 then you must back up your database,
300  install
301      <ProductName>Postgres95</ProductName> v1.09, restore your database,
302  then back it up again.
303      You should also read the release notes which should cover any
304  release-specific issues.
305 </Para>
306
307 <caution>
308 <Para>
309      You must make sure that your database is not updated in the middle of
310      your backup.  If necessary, bring down postmaster, edit the permissions
311      in file <filename>/usr/local/pgsql/data/pg_hba.conf</filename>
312  to allow only you on, then
313      bring <application>postmaster</application> back up.
314 </Para>
315 </caution>
316
317 </Step>
318
319 <Step Performance="required">
320 <Para>
321 If you are upgrading an existing system then kill the postmaster.  Type
322 <ProgramListing>
323 $ ps -ax | grep postmaster
324 </ProgramListing>
325
326      This should list the process numbers for a number of processes.  Type
327      the following line, with <replaceable>pid</replaceable>
328  replaced by the process id for process
329      <literal>postmaster</literal>.  
330 (Do not use the id for process "grep postmaster".)  Type
331 <programlisting>
332 $ kill <replaceable>pid</replaceable>
333 </programlisting>
334 to actually stop the process.
335
336 <tip>
337 <para>
338 On systems which have <productname>Postgres</productname> started at boot time, there
339 is probably a startup file which will accomplish the same thing. For example, on my
340 Linux system I can type
341 <programlisting>
342 $ /etc/rc.d/init.d/postgres.init stop
343 </programlisting>
344 to halt <productname>Postgres</productname>.
345 </para>
346 </tip>
347 </Para>
348 </Step>
349
350 <Step Performance="required">
351 <Para>
352 If you are upgrading an existing system then move the old directories
353      out of the way.  If you are short of disk space then you may have to
354      back up and delete the directories instead.  If you do this, save the
355      old database in the <filename>/usr/local/pgsql/data</filename> directory tree.  At a
356      minimum, save file <filename>/usr/local/pgsql/data/pg_hba.conf</filename>.
357 </Para>
358
359 <Para>
360      Type the following:
361 <programlisting>
362 $ su -
363 $ cd /usr/src
364 $ mv pgsql pgsql_6_0
365 $ cd /usr/local
366 $ mv pgsql pgsql_6_0
367 $ exit
368 </programlisting>
369 </Para>
370
371 <Para>
372      If you are not using <filename>/usr/local/pgsql/data</filename>
373  as your data directory
374      (check to see if environment variable PGDATA is set to something
375      else) then you will also want to move this directory in the same
376      manner.
377 </Para>
378 </Step>
379
380 <Step Performance="required" id="newdirs">
381 <Para>
382   Make new source and install directories.  The actual paths can be
383      different for your installation but you must be consistent throughout this procedure.
384 </para>
385 <note>
386 <para>
387 There are two places in this installation procedure where you will have an opportunity
388 to specify installation locations for programs, libraries, documentation, and other files.
389 Usually it is sufficient to specify these at the <command>make install</command> stage
390 of installation.
391 </para>
392 </note>
393
394 <para>
395      Type
396 <ProgramListing>
397 $ su
398 $ cd /usr/src
399 $ mkdir pgsql
400 $ chown postgres:postgres pgsql
401 $ cd /usr/local
402 $ mkdir pgsql
403 $ chown postgres:postgres pgsql
404 $ exit
405 </ProgramListing>
406 </Para>
407 </Step>
408
409 <Step Performance="required">
410 <Para>
411  Unzip and untar the new source file.  Type
412 <ProgramListing>
413 $ cd /usr/src/pgsql
414 $ gunzip -c ~/postgresql-v6.4.tar.gz | tar xvf -
415 </ProgramListing>
416 </Para>
417 </Step>
418
419 <Step Performance="required">
420 <Para>
421  Configure the source code for your system.  It is this step at which
422      you can specify your actual installation path for
423      the build process (see the --prefix option below).  Type
424 <ProgramListing>
425 $ cd /usr/src/pgsql/src
426 $ ./configure [ <replaceable>options</replaceable> ]
427 </ProgramListing>
428 </Para>
429
430 <substeps>
431
432 <Step Performance="optional">
433 <Para>
434      Among other chores, the configure script selects a system-specific
435      "template" file from the files provided in the template subdirectory.
436      If it cannot guess which one to use for your system, it will say so and
437      exit.  In that case you'll need to figure out which one to use and run
438      configure again, this time giving the 
439 <option>--with-template=TEMPLATE</option> option to
440      make the right file be chosen.
441
442 <note>
443 <title>Please Report Problems</title>
444
445 <para>
446 If your system is not automatically recognized by configure and you have to do this, please
447      send email to 
448 <ulink url="mailto:scrappy@hub.org">scrappy@hub.org</ulink> with the output of the program
449      <application>./config.guess</application>. Indicate what the template file should be.
450 </para>
451 </note>
452
453 </Para>
454 </step>
455 <Step Performance="optional">
456 <Para>
457 Choose configuration options. Check <xref linkend="config" endterm="install-config">
458 for details. However, for a plain-vanilla first installation with no extra
459 options like multi-byte character support or locale collation support it may
460 be adequate to have chosen the installation areas and to run configure without
461 extra options specified.
462
463      The configure script accepts many additional options that you can use
464      if you don't like the default configuration.  To see them all, type
465 <ProgramListing>
466      ./configure --help
467 </ProgramListing>
468      Some of the more commonly used ones are:
469 <ProgramListing>
470        --prefix=BASEDIR   Selects a different base directory for the
471                           installation of the <ProductName>Postgres</ProductName> configuration.
472                           The default is /usr/local/pgsql.
473        --with-template=TEMPLATE
474                           Use template file TEMPLATE - the template
475                           files are assumed to be in the directory
476                           src/template, so look there for proper values.
477        --with-tcl         Build interface libraries and programs requiring
478                           Tcl/Tk, including libpgtcl, pgtclsh, and pgtksh.
479        --with-perl        Build the Perl interface library.
480        --with-odbc        Build the ODBC driver package.
481        --enable-hba       Enables Host Based Authentication (DEFAULT)
482        --disable-hba      Disables Host Based Authentication
483        --enable-locale    Enables USE_LOCALE
484        --enable-cassert   Enables ASSERT_CHECKING
485        --with-CC=compiler
486                           Use a specific C compiler that the configure
487                           script cannot find.
488        --with-CXX=compiler
489        --without-CXX
490                           Use a specific C++ compiler that the configure
491                           script cannot find, or exclude C++ compilation
492                           altogether.   (This only affects libpq++ at
493                           present.)
494 </ProgramListing>
495 </Para>
496 </step>
497 <Step Performance="required">
498 <Para>
499 Here is the configure script used on a Sparc Solaris 2.5 system
500  with <filename>/opt/postgres</filename> specified as
501  the installation base directory:
502
503 <ProgramListing>
504 $ ./configure --prefix=/opt/postgres \
505     --with-template=sparc_solaris-gcc --with-pgport=5432 \
506     --enable-hba --disable-locale
507 </ProgramListing>
508
509 <tip>
510 <para>
511      Of course, you may type these three lines all
512      on the same line.
513 </para>
514 </tip>
515
516 </Para>
517 </Step>
518
519 </substeps>
520 </step>
521 <Step Performance="required">
522 <Para>
523 Install the <application>man</application> and
524 <acronym>HTML</acronym> documentation. Type
525
526 <ProgramListing>
527 $ cd /usr/src/pgsql/doc
528 $ gmake install
529 </ProgramListing>
530 </para>
531 <para>
532 The documentation is also available in Postscript format. Look for files
533 ending with <filename>.ps.gz</filename> in the same directory.
534 </para>
535 </step>
536 <Step Performance="required">
537 <Para>
538 Compile the program.  Type
539
540 <ProgramListing>
541 $ cd /usr/src/pgsql/src
542 $ gmake all >& make.log &
543 $ tail -f make.log
544 </ProgramListing>
545 </Para>
546
547 <Para>
548      The last line displayed will hopefully be 
549 <programlisting>
550 All of PostgreSQL is successfully made. Ready to install.
551 </programlisting>
552
553   At this point, or earlier
554      if you wish, type control-C to get out of tail.  (If you have
555      problems later on you may wish to examine file make.log for
556      warning and error messages.)
557
558 <note>
559 <para>
560 You will probably find a number of warning
561      messages in make.log.  Unless you have problems later on, these
562      messages may be safely ignored.
563 </para>
564 </note>
565 </para>
566 <Para>
567      If the compiler fails with a message stating that 
568 the <application>flex</application> command
569      cannot be found then install <application>flex</application> as described earlier.
570   Next,
571      change directory back to this directory, type 
572 <programlisting>
573 $ make clean
574 </programlisting>
575 then recompile again.
576 </Para>
577
578 <Para>
579      Compiler options, such as optimization and debugging, may 
580      be specified on the command line using the COPT variable.
581      For example, typing
582 <ProgramListing>
583 $ gmake COPT="-g" all >& make.log &
584 </ProgramListing>
585      would invoke your compiler's <option>-g</option> option in all steps of the
586      build.  See <filename>src/Makefile.global.in</filename> for further details.
587 </Para>
588 </Step>
589
590 <Step Performance="required">
591 <Para>
592  Install the program.  Type
593 <ProgramListing>
594 $ cd /usr/src/pgsql/src
595 $ gmake install >& make.install.log &
596 $ tail -f make.install.log
597 </ProgramListing>
598 </Para>
599
600 <Para>
601      The last line displayed will be 
602 <programlisting>
603 gmake[1]: Leaving directory `/usr/src/pgsql/src/man'
604 </programlisting>
605 At this point, or earlier if you wish,
606      type control-C to get out of tail.
607 </Para>
608 </Step>
609
610 <Step Performance="required">
611 <Para>
612 If necessary, tell your system how to find the new shared libraries.  You can
613 do <emphasis>one</emphasis> of the following, preferably the first:
614 </para>
615 <SubSteps>
616 <Step Performance="optional">
617 <Para>
618        As root, edit file <filename>/etc/ld.so.conf</filename>.  Add a line
619 <programlisting>
620 <FileName>/usr/local/pgsql/lib</FileName>
621 </programlisting>
622 to the file.  Then run command <Command>/sbin/ldconfig</Command>.
623 </Para>
624 </Step>
625
626 <Step Performance="optional">
627 <Para>
628        In a bash shell, type
629 <ProgramListing>
630     export LD_LIBRARY_PATH=/usr/local/pgsql/lib
631 </ProgramListing>
632 </Para>
633 </Step>
634 <Step Performance="optional">
635 <Para>
636        In a csh shell, type
637 <ProgramListing>
638     setenv LD_LIBRARY_PATH /usr/local/pgsql/lib
639 </ProgramListing>
640 </para>
641 </Step>
642 </SubSteps>
643
644 <Para>
645      Please note that the above commands may vary wildly for different
646      operating systems.  Check the platform specific notes, such as
647      those for Ultrix4.x or and for non-ELF Linux.
648 </Para>
649
650 <Para>
651      If, when you create the database, you get the message 
652 <programlisting>
653 pg_id: can't load library 'libpq.so'
654 </programlisting>
655  then the above step was necessary.  Simply
656      do this step, then try to create the database again.
657 </Para>
658 </Step>
659
660    <Step Performance="optional">
661     <Para>
662      If you used the <option>--with-perl</option> option to configure, check
663      the install log to see whether the Perl module was actually installed.
664      If you've followed our advice to make the Postgres files be owned by
665      an unprivileged userid, then the Perl module won't have been installed,
666      for lack of write privileges on the Perl library directories.  You can
667      complete its installation, either now or later, by becoming the user that
668      does own the Perl library (often root) (via <command>su</command>) and doing
669      <ProgramListing>
670       $ cd /usr/src/pgsql/src/interfaces/perl5
671       $ gmake install
672      </ProgramListing>
673     </Para>
674    </Step>
675    
676    <Step Performance="required">
677     <Para>
678      If it has not already been done, then prepare account <literal>postgres</literal>
679      for using <ProductName>Postgres</ProductName>.
680      Any account that will use <ProductName>Postgres</ProductName> must
681      be similarly prepared. 
682     </para>
683     <para>
684      There are several ways to influence the runtime environment of the
685      <ProductName>Postgres</ProductName>
686      server. Refer to the <citetitle>Administrator's Guide</citetitle>
687      for more information.
688      <note>
689       <para>
690        The following instructions are for a
691        bash/sh shell.  Adapt accordingly for other shells.
692       </para>
693      </note>
694     </Para>
695     
696     <substeps>
697      
698      <Step Performance="required">
699       <Para>
700        Add the following lines to your login environment:
701        
702        shell, <filename>~/.bash_profile</filename>:
703        <ProgramListing>
704         PATH=$PATH:/usr/local/pgsql/bin
705         MANPATH=$MANPATH:/usr/local/pgsql/man
706         PGLIB=/usr/local/pgsql/lib
707         PGDATA=/usr/local/pgsql/data
708         export PATH MANPATH PGLIB PGDATA
709        </ProgramListing>
710       </Para>
711      </step>
712      <Step Performance="required">
713       <para>
714        Several regression tests could fail if the user's locale collation
715        scheme is different from that of standard C locale.
716       </para>
717       <para>
718        If you configure and compile <ProductName>Postgres</ProductName>
719        with the <option>--enable-locale</option> option then
720        set locale environment to C (or unset all LC_* variables)
721        by putting these additional lines to your login environment
722        before starting postmaster:
723        <ProgramListing>
724         LC_COLLATE=C
725         LC_CTYPE=C
726         LC_COLLATE=C
727         export LC_COLLATE LC_CTYPE LC_COLLATE
728        </ProgramListing>
729        
730        <ProgramListing>
731         
732        </ProgramListing>
733       </para>
734      </step>
735
736      <Step Performance="required">
737       <Para>
738        Make sure that you have defined these variables before continuing
739        with the remaining steps.  The easiest way to do this is to type:
740        <ProgramListing>
741         $ source ~/.bash_profile
742        </ProgramListing>
743       </Para>
744      </Step>
745      
746     </substeps>
747    </step>
748
749 <Step Performance="required">
750 <Para>
751  Create the database installation from your <ProductName>Postgres</ProductName> 
752 superuser account (typically account <literal>postgres</literal>).
753
754 <Emphasis>Do not do the following as root!</Emphasis>
755 This would be a major security hole.  Type
756 <ProgramListing>
757 $ initdb
758 </ProgramListing>
759 </Para>
760 </Step>
761
762 <Step Performance="required">
763 <Para>
764  Set up permissions to access the database system.  Do this by editing
765      file <filename>/usr/local/pgsql/data/pg_hba.conf</filename>.  The instructions are
766      included in the file.  (If your database is not located in the
767      default location, i.e. if <envar>PGDATA</envar> is set to point elsewhere, then the
768      location of this file will change accordingly.)  This file should be
769      made read only again once you are finished.
770
771      If you are upgrading from v6.0 or later you can copy file <filename>pg_hba.conf</filename> from
772      your old database on top of the one in your new database, rather than
773      redoing the file from scratch.
774 </Para>
775 </Step>
776
777 <Step Performance="required">
778 <para>
779 Briefly test that the backend will start and run by running it from
780 the command line.
781 </para>
782 <substeps>
783
784 <Step Performance="required">
785 <para>
786      Start the postmaster daemon running in the background by typing
787 <ProgramListing>
788 $ cd
789 $ postmaster -i
790 </ProgramListing>
791 </Para>
792 </Step>
793
794 <Step Performance="required">
795 <para>
796 Create a database by typing
797 <ProgramListing>
798 $ createdb
799 </ProgramListing>
800 </para>
801 </step>
802 <Step Performance="required">
803 <para>
804 Connect to the new database:
805 <ProgramListing>
806 $ psql
807 </ProgramListing>
808 </para>
809 </step>
810 <Step Performance="required">
811 <para>
812 And run a sample query:
813 <ProgramListing>
814 postgres=> SELECT datetime 'now';
815 </ProgramListing>
816 </para>
817 </step>
818 <Step Performance="required">
819 <para>
820 Exit <application>psql</application>:
821 <ProgramListing>
822 postgres=> \q
823 </ProgramListing>
824 </para>
825 </step>
826 <Step Performance="required">
827 <para>
828 Remove the test database (unless you will want to use it later for other tests):
829 <ProgramListing>
830 $ destroydb
831 </ProgramListing>
832 </para>
833 </step>
834 </substeps>
835 </step>
836 <Step Performance="required">
837 <Para>
838      Run postmaster in the background from your <ProductName>Postgres</ProductName> 
839 superuser account (typically account <literal>postgres</literal>).
840 <emphasis>Do not run <application>postmaster</application> 
841 from the root account!</emphasis>
842 </para>
843 <Para>
844 Usually, you will want to modify
845      your computer so that it will automatically start postmaster whenever
846     it boots. It is not required; the <ProductName>Postgres</ProductName> 
847 server can
848 be run successfully from non-privileged accounts without root intervention.
849 </para>
850 <para>
851      Here are some suggestions on how to do this, contributed by various
852      users.
853 </para>
854 <para>
855      Whatever you do, postmaster must be run by 
856 the <ProductName>Postgres</ProductName> superuser (<literal>postgres</literal>?)
857 <emphasis>and not by root</emphasis>.
858 This is why all of the examples below start by switching user
859      (su) to postgres.  These commands also take into account the fact
860      that environment variables like PATH and PGDATA may not be set properly.
861
862      The examples are as follows.  Use them with extreme caution.
863
864 <itemizedlist mark="bullet">
865 <listitem>
866 <para>
867 If you are installing from a non-privileged account and have no root access, then
868 start the <application>postmaster</application> and send it to the background:
869
870 <ProgramListing>
871 $ cd
872 $ nohup postmaster > regress.log 2>&1 &
873 </ProgramListing>
874 </para>
875 </listitem>
876 <listitem>
877 <para>
878 Edit file rc.local on NetBSD or file rc2.d on SPARC Solaris
879           2.5.1 to contain the following single line:
880 <programlisting>
881 su postgres -c "/usr/local/pgsql/bin/postmaster -S -D /usr/local/pgsql/data"
882 </programlisting>
883 </para>
884 </listitem>
885
886 <listitem>
887 <para>
888 In FreeBSD 2.2-RELEASE edit /usr/local/etc/rc.d/pgsql.sh to
889           contain the following lines and make it chmod 755 and chown
890           root:bin.
891
892 <programlisting>
893 #!/bin/sh
894 [ -x /usr/local/pgsql/bin/postmaster ] && {
895     su -l pgsql -c 'exec /usr/local/pgsql/bin/postmaster
896         -D/usr/local/pgsql/data
897         -S -o -F > /usr/local/pgsql/errlog' &
898     echo -n ' pgsql'
899 }
900 </programlisting>
901
902           You may put the line breaks as shown above.  The shell is smart
903           enough to keep parsing beyond end-of-line if there is an
904           expression unfinished.  The exec saves one layer of shell under
905           the postmaster process so the parent is init.
906 </para>
907 </listitem>
908
909 <listitem>
910 <para>
911 In RedHat Linux add a file <filename>/etc/rc.d/init.d/postgres.init</filename>
912 which is based on the example in <filename>contrib/linux/</filename>.
913 Then make a softlink to this file from
914  <filename>/etc/rc.d/rc5.d/S98postgres.init</filename>.
915 </para>
916 </listitem>
917
918 <listitem>
919 <para>
920 In RedHat Linux edit file /etc/inittab to add the
921           following as a single line:
922
923 <programlisting>
924 pg:2345:respawn:/bin/su - postgres -c
925     "/usr/local/pgsql/bin/postmaster -D/usr/local/pgsql/data
926     &gt;&gt; /usr/local/pgsql/server.log 2&gt;&1 &lt;/dev/null"
927 </programlisting>
928
929           (The author of this example says this example will revive the
930           postmaster if it dies, but he doesn't know if there are other side
931           effects.)
932 </para>
933 </listitem>
934
935 </itemizedlist>
936
937 </Para>
938 </Step>
939
940 <Step Performance="required">
941 <Para>
942      Run the regression tests.
943      The file <filename>/usr/src/pgsql/src/test/regress/README</filename> has detailed
944      instructions for running and interpreting the regression tests.
945      A short version follows here:
946 </Para>
947
948 <substeps>
949
950 <Step Performance="required">
951 <Para>
952     Type
953 <ProgramListing>
954 $ cd /usr/src/pgsql/src/test/regress
955 $ gmake clean
956 $ gmake all runtest
957 </ProgramListing>
958 </Para>
959
960 <Para>
961      You do not need to type <command>gmake clean</command>
962  if this is the first time you
963      are running the tests.
964 </Para>
965
966 <Para>
967      You should get on the screen (and also written to file <filename>./regress.out</filename>)
968      a series of statements stating which tests passed and which tests
969      failed.  Please note that it can be normal for some tests to
970      "fail" on some platforms.  
971 The script says a test has failed if there is any difference
972      at all between the actual output of the test and the expected output.
973      Thus, tests may "fail" due to minor differences in wording of error
974      messages, small differences in floating-point roundoff, etc, between
975      your system and the regression test reference platform.
976      "Failures" of this type do not indicate a problem with
977      <ProductName>Postgres</ProductName>.
978      The file <filename>./regression.diffs</filename> contains the textual differences between
979      the actual test output on your machine and the "expected" output
980      (which is simply what the reference system produced).  You should
981      carefully examine each difference listed to see whether it appears to
982      be a significant issue.
983 </Para>
984
985 <para>
986 For example,
987
988 <itemizedlist>
989 <listitem>
990 <Para>
991      For a i686/Linux-ELF platform, no tests failed since this is the
992      v6.4 regression testing reference platform.
993 </Para>
994 </listitem>
995
996 <listitem>
997 <Para>
998      For the SPARC/Linux-ELF platform, using the 970525 beta version of
999      <ProductName>Postgres</ProductName> v6.2 the following tests "failed":
1000      float8 and geometry "failed" due to minor precision differences in
1001      floating point numbers.  select_views produces massively different output,
1002      but the differences are due to minor floating point differences.
1003 </Para>
1004 </listitem>
1005
1006 </itemizedlist>
1007 </para>
1008 <Para>
1009      Even if a test result clearly indicates a real failure, it may be a
1010      localized problem that will not affect you.  An example is that the
1011      <type>int8</type> test will fail, producing obviously incorrect output, if your
1012      machine and C compiler do not provide a 64-bit integer data type
1013      (or if they do but configure didn't discover it).  This is not
1014      something to worry about unless you need to store 64-bit integers.
1015 </Para>
1016
1017 <Para>
1018      Conclusion?  If you do see failures, try to understand the nature of
1019      the differences and then decide if those differences will affect your
1020      intended use of <ProductName>Postgres</ProductName>.  The regression
1021      tests are a helpful tool, but they may require some study to be useful.
1022 </Para>
1023
1024 <Para>
1025      After running the regression tests, type
1026
1027 <ProgramListing>
1028 $ destroydb regression
1029 $ cd /usr/src/pgsql/src/test/regress
1030 $ gmake clean
1031 </ProgramListing>
1032
1033     to recover the disk space used for the tests.  (You may want to save
1034     the <filename>regression.diffs</filename> file in another place before doing this.)
1035 </Para>
1036 </Step>
1037
1038 </substeps>
1039 </step>
1040 <Step Performance="required">
1041 <Para>
1042  If you haven't already done so, this would be a good time to modify
1043       your computer to do regular maintainence.  The following should be
1044       done at regular intervals:
1045 </para>
1046 <procedure>
1047 <title>Minimal Backup Procedure</title>
1048
1049 <step performance="required">
1050 <para>
1051 Run the <acronym>SQL</acronym> command <command>VACUUM</command>.  
1052 This will clean up your database.
1053 </para>
1054 </step>
1055 <step performance="required">
1056 <para>
1057 Back up your system.  (You should probably keep the last few
1058            backups on hand.)  Preferably, no one else should be using the
1059            system at the time.
1060 </para>
1061 </step>
1062 </procedure>
1063
1064 <para>
1065       Ideally, the above tasks should be done by a shell script that is
1066       run nightly or weekly by cron.  
1067 Look at the man page for <application>crontab</application>
1068       for a starting point on how to do this.  (If you do it, please
1069       e-mail us a copy of your shell script.  We would like to set up
1070       our own systems to do this too.)
1071 </Para>
1072 </Step>
1073
1074 <Step Performance="required">
1075 <Para>
1076  If you are upgrading an existing system then reinstall your old database.
1077      Type
1078 <ProgramListing>
1079 $ cd
1080 $ psql -e template1 < db.out
1081 </ProgramListing>
1082
1083      If your pre-v6.2 database uses either path or polygon geometric data types,
1084      then you will need to upgrade any columns containing those types. To
1085      do so, type (from within psql)
1086 <ProgramListing>
1087 UPDATE <replaceable>FirstTable</replaceable> SET <replaceable>PathCol</replaceable> = UpgradePath(<replaceable>PathCol</replaceable>);
1088 UPDATE <replaceable>SecondTable</replaceable> SET <replaceable>PathCol</replaceable> = UpgradePath(<replaceable>PathCol</replaceable>);
1089 ...
1090 VACUUM;
1091 </ProgramListing>
1092
1093      UpgradePath() checks to see that a path value is consistant with the
1094      old syntax, and will not update a column which fails that examination.
1095      UpgradePoly() cannot verify that a polygon is in fact from an old
1096      syntax, but RevertPoly() is provided to reverse the effects of a
1097      mis-applied upgrade.
1098 </Para>
1099 </Step>
1100
1101 <Step Performance="required">
1102 <Para>
1103  If you are a new user, you may wish to play with <ProductName>Postgres</ProductName> as described
1104      below.
1105 </Para>
1106 </Step>
1107
1108 <Step Performance="required">
1109 <Para>
1110  Clean up after yourself.  Type
1111 <ProgramListing>
1112 $ rm -rf /usr/src/pgsql_6_0
1113 $ rm -rf /usr/local/pgsql_6_0
1114 # Also delete old database directory tree if it is not in
1115 #  /usr/local/pgsql_6_0/data
1116 $ rm ~/postgresql-v6.2.1.tar.gz
1117 </ProgramListing>
1118 </Para>
1119 </Step>
1120
1121 <Step Performance="required">
1122 <Para>
1123  You will probably want to print out the documentation. If you have
1124 a Postscript printer, or have your machine already set up to accept
1125 Postscript files using a print filter, then to print the User's Guide
1126 simply type
1127
1128 <programlisting>
1129 $ cd /usr/local/pgsql/doc
1130 $ gunzip user.ps.tz | lpr
1131 </programlisting>
1132 </para>
1133 <para>
1134   Here is how
1135      you might do it if you have Ghostscript on your system and are
1136      writing to a laserjet printer.
1137
1138 <programlisting>
1139 $ alias gshp='gs -sDEVICE=laserjet -r300 -dNOPAUSE'
1140 $ export GS_LIB=/usr/share/ghostscript:/usr/share/ghostscript/fonts
1141 $ gunzip user.ps.gz
1142 $ gshp -sOUTPUTFILE=user.hp user.ps
1143 $ gzip user.ps
1144 $ lpr -l -s -r manpage.hp
1145 </programlisting>
1146 </para>
1147 </Step>
1148
1149 <Step Performance="required">
1150 <Para>
1151  The <ProductName>Postgres</ProductName> team wants
1152  to keep <ProductName>Postgres</ProductName> working on all of the
1153      supported platforms.  We therefore ask you to let us know if you did
1154      or did not get <ProductName>Postgres</ProductName> to work on you system.
1155   Please send a
1156      mail message to 
1157 <ulink url="mailto:pgsql-ports@postgresql.org">pgsql-ports@postgresql.org</ulink>
1158  telling us the following:
1159
1160 <itemizedlist>
1161 <listitem>
1162 <para>
1163 The version of <ProductName>Postgres</ProductName> (v6.4, 6.3.2, beta 981014, etc.).
1164 </para>
1165 </listitem>
1166
1167 <listitem>
1168 <para>
1169 Your operating system (i.e. RedHat v5.1 Linux v2.0.34).
1170 </para>
1171 </listitem>
1172
1173 <listitem>
1174 <para>
1175 Your hardware (SPARC, i486, etc.).
1176 </para>
1177 </listitem>
1178
1179 <listitem>
1180 <para>
1181 Did you compile, install and run the regression tests cleanly?
1182          If not, what source code did you change (i.e. patches you
1183          applied, changes you made, etc.), what tests failed, etc.
1184          It is normal to get many warning when you compile.  You do
1185          not need to report these.
1186 </para>
1187 </listitem>
1188
1189 </itemizedlist>
1190
1191 </Para>
1192 </Step>
1193
1194 <Step Performance="required">
1195 <Para>
1196  Now create, access and manipulate databases as desired.  Write client
1197      programs to access the database server.  In other words, <emphasis>enjoy</emphasis>!
1198 </Para>
1199 </Step>
1200 </Procedure>
1201 </sect1>
1202
1203 <Sect1>
1204 <Title>Playing with <ProductName>Postgres</ProductName></Title>
1205
1206 <Para>
1207 After <ProductName>Postgres</ProductName> is installed, a database system is created, a postmaster
1208 daemon is running, and the regression tests have passed, you'll want to 
1209 see <ProductName>Postgres</ProductName> do something.  That's easy.  Invoke the interactive interface
1210 to <ProductName>Postgres</ProductName>, <Application>psql</Application>:
1211
1212 <ProgramListing>
1213 % psql template1
1214 </ProgramListing>
1215
1216 (psql has to open a particular database, but at this point the only one
1217 that exists is the template1 database, which always exists.  We will connect
1218 to it only long enough to create another one and switch to it.)
1219 </Para>
1220
1221 <Para>
1222 The response from psql is:
1223
1224 <ProgramListing>
1225 Welcome to the POSTGRESQL interactive sql monitor:
1226   Please read the file COPYRIGHT for copyright terms of POSTGRESQL
1227
1228    type \? for help on slash commands
1229    type \q to quit
1230    type \g or terminate with semicolon to execute query
1231  You are currently connected to the database: template1
1232
1233 template1=>
1234 </ProgramListing>
1235 </Para>
1236
1237 <Para>
1238 Create the database foo:
1239
1240 <ProgramListing>
1241 template1=> create database foo;
1242 CREATEDB
1243 </ProgramListing>
1244
1245 (Get in the habit of including those SQL semicolons.  Psql won't execute
1246 anything until it sees the semicolon or a "\g" and the semicolon is required
1247 to delimit multiple statements.)
1248 </Para>
1249
1250 <Para>
1251 Now connect to the new database:
1252
1253 <ProgramListing>
1254 template1=> \c foo
1255 connecting to new database: foo
1256 </ProgramListing>
1257
1258 ("slash" commands aren't SQL, so no semicolon.  Use \? to see all the slash commands.)
1259 </Para>
1260
1261 <Para>
1262 And create a table:
1263
1264 <ProgramListing>
1265 foo=> create table bar (i int4, c char(16));
1266 CREATE
1267 </ProgramListing>
1268 </Para>
1269
1270 <Para>
1271 Then inspect the new table:
1272
1273 <ProgramListing>
1274 foo=> \d bar
1275
1276 Table    = bar
1277 +----------------------------------+----------------------------------+-------+
1278 |              Field               |              Type                | Length|
1279 +----------------------------------+----------------------------------+-------+
1280 | i                                | int4                             |     4 |
1281 | c                                | (bp)char                         |    16 |
1282 +----------------------------------+----------------------------------+-------+
1283 </ProgramListing>
1284 </Para>
1285
1286 <Para>
1287 And so on.  You get the idea.
1288 </Para>
1289 </Sect1>
1290
1291 <Sect1>
1292 <Title>The Next Step</Title>
1293
1294 <Para>
1295 Questions? Bugs? Feedback?
1296 First, read the files in directory <filename>/usr/src/pgsql/doc/</filename>.  
1297 The FAQ in this directory may be particularly useful.
1298 </Para>
1299
1300 <Para>
1301 If <ProductName>Postgres</ProductName> failed to compile on your computer 
1302 then fill out the form in file <filename>/usr/src/pgsql/doc/bug.template</filename>
1303  and mail it to the location indicated at the top of the form.
1304 </Para>
1305
1306 <Para>
1307 Check on the web site at
1308 <ULink url="http://www.postgresql.org">http://www.postgresql.org</ULink>
1309 For more information on the various support mailing lists.
1310 </Para>
1311 </Sect1>
1312
1313 <Sect1>
1314 <Title>Porting Notes</Title>
1315
1316 <Note>
1317 <Para>
1318 Check for any platform-specific FAQs in the <filename>doc/</filename> directory of
1319 the source distribution. For some ports, the notes below may be out of date.
1320 </Para>
1321 </Note>
1322
1323   <Sect2>
1324    <Title>Ultrix4.x</Title>
1325    
1326    <para>
1327     <note>
1328      <para>
1329       There have been no recent reports of Ultrix usage with <productname>Postgres</productname>.
1330      </para>
1331     </note>
1332    </para>
1333    <para>
1334     You need to install the libdl-1.1 package since Ultrix 4.x doesn't
1335     have a dynamic loader. It's available in
1336     s2k-ftp.CS.Berkeley.EDU:pub/personal/andrew/libdl-1.1.tar.Z
1337    </Para>
1338   </Sect2>
1339   
1340   <Sect2>
1341    <Title>Linux</Title>
1342    
1343    <Sect3>
1344     <Sect3Info>
1345      <Author>
1346       <FirstName>Thomas G.</FirstName>
1347       <SurName>Lockhart</SurName>
1348      </Author>
1349      <Date>1998-02-19</Date>
1350     </Sect3Info>
1351     <Title>Linux ELF</Title>
1352     
1353     <Para>
1354      The regression test reference machine is
1355      a linux-2.0.30/libc-5.3.12/RedHat-4.2 installation running on a dual processor i686.
1356      The linux-elf port installs cleanly. See the Linux FAQ for more details.
1357     </Para>
1358    </Sect3>
1359
1360 <Sect3>
1361 <Sect3Info>
1362 <Date>1995-05-11</Date>
1363 </Sect3Info>
1364 <Title>Linux a.out</Title>
1365
1366 <Para>
1367         For non-ELF Linux, the dld library MUST be obtained and installed on
1368         the system. It enables dynamic link loading capability to the <ProductName>Postgres</ProductName>
1369         port. The dld library can be obtained from the sunsite linux
1370         distributions. The current name is dld-3.2.5.
1371 <ULink url="sneaker@powergrid.electriciti.com">Jalon Q. Zimmerman</ULink>
1372 </Para>
1373 </Sect3>
1374 </Sect2>
1375
1376 <Sect2>
1377 <Title>BSD/OS</Title>
1378
1379 <Para>
1380         For BSD/OS 2.0 and 2.01, you will need to get the GNU dld library.
1381 </Para>
1382 </Sect2>
1383
1384 <Sect2>
1385 <Title>NeXT</Title>
1386
1387 <Para>
1388         The NeXT port for v1.09 was supplied by 
1389 <ULink url="mailto:tom@basil.icce.rug.nl">Tom R. Hageman</ULink>.
1390         It requires a SysV IPC emulation library and header files for
1391         shared libary and semaphore stuff.   Tom just happens to sell such
1392         a product so contact him for information.  He has also indicated that
1393         binary releases of <ProductName>Postgres</ProductName> for NEXTSTEP will be made available to
1394         the general public.  Contact Info@RnA.nl for information.
1395 </para>
1396 <Para>
1397 We have no recent reports of successful NeXT installations (as of v6.2.1). 
1398 However, the client-side libraries should work even
1399 if the backend is not supported.
1400 </Para>
1401 </Sect2>
1402 </Sect1>
1403
1404 </Chapter>