Upgrade PostgreSQL from 9.4 to 9.6 on RHEL 7
Posted by FatDBA on September 3, 2018
Hi Mates,
Every other day while doing this POC (Data migrations between Oracle and PostgreSQL), i am facing regular challenges (But i like them ;)) , this time related with the application and database support. Project team asked us to upgrade the database to at-least 9.6 (Though we have 10 in the marked as well but i guess not yet ready for Prod’s).
Its good to update you that you can run various versions of PostgreSQL at the same time but as per the ask we have this test DB running on version 9.4 and would be upgraded to 9.6. So, before i start with the steps, lets quickly look and collect details about all objects till now created on the database as this will be used to TVT testings later on.
Okay, so we are running on PostgreSQL 9.4.19 have created few sample/test databases with tables, indexes, tablespaces created.
Environment:
Server: RHEL 7 64 Bit
Upgrade: From 9.4.19 to 9.6.10
Pre Checks:
-bash-4.2$ uname -ar
Linux fatdba.localdomain 3.10.0-514.21.1.el7.x86_64 #1 SMP Thu May 25 16:26:01 PDT 2017 x86_64 x86_64 x86_64 GNU/Linux
-bash-4.2$
postgres=# select version();
version
----------------------------------------------------------------------------------------------------------------
PostgreSQL 9.4.19 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28), 64-bit
(1 row)
elephant=# select datname from pg_database;
datname
-----------
template1
template0
postgres
elephant
dixitdb
(5 rows)
elephant=# \c postgres
You are now connected to database "postgres" as user "postgres".
postgres=# \dt+
List of relations
Schema | Name | Type | Owner | Size | Description
--------+------------+-------+----------+------------+-------------
public | alee | table | postgres | 128 kB |
public | events | table | postgres | 8192 bytes |
public | large_test | table | postgres | 995 MB |
(3 rows)
postgres=#
Step 1: Download the required package from PostgreSQL official website (Link: https://www.postgresql.org/download/linux/redhat/), here you will find the latest repository RPM for your OS and the latest PG versions.
[root@fatdba ~]#
[root@fatdba ~]# yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm
Loaded plugins: langpacks, ulninfo
pgdg-redhat96-9.6-3.noarch.rpm | 4.7 kB 00:00:00
Examining /var/tmp/yum-root-fEvD8A/pgdg-redhat96-9.6-3.noarch.rpm: pgdg-redhat96-9.6-3.noarch
Marking /var/tmp/yum-root-fEvD8A/pgdg-redhat96-9.6-3.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package pgdg-redhat96.noarch 0:9.6-3 will be installed
--> Finished Dependency Resolution
cassandra/signature | 833 B 00:00:00
cassandra/signature | 2.9 kB 00:00:00 !!!
mongodb-org-3.4/7Server | 2.5 kB 00:00:00
ol7_UEKR4/x86_64 | 1.2 kB 00:00:00
ol7_addons/x86_64 | 1.2 kB 00:00:00
ol7_latest/x86_64 | 1.4 kB 00:00:00
pgdg94/7Server/x86_64 | 4.1 kB 00:00:00
Dependencies Resolved
=============================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================
Installing:
pgdg-redhat96 noarch 9.6-3 /pgdg-redhat96-9.6-3.noarch 2.7 k
Transaction Summary
=============================================================================================================================================================================================
Install 1 Package
Total size: 2.7 k
Installed size: 2.7 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : pgdg-redhat96-9.6-3.noarch 1/1
Verifying : pgdg-redhat96-9.6-3.noarch 1/1
Installed:
pgdg-redhat96.noarch 0:9.6-3
Complete!
[root@fatdba ~]#
[root@fatdba ~]#
[root@fatdba ~]# yum install postgresql96
Loaded plugins: langpacks, ulninfo
pgdg96 | 4.1 kB 00:00:00
(1/2): pgdg96/7Server/x86_64/group_gz | 249 B 00:00:01
(2/2): pgdg96/7Server/x86_64/primary_db | 197 kB 00:00:01
Resolving Dependencies
--> Running transaction check
---> Package postgresql96.x86_64 0:9.6.10-1PGDG.rhel7 will be installed
--> Processing Dependency: postgresql96-libs(x86-64) = 9.6.10-1PGDG.rhel7 for package: postgresql96-9.6.10-1PGDG.rhel7.x86_64
--> Running transaction check
---> Package postgresql96-libs.x86_64 0:9.6.10-1PGDG.rhel7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================
Installing:
postgresql96 x86_64 9.6.10-1PGDG.rhel7 pgdg96 1.4 M
Installing for dependencies:
postgresql96-libs x86_64 9.6.10-1PGDG.rhel7 pgdg96 318 k
Transaction Summary
=============================================================================================================================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 1.7 M
Installed size: 8.7 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): postgresql96-libs-9.6.10-1PGDG.rhel7.x86_64.rpm | 318 kB 00:00:07
(2/2): postgresql96-9.6.10-1PGDG.rhel7.x86_64.rpm | 1.4 MB 00:00:10
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 169 kB/s | 1.7 MB 00:00:10
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : postgresql96-libs-9.6.10-1PGDG.rhel7.x86_64 1/2
Installing : postgresql96-9.6.10-1PGDG.rhel7.x86_64 2/2
Verifying : postgresql96-libs-9.6.10-1PGDG.rhel7.x86_64 1/2
Verifying : postgresql96-9.6.10-1PGDG.rhel7.x86_64 2/2
Installed:
postgresql96.x86_64 0:9.6.10-1PGDG.rhel7
Dependency Installed:
postgresql96-libs.x86_64 0:9.6.10-1PGDG.rhel7
Complete!
[root@fatdba ~]#
[root@fatdba ~]# yum install postgresql96-server
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package postgresql96-server.x86_64 0:9.6.10-1PGDG.rhel7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================
Installing:
postgresql96-server x86_64 9.6.10-1PGDG.rhel7 pgdg96 4.5 M
Transaction Summary
=============================================================================================================================================================================================
Install 1 Package
Total download size: 4.5 M
Installed size: 19 M
Is this ok [y/d/N]: y
Downloading packages:
postgresql96-server-9.6.10-1PGDG.rhel7.x86_64.rpm | 4.5 MB 00:00:11
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : postgresql96-server-9.6.10-1PGDG.rhel7.x86_64 1/1
Verifying : postgresql96-server-9.6.10-1PGDG.rhel7.x86_64 1/1
Installed:
postgresql96-server.x86_64 0:9.6.10-1PGDG.rhel7
Complete!
[root@fatdba ~]#
Step 2: Create the new PostgreSQL directory. This you can do this by calling the initdb (Initialize DB) with setup shell present under new installed directory for 9.6
[root@fatdba ~]#
[root@fatdba ~]# /usr/pgsql-9.6/bin/postgresql96-setup initdb
Initializing database ... OK
[root@fatdba ~]#
[root@fatdba ~]#
[root@fatdba ~]#
[root@fatdba ~]# cd /var/lib/pgsql
[root@fatdba pgsql]# ls -lthr
total 0
drwxrwxrwx 4 postgres postgres 48 Sep 3 04:39 9.4
drwx------ 3 postgres postgres 29 Sep 3 04:44 tbs
drwx------ 3 postgres postgres 29 Sep 3 20:31 tbs1
drwx------ 4 postgres postgres 48 Sep 3 20:40 9.6
[root@fatdba pgsql]# su - postgres
Last login: Mon Sep 3 20:24:34 IST 2018 on pts/3
-bash-4.2$
Step 3: Before you go with real upgrade steps, its always best and advised to see if its all set and ready for the upgrade. This is one of the most important per-requsites to check the abilities.
Below at the end of the check run it says ‘Cluster is Compatible’ and this is good enough to say that the system is all set for the upgrade.
-bash-4.2$ /usr/pgsql-9.6/bin/pg_upgrade --old-bindir=/usr/pgsql-9.4/bin/ --new-bindir=/usr/pgsql-9.6/bin/ --old-datadir=/var/lib/pgsql/9.4/data/ --new-datadir=/var/lib/pgsql/9.6/data/ --check
*failure*
Consult the last few lines of "pg_upgrade_server.log" for
the probable cause of the failure.
Performing Consistency Checks on Old Live Server
------------------------------------------------
Checking cluster versions ok
Checking database user is the install user ok
Checking database connection settings ok
Checking for prepared transactions ok
Checking for reg* system OID user data types ok
Checking for contrib/isn with bigint-passing mismatch ok
Checking for roles starting with 'pg_' ok
Checking for presence of required libraries ok
Checking database user is the install user ok
Checking for prepared transactions ok
*Clusters are compatible*
-bash-4.2$
Step 4: Till this time the older version is still running, so before we do the original upgrade steps that needs to be stopped.
-bash-4.2$ ps -ef|grep post
root 1378 1 0 20:04 ? 00:00:00 /usr/libexec/postfix/master -w
postfix 1380 1378 0 20:04 ? 00:00:00 qmgr -l -t unix -u
postgres 3381 1 0 20:10 ? 00:00:00 /usr/pgsql-9.4/bin/postgres -D /var/lib/pgsql/9.4/data
postgres 3382 3381 0 20:10 ? 00:00:00 postgres: logger process
postgres 3384 3381 0 20:10 ? 00:00:01 postgres: checkpointer process
postgres 3385 3381 0 20:10 ? 00:00:00 postgres: writer process
postgres 3386 3381 0 20:10 ? 00:00:01 postgres: wal writer process
postgres 3387 3381 0 20:10 ? 00:00:00 postgres: autovacuum launcher process
postgres 3388 3381 0 20:10 ? 00:00:00 postgres: stats collector process
-bash-4.2$ su - root
Password:
Last login: Mon Sep 3 20:42:59 IST 2018 from 192.168.40.1 on pts/4
[root@fatdba ~]#
[root@fatdba ~]#
[root@fatdba ~]# service postgresql-9.4 stop
Redirecting to /bin/systemctl stop postgresql-9.4.service
[root@fatdba ~]#
[root@fatdba ~]# service postgresql-9.4 status
Redirecting to /bin/systemctl status postgresql-9.4.service
● postgresql-9.4.service - PostgreSQL 9.4 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-9.4.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Mon 2018-09-03 20:44:59 IST; 5s ago
Docs: https://www.postgresql.org/docs/9.4/static/
Process: 4924 ExecStop=/usr/pgsql-9.4/bin/pg_ctl stop -D ${PGDATA} -s -m fast (code=exited, status=0/SUCCESS)
Main PID: 3381 (code=exited, status=0/SUCCESS)
Sep 03 04:40:02 fatdba.localdomain systemd[1]: Starting PostgreSQL 9.4 database server...
Sep 03 04:40:02 fatdba.localdomain pg_ctl[3377]: LOG: redirecting log output to logging collector process
Sep 03 04:40:02 fatdba.localdomain pg_ctl[3377]: HINT: Future log output will appear in directory "pg_log".
Sep 03 04:40:03 fatdba.localdomain systemd[1]: Started PostgreSQL 9.4 database server.
Sep 03 20:44:58 fatdba.localdomain systemd[1]: Stopping PostgreSQL 9.4 database server...
Sep 03 20:44:59 fatdba.localdomain systemd[1]: Stopped PostgreSQL 9.4 database server.
[root@fatdba ~]#
[root@fatdba ~]# ps -ef|grep post
root 1378 1 0 20:04 ? 00:00:00 /usr/libexec/postfix/master -w
postfix 1380 1378 0 20:04 ? 00:00:00 qmgr -l -t unix -u
postfix 4113 1378 0 20:24 ? 00:00:00 pickup -l -t unix -u
postgres 4835 4708 0 20:43 pts/4 00:00:00 tail -200f pg_upgrade_server.log
root 4938 4864 0 20:45 pts/3 00:00:00 grep --color=auto post
Step 5: Let’s upgrade the database now. The upgrade took around ~ 5 minutes for a 5 GB database.
-bash-4.2$ /usr/pgsql-9.6/bin/pg_upgrade --old-bindir=/usr/pgsql-9.4/bin/ --new-bindir=/usr/pgsql-9.6/bin/ --old-datadir=/var/lib/pgsql/9.4/data/ --new-datadir=/var/lib/pgsql/9.6/data/
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 reg* system OID user data types ok
Checking for contrib/isn with bigint-passing mismatch ok
Checking for roles starting with 'pg_' 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
If pg_upgrade fails after this point, you must re-initdb the
new cluster before continuing.
Performing Upgrade
------------------
Analyzing all rows in the new cluster ok
Freezing all rows on the new cluster ok
Deleting files from new pg_clog ok
Copying old pg_clog to new server 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 analyze new cluster ok
Creating script to delete old cluster ok
Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade so,
once you start the new server, consider running:
./analyze_new_cluster.sh
Running this script will delete the old cluster's data files:
./delete_old_cluster.sh
-bash-4.2$
-bash-4.2$
Its always good to put a TAIL on server upgrade logs.
-bash-4.2$ ls -ltrh
total 12K
drwxrwxrwx 4 postgres postgres 48 Sep 3 04:39 9.4
drwx------ 3 postgres postgres 29 Sep 3 04:44 tbs
drwx------ 3 postgres postgres 29 Sep 3 20:31 tbs1
drwx------ 4 postgres postgres 48 Sep 3 20:40 9.6
-rw------- 1 postgres postgres 179 Sep 3 20:43 pg_upgrade_utility.log
-rw------- 1 postgres postgres 1.1K Sep 3 20:43 pg_upgrade_internal.log
-rw------- 1 postgres postgres 1.6K Sep 3 20:43 pg_upgrade_server.log
-----------------------------------------------------------------
pg_upgrade run on Mon Sep 3 20:46:48 2018
-----------------------------------------------------------------
command: "/usr/pgsql-9.4/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/var/lib/pgsql/9.4/data/" -o "-p 50432 -b -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directories='/var/lib/pgsql'" start >> "pg_upgrade_server.log" 2>&1
waiting for server to start....LOG: redirecting log output to logging collector process
HINT: Future log output will appear in directory "pg_log".
done
server started
command: "/usr/pgsql-9.4/bin/pg_ctl" -w -D "/var/lib/pgsql/9.4/data/" -o "" -m smart stop >> "pg_upgrade_server.log" 2>&1
waiting for server to shut down.... done
server stopped
command: "/usr/pgsql-9.6/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/var/lib/pgsql/9.6/data/" -o "-p 50432 -b -c synchronous_commit=off -c fsync=off -c full_page_writes=off -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directories='/var/lib/pgsql'" start >> "pg_upgrade_server.log" 2>&1
waiting for server to start.... LOG: redirecting log output to logging collector process
HINT: Future log output will appear in directory "pg_log".
done
server started
command: "/usr/pgsql-9.6/bin/pg_ctl" -w -D "/var/lib/pgsql/9.6/data/" -o "" -m smart stop >> "pg_upgrade_server.log" 2>&1
waiting for server to shut down.... done
server stopped
command: "/usr/pgsql-9.6/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/var/lib/pgsql/9.6/data/" -o "-p 50432 -b -c synchronous_commit=off -c fsync=off -c full_page_writes=off -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directories='/var/lib/pgsql'" start >> "pg_upgrade_server.log" 2>&1
waiting for server to start.... LOG: redirecting log output to logging collector process
HINT: Future log output will appear in directory "pg_log".
done
server started
command: "/usr/pgsql-9.6/bin/pg_ctl" -w -D "/var/lib/pgsql/9.6/data/" -o "" -m smart stop >> "pg_upgrade_server.log" 2>&1
waiting for server to shut down.... done
server stopped
command: "/usr/pgsql-9.6/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/var/lib/pgsql/9.6/data/" -o "-p 50432 -b -c synchronous_commit=off -c fsync=off -c full_page_writes=off -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directories='/var/lib/pgsql'" start >> "pg_upgrade_server.log" 2>&1
waiting for server to start.... LOG: redirecting log output to logging collector process
HINT: Future log output will appear in directory "pg_log".
done
server started
command: "/usr/pgsql-9.6/bin/pg_ctl" -w -D "/var/lib/pgsql/9.6/data/" -o "" -m smart stop >> "pg_upgrade_server.log" 2>&1
waiting for server to shut down.... done
server stopped
Step 6: Once the upgrade is done, we have to start & enable the new postgreSQL service.
Okay so below we can see the postmaster and its associated background processes started from new version (9.6) and are accessing the right data directory.
Note: Before you start the new service, always make sure you have all required values set in new parameter or configuration files, moved from old database to the new. For example listen_addresses and max_connections of postgresql.conf or any specific settings related with authorization defied on pg_hba.conf files.
[root@fatdba ~]# service postgresql-9.6 start
Redirecting to /bin/systemctl start postgresql-9.6.service
[root@fatdba ~]#
[root@fatdba ~]# ps -ef|grep post
root 1378 1 0 20:04 ? 00:00:00 /usr/libexec/postfix/master -w
postfix 1380 1378 0 20:04 ? 00:00:00 qmgr -l -t unix -u
postgres 5298 1 0 20:48 ? 00:00:00 /usr/pgsql-9.6/bin/postmaster -D /var/lib/pgsql/9.6/data/
postgres 5301 5298 0 20:48 ? 00:00:00 postgres: logger process
postgres 5303 5298 0 20:48 ? 00:00:00 postgres: checkpointer process
postgres 5304 5298 0 20:48 ? 00:00:00 postgres: writer process
postgres 5305 5298 0 20:48 ? 00:00:00 postgres: wal writer process
postgres 5306 5298 0 20:48 ? 00:00:00 postgres: autovacuum launcher process
postgres 5307 5298 0 20:48 ? 00:00:00 postgres: stats collector process
root 5309 5228 0 20:48 pts/3 00:00:00 grep --color=auto post
[root@fatdba ~]#
[root@fatdba ~]#
[root@fatdba ~]# systemctl enable postgresql-9.6
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-9.6.service to /usr/lib/systemd/system/postgresql-9.6.service.
[root@fatdba ~]#
Postchecks:
The upgrade script creates two new scripts under parent directory, analyze_new_cluster.sh and delete_old_cluster.sh, its good to run analyze_new_cluster.sh which performs the vaccuming or collects stats for objects and is a must in big production setups.
-bash-4.2$ ls -ltrh
total 8.0K
drwxrwxrwx 4 postgres postgres 48 Sep 3 04:39 9.4
drwx------ 4 postgres postgres 48 Sep 3 20:40 9.6
drwx------ 4 postgres postgres 52 Sep 3 20:46 tbs1
drwx------ 4 postgres postgres 52 Sep 3 20:46 tbs
-rwx------ 1 postgres postgres 135 Sep 3 20:47 delete_old_cluster.sh
-rwx------ 1 postgres postgres 755 Sep 3 20:47 analyze_new_cluster.sh
-bash-4.2$ ./analyze_new_cluster.sh
This script will generate minimal optimizer statistics rapidly
so your system is usable, and then gather statistics twice more
with increasing accuracy. When it is done, your system will
have the default level of optimizer statistics.
If you have used ALTER TABLE to modify the statistics target for
any tables, you might want to remove them and restore them after
running this script because they will delay fast statistics generation.
If you would like default statistics as quickly as possible, cancel
this script and run:
"/usr/pgsql-9.6/bin/vacuumdb" --all --analyze-only
vacuumdb: processing database "dixitdb": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "elephant": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "postgres": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "template1": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "dixitdb": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "elephant": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "postgres": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "template1": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "dixitdb": Generating default (full) optimizer statistics
vacuumdb: processing database "elephant": Generating default (full) optimizer statistics
vacuumdb: processing database "postgres": Generating default (full) optimizer statistics
vacuumdb: processing database "template1": Generating default (full) optimizer statistics
Done
-bash-4.2$
Post Verification or Sanity Tests.
-bash-4.2$
-bash-4.2$ psql -d elephant -U postgres
psql (9.6.10)
Type "help" for help.
elephant=#
elephant=# select version();
version
-----------------------------------------------------------------------------------------------------------
PostgreSQL 9.6.10 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28), 64-bit
(1 row)
elephant=#
elephant=# \d+
List of relations
Schema | Name | Type | Owner | Size | Description
--------+--------+-------+----------+---------+-------------
public | serbia | table | postgres | 5120 kB |
(1 row)
elephant=# \dt+
List of relations
Schema | Name | Type | Owner | Size | Description
--------+--------+-------+----------+---------+-------------
public | serbia | table | postgres | 5120 kB |
(1 row)
elephant=#
elephant=#
elephant=# \c postgres
You are now connected to database "postgres" as user "postgres".
postgres=#
postgres=#
postgres=# \dt+
List of relations
Schema | Name | Type | Owner | Size | Description
--------+------------+-------+----------+------------+-------------
public | alee | table | postgres | 128 kB |
public | events | table | postgres | 8192 bytes |
public | large_test | table | postgres | 995 MB |
(3 rows)
postgres=#
postgres=#
postgres=# \q
Okay we are all good and no corruption, loss is noticied and we can consider this upgrade as SUCCESSFULL.
Now if required we can go and delete the old database (Postgres calls it a Cluster).
-bash-4.2$
-bash-4.2$ ./delete_old_cluster.sh
Hope It Helps
Prashant Dixit
Manish Gupta said
Hi Prashant, thank you for sharing this upgrade method. Step-3 and Step-5 are using same commands, how can we ensure that step-3 is not actually initiating the actual upgrade and will provide us a review kind of status for our upgrade ?