📄 install.sgml
字号:
<Chapter Id="install"> <Title>Installation</Title> <Abstract> <Para> Complete installation instructions for <ProductName>Postgres</ProductName> v6.5.1. </Para> </Abstract> <Para> Before installing <ProductName>Postgres</ProductName>, you may wish to visit <ULink url="http://www.postgresql.org">www.postgresql.org</ULink> for up to date information, patches, etc. </Para> <Para> These installation instructions assume: <ItemizedList Mark="bullet" Spacing="compact"> <ListItem> <Para> Commands are Unix-compatible. See note below. </Para> </ListItem> <ListItem> <Para> Defaults are used except where noted. </Para> </ListItem> <ListItem> <Para> User <literal>postgres</literal> is the <ProductName>Postgres</ProductName> superuser. </Para> </ListItem> <ListItem> <Para> The source path is <filename>/usr/src/pgsql</filename> (other paths are possible). </Para> </ListItem> <ListItem> <Para> The runtime path is <filename>/usr/local/pgsql</filename> (other paths are possible). </Para> </ListItem> </ItemizedList> </para> <Para> Commands were tested on RedHat Linux version 5.2 using the tcsh shell. Except where noted, they will probably work on most systems. Commands like <command>ps</command> and <command>tar</command> may vary wildly between platforms on what options you should use. <Emphasis>Use common sense</Emphasis> before typing in these commands. </Para> <Para> Our Makefiles require GNU <Application>make</Application> (called <Quote>gmake</Quote> in this document). They will <Emphasis>not</Emphasis> work with non-GNU <Application>make</Application> programs. If you have GNU <Application>make</Application> installed under the name <Quote>make</Quote> instead of <Quote>gmake</Quote>, then you will use the command <command>make</command> instead. That's OK, but you need to have the GNU form of <Application>make</Application> to succeed with an installation. </Para> <Sect1> <Title>Requirements to Run <ProductName>Postgres</ProductName></Title> <Para> Up to date information on supported platforms is at <ulink url="http://www.postgresql.org/docs/admin/install.htm"> http://www.postgresql.org/docs/admin/install.htm</ulink>. In general, most Unix-compatible platforms with modern libraries should be able to run <ProductName>Postgres</ProductName>. </para> <para> Although the minimum required memory for running <ProductName>Postgres</ProductName> is as little as 8MB, there are noticable improvements in runtimes for the regression tests when expanding memory up to 96MB on a relatively fast dual-processor system running X-Windows. The rule is you can never have too much memory. </para> <Para> Check that you have sufficient disk space. You will need about 30 Mbytes for <filename>/usr/src/pgsql</filename>, about 5 Mbytes for <filename>/usr/local/pgsql</filename> (excluding your database) and 1 Mbyte for an empty database. The database will temporarily grow to about 20 Mbytes during the regression tests. You will also need about 3 Mbytes for the distribution tar file. </Para> <Para> We therefore recommend that during installation and testing you have well over 20 Mbytes free under <filename>/usr/local</filename> and another 25 Mbytes free on the disk partition containing your database. Once you delete the source files, tar file and regression database, you will need 2 Mbytes for <filename>/usr/local/pgsql</filename>, 1 Mbyte for the empty database, plus about five times the space you would require to store your database data in a flat file. </Para> <Para> To check for disk space, use <programlisting>$ df -k </programlisting> </para> </Sect1><Sect1><Title>Installation Procedure</Title><Procedure><Title><ProductName>Postgres</ProductName> Installation</Title><Para>For a fresh install or upgrading from previous releases of<ProductName>Postgres</ProductName>:</Para><Step Performance="required"><Para>Read any last minute information and platform specific porting notes. There are some platform specific notes at the end of this file for Ultrix4.x, Linux, BSD/OS and NeXT. There are other files in directory <FileName>/usr/src/pgsql/doc</FileName>, including files FAQ-Irix and FAQ-Linux. Also look in directory<ULink url="ftp://ftp.postgresql.org/pub">ftp://ftp.postgresql.org/pub</ULink>. If there is a file called INSTALL in this directory then this file will contain the latest installation information.</Para><Para> Please note that a "tested" platform in the list given earlier simply means that someone went to the effort at some point of making sure that a <ProductName>Postgres</ProductName> distribution would compile and run on this platform without modifying the code. Since the current developers will not have access to all of these platforms, some of them may not compile cleanly and pass the regression tests in the current release due to minor problems. Any such known problems and their solutions will be posted in <ULink url="ftp://ftp.postgresql.org/pub/INSTALL">ftp://ftp.postgresql.org/pub/INSTALL</ULink>.</Para></Step><Step Performance="optional"><Para>Create the <ProductName>Postgres</ProductName> superuser account(<literal>postgres</literal> is commonly used) if it does not already exist.</para><para>The owner of the Postgres files can be any unprivileged user account.It <emphasis>must not</emphasis> be <literal>root</literal>, <literal>bin</literal>,or any other account with special access rights, as that would create a security risk.</para></Step><Step Performance="required"><Para>Log in to the <ProductName>Postgres</ProductName> superuser account. Most of theremaining steps in the installation will happen in this account.</para></step><Step Performance="required"><Para>Ftp file <ulink url="ftp://ftp.postgresql.org/pub/postgresql-v6.5.1.tar.gz"> <filename>ftp://ftp.postgresql.org/pub/postgresql-v6.5.1.tar.gz</filename></ulink> from the Internet. Store it in your home directory.</Para></Step><Step Performance="required"><Para>Some platforms use <application>flex</application>. If your system uses <application>flex</application> then make sure you have a good version. To check, type <programlisting>$ flex --version</programlisting></Para><Para> If the <application>flex</application> command is not found then you probably do not need it. If the version is 2.5.2 or 2.5.4 or greater then you are okay. If it is 2.5.3 or before 2.5.2 then you will have to upgrade <application>flex</application>. You may get it at <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>.</Para><Para> If you need <application>flex</application> and don't have it or have the wrong version, then you will be told so when you attempt to compile the program. Feel free to skip this step if you aren't sure you need it. If you do need it then you will be told to install/upgrade <application>flex</application> when you try to compile <productname>Postgres</productname>.</Para><Para>You may want to do the entire <application>flex</application> installation fromthe root account, though that is not absolutely necessary.Assuming that you want the installation to place files in the usual defaultareas, type the following:<ProgramListing>$ su -$ cd /usr/local/srcftp prep.ai.mit.eduftp> cd /pub/gnu/ftp> binaryftp> get flex-2.5.4.tar.gzftp> quit$ gunzip -c flex-2.5.4.tar.gz | tar xvf -$ cd flex-2.5.4$ configure --prefix=/usr$ gmake$ gmake check# You must be root when typing the next line:$ gmake install$ cd /usr/local/src$ rm -rf flex-2.5.4</ProgramListing></Para><Para> This will update files <filename>/usr/man/man1/flex.1</filename>, <filename>/usr/bin/flex</filename>, <filename>/usr/lib/libfl.a</filename>, <filename>/usr/include/FlexLexer.h</filename> and will add a link <filename>/usr/bin/flex++</filename> which points to flex.</Para></Step><Step Performance="required"><Para>If you are not upgrading an existing system then skip to <xref linkend="newdirs">.If you are upgrading from 6.5, you do not need to dump/reload or initdb.Simply compile the source code, stop the postmaster, do a "make install", andrestart the postmaster.If you are upgrading from 6.4.* or earlier, back up your database. For alpha- and beta-level releases, the database format is liable to change, often every few weeks, with no notice besides a quick comment in the HACKERS mailing list. Full releases always require a dump/reload from previous releases. It is therefore a bad idea to skip this step. </para><tip><para>Do not use the <application>pg_dumpall</application> script from v6.0 or everything will be owned by the <ProductName>Postgres</ProductName> super user.</para></tip><para>To dump your fairly recent post-v6.0 database installation, type<programlisting>$ pg_dumpall > db.out</programlisting></para><para>To use the latest <application>pg_dumpall</application> script on yourexisting older database before upgrading <productname>Postgres</productname>,pull the most recent version of <application>pg_dumpall</application>from the new distribution:<ProgramListing>$ cd$ gunzip -c postgresql-v6.5.1.tar.gz \ | tar xvf - src/bin/pg_dump/pg_dumpall$ chmod a+x src/bin/pg_dump/pg_dumpall$ src/bin/pg_dump/pg_dumpall > db.out$ rm -rf src</ProgramListing></Para><Para> If you wish to preserve object id's (oids), then use the -o option when running <application>pg_dumpall</application>. However, unless you have a special reason for doing this (such as using OIDs as keysin tables), don't do it.</Para><Para> If the <application>pg_dumpall</application> command seems to take a long time and you think it might have died, then, from another terminal, type<programlisting>$ ls -l db.out</programlisting> several times to see if the size of the file is growing.</Para><Para> Please note that if you are upgrading from a version prior to <ProductName>Postgres95</ProductName> v1.09 then you must back up your database, install <ProductName>Postgres95</ProductName> v1.09, restore your database, then back it up again. You should also read the release notes which should cover any release-specific issues.</Para><caution><Para> You must make sure that your database is not updated in the middle of your backup. If necessary, bring down postmaster, edit the permissions in file <filename>/usr/local/pgsql/data/pg_hba.conf</filename> to allow only you on, then bring <application>postmaster</application> back up.</Para></caution></Step><Step Performance="required"><Para>If you are upgrading an existing system then kill the postmaster. Type<ProgramListing>$ ps -ax | grep postmaster</ProgramListing> This should list the process numbers for a number of processes. Type the following line, with <replaceable>pid</replaceable> replaced by the process id for process <literal>postmaster</literal>. (Do not use the id for process "grep postmaster".) Type<programlisting>$ kill <replaceable>pid</replaceable></programlisting>to actually stop the process.<tip><para>On systems which have <productname>Postgres</productname> started at boot time, thereis probably a startup file which will accomplish the same thing. For example, on myLinux system I can type<programlisting>$ /etc/rc.d/init.d/postgres.init stop</programlisting>to halt <productname>Postgres</productname>.</para></tip></Para></Step><Step Performance="required"><Para>If you are upgrading an existing system then move the old directories out of the way. If you are short of disk space then you may have to back up and delete the directories instead. If you do this, save the old database in the <filename>/usr/local/pgsql/data</filename> directory tree. At a minimum, save file <filename>/usr/local/pgsql/data/pg_hba.conf</filename>.</Para><Para> Type the following:<programlisting>$ su -$ cd /usr/src$ mv pgsql pgsql_6_0$ cd /usr/local$ mv pgsql pgsql_6_0$ exit</programlisting></Para><Para> If you are not using <filename>/usr/local/pgsql/data</filename> as your data directory (check to see if environment variable PGDATA is set to something else) then you will also want to move this directory in the same manner.</Para></Step><Step Performance="required" id="newdirs"><Para> Make new source and install directories. The actual paths can be different for your installation but you must be consistent throughout this procedure.</para><note><para>There are two places in this installation procedure where you will have an opportunityto specify installation locations for programs, libraries, documentation, and other files.Usually it is sufficient to specify these at the <command>gmake install</command> stageof installation.</para></note><para> Type<ProgramListing>$ su$ cd /usr/src$ mkdir pgsql$ chown postgres:postgres pgsql$ cd /usr/local$ mkdir pgsql$ chown postgres:postgres pgsql$ exit</ProgramListing></Para></Step><Step Performance="required"><Para> Unzip and untar the new source file. Type<ProgramListing>$ cd /usr/src/pgsql$ gunzip -c ~/postgresql-v6.5.1.tar.gz | tar xvf -</ProgramListing></Para></Step><Step Performance="required"><Para> Configure the source code for your system. It is this step at which you can specify your actual installation path for the build process (see the --prefix option below). Type<ProgramListing>$ cd /usr/src/pgsql/src$ ./configure [ <replaceable>options</replaceable> ]</ProgramListing></Para><substeps><Step Performance="optional"><Para> Among other chores, the configure script selects a system-specific "template" file from the files provided in the template subdirectory. If it cannot guess which one to use for your system, it will say so and exit. In that case you'll need to figure out which one to use and run configure again, this time giving the <option>--with-template=TEMPLATE</option> option to make the right file be chosen.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -