INTRO
======
https://dbvisit.com/blog/database-upgrade-methods-oracle-19c
https://www.br8dba.com/tag/steps-for-upgrading-oracle-database-to-19c-using-dbua/
A database upgrade involves moving from an older version of a database management
system (DBMS) to a newer version. Database upgrades can be done
in two ways via DBUA or CLI.
PRE_INSTALLATION STEPS
======================
--> Run the 19c pre-install package on Linux to complete all OS level pre-
requisites.
yum install -y oracle-database-preinstall-19c
yum update -y
--> Create a backup dir and back up important files like listener.ora, sqlnet.ora,
tnsnames.ora and spfile.
mkdir /u01/backup
cd $ORACLE_HOME/network/admin
cp -p listener.ora sqlnet.ora tnsnames.ora /u01/backup/
cd $ORACLE_HOME/dbs
cp -p spfiletest.ora orapwtest /u01/backup/
--> Copy 19c software into new db home and install Oracle 19c software.
mkdir -p /u02/app/oracle/product/19c/db_1
chown -R oracle:oinstall /u02/
unzip
./runInstaller
--> Make a dir for the pre-upgrade script, then run the script
mkdir -p /home/oracle/preupgrade
/u01/app/oracle/product/12c/db_1/jdk/bin/java -jar
/u02/app/oracle/product/19c/db_1/rdbms/admin/preupgrade.jar FILE DIR
/home/oracle/preupgrade
==================
PREUPGRADE SUMMARY
==================
/home/oracle/preupgrade/preupgrade.log
/home/oracle/preupgrade/preupgrade_fixups.sql
/home/oracle/preupgrade/postupgrade_fixups.sql
Execute fixup scripts as indicated below:
Before upgrade:
Log into the database and execute the preupgrade fixups
@/home/oracle/preupgrade/preupgrade_fixups.sql
After the upgrade:
Log into the database and execute the postupgrade fixups
@/home/oracle/preupgrade/postupgrade_fixups.sql
Preupgrade complete: 2024-09-08T21:13:49
The preupgrade summary provides three files;
a. The log file which shows recommendations to be worked on pre upgrade.
b. The preupgrade_fixups.sql which is run after the recommendations have been
resolved.
c. The postupgrade_fixups.sql which is run after the upgrade is complete.
The log file showed recommendation across the tablespace.
INFORMATION ONLY
================
3. To help you keep track of your tablespace allocations, the following
AUTOEXTEND tablespaces are expected to successfully EXTEND during the
upgrade process.
Min Size
Tablespace Size For Upgrade
-
SYSAUX 470 MB 500 MB
SYSTEM 800 MB 912 MB
TEMP 32 MB 150 MB
UNDOTBS1 70 MB 439 MB
Minimum tablespace sizes for upgrade are estimates.
--> When such is flagged, the datafiles sizes should be adjusted in size to either
match or exceed recommendatiod as shown below;
SQL> alter database datafile '/u01/app/oracle/oradata/test/users01.dbf' resize 1g;
Database altered.
SQL> SQL> alter database datafile '/u01/app/oracle/oradata/test/undotbs01.dbf'
resize 1g;
Database altered.
SQL> alter database datafile '/u01/app/oracle/oradata/test/system01.dbf' resize 1g;
Database altered.
SQL> alter database datafile '/u01/app/oracle/oradata/test/sysaux01.dbf' resize
1g;
Database altered.
P.S: If Tablespace auto extend is ON and max size also set, no action is taken.
====
--> Gather Dictionary statistics
SQL> SET ECHO ON;
SQL> SET SERVEROUTPUT ON;
SQL> EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;
--> Purge Recycle bin
SQL> PURGE DBA_RECYCLEBIN;
--> Check for invalid objects
SQL> select count(*) from dba_objects where status='INVALID';
--> Run preupgrade script
SQL> @/home/oracle/preupgrade/preupgrade_fixups.sql
--> Verify archive log dest path and size.
SQL> show parameter recovery;
NAME TYPE VALUE
-
db_recovery_file_dest string /u01/app/oracle/fast_recovery_
area/test
db_recovery_file_dest_size big integer 8016M
recovery_parallelism integer 0
remote_recovery_file_dest string
--> Create flashback guaranteed restore point
SQL> create restore point pre_upgrade guarantee flashback database;
SQL>
col name for a20
col GUARANTEE_FLASHBACK_DATABASE for a10
col TIME for a60
set lines 190
select NAME,GUARANTEE_FLASHBACK_DATABASE,TIME from V$restore_point;
NAME GUARANTEE_ TIME
PRE_UPGRADE YES 08-SEP-24 10.37.47.000000000 PM
UPGRADE
========
--> From 19c home dir, run the dbua
/u01/app/oracle/product/19.0.0/dbhome_1/bin/dbua
[oracle@testone bin]$ ./dbua
Logs directory: /u02/app/oracle/cfgtoollogs/dbua/upgrade2024-09-08_10-47-19PM
Database upgrade has been completed successfully, and the database is ready to use.
The upgrade took about an hour, thirty mins.
POST UPGRADE
=============
--> Verify new Oracle home
cat /etc/oratab
--> Verify timezone version
SQL> SELECT version FROM v$timezone_file;
--> Verify invalid objects
SQL> select count(1) from dba_objects where status='INVALID';
--> Verify dba_registry
SQL> select COMP_ID,COMP_NAME,VERSION,STATUS from dba_registry;
--> Drop restore point
SQL> drop restore point PRE_UPGRADE;
--> Update compatible parameter
SQL> show parameter compatible
SQL> ALTER SYSTEM SET COMPATIBLE = '19.0.0' SCOPE=SPFILE;
--> Restart database and reconfirm compatible parameter
SQL> show parameter compatible;
NAME TYPE VALUE
-
compatible string 19.0.0
noncdb_compatible boolean FALSE
SQL>
END
=======
Errors
=======
--> During the upgrade, I was having issues trying to resize the temp datafile as
seen below;
SQL> alter database tempfile '/u01/app/oracle/oradata/test/temp01.dbf' resize 1g;
alter database tempfile '/u01/app/oracle/oradata/test/temp01.dbf' resize 1g
*
ERROR at line 1:
ORA-00376: file 201 cannot be read at this time
ORA-01110: data file 201: '/u01/app/oracle/oradata/test/temp01.dbf'
--> But the file exists
SQL> select file_name from dba_temp_files;
FILE_NAME
SQL> !ls /u01/app/oracle/oradata/test/temp01.dbf
/u01/app/oracle/oradata/test/temp01.dbf
--> I had to create a new tempspace tablespace and create a new one
SQL> CREATE TEMPORARY TABLESPACE temp2 TEMPFILE
'/u01/app/oracle/oradata/test/temp02.dbf' SIZE 1G;
Tablespace created.
SQL> ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp2;
Database altered.
SQL> DROP TABLESPACE temp INCLUDING CONTENTS AND DATAFILES;
Tablespace dropped.