<!-- doc/src/sgml/installation-rpm.sgml -->

 <sect1 id="install-rpm">
 <title>Installation from RPM</title>
 <para>
  This chapter describes the installation of <productname>Pgpool-II</productname> from RPM.
  If you are going to install from the source code, please check <xref linkend="install-source">.
 </para>
 <para>
  <productname>Pgpool-II</productname> community provides RPM packages for RHEL10/9/8
  and the operating system which is compatible with RHEL.
  You can download package files from
  <ulink url="https://www.pgpool.net/yum/">official Pgpool-II repository</ulink>.
 </para>
 <para>
   <productname>Pgpool-II</productname> official repository contains the following packages:
 </para>
 <table id="rpm-packages">
  <title>Pgpool-II RPM Packages</title>
  <tgroup cols="2">
   <thead>
    <row>
     <entry>Package</entry>
     <entry>Description</entry>
    </row>
   </thead>
   <tbody>
    <row>
     <entry>pgpool-II-pgXX</entry>
     <entry>Libraries and binaries required to run Pgpool-II</entry>
    </row>
    <row>
     <entry>pgpool-II-pgXX-extensions</entry>
     <entry>This package must be installed on all PostgreSQL servers to use online recovery functionality</entry>
    </row>
    <row>
     <entry>pgpool-II-pgXX-debuginfo</entry>
     <entry>Debug symbols for debugging</entry>
    </row>
    <row>
     <entry>pgpool-II-pgXX-debugsource</entry>
     <entry>Only for RHEL10/9/8. Debug symbols for debugging</entry>
    </row>
    <row>
     <entry>pgpool-II-pgXX-extensions-debuginfo</entry>
     <entry>Only for RHEL10/9/8. Debug symbols for debugging</entry>
    </row>
    <row>
     <entry>pgpool-II-pgXX-devel</entry>
     <entry>Header files for developers</entry>
    </row>
   </tbody>
  </tgroup>
 </table>

 <para>
  <productname>Pgpool-II</productname> needs <productname>PostgreSQL</productname>'s
  library and extensions directory. Since the directory paths are different in
  the particular <productname>PostgreSQL</productname> versions,
  <productname>Pgpool-II</productname> provides separate packages for each PostgreSQL version.
  "XX" in the above package is a two-digit number representing the version of PostgreSQL.
  Choose <productname>Pgpool-II</productname> RPM corresponding to your PostgreSQL version.
  (For example, if you are using PostgreSQL 18, you need to install <filename>pgpool-II-pg18</filename>)
 </para>

 <sect2 id="before-installing">
  <title>Before Installing</title>
  <para>
   Since <productname>Pgpool-II</productname> related packages are also included in
   <productname>PostgreSQL</productname> YUM repository,
   if PostgreSQL repository package is already installed,
   add the "exclude" settings to <filename>/etc/yum.repos.d/pgdg-redhat-all.repo</filename>,
   so that <productname>Pgpool-II</productname> will not be installed from
   <productname>PostgreSQL</productname> YUM repository.
   If <productname>Pgpool-II</productname> and <productname>PostgreSQL</productname>
   are installed on separate servers, you can skip this section.
  </para>
  <programlisting>
vi /etc/yum.repos.d/pgdg-redhat-all.repo
  </programlisting>
  <para>
   The following is a setting example of <filename>/etc/yum.repos.d/pgdg-redhat-all.repo</filename>.
  </para>
  <programlisting>
[pgdg-common]
...
exclude=pgpool*

[pgdg18]
...
exclude=pgpool*

[pgdg17]
...
exclude=pgpool*

[pgdg16]
...
exclude=pgpool*

[pgdg15]
...
exclude=pgpool*

[pgdg14]
...
exclude=pgpool*

