1. check version before upgrade
SELECT version();
select pg_read_file('/etc/hostname') as hostname, version();
[root@teguhth ~]# su - postgres
Last login: Wed Oct 11 11:15:58 WIB 2023 on pts/1
-bash-4.2$ psql
psql (15.4)
Type "help" for help.
postgres=# SELECT version();
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 15.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
(1 row)
postgres=# select pg_read_file('/etc/hostname') as hostname, version();
hostname | version
----------+---------------------------------------------------------------------------------------------------------
teguhth +| PostgreSQL 15.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
|
(1 row)
postgres=#
2. backup all
su - postgres -c "pg_dumpall -p 5432 > /data/edb/backupupgrade/all_15postgres.sql"
[root@teguhth ~]# su - postgres -c "pg_dumpall -p 5432 > /data/edb/backupupgrade/all_15postgres.sql"
[root@teguhth ~]# ls -l /data/edb/backupupgrade/all_15postgres.sql
-rw-r--r-- 1 postgres postgres 20398 Oct 17 09:35 /data/edb/backupupgrade/all_15postgres.sql
[root@teguhth ~]#
3. remove old repository & install repository, install postgres16
detail http://teguhth.blogspot.com/2021/07/install-postgresql-linux-using.html
rpm -qa | grep -i pgdg
yum remove pgdg-redhat-repo-42.0-32.noarch -y
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum clean all
yum -y install postgresql16-server
[root@teguhth-redhat8 data]# yum clean all
82 files removed
[root@teguhth-redhat8 data]#
[root@teguhth-redhat8 data]# yum -y install postgresql16-server
CentOS-8 - AppStream 265 kB/s | 8.4 MB 00:32
CentOS-8 - Base 282 kB/s | 4.6 MB 00:16
CentOS-8 - Extras 11 kB/s | 10 kB 00:00
MariaDB Server 94 kB/s | 520 kB 00:05
MariaDB MaxScale 2.4 kB/s | 6.8 kB 00:02
MariaDB Tools 19 kB/s | 25 kB 00:01
PostgreSQL common RPMs for RHEL / Rocky 8 - x86_64 114 kB/s | 876 kB 00:07
PostgreSQL 16 for RHEL / Rocky 8 - x86_64 12 kB/s | 112 kB 00:09
PostgreSQL 15 for RHEL / Rocky 8 - x86_64 58 kB/s | 379 kB 00:06
PostgreSQL 14 for RHEL / Rocky 8 - x86_64 51 kB/s | 678 kB 00:13
PostgreSQL 13 for RHEL / Rocky 8 - x86_64 69 kB/s | 963 kB 00:14
PostgreSQL 12 for RHEL / Rocky 8 - x86_64 61 kB/s | 1.1 MB 00:17
PostgreSQL 11 for RHEL / Rocky 8 - x86_64 135 kB/s | 1.2 MB 00:09
Dependencies resolved.
==================================================================================================================================================================
Package Architecture Version Repository Size
==================================================================================================================================================================
Installing:
postgresql16-server x86_64 16.0-1PGDG.rhel8 pgdg16 6.7 M
Installing dependencies:
postgresql16 x86_64 16.0-1PGDG.rhel8 pgdg16 1.9 M
postgresql16-libs x86_64 16.0-1PGDG.rhel8 pgdg16 325 k
Transaction Summary
==================================================================================================================================================================
Install 3 Packages
Total download size: 8.9 M
Installed size: 38 M
Downloading Packages:
(1/3): postgresql16-libs-16.0-1PGDG.rhel8.x86_64.rpm 76 kB/s | 325 kB 00:04
(2/3): postgresql16-16.0-1PGDG.rhel8.x86_64.rpm 97 kB/s | 1.9 MB 00:19
(3/3): postgresql16-server-16.0-1PGDG.rhel8.x86_64.rpm 88 kB/s | 6.7 MB 01:17
------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 117 kB/s | 8.9 MB 01:17
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : postgresql16-libs-16.0-1PGDG.rhel8.x86_64 1/3
Running scriptlet: postgresql16-libs-16.0-1PGDG.rhel8.x86_64 1/3
Installing : postgresql16-16.0-1PGDG.rhel8.x86_64 2/3
Running scriptlet: postgresql16-16.0-1PGDG.rhel8.x86_64 2/3
Running scriptlet: postgresql16-server-16.0-1PGDG.rhel8.x86_64 3/3
Installing : postgresql16-server-16.0-1PGDG.rhel8.x86_64 3/3
Running scriptlet: postgresql16-server-16.0-1PGDG.rhel8.x86_64 3/3
Verifying : postgresql16-16.0-1PGDG.rhel8.x86_64 1/3
Verifying : postgresql16-libs-16.0-1PGDG.rhel8.x86_64 2/3
Verifying : postgresql16-server-16.0-1PGDG.rhel8.x86_64 3/3
Installed:
postgresql16-16.0-1PGDG.rhel8.x86_64 postgresql16-libs-16.0-1PGDG.rhel8.x86_64 postgresql16-server-16.0-1PGDG.rhel8.x86_64
Complete!
[root@teguhth-redhat8 data]#
4. Inisialize the DB
[root@teguhth-redhat8 data]# /usr/pgsql-16/bin/postgresql-16-setup initdb
Initializing database ... OK
[root@teguhth-redhat8 data]#
[root@teguhth data]#
5. stop old progres 15
systemctl stop postgresql-15
[root@teguhth-redhat8 data]# systemctl stop postgresql-15
[root@teguhth-redhat8 data]# systemctl status postgresql-15
? postgresql-15.service - PostgreSQL 15 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-15.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Tue 2023-10-17 10:11:42 WIB; 11s ago
Docs: https://www.postgresql.org/docs/15/static/
Process: 1081 ExecStart=/usr/pgsql-15/bin/postmaster -D ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 1081 (code=exited, status=0/SUCCESS)
Oct 17 09:59:33 teguhth-redhat8 systemd[1]: Starting PostgreSQL 15 database server...
Oct 17 09:59:34 teguhth-redhat8 postmaster[1081]: 2023-10-17 09:59:34.296 WIB [1081] LOG: redirecting log output to logging collector process
Oct 17 09:59:34 teguhth-redhat8 postmaster[1081]: 2023-10-17 09:59:34.296 WIB [1081] HINT: Future log output will appear in directory "log".
Oct 17 09:59:34 teguhth-redhat8 systemd[1]: Started PostgreSQL 15 database server.
Oct 17 10:11:42 teguhth-redhat8 systemd[1]: Stopping PostgreSQL 15 database server...
Oct 17 10:11:42 teguhth-redhat8 systemd[1]: Stopped PostgreSQL 15 database server.
[root@teguhth-redhat8 data]#
6. Check that everything is fine before upgrade
su - postgres
/usr/pgsql-16/bin/pg_upgrade --old-datadir=/var/lib/pgsql/15/data --new-datadir=/var/lib/pgsql/16/data --old-bindir=/usr/pgsql-15/bin --new-bindir=/usr/pgsql-16/bin --old-options '-c config_file=/var/lib/pgsql/15/data/postgresql.conf' --new-options '-c config_file=/var/lib/pgsql/16/data/postgresql.conf' --check
[root@teguhth-redhat8 data]# su - postgres
Last login: Tue Oct 17 09:47:33 WIB 2023 on pts/0
[postgres@teguhth-redhat8 ~]$ /usr/pgsql-16/bin/pg_upgrade --old-datadir=/var/lib/pgsql/15/data --new-datadir=/var/lib/pgsql/16/data --old-bindir=/usr/pgsql-15/bin --new-bindir=/usr/pgsql-16/bin --old-options '-c config_file=/var/lib/pgsql/15/data/postgresql.conf' --new-options '-c config_file=/var/lib/pgsql/16/data/postgresql.conf' --check
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
Checking database user is the install user ok
Checking database connection settings ok
Checking for prepared transactions ok
Checking for system-defined composite types in user tables ok
Checking for reg* data types in user tables ok
Checking for contrib/isn with bigint-passing mismatch ok
Checking for incompatible "aclitem" data type in user tables ok
Checking for presence of required libraries ok
Checking database user is the install user ok
Checking for prepared transactions ok
Checking for new cluster tablespace directories ok
*Clusters are compatible*
[postgres@teguhth-redhat8 ~]$
7. upgrade postgresql
/usr/pgsql-16/bin/pg_upgrade --old-datadir=/var/lib/pgsql/15/data --new-datadir=/var/lib/pgsql/16/data --old-bindir=/usr/pgsql-15/bin --new-bindir=/usr/pgsql-16/bin --old-options '-c config_file=/var/lib/pgsql/15/data/postgresql.conf' --new-options '-c config_file=/var/lib/pgsql/16/data/postgresql.conf'
[postgres@teguhth-redhat8 ~]$ /usr/pgsql-16/bin/pg_upgrade --old-datadir=/var/lib/pgsql/15/data --new-datadir=/var/lib/pgsql/16/data --old-bindir=/usr/pgsql-15/bin --new-bindir=/usr/pgsql-16/bin --old-options '-c config_file=/var/lib/pgsql/15/data/postgresql.conf' --new-options '-c config_file=/var/lib/pgsql/16/data/postgresql.conf'
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
Checking database user is the install user ok
Checking database connection settings ok
Checking for prepared transactions ok
Checking for system-defined composite types in user tables ok
Checking for reg* data types in user tables ok
Checking for contrib/isn with bigint-passing mismatch ok
Checking for incompatible "aclitem" data type in user tables ok
Creating dump of global objects ok
Creating dump of database schemas
ok
Checking for presence of required libraries ok
Checking database user is the install user ok
Checking for prepared transactions ok
Checking for new cluster tablespace directories ok
If pg_upgrade fails after this point, you must re-initdb the
new cluster before continuing.
Performing Upgrade
------------------
Setting locale and encoding for new cluster ok
Analyzing all rows in the new cluster ok
Freezing all rows in the new cluster ok
Deleting files from new pg_xact ok
Copying old pg_xact to new server ok
Setting oldest XID for new cluster ok
Setting next transaction ID and epoch for new cluster ok
Deleting files from new pg_multixact/offsets ok
Copying old pg_multixact/offsets to new server ok
Deleting files from new pg_multixact/members ok
Copying old pg_multixact/members to new server ok
Setting next multixact ID and offset for new cluster ok
Resetting WAL archives ok
Setting frozenxid and minmxid counters in new cluster ok
Restoring global objects in the new cluster ok
Restoring database schemas in the new cluster
ok
Copying user relation files
ok
Setting next OID for new cluster ok
Sync data directory to disk ok
Creating script to delete old cluster ok
Checking for extension updates ok
Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade.
Once you start the new server, consider running:
/usr/pgsql-16/bin/vacuumdb --all --analyze-in-stages
Running this script will delete the old cluster's data files:
./delete_old_cluster.sh
[postgres@teguhth-redhat8 ~]$
8. start new postgresql
systemctl start postgresql-16
[root@teguhth-redhat8 data]# systemctl start postgresql-16
[root@teguhth-redhat8 data]# systemctl enable postgresql-16
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-16.service ? /usr/lib/systemd/system/postgresql-16.service.
[root@teguhth-redhat8 data]#
9. check new version
[postgres@teguhth-redhat8 ~]$ psql -c "select pg_read_file('/etc/hostname') as hostname, version();"
hostname | version
-----------------+---------------------------------------------------------------------------------------------------------
teguhth-redhat8+| PostgreSQL 16.0 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-18), 64-bit
|
(1 row)
[postgres@teguhth-redhat8 ~]$
\l
select pg_read_file('/etc/hostname') as hostname,version(),datname from pg_database;
10. copy all old config to new config
su - postgres
cp /var/lib/pgsql/15/data/postgresql.conf /var/lib/pgsql/16/data/postgresql.conf
cp /var/lib/pgsql/15/data/pg_hba.conf /var/lib/pgsql/16/data/pg_hba.conf
[postgres@teguhth-redhat8 ~]$ cp /var/lib/pgsql/15/data/postgresql.conf /var/lib/pgsql/16/data/postgresql.conf
[postgres@teguhth-redhat8 ~]$ cp /var/lib/pgsql/15/data/pg_hba.conf /var/lib/pgsql/16/data/pg_hba.conf
[postgres@teguhth-redhat8 ~]$
11. restart new postgresql-16 again
systemctl restart postgresql-16
[root@teguhth-redhat8 data]# systemctl restart postgresql-16
[root@teguhth-redhat8 data]#
12. check new version again
-bash-4.2$ psql -c "select pg_read_file('/etc/hostname') as hostname, version();"
hostname | version
----------+---------------------------------------------------------------------------------------------------------
teguhth +| PostgreSQL 15.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
|
(1 row)
13. check rpm for posgres
rpm -qa | grep -i postgres
[root@teguhth-redhat8 ~]# rpm -qa | grep -i postgres
postgresql16-server-16.0-1PGDG.rhel8.x86_64
postgresql15-libs-15.4-1PGDG.rhel8.x86_64
postgresql15-server-15.4-1PGDG.rhel8.x86_64
postgresql16-16.0-1PGDG.rhel8.x86_64
postgresql15-15.4-1PGDG.rhel8.x86_64
postgresql16-libs-16.0-1PGDG.rhel8.x86_64
[root@teguhth-redhat8 ~]#
14. remove & delete old directory
yum remove postgresql15* -y
[root@teguhth ~]# yum remove postgresql15* -y
[root@teguhth ~]# rm -rf /var/lib/pgsql/15
15. check packet
[root@teguhth ~]# rpm -qa | grep -i postgres
[root@teguhth-redhat8 ~]#
[root@teguhth-redhat8 ~]#
[root@teguhth-redhat8 ~]# rpm -qa | grep -i postgres
postgresql16-server-16.0-1PGDG.rhel8.x86_64
postgresql16-16.0-1PGDG.rhel8.x86_64
postgresql16-libs-16.0-1PGDG.rhel8.x86_64
[root@teguhth-redhat8 ~]#
16. login n cek database
\c teguhth
select * from pembelian;
SELECT version();
select pg_read_file('/etc/hostname') as hostname, version();
[root@teguhth ~]# su - postgres
Last login: Wed Oct 11 11:15:58 WIB 2023 on pts/1
-bash-4.2$ psql
psql (15.4)
Type "help" for help.
postgres=# SELECT version();
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 15.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
(1 row)
postgres=# select pg_read_file('/etc/hostname') as hostname, version();
hostname | version
----------+---------------------------------------------------------------------------------------------------------
teguhth +| PostgreSQL 15.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
|
(1 row)
postgres=#
2. backup all
su - postgres -c "pg_dumpall -p 5432 > /data/edb/backupupgrade/all_15postgres.sql"
[root@teguhth ~]# su - postgres -c "pg_dumpall -p 5432 > /data/edb/backupupgrade/all_15postgres.sql"
[root@teguhth ~]# ls -l /data/edb/backupupgrade/all_15postgres.sql
-rw-r--r-- 1 postgres postgres 20398 Oct 17 09:35 /data/edb/backupupgrade/all_15postgres.sql
[root@teguhth ~]#
3. remove old repository & install repository, install postgres16
detail http://teguhth.blogspot.com/2021/07/install-postgresql-linux-using.html
rpm -qa | grep -i pgdg
yum remove pgdg-redhat-repo-42.0-32.noarch -y
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum clean all
yum -y install postgresql16-server
[root@teguhth-redhat8 data]# yum clean all
82 files removed
[root@teguhth-redhat8 data]#
[root@teguhth-redhat8 data]# yum -y install postgresql16-server
CentOS-8 - AppStream 265 kB/s | 8.4 MB 00:32
CentOS-8 - Base 282 kB/s | 4.6 MB 00:16
CentOS-8 - Extras 11 kB/s | 10 kB 00:00
MariaDB Server 94 kB/s | 520 kB 00:05
MariaDB MaxScale 2.4 kB/s | 6.8 kB 00:02
MariaDB Tools 19 kB/s | 25 kB 00:01
PostgreSQL common RPMs for RHEL / Rocky 8 - x86_64 114 kB/s | 876 kB 00:07
PostgreSQL 16 for RHEL / Rocky 8 - x86_64 12 kB/s | 112 kB 00:09
PostgreSQL 15 for RHEL / Rocky 8 - x86_64 58 kB/s | 379 kB 00:06
PostgreSQL 14 for RHEL / Rocky 8 - x86_64 51 kB/s | 678 kB 00:13
PostgreSQL 13 for RHEL / Rocky 8 - x86_64 69 kB/s | 963 kB 00:14
PostgreSQL 12 for RHEL / Rocky 8 - x86_64 61 kB/s | 1.1 MB 00:17
PostgreSQL 11 for RHEL / Rocky 8 - x86_64 135 kB/s | 1.2 MB 00:09
Dependencies resolved.
==================================================================================================================================================================
Package Architecture Version Repository Size
==================================================================================================================================================================
Installing:
postgresql16-server x86_64 16.0-1PGDG.rhel8 pgdg16 6.7 M
Installing dependencies:
postgresql16 x86_64 16.0-1PGDG.rhel8 pgdg16 1.9 M
postgresql16-libs x86_64 16.0-1PGDG.rhel8 pgdg16 325 k
Transaction Summary
==================================================================================================================================================================
Install 3 Packages
Total download size: 8.9 M
Installed size: 38 M
Downloading Packages:
(1/3): postgresql16-libs-16.0-1PGDG.rhel8.x86_64.rpm 76 kB/s | 325 kB 00:04
(2/3): postgresql16-16.0-1PGDG.rhel8.x86_64.rpm 97 kB/s | 1.9 MB 00:19
(3/3): postgresql16-server-16.0-1PGDG.rhel8.x86_64.rpm 88 kB/s | 6.7 MB 01:17
------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 117 kB/s | 8.9 MB 01:17
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : postgresql16-libs-16.0-1PGDG.rhel8.x86_64 1/3
Running scriptlet: postgresql16-libs-16.0-1PGDG.rhel8.x86_64 1/3
Installing : postgresql16-16.0-1PGDG.rhel8.x86_64 2/3
Running scriptlet: postgresql16-16.0-1PGDG.rhel8.x86_64 2/3
Running scriptlet: postgresql16-server-16.0-1PGDG.rhel8.x86_64 3/3
Installing : postgresql16-server-16.0-1PGDG.rhel8.x86_64 3/3
Running scriptlet: postgresql16-server-16.0-1PGDG.rhel8.x86_64 3/3
Verifying : postgresql16-16.0-1PGDG.rhel8.x86_64 1/3
Verifying : postgresql16-libs-16.0-1PGDG.rhel8.x86_64 2/3
Verifying : postgresql16-server-16.0-1PGDG.rhel8.x86_64 3/3
Installed:
postgresql16-16.0-1PGDG.rhel8.x86_64 postgresql16-libs-16.0-1PGDG.rhel8.x86_64 postgresql16-server-16.0-1PGDG.rhel8.x86_64
Complete!
[root@teguhth-redhat8 data]#
4. Inisialize the DB
[root@teguhth-redhat8 data]# /usr/pgsql-16/bin/postgresql-16-setup initdb
Initializing database ... OK
[root@teguhth-redhat8 data]#
[root@teguhth data]#
5. stop old progres 15
systemctl stop postgresql-15
[root@teguhth-redhat8 data]# systemctl stop postgresql-15
[root@teguhth-redhat8 data]# systemctl status postgresql-15
? postgresql-15.service - PostgreSQL 15 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-15.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Tue 2023-10-17 10:11:42 WIB; 11s ago
Docs: https://www.postgresql.org/docs/15/static/
Process: 1081 ExecStart=/usr/pgsql-15/bin/postmaster -D ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 1081 (code=exited, status=0/SUCCESS)
Oct 17 09:59:33 teguhth-redhat8 systemd[1]: Starting PostgreSQL 15 database server...
Oct 17 09:59:34 teguhth-redhat8 postmaster[1081]: 2023-10-17 09:59:34.296 WIB [1081] LOG: redirecting log output to logging collector process
Oct 17 09:59:34 teguhth-redhat8 postmaster[1081]: 2023-10-17 09:59:34.296 WIB [1081] HINT: Future log output will appear in directory "log".
Oct 17 09:59:34 teguhth-redhat8 systemd[1]: Started PostgreSQL 15 database server.
Oct 17 10:11:42 teguhth-redhat8 systemd[1]: Stopping PostgreSQL 15 database server...
Oct 17 10:11:42 teguhth-redhat8 systemd[1]: Stopped PostgreSQL 15 database server.
[root@teguhth-redhat8 data]#
6. Check that everything is fine before upgrade
su - postgres
/usr/pgsql-16/bin/pg_upgrade --old-datadir=/var/lib/pgsql/15/data --new-datadir=/var/lib/pgsql/16/data --old-bindir=/usr/pgsql-15/bin --new-bindir=/usr/pgsql-16/bin --old-options '-c config_file=/var/lib/pgsql/15/data/postgresql.conf' --new-options '-c config_file=/var/lib/pgsql/16/data/postgresql.conf' --check
[root@teguhth-redhat8 data]# su - postgres
Last login: Tue Oct 17 09:47:33 WIB 2023 on pts/0
[postgres@teguhth-redhat8 ~]$ /usr/pgsql-16/bin/pg_upgrade --old-datadir=/var/lib/pgsql/15/data --new-datadir=/var/lib/pgsql/16/data --old-bindir=/usr/pgsql-15/bin --new-bindir=/usr/pgsql-16/bin --old-options '-c config_file=/var/lib/pgsql/15/data/postgresql.conf' --new-options '-c config_file=/var/lib/pgsql/16/data/postgresql.conf' --check
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
Checking database user is the install user ok
Checking database connection settings ok
Checking for prepared transactions ok
Checking for system-defined composite types in user tables ok
Checking for reg* data types in user tables ok
Checking for contrib/isn with bigint-passing mismatch ok
Checking for incompatible "aclitem" data type in user tables ok
Checking for presence of required libraries ok
Checking database user is the install user ok
Checking for prepared transactions ok
Checking for new cluster tablespace directories ok
*Clusters are compatible*
[postgres@teguhth-redhat8 ~]$
7. upgrade postgresql
/usr/pgsql-16/bin/pg_upgrade --old-datadir=/var/lib/pgsql/15/data --new-datadir=/var/lib/pgsql/16/data --old-bindir=/usr/pgsql-15/bin --new-bindir=/usr/pgsql-16/bin --old-options '-c config_file=/var/lib/pgsql/15/data/postgresql.conf' --new-options '-c config_file=/var/lib/pgsql/16/data/postgresql.conf'
[postgres@teguhth-redhat8 ~]$ /usr/pgsql-16/bin/pg_upgrade --old-datadir=/var/lib/pgsql/15/data --new-datadir=/var/lib/pgsql/16/data --old-bindir=/usr/pgsql-15/bin --new-bindir=/usr/pgsql-16/bin --old-options '-c config_file=/var/lib/pgsql/15/data/postgresql.conf' --new-options '-c config_file=/var/lib/pgsql/16/data/postgresql.conf'
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
Checking database user is the install user ok
Checking database connection settings ok
Checking for prepared transactions ok
Checking for system-defined composite types in user tables ok
Checking for reg* data types in user tables ok
Checking for contrib/isn with bigint-passing mismatch ok
Checking for incompatible "aclitem" data type in user tables ok
Creating dump of global objects ok
Creating dump of database schemas
ok
Checking for presence of required libraries ok
Checking database user is the install user ok
Checking for prepared transactions ok
Checking for new cluster tablespace directories ok
If pg_upgrade fails after this point, you must re-initdb the
new cluster before continuing.
Performing Upgrade
------------------
Setting locale and encoding for new cluster ok
Analyzing all rows in the new cluster ok
Freezing all rows in the new cluster ok
Deleting files from new pg_xact ok
Copying old pg_xact to new server ok
Setting oldest XID for new cluster ok
Setting next transaction ID and epoch for new cluster ok
Deleting files from new pg_multixact/offsets ok
Copying old pg_multixact/offsets to new server ok
Deleting files from new pg_multixact/members ok
Copying old pg_multixact/members to new server ok
Setting next multixact ID and offset for new cluster ok
Resetting WAL archives ok
Setting frozenxid and minmxid counters in new cluster ok
Restoring global objects in the new cluster ok
Restoring database schemas in the new cluster
ok
Copying user relation files
ok
Setting next OID for new cluster ok
Sync data directory to disk ok
Creating script to delete old cluster ok
Checking for extension updates ok
Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade.
Once you start the new server, consider running:
/usr/pgsql-16/bin/vacuumdb --all --analyze-in-stages
Running this script will delete the old cluster's data files:
./delete_old_cluster.sh
[postgres@teguhth-redhat8 ~]$
8. start new postgresql
systemctl start postgresql-16
[root@teguhth-redhat8 data]# systemctl start postgresql-16
[root@teguhth-redhat8 data]# systemctl enable postgresql-16
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-16.service ? /usr/lib/systemd/system/postgresql-16.service.
[root@teguhth-redhat8 data]#
9. check new version
[postgres@teguhth-redhat8 ~]$ psql -c "select pg_read_file('/etc/hostname') as hostname, version();"
hostname | version
-----------------+---------------------------------------------------------------------------------------------------------
teguhth-redhat8+| PostgreSQL 16.0 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-18), 64-bit
|
(1 row)
[postgres@teguhth-redhat8 ~]$
\l
select pg_read_file('/etc/hostname') as hostname,version(),datname from pg_database;
10. copy all old config to new config
su - postgres
cp /var/lib/pgsql/15/data/postgresql.conf /var/lib/pgsql/16/data/postgresql.conf
cp /var/lib/pgsql/15/data/pg_hba.conf /var/lib/pgsql/16/data/pg_hba.conf
[postgres@teguhth-redhat8 ~]$ cp /var/lib/pgsql/15/data/postgresql.conf /var/lib/pgsql/16/data/postgresql.conf
[postgres@teguhth-redhat8 ~]$ cp /var/lib/pgsql/15/data/pg_hba.conf /var/lib/pgsql/16/data/pg_hba.conf
[postgres@teguhth-redhat8 ~]$
11. restart new postgresql-16 again
systemctl restart postgresql-16
[root@teguhth-redhat8 data]# systemctl restart postgresql-16
[root@teguhth-redhat8 data]#
12. check new version again
-bash-4.2$ psql -c "select pg_read_file('/etc/hostname') as hostname, version();"
hostname | version
----------+---------------------------------------------------------------------------------------------------------
teguhth +| PostgreSQL 15.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
|
(1 row)
13. check rpm for posgres
rpm -qa | grep -i postgres
[root@teguhth-redhat8 ~]# rpm -qa | grep -i postgres
postgresql16-server-16.0-1PGDG.rhel8.x86_64
postgresql15-libs-15.4-1PGDG.rhel8.x86_64
postgresql15-server-15.4-1PGDG.rhel8.x86_64
postgresql16-16.0-1PGDG.rhel8.x86_64
postgresql15-15.4-1PGDG.rhel8.x86_64
postgresql16-libs-16.0-1PGDG.rhel8.x86_64
[root@teguhth-redhat8 ~]#
14. remove & delete old directory
yum remove postgresql15* -y
[root@teguhth ~]# yum remove postgresql15* -y
[root@teguhth ~]# rm -rf /var/lib/pgsql/15
15. check packet
[root@teguhth ~]# rpm -qa | grep -i postgres
[root@teguhth-redhat8 ~]#
[root@teguhth-redhat8 ~]#
[root@teguhth-redhat8 ~]# rpm -qa | grep -i postgres
postgresql16-server-16.0-1PGDG.rhel8.x86_64
postgresql16-16.0-1PGDG.rhel8.x86_64
postgresql16-libs-16.0-1PGDG.rhel8.x86_64
[root@teguhth-redhat8 ~]#
16. login n cek database
\c teguhth
select * from pembelian;
No comments:
Post a Comment