这个博客是关于一个快速的、基于脚本的、具有自动故障转移功能的 repmgr 双节点集群的设置。这个设置非常简单,与 patroni 设置相比要求非常低,例如作为防火墙上的开放端口,我们只需要端口 5432,这是 PostgreSQL 的默认端口。
首先是一些要求,在我的例子中是两个具有固定 IP 的虚拟机:
[root@el8-repmgr-1 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
192.168.198.131 el8-repmgr-1 el8-repmgr-1.localdomain
192.168.198.132 el8-repmgr-2 el8-repmgr-2.localdomain
[root@el8-repmgr-1 ~]#对于整个安装和配置过程,我编写了一些 shell 脚本,对于 PostgreSQL 安装是这样的:
###########################################################################################
# Istalling PostgreSQL on AlmaLinux 8 / CentOS 8 / Oracle Linux 8 / RHEL 8 /Rocky Linux 8 #
# By Karsten Lenz dbi-services sa 2020.05.14 #
###########################################################################################
#!/bin/bash
echo "PostgreSQL Installation on AlmaLinux 8 / CentOS 8 / Oracle Linxu 8 / RHEL 8 / Rocky Linux 8"
echo ""
function printHelp() {
printf "Usage:\n"
printf "${progName} [OPTION]\n\n"
printf "Options:\n"
printf "\t -v <PostgreSQL Version>\t\tMajor Release of Postgresql (required)\n"
printf "\t -t <PostgreSQL Node Type>\t\tIf the System is Primary / Single (p) or Secondary (s) in a Cluster (required)\n"
printf "\t -h <Help>\t\t\t\tprints this help\n"
}
while getopts v:t:h option 2>/dev/null
do
case "${option}"
in
v) VERSION=${OPTARG};;
t) TYPE=${OPTARG};;
h) printHelp; exit 2;;
*) printf "Unsupported option or parameter value missing '$*'\n";
printf "Run ${progName} -h to print help\n"; exit 1;;
esac
done
echo "Disabling PostgreSQL Packages provided by CentOS 8 or RedHat 8"
dnf -y module disable postgresql
echo "Adding PostgreSQL Repository"
dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
echo "Installing PostgreSQL Packages including barman, repmgr and pg_stat_kcache"
# adaptation needed in fact renamed packages in postgresql 14 for repmgr and pg_stat_kcache
if [ $VERSION == '14' ]
then
dnf -y install postgresql$VERSION postgresql$VERSION-libs postgresql$VERSION-server postgresql$VERSION-contrib pg_stat_kcache_$VERSION repmgr_$VERSION barman
elif [ $VERSION != '14' ]
then
dnf -y install postgresql$VERSION postgresql$VERSION-libs postgresql$VERSION-server postgresql$VERSION-contrib pg_stat_kcache$VERSION repmgr$VERSION barman
fi
echo "Creating override.conf"
# creating empty override.conf for postgresql service
mkdir /etc/systemd/system/postgresql-$VERSION.service.d
# define vriable for tee
OVERRIDE_CONF=/etc/systemd/system/postgresql-$VERSION.service.d/override.conf
touch $OVERRIDE_CONF
# adding values to override.conf
echo "[Service]" | tee -a $OVERRIDE_CONF
echo "Environment=PGDATA=/pgdata/$VERSION/data" | tee -a $OVERRIDE_CONF
if [ $TYPE == 'p' ]
then
echo "Initialyze PostgreSQL $VERSION"
/usr/pgsql-$VERSION/bin/postgresql-$VERSION-setup initdb
echo "Enable PostgreSQL Service"
systemctl enable postgresql-$VERSION.service
echo "Start PostgreSQL $VERSION"
systemctl start postgresql-$VERSION.service
elif [ $TYPE == 's' ]
then
echo "Initialyze PostgreSQL $VERSION"
/usr/pgsql-$VERSION/bin/postgresql-$VERSION-setup initdb
echo "Enable PostgreSQL Service"
systemctl enable postgresql-$VERSION.service
fi
# add user to sudoers
usermod -aG wheel postgres
# set rights on /pgdata and /etc/repmgr
chown -R postgres:postgres /pgdata
chown -R postgres:postgres /etc/repmgr
# open firewall port 5432 for Potsgresql
firewall-cmd --zone=public --permanent --add-port 5432/tcp
firewall-cmd --reload这些脚本有一个帮助函数 -h,所以他们说了如何使用它:
[root@el8-repmgr-1 install]# sh pg_install.sh -h
PostgreSQL Installation on AlmaLinux 8 / CentOS 8 / Oracle Linxu 8 / RHEL 8 / Rocky Linux 8
Usage:
[OPTION]
Options:
-v <PostgreSQL Version> Major Release of Postgresql (required)
-t <PostgreSQL Node Type> If the System is Primary / Single (p) or Secondary (s) in a Cluster (required)
-h <Help> prints this help
[root@el8-repmgr-1 install]#所以我们将首先启动主节点或领导节点:
[root@el8-repmgr-1 install]# sh pg_setup.sh -v 14 -t p
PostgreSQL Installation on AlmaLinux 8 / CentOS 8 / Oracle Linxu 8 / RHEL 8 / Rocky Linux 8
Disabling PostgreSQL Packages provided by CentOS 8 or RedHat 8
Last metadata expiration check: 6:31:10 ago on Thu 22 Dec 2022 08:48:47 AM CET.
Dependencies resolved.
==========================================================================================================================================================================================================================================================================================
Package Architecture Version Repository Size
==========================================================================================================================================================================================================================================================================================
Disabling modules:
postgresql
Transaction Summary
==========================================================================================================================================================================================================================================================================================
Complete!
Adding PostgreSQL Repository
Last metadata expiration check: 6:31:10 ago on Thu 22 Dec 2022 08:48:47 AM CET.
pgdg-redhat-repo-latest.noarch.rpm 82 kB/s | 13 kB 00:00
Dependencies resolved.
==========================================================================================================================================================================================================================================================================================
Package Architecture Version Repository Size
==========================================================================================================================================================================================================================================================================================
Installing:
pgdg-redhat-repo noarch 42.0-28 @commandline 13 k
Transaction Summary
==========================================================================================================================================================================================================================================================================================
Install 1 Package
Total size: 13 k
Installed size: 14 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : pgdg-redhat-repo-42.0-28.noarch 1/1
Verifying : pgdg-redhat-repo-42.0-28.noarch 1/1
Installed:
pgdg-redhat-repo-42.0-28.noarch
Complete!
Installing PostgreSQL Packages including barman, repmgr and pg_stat_kcache
PostgreSQL common RPMs for RHEL / Rocky 8 - x86_64 596 B/s | 195 B 00:00
PostgreSQL common RPMs for RHEL / Rocky 8 - x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
PostgreSQL common RPMs for RHEL / Rocky 8 - x86_64 1.0 MB/s | 702 kB 00:00
PostgreSQL 15 for RHEL / Rocky 8 - x86_64 647 B/s | 195 B 00:00
PostgreSQL 15 for RHEL / Rocky 8 - x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
PostgreSQL 15 for RHEL / Rocky 8 - x86_64 280 kB/s | 161 kB 00:00
PostgreSQL 14 for RHEL / Rocky 8 - x86_64 546 B/s | 195 B 00:00
PostgreSQL 14 for RHEL / Rocky 8 - x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
PostgreSQL 14 for RHEL / Rocky 8 - x86_64 721 kB/s | 459 kB 00:00
PostgreSQL 13 for RHEL / Rocky 8 - x86_64 607 B/s | 195 B 00:00
PostgreSQL 13 for RHEL / Rocky 8 - x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
PostgreSQL 13 for RHEL / Rocky 8 - x86_64 1.2 MB/s | 752 kB 00:00
PostgreSQL 12 for RHEL / Rocky 8 - x86_64 600 B/s | 195 B 00:00
PostgreSQL 12 for RHEL / Rocky 8 - x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
PostgreSQL 12 for RHEL / Rocky 8 - x86_64 1.1 MB/s | 899 kB 00:00
PostgreSQL 11 for RHEL / Rocky 8 - x86_64 616 B/s | 195 B 00:00
PostgreSQL 11 for RHEL / Rocky 8 - x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
PostgreSQL 11 for RHEL / Rocky 8 - x86_64 1.6 MB/s | 1.1 MB 00:00
PostgreSQL 10 for RHEL / Rocky 8 - x86_64 644 B/s | 195 B 00:00
PostgreSQL 10 for RHEL / Rocky 8 - x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
PostgreSQL 10 for RHEL / Rocky 8 - x86_64 1.0 MB/s | 700 kB 00:00
Dependencies resolved.
==========================================================================================================================================================================================================================================================================================
Package Architecture Version Repository Size
==========================================================================================================================================================================================================================================================================================
Installing:
barman noarch 3.3.0-1.rhel8 pgdg-common 48 k
pg_stat_kcache_14 x86_64 2.2.1-2.rhel8 pgdg14 47 k
postgresql14 x86_64 14.6-1PGDG.rhel8 pgdg14 1.5 M
postgresql14-contrib x86_64 14.6-1PGDG.rhel8 pgdg14 726 k
postgresql14-libs x86_64 14.6-1PGDG.rhel8 pgdg14 278 k
postgresql14-server x86_64 14.6-1PGDG.rhel8 pgdg14 5.7 M
repmgr_14 x86_64 5.3.3-1.rhel8 pgdg14 284 k
Installing dependencies:
libicu x86_64 60.3-2.el8_1 baseos 8.8 M
lz4 x86_64 1.8.3-3.el8_4 baseos 102 k
perl-Carp noarch 1.42-396.el8 baseos 30 k
perl-Data-Dumper x86_64 2.167-399.el8 baseos 58 k
perl-Digest noarch 1.17-395.el8 appstream 27 k
perl-Digest-MD5 x86_64 2.55-396.el8 appstream 37 k
perl-Encode x86_64 4:2.97-3.el8 baseos 1.5 M
perl-Errno x86_64 1.28-421.el8 baseos 75 k
perl-Exporter noarch 5.72-396.el8 baseos 34 k
perl-File-Path noarch 2.15-2.el8 baseos 38 k
perl-File-Temp noarch 0.230.600-1.el8 baseos 62 k
perl-Getopt-Long noarch 1:2.50-4.el8 baseos 63 k
perl-HTTP-Tiny noarch 0.074-1.el8 baseos 58 k
perl-IO x86_64 1.38-421.el8 baseos 141 k
perl-MIME-Base64 x86_64 3.15-396.el8 baseos 30 k
perl-Net-SSLeay x86_64 1.88-2.module_el8.6.0+2811+fe6c84b0 appstream 378 k
perl-PathTools x86_64 3.74-1.el8 baseos 90 k
perl-Pod-Escapes noarch 1:1.07-395.el8 baseos 20 k
perl-Pod-Perldoc noarch 3.28-396.el8 baseos 86 k
perl-Pod-Simple noarch 1:3.35-395.el8 baseos 213 k
perl-Pod-Usage noarch 4:1.69-395.el8 baseos 34 k
perl-Scalar-List-Utils x86_64 3:1.49-2.el8 baseos 68 k
perl-Socket x86_64 4:2.027-3.el8 baseos 59 k
perl-Storable x86_64 1:3.11-3.el8 baseos 98 k
perl-Term-ANSIColor noarch 4.06-396.el8 baseos 46 k
perl-Term-Cap noarch 1.17-395.el8 baseos 23 k
perl-Text-ParseWords noarch 3.30-395.el8 baseos 18 k
perl-Text-Tabs+Wrap noarch 2013.0523-395.el8 baseos 24 k
perl-Time-Local noarch 1:1.280-1.el8 baseos 33 k
perl-URI noarch 1.73-3.el8 appstream 116 k
perl-Unicode-Normalize x86_64 1.25-396.el8 baseos 82 k
perl-constant noarch 1.33-396.el8 baseos 25 k
perl-interpreter x86_64 4:5.26.3-421.el8 baseos 6.3 M
perl-libnet noarch 3.11-3.el8 appstream 121 k
perl-libs x86_64 4:5.26.3-421.el8 baseos 1.6 M
perl-macros x86_64 4:5.26.3-421.el8 baseos 71 k
perl-parent noarch 1:0.237-1.el8 baseos 20 k
perl-podlators noarch 4.11-1.el8 baseos 118 k
perl-threads x86_64 1:2.21-2.el8 baseos 61 k
perl-threads-shared x86_64 1.58-2.el8 baseos 47 k
python3-argcomplete noarch 1.9.3-6.el8 appstream 60 k
python3-barman noarch 3.3.0-1.rhel8 pgdg-common 455 k
python3-pip noarch 9.0.3-22.el8 appstream 19 k
python3-psycopg2 x86_64 2.8.6-1.rhel8 pgdg-common 178 k
python3-setuptools noarch 39.2.0-6.el8 baseos 162 k
python36 x86_64 3.6.8-38.module_el8.5.0+2569+5c5719bc appstream 18 k
rsync x86_64 3.1.3-19.el8 baseos 409 k
Installing weak dependencies:
perl-IO-Socket-IP noarch 0.39-5.el8 appstream 47 k
perl-IO-Socket-SSL noarch 2.066-4.module_el8.6.0+2811+fe6c84b0 appstream 297 k
perl-Mozilla-CA noarch 20160104-7.module_el8.5.0+2812+ed912d05 appstream 14 k
Enabling module streams:
perl 5.26
perl-IO-Socket-SSL 2.066
perl-libwww-perl 6.34
python36 3.6
Transaction Summary
==========================================================================================================================================================================================================================================================================================
Install 57 Packages
Total download size: 31 M
Installed size: 107 M
Downloading Packages:
(1/57): perl-Carp-1.42-396.el8.noarch.rpm 291 kB/s | 30 kB 00:00
(2/57): lz4-1.8.3-3.el8_4.x86_64.rpm 682 kB/s | 102 kB 00:00
(3/57): perl-Data-Dumper-2.167-399.el8.x86_64.rpm 1.2 MB/s | 58 kB 00:00
(4/57): perl-Errno-1.28-421.el8.x86_64.rpm 1.5 MB/s | 75 kB 00:00
(5/57): perl-Exporter-5.72-396.el8.noarch.rpm 1.1 MB/s | 34 kB 00:00
(6/57): perl-File-Path-2.15-2.el8.noarch.rpm 1.3 MB/s | 38 kB 00:00
(7/57): perl-Encode-2.97-3.el8.x86_64.rpm 11 MB/s | 1.5 MB 00:00
(8/57): perl-File-Temp-0.230.600-1.el8.noarch.rpm 2.0 MB/s | 62 kB 00:00
(9/57): perl-HTTP-Tiny-0.074-1.el8.noarch.rpm 1.5 MB/s | 58 kB 00:00
(10/57): perl-Getopt-Long-2.50-4.el8.noarch.rpm 1.5 MB/s | 63 kB 00:00
(11/57): perl-IO-1.38-421.el8.x86_64.rpm 3.8 MB/s | 141 kB 00:00
(12/57): perl-MIME-Base64-3.15-396.el8.x86_64.rpm 783 kB/s | 30 kB 00:00
(13/57): perl-Pod-Escapes-1.07-395.el8.noarch.rpm 658 kB/s | 20 kB 00:00
(14/57): perl-PathTools-3.74-1.el8.x86_64.rpm 2.4 MB/s | 90 kB 00:00
(15/57): perl-Pod-Perldoc-3.28-396.el8.noarch.rpm 2.8 MB/s | 86 kB 00:00
(16/57): perl-Pod-Simple-3.35-395.el8.noarch.rpm 5.1 MB/s | 213 kB 00:00
(17/57): libicu-60.3-2.el8_1.x86_64.rpm 19 MB/s | 8.8 MB 00:00
(18/57): perl-Pod-Usage-1.69-395.el8.noarch.rpm 912 kB/s | 34 kB 00:00
(19/57): perl-Scalar-List-Utils-1.49-2.el8.x86_64.rpm 2.5 MB/s | 68 kB 00:00
(20/57): perl-Term-ANSIColor-4.06-396.el8.noarch.rpm 1.9 MB/s | 46 kB 00:00
(21/57): perl-Storable-3.11-3.el8.x86_64.rpm 3.2 MB/s | 98 kB 00:00
(22/57): perl-Socket-2.027-3.el8.x86_64.rpm 1.6 MB/s | 59 kB 00:00
(23/57): perl-Term-Cap-1.17-395.el8.noarch.rpm 756 kB/s | 23 kB 00:00
(24/57): perl-Text-ParseWords-3.30-395.el8.noarch.rpm 547 kB/s | 18 kB 00:00
(25/57): perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch.rpm 794 kB/s | 24 kB 00:00
(26/57): perl-Time-Local-1.280-1.el8.noarch.rpm 1.3 MB/s | 33 kB 00:00
(27/57): perl-Unicode-Normalize-1.25-396.el8.x86_64.rpm 2.6 MB/s | 82 kB 00:00
(28/57): perl-constant-1.33-396.el8.noarch.rpm 820 kB/s | 25 kB 00:00
(29/57): perl-macros-5.26.3-421.el8.x86_64.rpm 2.4 MB/s | 71 kB 00:00
(30/57): perl-parent-0.237-1.el8.noarch.rpm 629 kB/s | 20 kB 00:00
(31/57): perl-podlators-4.11-1.el8.noarch.rpm 3.3 MB/s | 118 kB 00:00
(32/57): perl-threads-2.21-2.el8.x86_64.rpm 2.2 MB/s | 61 kB 00:00
(33/57): perl-threads-shared-1.58-2.el8.x86_64.rpm 1.8 MB/s | 47 kB 00:00
(34/57): python3-setuptools-39.2.0-6.el8.noarch.rpm 5.1 MB/s | 162 kB 00:00
(35/57): rsync-3.1.3-19.el8.x86_64.rpm 11 MB/s | 409 kB 00:00
(36/57): perl-Digest-1.17-395.el8.noarch.rpm 711 kB/s | 27 kB 00:00
(37/57): perl-libs-5.26.3-421.el8.x86_64.rpm 5.9 MB/s | 1.6 MB 00:00
(38/57): perl-interpreter-5.26.3-421.el8.x86_64.rpm 21 MB/s | 6.3 MB 00:00
(39/57): perl-Digest-MD5-2.55-396.el8.x86_64.rpm 1.0 MB/s | 37 kB 00:00
(40/57): perl-IO-Socket-IP-0.39-5.el8.noarch.rpm 1.4 MB/s | 47 kB 00:00
(41/57): perl-IO-Socket-SSL-2.066-4.module_el8.6.0+2811+fe6c84b0.noarch.rpm 11 MB/s | 297 kB 00:00
(42/57): perl-Mozilla-CA-20160104-7.module_el8.5.0+2812+ed912d05.noarch.rpm 516 kB/s | 14 kB 00:00
(43/57): perl-libnet-3.11-3.el8.noarch.rpm 4.5 MB/s | 121 kB 00:00
(44/57): perl-URI-1.73-3.el8.noarch.rpm 3.7 MB/s | 116 kB 00:00
(45/57): perl-Net-SSLeay-1.88-2.module_el8.6.0+2811+fe6c84b0.x86_64.rpm 6.0 MB/s | 378 kB 00:00
(46/57): python3-argcomplete-1.9.3-6.el8.noarch.rpm 2.0 MB/s | 60 kB 00:00
(47/57): python3-pip-9.0.3-22.el8.noarch.rpm 578 kB/s | 19 kB 00:00
(48/57): python36-3.6.8-38.module_el8.5.0+2569+5c5719bc.x86_64.rpm 673 kB/s | 18 kB 00:00
(49/57): barman-3.3.0-1.rhel8.noarch.rpm 241 kB/s | 48 kB 00:00
(50/57): pg_stat_kcache_14-2.2.1-2.rhel8.x86_64.rpm 1.7 MB/s | 47 kB 00:00
(51/57): python3-psycopg2-2.8.6-1.rhel8.x86_64.rpm 679 kB/s | 178 kB 00:00
(52/57): python3-barman-3.3.0-1.rhel8.noarch.rpm 1.4 MB/s | 455 kB 00:00
(53/57): postgresql14-libs-14.6-1PGDG.rhel8.x86_64.rpm 3.0 MB/s | 278 kB 00:00
(54/57): postgresql14-contrib-14.6-1PGDG.rhel8.x86_64.rpm 2.8 MB/s | 726 kB 00:00
(55/57): repmgr_14-5.3.3-1.rhel8.x86_64.rpm 3.3 MB/s | 284 kB 00:00
(56/57): postgresql14-14.6-1PGDG.rhel8.x86_64.rpm 3.0 MB/s | 1.5 MB 00:00
(57/57): postgresql14-server-14.6-1PGDG.rhel8.x86_64.rpm 8.8 MB/s | 5.7 MB 00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 9.0 MB/s | 31 MB 00:03
PostgreSQL common RPMs for RHEL / Rocky 8 - x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : perl-Digest-1.17-395.el8.noarch 1/57
Installing : perl-Digest-MD5-2.55-396.el8.x86_64 2/57
Installing : perl-Data-Dumper-2.167-399.el8.x86_64 3/57
Installing : perl-libnet-3.11-3.el8.noarch 4/57
Installing : perl-Net-SSLeay-1.88-2.module_el8.6.0+2811+fe6c84b0.x86_64 5/57
Installing : perl-URI-1.73-3.el8.noarch 6/57
Installing : perl-Pod-Escapes-1:1.07-395.el8.noarch 7/57
Installing : perl-Time-Local-1:1.280-1.el8.noarch 8/57
Installing : perl-IO-Socket-IP-0.39-5.el8.noarch 9/57
Installing : perl-Mozilla-CA-20160104-7.module_el8.5.0+2812+ed912d05.noarch 10/57
Installing : perl-IO-Socket-SSL-2.066-4.module_el8.6.0+2811+fe6c84b0.noarch 11/57
Installing : perl-Term-ANSIColor-4.06-396.el8.noarch 12/57
Installing : perl-Term-Cap-1.17-395.el8.noarch 13/57
Installing : perl-File-Temp-0.230.600-1.el8.noarch 14/57
Installing : perl-Pod-Simple-1:3.35-395.el8.noarch 15/57
Installing : perl-HTTP-Tiny-0.074-1.el8.noarch 16/57
Installing : perl-podlators-4.11-1.el8.noarch 17/57
Installing : perl-Pod-Perldoc-3.28-396.el8.noarch 18/57
Installing : perl-Text-ParseWords-3.30-395.el8.noarch 19/57
Installing : perl-Pod-Usage-4:1.69-395.el8.noarch 20/57
Installing : perl-MIME-Base64-3.15-396.el8.x86_64 21/57
Installing : perl-Storable-1:3.11-3.el8.x86_64 22/57
Installing : perl-Getopt-Long-1:2.50-4.el8.noarch 23/57
Installing : perl-Errno-1.28-421.el8.x86_64 24/57
Installing : perl-Socket-4:2.027-3.el8.x86_64 25/57
Installing : perl-Encode-4:2.97-3.el8.x86_64 26/57
Installing : perl-Exporter-5.72-396.el8.noarch 27/57
Installing : perl-Scalar-List-Utils-3:1.49-2.el8.x86_64 28/57
Installing : perl-macros-4:5.26.3-421.el8.x86_64 29/57
Installing : perl-parent-1:0.237-1.el8.noarch 30/57
Installing : perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch 31/57
Installing : perl-Unicode-Normalize-1.25-396.el8.x86_64 32/57
Installing : perl-File-Path-2.15-2.el8.noarch 33/57
Installing : perl-IO-1.38-421.el8.x86_64 34/57
Installing : perl-PathTools-3.74-1.el8.x86_64 35/57
Installing : perl-constant-1.33-396.el8.noarch 36/57
Installing : perl-threads-1:2.21-2.el8.x86_64 37/57
Installing : perl-threads-shared-1.58-2.el8.x86_64 38/57
Installing : perl-libs-4:5.26.3-421.el8.x86_64 39/57
Installing : perl-Carp-1.42-396.el8.noarch 40/57
Installing : perl-interpreter-4:5.26.3-421.el8.x86_64 41/57
Installing : postgresql14-libs-14.6-1PGDG.rhel8.x86_64 42/57
Running scriptlet: postgresql14-libs-14.6-1PGDG.rhel8.x86_64 42/57
Installing : python3-setuptools-39.2.0-6.el8.noarch 43/57
Installing : python3-pip-9.0.3-22.el8.noarch 44/57
Installing : python36-3.6.8-38.module_el8.5.0+2569+5c5719bc.x86_64 45/57
Running scriptlet: python36-3.6.8-38.module_el8.5.0+2569+5c5719bc.x86_64 45/57
Installing : libicu-60.3-2.el8_1.x86_64 46/57
Running scriptlet: libicu-60.3-2.el8_1.x86_64 46/57
Installing : python3-psycopg2-2.8.6-1.rhel8.x86_64 47/57
Installing : python3-argcomplete-1.9.3-6.el8.noarch 48/57
Installing : python3-barman-3.3.0-1.rhel8.noarch 49/57
Installing : rsync-3.1.3-19.el8.x86_64 50/57
Installing : lz4-1.8.3-3.el8_4.x86_64 51/57
Installing : postgresql14-14.6-1PGDG.rhel8.x86_64 52/57
Running scriptlet: postgresql14-14.6-1PGDG.rhel8.x86_64 52/57
Running scriptlet: postgresql14-server-14.6-1PGDG.rhel8.x86_64 53/57
Installing : postgresql14-server-14.6-1PGDG.rhel8.x86_64 53/57
Running scriptlet: postgresql14-server-14.6-1PGDG.rhel8.x86_64 53/57
Installing : pg_stat_kcache_14-2.2.1-2.rhel8.x86_64 54/57
Running scriptlet: pg_stat_kcache_14-2.2.1-2.rhel8.x86_64 54/57
Installing : postgresql14-contrib-14.6-1PGDG.rhel8.x86_64 55/57
Running scriptlet: repmgr_14-5.3.3-1.rhel8.x86_64 56/57
Installing : repmgr_14-5.3.3-1.rhel8.x86_64 56/57
Running scriptlet: repmgr_14-5.3.3-1.rhel8.x86_64 56/57
Running scriptlet: barman-3.3.0-1.rhel8.noarch 57/57
Installing : barman-3.3.0-1.rhel8.noarch 57/57
Running scriptlet: barman-3.3.0-1.rhel8.noarch 57/57
Verifying : libicu-60.3-2.el8_1.x86_64 1/57
Verifying : lz4-1.8.3-3.el8_4.x86_64 2/57
Verifying : perl-Carp-1.42-396.el8.noarch 3/57
Verifying : perl-Data-Dumper-2.167-399.el8.x86_64 4/57
Verifying : perl-Encode-4:2.97-3.el8.x86_64 5/57
Verifying : perl-Errno-1.28-421.el8.x86_64 6/57
Verifying : perl-Exporter-5.72-396.el8.noarch 7/57
Verifying : perl-File-Path-2.15-2.el8.noarch 8/57
Verifying : perl-File-Temp-0.230.600-1.el8.noarch 9/57
Verifying : perl-Getopt-Long-1:2.50-4.el8.noarch 10/57
Verifying : perl-HTTP-Tiny-0.074-1.el8.noarch 11/57
Verifying : perl-IO-1.38-421.el8.x86_64 12/57
Verifying : perl-MIME-Base64-3.15-396.el8.x86_64 13/57
Verifying : perl-PathTools-3.74-1.el8.x86_64 14/57
Verifying : perl-Pod-Escapes-1:1.07-395.el8.noarch 15/57
Verifying : perl-Pod-Perldoc-3.28-396.el8.noarch 16/57
Verifying : perl-Pod-Simple-1:3.35-395.el8.noarch 17/57
Verifying : perl-Pod-Usage-4:1.69-395.el8.noarch 18/57
Verifying : perl-Scalar-List-Utils-3:1.49-2.el8.x86_64 19/57
Verifying : perl-Socket-4:2.027-3.el8.x86_64 20/57
Verifying : perl-Storable-1:3.11-3.el8.x86_64 21/57
Verifying : perl-Term-ANSIColor-4.06-396.el8.noarch 22/57
Verifying : perl-Term-Cap-1.17-395.el8.noarch 23/57
Verifying : perl-Text-ParseWords-3.30-395.el8.noarch 24/57
Verifying : perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch 25/57
Verifying : perl-Time-Local-1:1.280-1.el8.noarch 26/57
Verifying : perl-Unicode-Normalize-1.25-396.el8.x86_64 27/57
Verifying : perl-constant-1.33-396.el8.noarch 28/57
Verifying : perl-interpreter-4:5.26.3-421.el8.x86_64 29/57
Verifying : perl-libs-4:5.26.3-421.el8.x86_64 30/57
Verifying : perl-macros-4:5.26.3-421.el8.x86_64 31/57
Verifying : perl-parent-1:0.237-1.el8.noarch 32/57
Verifying : perl-podlators-4.11-1.el8.noarch 33/57
Verifying : perl-threads-1:2.21-2.el8.x86_64 34/57
Verifying : perl-threads-shared-1.58-2.el8.x86_64 35/57
Verifying : python3-setuptools-39.2.0-6.el8.noarch 36/57
Verifying : rsync-3.1.3-19.el8.x86_64 37/57
Verifying : perl-Digest-1.17-395.el8.noarch 38/57
Verifying : perl-Digest-MD5-2.55-396.el8.x86_64 39/57
Verifying : perl-IO-Socket-IP-0.39-5.el8.noarch 40/57
Verifying : perl-IO-Socket-SSL-2.066-4.module_el8.6.0+2811+fe6c84b0.noarch 41/57
Verifying : perl-Mozilla-CA-20160104-7.module_el8.5.0+2812+ed912d05.noarch 42/57
Verifying : perl-Net-SSLeay-1.88-2.module_el8.6.0+2811+fe6c84b0.x86_64 43/57
Verifying : perl-URI-1.73-3.el8.noarch 44/57
Verifying : perl-libnet-3.11-3.el8.noarch 45/57
Verifying : python3-argcomplete-1.9.3-6.el8.noarch 46/57
Verifying : python3-pip-9.0.3-22.el8.noarch 47/57
Verifying : python36-3.6.8-38.module_el8.5.0+2569+5c5719bc.x86_64 48/57
Verifying : barman-3.3.0-1.rhel8.noarch 49/57
Verifying : python3-barman-3.3.0-1.rhel8.noarch 50/57
Verifying : python3-psycopg2-2.8.6-1.rhel8.x86_64 51/57
Verifying : pg_stat_kcache_14-2.2.1-2.rhel8.x86_64 52/57
Verifying : postgresql14-14.6-1PGDG.rhel8.x86_64 53/57
Verifying : postgresql14-contrib-14.6-1PGDG.rhel8.x86_64 54/57
Verifying : postgresql14-libs-14.6-1PGDG.rhel8.x86_64 55/57
Verifying : postgresql14-server-14.6-1PGDG.rhel8.x86_64 56/57
Verifying : repmgr_14-5.3.3-1.rhel8.x86_64 57/57
Installed:
barman-3.3.0-1.rhel8.noarch libicu-60.3-2.el8_1.x86_64 lz4-1.8.3-3.el8_4.x86_64 perl-Carp-1.42-396.el8.noarch perl-Data-Dumper-2.167-399.el8.x86_64
perl-Digest-1.17-395.el8.noarch perl-Digest-MD5-2.55-396.el8.x86_64 perl-Encode-4:2.97-3.el8.x86_64 perl-Errno-1.28-421.el8.x86_64 perl-Exporter-5.72-396.el8.noarch
perl-File-Path-2.15-2.el8.noarch perl-File-Temp-0.230.600-1.el8.noarch perl-Getopt-Long-1:2.50-4.el8.noarch perl-HTTP-Tiny-0.074-1.el8.noarch perl-IO-1.38-421.el8.x86_64
perl-IO-Socket-IP-0.39-5.el8.noarch perl-IO-Socket-SSL-2.066-4.module_el8.6.0+2811+fe6c84b0.noarch perl-MIME-Base64-3.15-396.el8.x86_64 perl-Mozilla-CA-20160104-7.module_el8.5.0+2812+ed912d05.noarch perl-Net-SSLeay-1.88-2.module_el8.6.0+2811+fe6c84b0.x86_64
perl-PathTools-3.74-1.el8.x86_64 perl-Pod-Escapes-1:1.07-395.el8.noarch perl-Pod-Perldoc-3.28-396.el8.noarch perl-Pod-Simple-1:3.35-395.el8.noarch perl-Pod-Usage-4:1.69-395.el8.noarch
perl-Scalar-List-Utils-3:1.49-2.el8.x86_64 perl-Socket-4:2.027-3.el8.x86_64 perl-Storable-1:3.11-3.el8.x86_64 perl-Term-ANSIColor-4.06-396.el8.noarch perl-Term-Cap-1.17-395.el8.noarch
perl-Text-ParseWords-3.30-395.el8.noarch perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch perl-Time-Local-1:1.280-1.el8.noarch perl-URI-1.73-3.el8.noarch perl-Unicode-Normalize-1.25-396.el8.x86_64
perl-constant-1.33-396.el8.noarch perl-interpreter-4:5.26.3-421.el8.x86_64 perl-libnet-3.11-3.el8.noarch perl-libs-4:5.26.3-421.el8.x86_64 perl-macros-4:5.26.3-421.el8.x86_64
perl-parent-1:0.237-1.el8.noarch perl-podlators-4.11-1.el8.noarch perl-threads-1:2.21-2.el8.x86_64 perl-threads-shared-1.58-2.el8.x86_64 pg_stat_kcache_14-2.2.1-2.rhel8.x86_64
postgresql14-14.6-1PGDG.rhel8.x86_64 postgresql14-contrib-14.6-1PGDG.rhel8.x86_64 postgresql14-libs-14.6-1PGDG.rhel8.x86_64 postgresql14-server-14.6-1PGDG.rhel8.x86_64 python3-argcomplete-1.9.3-6.el8.noarch
python3-barman-3.3.0-1.rhel8.noarch python3-pip-9.0.3-22.el8.noarch python3-psycopg2-2.8.6-1.rhel8.x86_64 python3-setuptools-39.2.0-6.el8.noarch python36-3.6.8-38.module_el8.5.0+2569+5c5719bc.x86_64
repmgr_14-5.3.3-1.rhel8.x86_64 rsync-3.1.3-19.el8.x86_64
Complete!
Creating override.conf
[Service]
Environment=PGDATA=/pgdata/14/data
Initialyze PostgreSQL 14
Initializing database ... OK
Enable PostgreSQL Service
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-14.service → /usr/lib/systemd/system/postgresql-14.service.
Start PostgreSQL 14
success
success
[root@el8-repmgr-1 install]#在 master / leader 节点 ist PostgreSQL 现在正在运行,我们可以通过 config.sh 脚本根据给定的 CPU 和内存资源配置 PostgreSQL,以下所有脚本都需要用作软件包安装创建的 postgres 用户,因此我们需要更改其他脚本的所有者。
[root@el8-repmgr-1 pgsql]# pwd
/opt/pgsql
[root@el8-repmgr-1 pgsql]# ls -la
total 0
drwxr-xr-x. 4 root root 35 Dec 22 14:36 .
drwxr-xr-x. 3 root root 19 Dec 22 14:36 ..
drwxr-xr-x. 2 root root 154 Dec 22 14:38 config
drwxr-xr-x. 2 root root 52 Dec 22 15:15 install
[root@el8-repmgr-1 pgsql]# chown -R postgres:postgres config/
[root@el8-repmgr-1 pgsql]#配置脚本:
[postgres@el8-repmgr-1 config]$ cat config.sh
##############################################
# PostgreSQL configuration #
# by Karsten Lenz dbi services sa 04.29.2022 #
##############################################
#!/bin/bash
echo "PostgreSQL Configuration"
echo ""
function printHelp {
printf "Usage:\n"
printf "${progName} [OPTION]\n\n"
printf "Options:\n"
printf "\t -c <Count of CPU used>\t\t\tAmount of CPU used by this system (required)\n"
printf "\t -m <Amount of Memory>\t\t\tAmount of Memory of this system (required)\n"
printf "\t -o <Max Connections>\t\t\tAmount of Connections of this system (default = 100))\n"
printf "\t -v <PostgreSQL Version>\t\tMajor Release of Postgresql (default = 14)\n"
printf "\t -h <Help>\t\t\t\tprints this help\n"
}
while getopts c:m:o:v:h option 2>/dev/null
do
case "${option}"
in
c) CPU=${OPTARG};;
m) RAM=${OPTARG};;
o) CONNECTIONS=${OPTARG:=100};;
v) VERSION=${OPTARG:=14};;
h) printHelp; exit 2;;
*) printf "Unsupported option or parameter value missing '$*'\n";
printf "Run ${printHelp} -h to print help\n"; exit 1;;
esac
done
# create ssl certificate and ssl key
openssl req -new -newkey rsa:4096 -nodes -x509 -subj "/C=CH/ST=DBAAS/L=ZUERICH/O=Dis/CN=www.dbi-services.com" -keyout /pgdata/ssl/pgsql.key -out /pgdata/ssl/pgsql.crt
# define parameters
rootdir=/opt/pgsql/config
cd ${rootdir}
# connections
max_connections=($CONNECTIONS)
echo max_connections : $max_connections
# memory
let shared_buffers=($RAM/4)
echo shared_buffers : $shared_buffers
let effective_cache_size=($RAM-$shared_buffers)
echo effective_cache_size : $effective_cache_size
let work_mem=($RAM*256/$CONNECTIONS)
echo work_mem : $work_mem
let maintenance_work_mem=($RAM*256/8)
echo maintenance_work_mem : $maintenance_work_mem
# cpu
let max_worker_processes=($CPU)
echo max_worker_processes : $max_worker_processes
let max_parallel_workers=($CPU)
echo max_parallel_workers : $max_parallel_workers
let max_parallel_workers_per_gather=($CPU/2)
echo max_parallel_workers_per_gather : $max_parallel_workers_per_gather
let max_parallel_maintenance_workers=($CPU/2)
echo max_parallel_maintenance_workers : $max_parallel_maintenance_workers
# cpu and memory configuration
psql -c "alter system set listen_addresses = '*';"
psql -c "alter system set max_connections = '$max_connections';"
psql -c "alter system set effective_cache_size = '$effective_cache_size GB';"
psql -c "alter system set shared_buffers = '$shared_buffers GB';"
psql -c "alter system set work_mem = '$work_mem MB';"
psql -c "alter system set maintenance_work_mem = '$maintenance_work_mem MB';"
psql -c "alter system set max_worker_processes = '$max_worker_processes';"
psql -c "alter system set max_parallel_workers = '$max_parallel_workers';"
psql -c "alter system set max_parallel_workers_per_gather = '$max_parallel_workers_per_gather';"
psql -c "alter system set max_parallel_maintenance_workers = '$max_parallel_maintenance_workers';"
psql -c "alter system set ssl_cert_file = '/pgdata/ssl/pgsql.crt';"
psql -c "alter system set ssl_key_file = '/pgdata/ssl/pgsql.key';"
psql -c "alter system set ssl = on;"
psql -c "alter system set ssl_ciphers = 'HIGH';"
psql -c "alter system set ssl_min_protocol_version = 'TLSv1.2';"
psql -c "alter system set shared_preload_libraries = pg_stat_statements;"
sudo service postgresql-$VERSION restart
exit
[postgres@el8-repmgr-1 config]$因此,让我们配置主节点/领导节点,给定的是 4 个 vCPU 和 8GB RAM。该脚本将重新启动 postgresql 服务,因此需要 postgres 用户具有 sudoers。
使用 visudo 调整 sudoers:
## Allows people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
## Same thing without a password
%wheel ALL=(ALL) NOPASSWD: ALL将 postgres 用户添加到 sudoers:
[root@el8-repmgr-1 pgsql]# usermod -aG wheel postgres
[root@el8-repmgr-1 pgsql]#现在我们可以使用配置脚本了。
[postgres@el8-repmgr-1 config]$ sh config.sh -h
PostgreSQL Configuration
Usage:
[OPTION]
Options:
-c <Count of CPU used> Amount of CPU used by this system (required)
-m <Amount of Memory> Amount of Memory of this system (required)
-o <Max Connections> Amount of Connections of this system (default = 100))
-v <PostgreSQL Version> Major Release of Postgresql (default = 14)
-h <Help> prints this help
[postgres@el8-repmgr-1 config]$
[postgres@el8-repmgr-1 config]$ sh config.sh -c 4 -m 8 -o 100 -v 14
PostgreSQL Configuration
Generating a RSA private key
....++++
...........................................................................................................................................................++++
writing new private key to '/pgdata/ssl/pgsql.key'
-----
max_connections : 100
shared_buffers : 2
effective_cache_size : 6
work_mem : 20
maintenance_work_mem : 256
max_worker_processes : 4
max_parallel_workers : 4
max_parallel_workers_per_gather : 2
max_parallel_maintenance_workers : 2
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
Redirecting to /bin/systemctl restart postgresql-14.service
[postgres@el8-repmgr-1 config]$现在我们可以为 repmgr 做准备,首先使用脚本设置 .pgpass。
[postgres@el8-repmgr-1 config]$ cat pgpass.sh
#!/bin/sh
########################################
# #
# pgpass setup script #
# #
# Author: Karsten Lenz / 2020.05.28 #
# #
########################################
progName=$(basename $0)
# postgresVersion=12
domain=localdomain
# pgData=/pgdata/$postgresVersion/data
# postgresConf=/pgdata/$postgresVersion/data/postgresql.conf
postgresHome=/var/lib/pgsql
# postgresBin=/usr/pgsql-$postgresVersion/bin
pgpass=$postgresHome/.pgpass
password=PutYourPasswordHere
function printHelp() {
printf "Usage:\n"
printf "${progName} [OPTION]\n\n"
printf "Options:\n"
printf "\t -p <Primary Server>\t\t\tserver where the primary host is running on (required)\n"
printf "\t -s <Secondary Server>\t\t\tserver where the secondary host is running on (required)\n"
printf "\t -h <Help>\t\t\t\tprints this help\n"
}
while getopts p:s:h option 2>/dev/null
do
case "${option}"
in
p) primServer=${OPTARG};;
s) secdServer=${OPTARG};;
h) printHelp; exit 2;;
*) printf "Unsupported option or parameter value missing '$*'\n";
printf "Run ${progName} -h to print help\n"; exit 1;;
esac
done
############ Log function ############
logFile=/tmp/pgpass_install.log
function log() {
echo "$(date +%Y.%m.%d-%H:%M:%S) [$$]$*" | tee -a $logFile
}
if [ -f $logFile ]; then
continue
else
touch $logFile
chmod -R 774 $logFile
sleep 2
fi
#clean .pgpass
rm -f $pgpass
#set values in .pgpass
log "INFO: #host:port:database:user:password in $pgpass"
echo "#host:port:database:user:password" | tee -a $pgpass
log "INFO: Setting localhost in $pgass"
echo "localhost:5432:*:repmgr:$password" | tee -a $pgpass
log "INFO: Setting 127.0.0.1 in $pgpass"
echo "127.0.0.1:5432:*:repmgr:$password" | tee -a $pgpass
log "INFO: Setting Primary $primServer in $pgpass"
echo "$primServer.$domain:5432:*:repmgr:$password" | tee -a $pgpass
log "INFO: Setting Primary $secdServer in $pgpass"
echo "$secdServer.$domain:5432:*:repmgr:$password" | tee -a $pgpass
#set .pgpass 0600
chmod 0600 $pgpass
#export PGPASSFILE
export PGPASSFILE='/var/lib/pgsql/.pgpass'
[postgres@el8-repmgr-1 config]$
[postgres@el8-repmgr-1 config]$ sh pgpass.sh -h
Usage:
pgpass.sh [OPTION]
Options:
-p <Primary Server> server where the primary host is running on (required)
-s <Secondary Server> server where the secondary host is running on (required)
-h <Help> prints this help
[postgres@el8-repmgr-1 config]$ sh pgpass.sh -p 192.168.198.131 -s 192.168.198.132
2022.12.22-16:01:18 [6166]INFO: #host:port:database:user:password in /var/lib/pgsql/.pgpass
#host:port:database:user:password
2022.12.22-16:01:18 [6166]INFO: Setting localhost in
localhost:5432:*:repmgr:PutYourPasswordHere
2022.12.22-16:01:18 [6166]INFO: Setting 127.0.0.1 in /var/lib/pgsql/.pgpass
127.0.0.1:5432:*:repmgr:PutYourPasswordHere
2022.12.22-16:01:18 [6166]INFO: Setting Primary 192.168.198.131 in /var/lib/pgsql/.pgpass
192.168.198.131.localdomain:5432:*:repmgr:PutYourPasswordHere
2022.12.22-16:01:18 [6166]INFO: Setting Primary 192.168.198.132 in /var/lib/pgsql/.pgpass
192.168.198.132.localdomain:5432:*:repmgr:PutYourPasswordHere
[postgres@el8-repmgr-1 config]$使用主/领导节点的设置脚本在主/领导节点上进行 repmgr 的时间:
#!/bin/sh
########################################
# RepMgr setup script #
# Rework: Karsten Lenz / 2022.08.11 #
########################################
progName=$(basename $0)
# postgresVersion=14
domain=localdomain
# repmgr_conf=/etc/repmgr/$postgresVersion/repmgr.conf
# pgData=/pgdata/$postgresVersion/data
# postgresConf=/pgdata/$postgresVersion/data/postgresql.conf
# postgresHome=/var/lib/pgsql/$postgresVersion
# postgresBin=/usr/pgsql-$postgresVersion/bin
password=PutYourPasswordHere
function printHelp() {
printf "Usage:\n"
printf "${progName} [OPTION]\n\n"
printf "Options:\n"
printf "\t -p <Primary Server>\t\t\thost where the primary server is running on (required)\n"
printf "\t -s <Standby Server>\t\t\thost where the standby server is running on (required)\n"
printf "\t -v <PostgreSQL Major Release>\t\tMajor Release Number default 14 (required)\n"
printf "\t -h <Help>\t\t\t\tprints this help\n"
}
while getopts c:p:s:v:h option 2>/dev/null
do
case "${option}"
in
p) primServer=${OPTARG};;
s) secdServer=${OPTARG};;
v) postgresVersion=${OPTARG:=14};;
h) printHelp; exit 2;;
*) printf "Unsupported option or parameter value missing '$*'\n";
printf "Run ${progName} -h to print help\n"; exit 1;;
esac
done
### Building Variables according to inputs ###
repmgr_conf=/etc/repmgr/$postgresVersion/repmgr.conf
pgData=/pgdata/$postgresVersion/data
postgresConf=/pgdata/$postgresVersion/data/postgresql.conf
postgresHome=/var/lib/pgsql/$postgresVersion
postgresBin=/usr/pgsql-$postgresVersion/bin
rootDir=/opt/pgsql
############ Log function ############
logFile=/tmp/repMaster_install.log
function log() {
echo "$(date +%Y.%m.%d-%H:%M:%S) [$$]$*" | tee -a $logFile
}
if [ -f $logFile ]; then
continue
else
touch $logFile
chmod -R 774 $logFile
sleep 2
fi
############ MAIN ############
psql -c "alter system set max_replication_slots = 10;"
psql -c "alter system set archive_mode = 'on';"
psql -c "alter system set archive_command = '/bin/true';"
psql -c "alter system set wal_level = 'replica';"
psql -c "alter system set max_wal_senders = 2;"
psql -c "create user repmgr with superuser"
log "INFO: create user repmgr with superuser"
psql -c "alter user repmgr with password '$password'"
log "INFO: alter user repmgr set password"
$postgresBin/createdb repmgrdb -O repmgr
log "INFO: Create database repmgrdb with owner repmgr"
$postgresBin/pg_ctl reload -D $pgData -W -s
if [ $? == 0 ]; then
log "INFO: Reloading postgres returned $?"
else
log "ERROR: Reloading postgres returned $?"
exit 8
fi
> $repmgr_conf
#log "INFO: Setting cluster=$repCluster in $repmgr_conf"
#echo "cluster=$repCluster" | tee -a $repmgr_conf
log "INFO: Setting node_id=1 in $repmgr_conf"
echo "node_id=1" | tee -a $repmgr_conf
log "INFO: Setting node_name=$primServer in $repmgr_conf"
echo "node_name=$primServer" | tee -a $repmgr_conf
log "INFO: Setting conninfo='host=$primServer.$domain user=repmgr dbname=repmgrdb' in $repmgr_conf"
echo "conninfo='host=$primServer.$domain user=repmgr dbname=repmgrdb'" | tee -a $repmgr_conf
log "INFO: Setting use_replication_slots=true"
echo "use_replication_slots=true" | tee -a $repmgr_conf
log "INFO: Setting data_directory='$pgData' in $repmgr_conf"
echo "data_directory='$pgData'" | tee -a $repmgr_conf
#/usr/psql-14/bin repmgrdb repmgr <<EOF
psql -c "ALTER USER repmgr SET search_path TO repmgr, public;"
log "INFO: ALTER USER repmgr SET search_path TO repmgr, public;"
$postgresBin/repmgr -f $repmgr_conf -F master register
if [ $? == 0 ]; then
log "INFO: Registering master returned $?"
else
log "ERROR: Registering master returned $?"
exit 8
fi[postgres@el8-repmgr-1 config]$ sh repMgrMasterNEW_setup.sh -p el8-repmgr-1 -s el8-repmgr-2 -v 14
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ERROR: role "repmgr" already exists
2022.12.22-16:19:58 [7333]INFO: create user repmgr with superuser
ALTER ROLE
2022.12.22-16:19:58 [7333]INFO: alter user repmgr set password
2022.12.22-16:19:58 [7333]INFO: Create database repmgrdb with owner repmgr
2022.12.22-16:19:58 [7333]INFO: Reloading postgres returned 0
2022.12.22-16:19:58 [7333]INFO: Setting node_id=1 in /etc/repmgr/14/repmgr.conf
node_id=1
2022.12.22-16:19:58 [7333]INFO: Setting node_name=el8-repmgr-1 in /etc/repmgr/14/repmgr.conf
node_name=el8-repmgr-1
2022.12.22-16:19:58 [7333]INFO: Setting conninfo='host=el8-repmgr-1.localdomain user=repmgr dbname=repmgrdb' in /etc/repmgr/14/repmgr.conf
conninfo='host=el8-repmgr-1.localdomain user=repmgr dbname=repmgrdb'
2022.12.22-16:19:58 [7333]INFO: Setting use_replication_slots=true
use_replication_slots=true
2022.12.22-16:19:58 [7333]INFO: Setting data_directory='/pgdata/14/data' in /etc/repmgr/14/repmgr.conf
data_directory='/pgdata/14/data'
ALTER ROLE
2022.12.22-16:19:58 [7333]INFO: ALTER USER repmgr SET search_path TO repmgr, public;
INFO: connecting to primary database...
NOTICE: attempting to install extension "repmgr"
NOTICE: "repmgr" extension successfully installed
NOTICE: primary node record (ID: 1) registered
2022.12.22-16:19:58 [7333]INFO: Registering master returned 0
[postgres@el8-repmgr-1 config]$
[postgres@el8-repmgr-1 config]$ /usr/pgsql-14/bin/repmgr cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+--------------+---------+-----------+----------+----------+----------+----------+-----------------------------------------------------------
1 | el8-repmgr-1 | primary | * running | | default | 100 | 1 | host=el8-repmgr-1.localdomain user=repmgr dbname=repmgrdb
[postgres@el8-repmgr-1 config]$Leader / Master 现在正在运行,让我们安装 Replica。
[root@el8-repmgr-2 install]# sh pg_setup.sh -h
PostgreSQL Installation on AlmaLinux 8 / CentOS 8 / Oracle Linxu 8 / RHEL 8 / Rocky Linux 8
Usage:
[OPTION]
Options:
-v <PostgreSQL Version> Major Release of Postgresql (required)
-t <PostgreSQL Node Type> If the System is Primary / Single (p) or Secondary (s) in a Cluster (required)
-h <Help> prints this help
[root@el8-repmgr-2 install]#
[root@el8-repmgr-2 install]# sh pg_setup.sh -v14 -t s
PostgreSQL Installation on AlmaLinux 8 / CentOS 8 / Oracle Linxu 8 / RHEL 8 / Rocky Linux 8
Disabling PostgreSQL Packages provided by CentOS 8 or RedHat 8
Last metadata expiration check: 7:03:32 ago on Thu 22 Dec 2022 02:59:34 PM CET.
Dependencies resolved.
==========================================================================================================================================================================================================================================================================================
Package Architecture Version Repository Size
==========================================================================================================================================================================================================================================================================================
Disabling modules:
postgresql
Transaction Summary
==========================================================================================================================================================================================================================================================================================
Complete!
Adding PostgreSQL Repository
Last metadata expiration check: 7:03:33 ago on Thu 22 Dec 2022 02:59:34 PM CET.
pgdg-redhat-repo-latest.noarch.rpm 14 kB/s | 13 kB 00:00
Dependencies resolved.
==========================================================================================================================================================================================================================================================================================
Package Architecture Version Repository Size
==========================================================================================================================================================================================================================================================================================
Installing:
pgdg-redhat-repo noarch 42.0-28 @commandline 13 k
Transaction Summary
==========================================================================================================================================================================================================================================================================================
Install 1 Package
Total size: 13 k
Installed size: 14 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : pgdg-redhat-repo-42.0-28.noarch 1/1
Verifying : pgdg-redhat-repo-42.0-28.noarch 1/1
Installed:
pgdg-redhat-repo-42.0-28.noarch
Complete!
Installing PostgreSQL Packages including barman, repmgr and pg_stat_kcache
PostgreSQL common RPMs for RHEL / Rocky 8 - x86_64 90 B/s | 195 B 00:02
PostgreSQL common RPMs for RHEL / Rocky 8 - x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
PostgreSQL common RPMs for RHEL / Rocky 8 - x86_64 159 kB/s | 702 kB 00:04
PostgreSQL 15 for RHEL / Rocky 8 - x86_64 82 B/s | 195 B 00:02
PostgreSQL 15 for RHEL / Rocky 8 - x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
PostgreSQL 15 for RHEL / Rocky 8 - x86_64 48 kB/s | 164 kB 00:03
PostgreSQL 14 for RHEL / Rocky 8 - x86_64 83 B/s | 195 B 00:02
PostgreSQL 14 for RHEL / Rocky 8 - x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
PostgreSQL 14 for RHEL / Rocky 8 - x86_64 112 kB/s | 463 kB 00:04
PostgreSQL 13 for RHEL / Rocky 8 - x86_64 115 B/s | 195 B 00:01
PostgreSQL 13 for RHEL / Rocky 8 - x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
PostgreSQL 13 for RHEL / Rocky 8 - x86_64 212 kB/s | 755 kB 00:03
PostgreSQL 12 for RHEL / Rocky 8 - x86_64 104 B/s | 195 B 00:01
PostgreSQL 12 for RHEL / Rocky 8 - x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
PostgreSQL 12 for RHEL / Rocky 8 - x86_64 217 kB/s | 901 kB 00:04
PostgreSQL 11 for RHEL / Rocky 8 - x86_64 105 B/s | 195 B 00:01
PostgreSQL 11 for RHEL / Rocky 8 - x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
PostgreSQL 11 for RHEL / Rocky 8 - x86_64 288 kB/s | 1.1 MB 00:03
PostgreSQL 10 for RHEL / Rocky 8 - x86_64 100 B/s | 195 B 00:01
PostgreSQL 10 for RHEL / Rocky 8 - x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
PostgreSQL 10 for RHEL / Rocky 8 - x86_64 194 kB/s | 700 kB 00:03
Dependencies resolved.
==========================================================================================================================================================================================================================================================================================
Package Architecture Version Repository Size
==========================================================================================================================================================================================================================================================================================
Installing:
barman noarch 3.3.0-1.rhel8 pgdg-common 48 k
pg_stat_kcache_14 x86_64 2.2.1-2.rhel8 pgdg14 47 k
postgresql14 x86_64 14.6-1PGDG.rhel8 pgdg14 1.5 M
postgresql14-contrib x86_64 14.6-1PGDG.rhel8 pgdg14 726 k
postgresql14-libs x86_64 14.6-1PGDG.rhel8 pgdg14 278 k
postgresql14-server x86_64 14.6-1PGDG.rhel8 pgdg14 5.7 M
repmgr_14 x86_64 5.3.3-1.rhel8 pgdg14 284 k
Installing dependencies:
libicu x86_64 60.3-2.el8_1 baseos 8.8 M
lz4 x86_64 1.8.3-3.el8_4 baseos 102 k
perl-Carp noarch 1.42-396.el8 baseos 30 k
perl-Data-Dumper x86_64 2.167-399.el8 baseos 58 k
perl-Digest noarch 1.17-395.el8 appstream 27 k
perl-Digest-MD5 x86_64 2.55-396.el8 appstream 37 k
perl-Encode x86_64 4:2.97-3.el8 baseos 1.5 M
perl-Errno x86_64 1.28-421.el8 baseos 75 k
perl-Exporter noarch 5.72-396.el8 baseos 34 k
perl-File-Path noarch 2.15-2.el8 baseos 38 k
perl-File-Temp noarch 0.230.600-1.el8 baseos 62 k
perl-Getopt-Long noarch 1:2.50-4.el8 baseos 63 k
perl-HTTP-Tiny noarch 0.074-1.el8 baseos 58 k
perl-IO x86_64 1.38-421.el8 baseos 141 k
perl-MIME-Base64 x86_64 3.15-396.el8 baseos 30 k
perl-Net-SSLeay x86_64 1.88-2.module_el8.6.0+2811+fe6c84b0 appstream 378 k
perl-PathTools x86_64 3.74-1.el8 baseos 90 k
perl-Pod-Escapes noarch 1:1.07-395.el8 baseos 20 k
perl-Pod-Perldoc noarch 3.28-396.el8 baseos 86 k
perl-Pod-Simple noarch 1:3.35-395.el8 baseos 213 k
perl-Pod-Usage noarch 4:1.69-395.el8 baseos 34 k
perl-Scalar-List-Utils x86_64 3:1.49-2.el8 baseos 68 k
perl-Socket x86_64 4:2.027-3.el8 baseos 59 k
perl-Storable x86_64 1:3.11-3.el8 baseos 98 k
perl-Term-ANSIColor noarch 4.06-396.el8 baseos 46 k
perl-Term-Cap noarch 1.17-395.el8 baseos 23 k
perl-Text-ParseWords noarch 3.30-395.el8 baseos 18 k
perl-Text-Tabs+Wrap noarch 2013.0523-395.el8 baseos 24 k
perl-Time-Local noarch 1:1.280-1.el8 baseos 33 k
perl-URI noarch 1.73-3.el8 appstream 116 k
perl-Unicode-Normalize x86_64 1.25-396.el8 baseos 82 k
perl-constant noarch 1.33-396.el8 baseos 25 k
perl-interpreter x86_64 4:5.26.3-421.el8 baseos 6.3 M
perl-libnet noarch 3.11-3.el8 appstream 121 k
perl-libs x86_64 4:5.26.3-421.el8 baseos 1.6 M
perl-macros x86_64 4:5.26.3-421.el8 baseos 71 k
perl-parent noarch 1:0.237-1.el8 baseos 20 k
perl-podlators noarch 4.11-1.el8 baseos 118 k
perl-threads x86_64 1:2.21-2.el8 baseos 61 k
perl-threads-shared x86_64 1.58-2.el8 baseos 47 k
python3-argcomplete noarch 1.9.3-6.el8 appstream 60 k
python3-barman noarch 3.3.0-1.rhel8 pgdg-common 455 k
python3-pip noarch 9.0.3-22.el8 appstream 19 k
python3-psycopg2 x86_64 2.8.6-1.rhel8 pgdg-common 178 k
python3-setuptools noarch 39.2.0-6.el8 baseos 162 k
python36 x86_64 3.6.8-38.module_el8.5.0+2569+5c5719bc appstream 18 k
rsync x86_64 3.1.3-19.el8 baseos 409 k
Installing weak dependencies:
perl-IO-Socket-IP noarch 0.39-5.el8 appstream 47 k
perl-IO-Socket-SSL noarch 2.066-4.module_el8.6.0+2811+fe6c84b0 appstream 297 k
perl-Mozilla-CA noarch 20160104-7.module_el8.5.0+2812+ed912d05 appstream 14 k
Enabling module streams:
perl 5.26
perl-IO-Socket-SSL 2.066
perl-libwww-perl 6.34
python36 3.6
Transaction Summary
==========================================================================================================================================================================================================================================================================================
Install 57 Packages
Total download size: 31 M
Installed size: 107 M
Downloading Packages:
(1/57): perl-Carp-1.42-396.el8.noarch.rpm 292 kB/s | 30 kB 00:00
(2/57): lz4-1.8.3-3.el8_4.x86_64.rpm 696 kB/s | 102 kB 00:00
(3/57): perl-Data-Dumper-2.167-399.el8.x86_64.rpm 1.1 MB/s | 58 kB 00:00
(4/57): perl-Errno-1.28-421.el8.x86_64.rpm 1.4 MB/s | 75 kB 00:00
(5/57): perl-Exporter-5.72-396.el8.noarch.rpm 991 kB/s | 34 kB 00:00
(6/57): perl-File-Path-2.15-2.el8.noarch.rpm 1.2 MB/s | 38 kB 00:00
(7/57): perl-File-Temp-0.230.600-1.el8.noarch.rpm 2.4 MB/s | 62 kB 00:00
(8/57): perl-Getopt-Long-2.50-4.el8.noarch.rpm 2.0 MB/s | 63 kB 00:00
(9/57): perl-HTTP-Tiny-0.074-1.el8.noarch.rpm 1.6 MB/s | 58 kB 00:00
(10/57): perl-IO-1.38-421.el8.x86_64.rpm 2.2 MB/s | 141 kB 00:00
(11/57): perl-MIME-Base64-3.15-396.el8.x86_64.rpm 1.0 MB/s | 30 kB 00:00
(12/57): perl-PathTools-3.74-1.el8.x86_64.rpm 3.2 MB/s | 90 kB 00:00
(13/57): perl-Pod-Escapes-1.07-395.el8.noarch.rpm 828 kB/s | 20 kB 00:00
(14/57): perl-Pod-Perldoc-3.28-396.el8.noarch.rpm 2.9 MB/s | 86 kB 00:00
(15/57): perl-Pod-Simple-3.35-395.el8.noarch.rpm 3.8 MB/s | 213 kB 00:00
(16/57): perl-Encode-2.97-3.el8.x86_64.rpm 3.1 MB/s | 1.5 MB 00:00
(17/57): perl-Pod-Usage-1.69-395.el8.noarch.rpm 1.3 MB/s | 34 kB 00:00
(18/57): perl-Scalar-List-Utils-1.49-2.el8.x86_64.rpm 2.1 MB/s | 68 kB 00:00
(19/57): perl-Socket-2.027-3.el8.x86_64.rpm 1.5 MB/s | 59 kB 00:00
(20/57): perl-Storable-3.11-3.el8.x86_64.rpm 2.9 MB/s | 98 kB 00:00
(21/57): perl-Term-ANSIColor-4.06-396.el8.noarch.rpm 1.3 MB/s | 46 kB 00:00
(22/57): perl-Term-Cap-1.17-395.el8.noarch.rpm 712 kB/s | 23 kB 00:00
(23/57): perl-Text-ParseWords-3.30-395.el8.noarch.rpm 681 kB/s | 18 kB 00:00
(24/57): perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch.rpm 965 kB/s | 24 kB 00:00
(25/57): perl-Time-Local-1.280-1.el8.noarch.rpm 1.2 MB/s | 33 kB 00:00
(26/57): perl-Unicode-Normalize-1.25-396.el8.x86_64.rpm 3.0 MB/s | 82 kB 00:00
(27/57): perl-constant-1.33-396.el8.noarch.rpm 846 kB/s | 25 kB 00:00
(28/57): perl-libs-5.26.3-421.el8.x86_64.rpm 6.5 MB/s | 1.6 MB 00:00
(29/57): perl-macros-5.26.3-421.el8.x86_64.rpm 2.4 MB/s | 71 kB 00:00
(30/57): perl-parent-0.237-1.el8.noarch.rpm 698 kB/s | 20 kB 00:00
(31/57): libicu-60.3-2.el8_1.x86_64.rpm 8.0 MB/s | 8.8 MB 00:01
(32/57): perl-podlators-4.11-1.el8.noarch.rpm 3.9 MB/s | 118 kB 00:00
(33/57): perl-threads-shared-1.58-2.el8.x86_64.rpm 1.9 MB/s | 47 kB 00:00
(34/57): perl-threads-2.21-2.el8.x86_64.rpm 2.2 MB/s | 61 kB 00:00
(35/57): python3-setuptools-39.2.0-6.el8.noarch.rpm 5.2 MB/s | 162 kB 00:00
(36/57): rsync-3.1.3-19.el8.x86_64.rpm 11 MB/s | 409 kB 00:00
(37/57): perl-Digest-1.17-395.el8.noarch.rpm 803 kB/s | 27 kB 00:00
(38/57): perl-Digest-MD5-2.55-396.el8.x86_64.rpm 1.4 MB/s | 37 kB 00:00
(39/57): perl-IO-Socket-IP-0.39-5.el8.noarch.rpm 1.5 MB/s | 47 kB 00:00
(40/57): perl-IO-Socket-SSL-2.066-4.module_el8.6.0+2811+fe6c84b0.noarch.rpm 7.9 MB/s | 297 kB 00:00
(41/57): perl-Mozilla-CA-20160104-7.module_el8.5.0+2812+ed912d05.noarch.rpm 486 kB/s | 14 kB 00:00
(42/57): perl-Net-SSLeay-1.88-2.module_el8.6.0+2811+fe6c84b0.x86_64.rpm 9.7 MB/s | 378 kB 00:00
(43/57): perl-URI-1.73-3.el8.noarch.rpm 5.1 MB/s | 116 kB 00:00
(44/57): perl-libnet-3.11-3.el8.noarch.rpm 4.3 MB/s | 121 kB 00:00
(45/57): python3-argcomplete-1.9.3-6.el8.noarch.rpm 2.1 MB/s | 60 kB 00:00
(46/57): python3-pip-9.0.3-22.el8.noarch.rpm 851 kB/s | 19 kB 00:00
(47/57): python36-3.6.8-38.module_el8.5.0+2569+5c5719bc.x86_64.rpm 692 kB/s | 18 kB 00:00
(48/57): perl-interpreter-5.26.3-421.el8.x86_64.rpm 9.6 MB/s | 6.3 MB 00:00
(49/57): barman-3.3.0-1.rhel8.noarch.rpm 30 kB/s | 48 kB 00:01
(50/57): python3-barman-3.3.0-1.rhel8.noarch.rpm 281 kB/s | 455 kB 00:01
(51/57): python3-psycopg2-2.8.6-1.rhel8.x86_64.rpm 116 kB/s | 178 kB 00:01
(52/57): pg_stat_kcache_14-2.2.1-2.rhel8.x86_64.rpm 103 kB/s | 47 kB 00:00
(53/57): postgresql14-14.6-1PGDG.rhel8.x86_64.rpm 2.9 MB/s | 1.5 MB 00:00
(54/57): postgresql14-contrib-14.6-1PGDG.rhel8.x86_64.rpm 1.3 MB/s | 726 kB 00:00
(55/57): repmgr_14-5.3.3-1.rhel8.x86_64.rpm 1.4 MB/s | 284 kB 00:00
(56/57): postgresql14-server-14.6-1PGDG.rhel8.x86_64.rpm 9.8 MB/s | 5.7 MB 00:00
(57/57): postgresql14-libs-14.6-1PGDG.rhel8.x86_64.rpm 408 kB/s | 278 kB 00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 5.5 MB/s | 31 MB 00:05
PostgreSQL common RPMs for RHEL / Rocky 8 - x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : perl-Digest-1.17-395.el8.noarch 1/57
Installing : perl-Digest-MD5-2.55-396.el8.x86_64 2/57
Installing : perl-Data-Dumper-2.167-399.el8.x86_64 3/57
Installing : perl-libnet-3.11-3.el8.noarch 4/57
Installing : perl-Net-SSLeay-1.88-2.module_el8.6.0+2811+fe6c84b0.x86_64 5/57
Installing : perl-URI-1.73-3.el8.noarch 6/57
Installing : perl-Pod-Escapes-1:1.07-395.el8.noarch 7/57
Installing : perl-Time-Local-1:1.280-1.el8.noarch 8/57
Installing : perl-IO-Socket-IP-0.39-5.el8.noarch 9/57
Installing : perl-Mozilla-CA-20160104-7.module_el8.5.0+2812+ed912d05.noarch 10/57
Installing : perl-IO-Socket-SSL-2.066-4.module_el8.6.0+2811+fe6c84b0.noarch 11/57
Installing : perl-Term-ANSIColor-4.06-396.el8.noarch 12/57
Installing : perl-Term-Cap-1.17-395.el8.noarch 13/57
Installing : perl-File-Temp-0.230.600-1.el8.noarch 14/57
Installing : perl-Pod-Simple-1:3.35-395.el8.noarch 15/57
Installing : perl-HTTP-Tiny-0.074-1.el8.noarch 16/57
Installing : perl-podlators-4.11-1.el8.noarch 17/57
Installing : perl-Pod-Perldoc-3.28-396.el8.noarch 18/57
Installing : perl-Text-ParseWords-3.30-395.el8.noarch 19/57
Installing : perl-Pod-Usage-4:1.69-395.el8.noarch 20/57
Installing : perl-MIME-Base64-3.15-396.el8.x86_64 21/57
Installing : perl-Storable-1:3.11-3.el8.x86_64 22/57
Installing : perl-Getopt-Long-1:2.50-4.el8.noarch 23/57
Installing : perl-Errno-1.28-421.el8.x86_64 24/57
Installing : perl-Socket-4:2.027-3.el8.x86_64 25/57
Installing : perl-Encode-4:2.97-3.el8.x86_64 26/57
Installing : perl-Exporter-5.72-396.el8.noarch 27/57
Installing : perl-Scalar-List-Utils-3:1.49-2.el8.x86_64 28/57
Installing : perl-macros-4:5.26.3-421.el8.x86_64 29/57
Installing : perl-parent-1:0.237-1.el8.noarch 30/57
Installing : perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch 31/57
Installing : perl-Unicode-Normalize-1.25-396.el8.x86_64 32/57
Installing : perl-File-Path-2.15-2.el8.noarch 33/57
Installing : perl-IO-1.38-421.el8.x86_64 34/57
Installing : perl-PathTools-3.74-1.el8.x86_64 35/57
Installing : perl-constant-1.33-396.el8.noarch 36/57
Installing : perl-threads-1:2.21-2.el8.x86_64 37/57
Installing : perl-threads-shared-1.58-2.el8.x86_64 38/57
Installing : perl-libs-4:5.26.3-421.el8.x86_64 39/57
Installing : perl-Carp-1.42-396.el8.noarch 40/57
Installing : perl-interpreter-4:5.26.3-421.el8.x86_64 41/57
Installing : postgresql14-libs-14.6-1PGDG.rhel8.x86_64 42/57
Running scriptlet: postgresql14-libs-14.6-1PGDG.rhel8.x86_64 42/57
Installing : python3-setuptools-39.2.0-6.el8.noarch 43/57
Installing : python3-pip-9.0.3-22.el8.noarch 44/57
Installing : python36-3.6.8-38.module_el8.5.0+2569+5c5719bc.x86_64 45/57
Running scriptlet: python36-3.6.8-38.module_el8.5.0+2569+5c5719bc.x86_64 45/57
Installing : libicu-60.3-2.el8_1.x86_64 46/57
Running scriptlet: libicu-60.3-2.el8_1.x86_64 46/57
Installing : python3-psycopg2-2.8.6-1.rhel8.x86_64 47/57
Installing : python3-argcomplete-1.9.3-6.el8.noarch 48/57
Installing : python3-barman-3.3.0-1.rhel8.noarch 49/57
Installing : rsync-3.1.3-19.el8.x86_64 50/57
Installing : lz4-1.8.3-3.el8_4.x86_64 51/57
Installing : postgresql14-14.6-1PGDG.rhel8.x86_64 52/57
Running scriptlet: postgresql14-14.6-1PGDG.rhel8.x86_64 52/57
Running scriptlet: postgresql14-server-14.6-1PGDG.rhel8.x86_64 53/57
Installing : postgresql14-server-14.6-1PGDG.rhel8.x86_64 53/57
Running scriptlet: postgresql14-server-14.6-1PGDG.rhel8.x86_64 53/57
Installing : pg_stat_kcache_14-2.2.1-2.rhel8.x86_64 54/57
Running scriptlet: pg_stat_kcache_14-2.2.1-2.rhel8.x86_64 54/57
Installing : postgresql14-contrib-14.6-1PGDG.rhel8.x86_64 55/57
Running scriptlet: repmgr_14-5.3.3-1.rhel8.x86_64 56/57
Installing : repmgr_14-5.3.3-1.rhel8.x86_64 56/57
Running scriptlet: repmgr_14-5.3.3-1.rhel8.x86_64 56/57
Running scriptlet: barman-3.3.0-1.rhel8.noarch 57/57
Installing : barman-3.3.0-1.rhel8.noarch 57/57
Running scriptlet: barman-3.3.0-1.rhel8.noarch 57/57
Verifying : libicu-60.3-2.el8_1.x86_64 1/57
Verifying : lz4-1.8.3-3.el8_4.x86_64 2/57
Verifying : perl-Carp-1.42-396.el8.noarch 3/57
Verifying : perl-Data-Dumper-2.167-399.el8.x86_64 4/57
Verifying : perl-Encode-4:2.97-3.el8.x86_64 5/57
Verifying : perl-Errno-1.28-421.el8.x86_64 6/57
Verifying : perl-Exporter-5.72-396.el8.noarch 7/57
Verifying : perl-File-Path-2.15-2.el8.noarch 8/57
Verifying : perl-File-Temp-0.230.600-1.el8.noarch 9/57
Verifying : perl-Getopt-Long-1:2.50-4.el8.noarch 10/57
Verifying : perl-HTTP-Tiny-0.074-1.el8.noarch 11/57
Verifying : perl-IO-1.38-421.el8.x86_64 12/57
Verifying : perl-MIME-Base64-3.15-396.el8.x86_64 13/57
Verifying : perl-PathTools-3.74-1.el8.x86_64 14/57
Verifying : perl-Pod-Escapes-1:1.07-395.el8.noarch 15/57
Verifying : perl-Pod-Perldoc-3.28-396.el8.noarch 16/57
Verifying : perl-Pod-Simple-1:3.35-395.el8.noarch 17/57
Verifying : perl-Pod-Usage-4:1.69-395.el8.noarch 18/57
Verifying : perl-Scalar-List-Utils-3:1.49-2.el8.x86_64 19/57
Verifying : perl-Socket-4:2.027-3.el8.x86_64 20/57
Verifying : perl-Storable-1:3.11-3.el8.x86_64 21/57
Verifying : perl-Term-ANSIColor-4.06-396.el8.noarch 22/57
Verifying : perl-Term-Cap-1.17-395.el8.noarch 23/57
Verifying : perl-Text-ParseWords-3.30-395.el8.noarch 24/57
Verifying : perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch 25/57
Verifying : perl-Time-Local-1:1.280-1.el8.noarch 26/57
Verifying : perl-Unicode-Normalize-1.25-396.el8.x86_64 27/57
Verifying : perl-constant-1.33-396.el8.noarch 28/57
Verifying : perl-interpreter-4:5.26.3-421.el8.x86_64 29/57
Verifying : perl-libs-4:5.26.3-421.el8.x86_64 30/57
Verifying : perl-macros-4:5.26.3-421.el8.x86_64 31/57
Verifying : perl-parent-1:0.237-1.el8.noarch 32/57
Verifying : perl-podlators-4.11-1.el8.noarch 33/57
Verifying : perl-threads-1:2.21-2.el8.x86_64 34/57
Verifying : perl-threads-shared-1.58-2.el8.x86_64 35/57
Verifying : python3-setuptools-39.2.0-6.el8.noarch 36/57
Verifying : rsync-3.1.3-19.el8.x86_64 37/57
Verifying : perl-Digest-1.17-395.el8.noarch 38/57
Verifying : perl-Digest-MD5-2.55-396.el8.x86_64 39/57
Verifying : perl-IO-Socket-IP-0.39-5.el8.noarch 40/57
Verifying : perl-IO-Socket-SSL-2.066-4.module_el8.6.0+2811+fe6c84b0.noarch 41/57
Verifying : perl-Mozilla-CA-20160104-7.module_el8.5.0+2812+ed912d05.noarch 42/57
Verifying : perl-Net-SSLeay-1.88-2.module_el8.6.0+2811+fe6c84b0.x86_64 43/57
Verifying : perl-URI-1.73-3.el8.noarch 44/57
Verifying : perl-libnet-3.11-3.el8.noarch 45/57
Verifying : python3-argcomplete-1.9.3-6.el8.noarch 46/57
Verifying : python3-pip-9.0.3-22.el8.noarch 47/57
Verifying : python36-3.6.8-38.module_el8.5.0+2569+5c5719bc.x86_64 48/57
Verifying : barman-3.3.0-1.rhel8.noarch 49/57
Verifying : python3-barman-3.3.0-1.rhel8.noarch 50/57
Verifying : python3-psycopg2-2.8.6-1.rhel8.x86_64 51/57
Verifying : pg_stat_kcache_14-2.2.1-2.rhel8.x86_64 52/57
Verifying : postgresql14-14.6-1PGDG.rhel8.x86_64 53/57
Verifying : postgresql14-contrib-14.6-1PGDG.rhel8.x86_64 54/57
Verifying : postgresql14-libs-14.6-1PGDG.rhel8.x86_64 55/57
Verifying : postgresql14-server-14.6-1PGDG.rhel8.x86_64 56/57
Verifying : repmgr_14-5.3.3-1.rhel8.x86_64 57/57
Installed:
barman-3.3.0-1.rhel8.noarch libicu-60.3-2.el8_1.x86_64 lz4-1.8.3-3.el8_4.x86_64 perl-Carp-1.42-396.el8.noarch perl-Data-Dumper-2.167-399.el8.x86_64
perl-Digest-1.17-395.el8.noarch perl-Digest-MD5-2.55-396.el8.x86_64 perl-Encode-4:2.97-3.el8.x86_64 perl-Errno-1.28-421.el8.x86_64 perl-Exporter-5.72-396.el8.noarch
perl-File-Path-2.15-2.el8.noarch perl-File-Temp-0.230.600-1.el8.noarch perl-Getopt-Long-1:2.50-4.el8.noarch perl-HTTP-Tiny-0.074-1.el8.noarch perl-IO-1.38-421.el8.x86_64
perl-IO-Socket-IP-0.39-5.el8.noarch perl-IO-Socket-SSL-2.066-4.module_el8.6.0+2811+fe6c84b0.noarch perl-MIME-Base64-3.15-396.el8.x86_64 perl-Mozilla-CA-20160104-7.module_el8.5.0+2812+ed912d05.noarch perl-Net-SSLeay-1.88-2.module_el8.6.0+2811+fe6c84b0.x86_64
perl-PathTools-3.74-1.el8.x86_64 perl-Pod-Escapes-1:1.07-395.el8.noarch perl-Pod-Perldoc-3.28-396.el8.noarch perl-Pod-Simple-1:3.35-395.el8.noarch perl-Pod-Usage-4:1.69-395.el8.noarch
perl-Scalar-List-Utils-3:1.49-2.el8.x86_64 perl-Socket-4:2.027-3.el8.x86_64 perl-Storable-1:3.11-3.el8.x86_64 perl-Term-ANSIColor-4.06-396.el8.noarch perl-Term-Cap-1.17-395.el8.noarch
perl-Text-ParseWords-3.30-395.el8.noarch perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch perl-Time-Local-1:1.280-1.el8.noarch perl-URI-1.73-3.el8.noarch perl-Unicode-Normalize-1.25-396.el8.x86_64
perl-constant-1.33-396.el8.noarch perl-interpreter-4:5.26.3-421.el8.x86_64 perl-libnet-3.11-3.el8.noarch perl-libs-4:5.26.3-421.el8.x86_64 perl-macros-4:5.26.3-421.el8.x86_64
perl-parent-1:0.237-1.el8.noarch perl-podlators-4.11-1.el8.noarch perl-threads-1:2.21-2.el8.x86_64 perl-threads-shared-1.58-2.el8.x86_64 pg_stat_kcache_14-2.2.1-2.rhel8.x86_64
postgresql14-14.6-1PGDG.rhel8.x86_64 postgresql14-contrib-14.6-1PGDG.rhel8.x86_64 postgresql14-libs-14.6-1PGDG.rhel8.x86_64 postgresql14-server-14.6-1PGDG.rhel8.x86_64 python3-argcomplete-1.9.3-6.el8.noarch
python3-barman-3.3.0-1.rhel8.noarch python3-pip-9.0.3-22.el8.noarch python3-psycopg2-2.8.6-1.rhel8.x86_64 python3-setuptools-39.2.0-6.el8.noarch python36-3.6.8-38.module_el8.5.0+2569+5c5719bc.x86_64
repmgr_14-5.3.3-1.rhel8.x86_64 rsync-3.1.3-19.el8.x86_64
Complete!
Creating override.conf
[Service]
Environment=PGDATA=/pgdata/14/data
Initialyze PostgreSQL 14
Initializing database ... OK
Enable PostgreSQL Service
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-14.service → /usr/lib/systemd/system/postgresql-14.service.
success
success
[root@el8-repmgr-2 install]#与 Master / Leader 安装的不同之处在于服务没有启动,我们需要一个空的 pgdata 来创建副本。在安装 PostgreSQL 之后,我们需要再次将配置脚本的所有权更改为 postgresql。
[root@el8-repmgr-2 pgsql]# chown -R postgres:postgres config/再次设置 .pgpass。
[postgres@el8-repmgr-2 config]$ sh pgpass.sh -h
Usage:
pgpass.sh [OPTION]
Options:
-p <Primary Server> server where the primary host is running on (required)
-s <Secondary Server> server where the secondary host is running on (required)
-h <Help> prints this help
[postgres@el8-repmgr-2 config]$
[postgres@el8-repmgr-2 config]$ sh pgpass.sh -p el8-repmgr-1 -s el8-repmgr2
2022.12.22-22:19:53 [4695]INFO: #host:port:database:user:password in /var/lib/pgsql/.pgpass
#host:port:database:user:password
2022.12.22-22:19:53 [4695]INFO: Setting localhost in
localhost:5432:*:repmgr:PutYourPasswordHere
2022.12.22-22:19:53 [4695]INFO: Setting 127.0.0.1 in /var/lib/pgsql/.pgpass
127.0.0.1:5432:*:repmgr:PutYourPasswordHere
2022.12.22-22:19:53 [4695]INFO: Setting Primary el8-repmgr-1 in /var/lib/pgsql/.pgpass
el8-repmgr-1.localdomain:5432:*:repmgr:PutYourPasswordHere
2022.12.22-22:19:53 [4695]INFO: Setting Primary el8-repmgr2 in /var/lib/pgsql/.pgpass
el8-repmgr2.localdomain:5432:*:repmgr:PutYourPasswordHere
[postgres@el8-repmgr-2 config]$现在我们可以开始副本节点的设置,同样,该脚本包含一个带 -h 的帮助。
[postgres@el8-repmgr-2 config]$ sh repMgrStandbyNEW_setup.sh -h
Usage:
repMgrStandbyNEW_setup.sh [OPTION]
Options:
-p <Primary Server> host where the primary server is running on (required)
-s <Standby Server> host where the standby server is running on (required)
-v <PostgreSQL Major Release> Major Release Number like 11 or 12 (required)
-h <Help> prints this help
[postgres@el8-repmgr-2 config]$
[root@el8-repmgr-2 config]# [postgres@el8-repmgr-2 config]$ sh repMgrStandbyNEW_setup.sh -p el8-repmgr-1 -s el8-repmgr-2 -v 14
2022.12.22-22:58:50 [6741]INFO: Setting node_id=2 in /etc/repmgr/14/repmgr.conf
node_id=2
2022.12.22-22:58:50 [6741]INFO: Setting node_name=el8-repmgr-2 in /etc/repmgr/14/repmgr.conf
node_name=el8-repmgr-2
2022.12.22-22:58:50 [6741]INFO: Setting conninfo='host=el8-repmgr-2.localdomain user=repmgr dbname=repmgrdb' in /etc/repmgr/14/repmgr.conf
conninfo='host=el8-repmgr-2.localdomain user=repmgr dbname=repmgrdb'
2022.12.22-22:58:50 [6741]Info: Setting 'use_replication_slots=true' in /etc/repmgr/14/repmgr.conf
use_replication_slots=true
2022.12.22-22:58:50 [6741]INFO: Setting data_directory='/pgdata/14/data' in /etc/repmgr/14/repmgr.conf
data_directory='/pgdata/14/data'
NOTICE: destination directory "/pgdata/14/data" provided
INFO: connecting to source node
DETAIL: connection string is: host=el8-repmgr-1.localdomain user=repmgr dbname=repmgrdb
DETAIL: current installation size is 34 MB
NOTICE: checking for available walsenders on the source node (2 required)
NOTICE: checking replication connections can be made to the source server (2 required)
WARNING: data checksums are not enabled and "wal_log_hints" is "off"
DETAIL: pg_rewind requires "wal_log_hints" to be enabled
WARNING: directory "/pgdata/14/data" exists but is not empty
NOTICE: -F/--force provided - deleting existing data directory "/pgdata/14/data"
NOTICE: starting backup (using pg_basebackup)...
HINT: this may take some time; consider using the -c/--fast-checkpoint option
INFO: executing:
pg_basebackup -l "repmgr base backup" -D /pgdata/14/data -h el8-repmgr-1.localdomain -p 5432 -U repmgr -X stream -S repmgr_slot_2
NOTICE: standby clone (using pg_basebackup) complete
NOTICE: you can now start your PostgreSQL server
HINT: for example: pg_ctl -D /pgdata/14/data start
HINT: after starting the server, you need to register this standby with "repmgr standby register"
2022.12.22-22:58:51 [6741]INFO: Registering standby returned 0
INFO: connecting to local node "el8-repmgr-2" (ID: 2)
INFO: connecting to primary database
WARNING: --upstream-node-id not supplied, assuming upstream node is primary (node ID: 1)
INFO: standby registration complete
NOTICE: standby node "el8-repmgr-2" (ID: 2) successfully registered
setup of standby successfully completed
[postgres@el8-repmgr-2 config]$现在集群已启动并正在运行。
[postgres@el8-repmgr-1 ~]$ /usr/pgsql-14/bin/repmgr cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+--------------+---------+-----------+--------------+----------+----------+----------+-----------------------------------------------------------
1 | el8-repmgr-1 | primary | * running | | default | 100 | 1 | host=el8-repmgr-1.localdomain user=repmgr dbname=repmgrdb
2 | el8-repmgr-2 | standby | running | el8-repmgr-1 | default | 100 | 1 | host=el8-repmgr-2.localdomain user=repmgr dbname=repmgrdb
[postgres@el8-repmgr-1 ~]$repmgr.conf 中的自动故障转移技巧:
node_id=1
node_name=el8-repmgr-1
conninfo='host=el8-repmgr-1.localdomain user=repmgr dbname=repmgrdb'
use_replication_slots=true
data_directory='/pgdata/14/data'
failover='automatic'
promote_command='/usr/pgsql-14/bin/repmgr standby promote -f /etc/repmgr/14/repmgr.conf --log-to-file'
follow_command='/usr/pgsql-14/bin/repmgr standby follow -f /etc/repmgr/14/repmgr.conf --log-to-file --upstream-node-id=%n'
monitor_interval_secs=2
connection_check_type='ping'
reconnect_attempts=6
reconnect_interval=10
standby_disconnect_on_failover=true
service_start_command='sudo /usr/bin/systemctl start postgresql-14.service'
service_stop_command='sudo /usr/bin/systemctl stop postgresql-14.service'
service_restart_command='sudo /usr/bin/systemctl restart postgresql-14.service'
service_reload_command='sudo /usr/bin/systemctl reload postgresql-14.service'故障转移
故障转移参数是 repmgr 守护进程的强制参数之一。该参数告诉守护进程在检测到故障转移情况时是否应该启动自动故障转移。它可以有两个值之一:“手动”或“自动”。我们将在每个节点中将其设置为自动。
提升命令
这是 repmgr 守护进程的另一个强制参数。这个参数告诉 repmgr 守护进程它应该运行什么命令来提升备用。此参数的值通常是“repmgr standby promote”命令,或调用该命令的 shell 脚本的路径
跟随命令
这是 repmgr 守护进程的第三个强制参数。此参数告诉备用节点跟随新的主节点。repmgr 守护进程在运行时用新主节点的节点 ID 替换 %n 占位符。
monitor_interval_secs
该参数告诉 repmgr 守护进程应该多久(以秒为单位)检查上游节点的可用性。在我们的例子中,只有一个上游节点:主节点。默认值为 2 秒,但无论如何我们都会在每个节点中显式设置它。
连接检查类型
connection_check_type 参数规定了 repmgr 守护进程将用于联系上游节点的协议。该参数可以取三个值:
- ping : repmgr 使用 PQPing() 方法
- 连接:repmgr 尝试创建到上游节点的新连接
- query:repmgr 尝试使用现有连接在上游节点上运行 SQL 查询
同样,我们将在每个节点中将此参数设置为默认值 ping。
重新连接尝试和重新连接间隔
当主节点变得不可用时,备用节点中的 repmgr 守护进程将尝试重新连接到主节点 reconnect_attempts 次。此参数的默认值为 6。在每次重新连接尝试之间,它将等待 reconnect_interval 秒,默认值为 10。出于演示目的,我们将使用较短的间隔和较少的重新连接尝试。我们在每个节点中设置这个参数。
standby_disconnect_on_failover
当备用节点中的 standby_disconnect_on_failover 参数设置为“true”时,repmgr 守护进程将确保其 WAL 接收器与主节点断开连接并且不接收任何 WAL 段。它还将等待其他备用节点的 WAL 接收器停止,然后再做出故障转移决定。此参数应在每个节点中设置为相同的值。我们将其设置为“真”。
这是一个小型双节点集群,下一篇博客将扩展到多节点集群并升级到 PostgreSQL 15。
原文标题:Fast setup of a two node repmgr cluster with auto failover
原文作者:Karsten Lenz
原文链接:https://www.dbi-services.com/blog/fast-setup-of-a-two-node-repmgr-cluster-with-auto-failover/




