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