[pgdg13]
...
exclude=pgpool*
  </programlisting>
 </sect2>

 <sect2 id="installing-rpm">
  <title>Installing RPM</title>
  <para>
   Here we install <productname>Pgpool-II</productname> using
   <ulink url="https://www.pgpool.net/yum">Pgpool-II official YUM repository</ulink>.
  </para>

  <para>
   The following commands assume that you are using Pgpool-II 4.7.x for PostgreSQL 18 on RHEL10.
   If you are using other versions, replace "pgXX" with your PostgreSQL version.
  </para>
  <para>
   First, install the repository corresponding to your <productname>Pgpool-II</productname>
   version and distribution.
   For REHL9/8, see <ulink url="https://www.pgpool.net/mediawiki/index.php/Yum_Repository">here</ulink>.
  </para>
  <programlisting>
dnf install https://www.pgpool.net/yum/rpms/4.7/redhat/rhel-10-x86_64/pgpool-II-release-4.7-1.noarch.rpm
  </programlisting>
  <para>
   To install <productname>Pgpool-II</productname> on Rocky Linux 10, you need to enable the EPEL repository and install libmemcached-awesome-devel to satisfy dependencies.
   Before installing <productname>Pgpool-II</productname>, run the following commands.
  </para>
  <programlisting>
dnf install epel-release
dnf install libmemcached-awesome-devel
  </programlisting>
  <para>
   Then, install <productname>Pgpool-II</productname>.
  </para>
  <programlisting>
dnf install pgpool-II-pg18
  </programlisting>
  <para>
   To use online recovery feature, install <filename>pgpool-II-pg18-extensions</filename>
   on <emphasis>all PostgreSQL servers</emphasis>.
   Because <filename>pgpool-II-pgXX-extensions</filename> depends on
   <filename>pgpool-II-pgXX</filename> package,
   if <productname>Pgpool-II</productname> and <productname>PostgreSQL</productname>
   are installed on separate servers, <filename>pgpool-II-pgXX</filename> also need to be installed
   on PostgreSQL servers.
  </para>
  <note>
   <para>
    <filename>pgpool-II-pgXX-extensions</filename> needs to be installed
    <emphasis>on the PostgreSQL servers</emphasis>.
    If <productname>Pgpool-II</productname> and <productname>PostgreSQL</productname>
    are installed on separate servers,
    it is not required to install it on the servers where <productname>Pgpool-II</productname> are running.
   </para>
  </note>
  <programlisting>
dnf install pgpool-II-pg18-extensions pgpool-II-pg18
  </programlisting>

  <para>
   Optionally you can install debuginfo and devel packages for developers if necessary.
  </para>
  <programlisting>
dnf install pgpool-II-pg18-debuginfo pgpool-II-pg18-devel
  </programlisting>
 </sect2>

 <sect2 id="configure-rpm">
  <title>Configuration Pgpool-II</title>
  <para>
   All the <productname>Pgpool-II</productname> configuration files
   are installed in <filename>/etc/pgpool-II</filename>. Please refer
   to <xref linkend="configuring-pgpool"> to see how to set up
    configuration files.
  </para>
 </sect2>

 <sect2 id="start-rpm">
  <title>Starting/stopping Pgpool-II</title>
  <para>
   On RHEL10/9/8, do this once, if set the automatic startup of <productname>Pgpool-II</productname>.
   <programlisting>
systemctl enable pgpool.service
   </programlisting>

   After this, to start <productname>Pgpool-II</productname>,
   run the following command or restart the whole system.
   Please note that PostgreSQL servers must have been started before this. 

   <programlisting>
systemctl start pgpool.service 
   </programlisting>

   To stop <productname>Pgpool-II</productname>, do this once.
   Please note that <productname>Pgpool-II</productname> must be stopped
   before stopping <productname>PostgreSQL</productname>.
   <programlisting>
systemctl stop pgpool.service 
   </programlisting>

   After this, you can stop <productname>PostgreSQL</productname>
   servers.
  </para>
 </sect2>
</sect1>
