Changeset 8753831e for server


Ignore:
Timestamp:
02/13/2018 09:34:53 AM (6 years ago)
Author:
Pierre Labastie <pieere@…>
Branches:
10.0, 10.1, 11.0, 11.1, 11.2, 11.3, 12.0, 12.1, 8.2, 8.3, 8.4, 9.0, 9.1, basic, bdubbs/svn, elogind, kea, ken/TL2024, ken/inkscape-core-mods, ken/tuningfonts, lazarus, lxqt, perl-modules, plabs/newcss, plabs/python-mods, python3.11, qt5new, rahul/power-profiles-daemon, renodr/vulkan-addition, trunk, upgradedb, xry111/intltool, xry111/llvm18, xry111/soup3, xry111/test-20220226, xry111/xf86-video-removal
Children:
e43e647
Parents:
8b28cb4a
Message:

Some refactoring of postgresql page. If you don't like it, please revert.

  • avoid testing the installation in the "install" section
  • move user creation at the beginning, as we do for other packages
  • make jhalfs happier

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@19759 af4574ff-66df-0310-9fd7-8a98e5e911e0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/databases/postgresql.xml

    r8b28cb4a r8753831e  
    8888    <title>Installation of PostgreSQL</title>
    8989
     90    <para>
     91      For enhanced security, it is better to have a dedicated group and user
     92      for running the PostgreSQL server. First, issue as the
     93      <systemitem class="username">root</systemitem> user:
     94    </para>
     95
     96<screen role="root"><userinput>groupadd -g 41 postgres &amp;&amp;
     97useradd -c "PostgreSQL Server" -g postgres -d /srv/pgsql/data \
     98        -u 41 postgres</userinput></screen>
     99
    90100    <para>Install <application>PostgreSQL</application> with the
    91101    following commands: </para>
     
    109119    you need to stop all PostgreSQL servers if any are running. If a previous
    110120    version of PostgreSQL is installed, it may be necessary to use
    111     <emphasis>--disable-rpath</emphasis> with <emphasis>configure</emphasis> to
    112     avoid failures, but <command>installing the binaries created using this
    113     switch is not recommended</command>. To test the results, issue:
     121    <command>--disable-rpath</command> with <command>configure</command> to
     122    avoid failures, but <emphasis>installing the binaries created using this
     123    switch is not recommended</emphasis>. To test the results, issue:
    114124    <command>make check</command>.</para>
    115125
     
    143153<screen role="root"><userinput>install -v -dm700 /srv/pgsql/data &amp;&amp;
    144154install -v -dm755 /run/postgresql &amp;&amp;
    145 
    146 groupadd -g 41 postgres &amp;&amp;
    147 useradd -c "PostgreSQL Server" -g postgres -d /srv/pgsql/data \
    148         -u 41 postgres &amp;&amp;
    149 
    150155chown -Rv postgres:postgres /srv/pgsql /run/postgresql</userinput></screen>
    151156
     
    155160<screen role="root"><userinput>su - postgres -c '/usr/bin/initdb -D /srv/pgsql/data'</userinput></screen>
    156161
    157     <para>Again as the <systemitem class="username">root</systemitem> user,
    158     start the database server with the following command:</para>
     162  </sect2>
     163
     164  <sect2 role="commands">
     165    <title>Command Explanations</title>
     166
     167    <para>
     168      <command>sed -i ...</command>: This sed changes server socket location
     169      from <filename class="directory">/tmp</filename> to
     170      <filename class="directory">/run/postgresql</filename><!-- and fix up the
     171      regression tests to use <filename class="directory">/tmp</filename> so
     172      that they can work reliably-->.
     173    </para>
     174
     175    <para><parameter>--docdir=/usr/share/doc/postgresql-&postgresql-version;</parameter>:
     176    This switch puts the documentation in a versioned directory.</para>
     177
     178    <para><parameter>--enable-thread-safety</parameter>: This switch makes the
     179    client libraries thread-safe by allowing concurrent threads in
     180    <filename class="libraryfile">libpq</filename> and ECPG programs to safely
     181    control their private connection handles.</para>
     182
     183    <para><option>--with-openssl</option>: builds the package  with support for
     184    <application>OpenSSL</application> encrypted connections.</para>
     185
     186    <para><option>--with-perl</option>: builds the PL/Perl server-side language.
     187    </para>
     188
     189    <para><option>--with-python</option>: builds the PL/Python server-side
     190    language. Add PYTHON=/usr/bin/python3 for Python3 support.</para>
     191
     192    <para><option>--with-tcl</option>: builds the PL/Tcl server-side language.</para>
     193
     194  </sect2>
     195
     196  <sect2 role="configuration">
     197    <title>Configuring PostgreSQL</title>
     198
     199    <sect3 id="postgresql-config">
     200      <title>Config Files</title>
     201
     202      <para><filename>$PGDATA/pg_ident.con</filename>,
     203      <filename>$PGDATA/pg_hba.conf</filename> and
     204      <filename>$PGDATA/postgresql.conf</filename></para>
     205
     206      <indexterm zone="postgresql postgresql-config">
     207        <primary sortas="e-A.PGDATA-pg_ident.con">$PGDATA/pg_indent.con</primary>
     208      </indexterm>
     209
     210      <indexterm zone="postgresql postgresql-config">
     211        <primary sortas="e-A.PGDATA-pg_hba.conf">$PGDATA/pg_hba_conf</primary>
     212      </indexterm>
     213
     214      <indexterm zone="postgresql postgresql-config">
     215        <primary sortas="e-A.PGDATA-postgresql.conf">$PGDATA/postgresql.conf</primary>
     216      </indexterm>
     217
     218      <para>The <envar>PGDATA</envar> environment variable is used to
     219      distinguish database clusters from one another by setting it to
     220      the value of the directory which contains the cluster desired.
     221      The three configuration files exist in every <filename
     222      class="directory">PGDATA/</filename> directory. Details on the
     223      format of the files and the options that can be set in each can
     224      be found in <ulink
     225      url="file:///usr/share/doc/postgresql-&postgresql-version;/html/index.html"/>.</para>
     226
     227    </sect3>
     228
     229    <sect3  id="postgresql-init">
     230      <title><phrase revision="sysv">Boot Script</phrase>
     231             <phrase revision="systemd">Systemd Unit</phrase></title>
     232
     233      <para>Install the
     234      <phrase revision="sysv"><filename>/etc/rc.d/init.d/postgresql</filename>
     235      init script</phrase>
     236      <phrase revision="systemd"><filename>postgresql.service</filename>
     237      unit</phrase> included in the
     238      <xref linkend="bootscripts" revision="sysv"/>
     239      <xref linkend="systemd-units" revision="systemd"/> package.</para>
     240
     241      <indexterm zone="postgresql postgresql-init">
     242        <primary sortas="f-postgresql">postgresql</primary>
     243      </indexterm>
     244
     245<screen role="root"><userinput>make install-postgresql</userinput></screen>
     246
     247    </sect3>
     248
     249    <sect3>
     250      <title>Starting the PostgreSQL Server and Creating a Sample Database</title>
     251
     252      <para>
     253        The database server can be manually started with the following command
     254        (as the <systemitem class="username">root</systemitem> user):
     255      </para>
    159256
    160257<screen role="root"><userinput>su - postgres -c '/usr/bin/postgres -D /srv/pgsql/data > \
    161258                  /srv/pgsql/data/logfile 2&gt;&amp;1 &amp;'</userinput></screen>
    162 
    163     <para>Still as user <systemitem class="username">root</systemitem>, create
    164     a database and verify the installation:</para>
     259      <note>
     260        <para>
     261          If you are scripting this part, you should wait for the server to
     262          start before going on, by adding for example
     263          <command>sleep 2</command> after the above command.
     264        </para>
     265      </note>
     266
     267      <para>
     268        The instructions below show how to create a database, add a table to
     269        it, insert some rows into the table and select them, to verify that the
     270        installation is working properly. Still as user <systemitem
     271        class="username">root</systemitem>, issue:
     272      </para>
    165273
    166274<screen role="root"><userinput>su - postgres -c '/usr/bin/createdb test' &amp;&amp;
     
    175283echo "select * from t1;" | (su - postgres -c '/usr/bin/psql test')</userinput></screen>
    176284
    177     <para>To shut down the server, as <systemitem
    178     class="username">root</systemitem>:</para>
     285      <para>
     286        When you are done with testing, you can shut down the server, by issuing
     287        as <systemitem class="username">root</systemitem>:
     288      </para>
    179289
    180290<screen role="root"><userinput>su - postgres -c "/usr/bin/pg_ctl stop -D /srv/pgsql/data"</userinput></screen>
    181 
    182   </sect2>
    183 
    184   <sect2 role="commands">
    185     <title>Command Explanations</title>
    186 
    187     <para>
    188       <command>sed -i ...</command>: This sed changes server socket location
    189       from <filename class="directory">/tmp</filename> to
    190       <filename class="directory">/run/postgresql</filename><!-- and fix up the
    191       regression tests to use <filename class="directory">/tmp</filename> so
    192       that they can work reliably-->.
    193     </para>
    194 
    195     <para><parameter>--docdir=/usr/share/doc/postgresql-&postgresql-version;</parameter>:
    196     This switch puts the documentation in a versioned directory.</para>
    197 
    198     <para><parameter>--enable-thread-safety</parameter>: This switch makes the
    199     client libraries thread-safe by allowing concurrent threads in
    200     <filename class="libraryfile">libpq</filename> and ECPG programs to safely
    201     control their private connection handles.</para>
    202 
    203     <para><option>--with-openssl</option>: builds the package  with support for
    204     <application>OpenSSL</application> encrypted connections.</para>
    205 
    206     <para><option>--with-perl</option>: builds the PL/Perl server-side language.
    207     </para>
    208 
    209     <para><option>--with-python</option>: builds the PL/Python server-side
    210     language. Add PYTHON=/usr/bin/python3 for Python3 support.</para>
    211 
    212     <para><option>--with-tcl</option>: builds the PL/Tcl server-side language.</para>
    213 
    214     <para><command>groupadd ...</command>; <command>useradd ...</command>:
    215     These commands add an unprivileged user and group to run the database
    216     server.</para>
    217 
    218     <para><command>createdb test; create table t1; insert into t1 values...;
    219     select * from t1</command>: Create a database, add a table to it, insert
    220     some rows into the table and select them to verify that the installation
    221     is working properly.</para>
    222 
    223   </sect2>
    224 
    225   <sect2 role="configuration">
    226     <title>Configuring PostgreSQL</title>
    227 
    228     <sect3 id="postgresql-config">
    229       <title>Config Files</title>
    230 
    231       <para><filename>$PGDATA/pg_ident.con</filename>,
    232       <filename>$PGDATA/pg_hba.conf</filename> and
    233       <filename>$PGDATA/postgresql.conf</filename></para>
    234 
    235       <indexterm zone="postgresql postgresql-config">
    236         <primary sortas="e-A.PGDATA-pg_ident.con">$PGDATA/pg_indent.con</primary>
    237       </indexterm>
    238 
    239       <indexterm zone="postgresql postgresql-config">
    240         <primary sortas="e-A.PGDATA-pg_hba.conf">$PGDATA/pg_hba_conf</primary>
    241       </indexterm>
    242 
    243       <indexterm zone="postgresql postgresql-config">
    244         <primary sortas="e-A.PGDATA-postgresql.conf">$PGDATA/postgresql.conf</primary>
    245       </indexterm>
    246 
    247       <para>The <envar>PGDATA</envar> environment variable is used to
    248       distinguish database clusters from one another by setting it to
    249       the value of the directory which contains the cluster desired.
    250       The three configuration files exist in every <filename
    251       class="directory">PGDATA/</filename> directory. Details on the
    252       format of the files and the options that can be set in each can
    253       be found in <ulink
    254       url="file:///usr/share/doc/postgresql-&postgresql-version;/html/index.html"/>.</para>
    255 
    256     </sect3>
    257 
    258     <sect3  id="postgresql-init">
    259       <title><phrase revision="sysv">Boot Script</phrase>
    260              <phrase revision="systemd">Systemd Unit</phrase></title>
    261 
    262       <para>Install the
    263       <phrase revision="sysv"><filename>/etc/rc.d/init.d/postgresql</filename>
    264       init script</phrase>
    265       <phrase revision="systemd"><filename>postgresql.service</filename>
    266       unit</phrase> included in the
    267       <xref linkend="bootscripts" revision="sysv"/>
    268       <xref linkend="systemd-units" revision="systemd"/> package.</para>
    269 
    270       <indexterm zone="postgresql postgresql-init">
    271         <primary sortas="f-postgresql">postgresql</primary>
    272       </indexterm>
    273 
    274 <screen role="root"><userinput>make install-postgresql</userinput></screen>
    275291
    276292    </sect3>
Note: See TracChangeset for help on using the changeset viewer.