Follow these steps to install PostgreSQL, Patroni
,
etcd
, and HAProxy
for the HA setup.
Procedure
-
Install the PostgreSQL database by using YUM repository:
- Optional: If you install the PostgreSQL binary files, create user
postgres
. If you install by using YUM repository, skip this step.
- 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
- Install PostgreSQL by using the following command:
dnf -y install postgresql12 postgresql12-server
- Install
Patroni
by using the following steps:
- Install Python and Python
pip
and other dependencies by using the
following command:
- Install
Patroni
and supporting libraries by using Python
pip
.
- Enable
Patroni
as service by using the following steps:
- Create system file for
patroni
Service with the following command:
vi /etc/systemd/system/patroni.service
- 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:
- Download
etcd
binary files from the following link:
- Extract archive with the following command:
tar -xvf etcd-v2.2.5-linux-amd64.tar.gz
- Move the
etcd
and etcdctl
binary files with the
following command:
mv etcd etcdctl /usr/local/bin
- Enable
etcd
service with the following steps:
- Create data directory for
etcd
with the following
command:mkdir -p /var/lib/etcd && mkdir -p /etc/etcd
- Create
etcd
user with the following
commands:groupadd –-system etcd
useradd -s /sbin/nologin –-system -g etcd etcd
- Change data directory ownership with the following
command:
chown -R etcd:etcd /var/lib/etcd
- Create system file for
etcd
servicevi /etc/systemd/system/etcd.service
- 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:
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:
- 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
- Instruct YUM to use the
epel
as
follows:yum install --enablerepo=epel <PACKAGE_NAME>