Installing the software

Follow these steps to install PostgreSQL, Patroni, etcd, and HAProxy for the HA setup.

Procedure

  • Install the PostgreSQL database by using YUM repository:
    1. Optional: If you install the PostgreSQL binary files, create user postgres. If you install by using YUM repository, skip this step.

      For more information about creating users, see Managing Users via Command-Line Tools.

    2. Configure the YUM repository:
      yum -y install 
      https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
    3. Install PostgreSQL by using the following command:
      dnf -y install postgresql12 postgresql12-server
  • Install Patroni by using the following steps:
    1. Install Python and Python pip and other dependencies by using the following command:
      yum install -y gcc python-devel python2-pip

      For more information, see Installing pip/setuptools/wheel with Linux Package Managers

    2. Install Patroni and supporting libraries by using Python pip.
      
      pip install --upgrade setuptools
      pip install psycopg2-binary
      pip install patroni
      pip install python-etcd
      
      For more information, see Patroni- Technical Requirements/Installation.
    3. Enable Patroni as service by using the following steps:
      1. Create system file for patroni Service with the following command:
        vi /etc/systemd/system/patroni.service
      2. Add the following lines:
        
        [Unit]
        Description=Patroni
        After=syslog.target network.target
        [Service]
        Type=simple
        User=postgres
        Group=postgres
        ExecStart=/bin/patroni <path>/patroni.yml
        KillMode=process
        TimeoutSec=30
        Restart=no
        [Install]
        WantedBy=multi-user.target

        <path> is location of the patroni_config.yaml file.

  • Install etcd with the following steps:
    1. Download etcd binary files from the following link:
    2. Extract archive with the following command:
      tar -xvf etcd-v2.2.5-linux-amd64.tar.gz
    3. Move the etcd and etcdctl binary files with the following command:
      mv etcd etcdctl  /usr/local/bin
    4. Enable etcd service with the following steps:
      1. Create data directory for etcd with the following command:
        mkdir -p /var/lib/etcd && mkdir -p /etc/etcd
      2. Create etcd user with the following commands:
        groupadd –-system etcd
        useradd -s /sbin/nologin –-system -g etcd etcd
        
      3. Change data directory ownership with the following command:
        chown -R etcd:etcd /var/lib/etcd
      4. Create system file for etcd service
        vi /etc/systemd/system/etcd.service
      5. Add the following lines:
        
        [Unit]
        Description=etcd cluster
        Documentation=https://github.com/etcd-io/etcd
        After=syslog.target network.target
        [Service]
        User=etcd
        Type-notify
        Environment file=/etc/etcd/default
        Environment=ETCD_DATA_DIR=/var/lib/etcd
        Environment=
        ExecStart=/usr/local/bin/etcd
        Restart=always
        RestartSec=10s
        LimitNOFILE=40000
        [Install]
        WantedBy=multi-user.target
  • Install HAProxy by using the following command:
    yum install -y haproxy
    For more information, see Install and Configure HAProxy.

What to do next

If all the open source packages are not available from default RHEL repositories, use epel repositories. To enable epel repository, follow these steps:
  1. Install epel with this command:
    yum install epel-release
    Or download and install directly from RPM with the following command:
    rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  2. Instruct YUM to use the epel as follows:
    yum install --enablerepo=epel <PACKAGE_NAME>