Disclaimer

Saturday 2 October 2021

RAC database upgrade

 

Performing upgrade database

Before perform upgrade, it's important to copy the database password file to new $ORACLE_HOME/dbs.

1
2
[oracle@node1:/home/oracle]$ cp -p $ORACLE_HOME/dbs/orapwracdb1 /u02/app/oracle/product/12.1.0/db1/dbs/
[oracle@node2:/home/oracle]$ cp -p $ORACLE_HOME/dbs/orapwracdb2 /u02/app/oracle/product/12.1.0/db1/dbs/

Disable archival is also advisable, for avoiding excessive archive logs generation during upgrade.

1


[oracle@node1:/home/oracle]$ srvctl stop database -d racdb -o immediate

Create a legacy init file to local from spfile, modify cluster_database to false, do some necessary modify. I modified the ORACLE_BASE to /u02, the adump to /u02, created the adump directory, and deleted the remote_listener.

1
SQL> create pfile='/home/oracle/init.ora' from spfile;

Now, SET the new ORACLE variables to 12c, and add the following entry to /etc/oratab in both nodes:

1
2
3
4
5
6
7
8
[oracle@node1:/home/oracle]$ . .bash_profile
[oracle@node1:/home/oracle]$ echo $ORACLE_HOME
/u02/app/oracle/product/12.1.0/db1
[oracle@node1:/home/oracle]$ which sqlplus
/u02/app/oracle/product/12.1.0/db1/bin/sqlplus
[root@node2 ~]# tail -2 /etc/oratab
#racdb:/u01/app/oracle/product/11gr2:N # line added by Agent
racdb:/u02/app/oracle/product/12.1.0/db1:N

Exectue startup upgrade now:

1
2
[oracle@node1:/home/oracle]$ sqlplus "/as sysdba"
SQL> startup upgrade pfile='/home/oracle/init.ora';

But when I upgrade by manually, the ASM diskgroup cannot be mounted as encounterred "permission denied" errors.

[Fix permission denied error of ASM disk]
1
2
3
4
5
6
7
8
9
[grid@node1:/home/grid]$ cd $ORACLE_HOME/bin
[grid@node1:/u02/app/grid/12.1.0/bin]$ ll /u01/app/oracle/product/11gr2/bin/oracle
-rwsr-s--x 1 oracle asmadmin 239626641 Apr 20 17:15 /u01/app/oracle/product/11gr2/bin/oracle
[grid@node1:/u02/app/grid/12.1.0/bin]$ ll /u02/app/oracle/product/12.1.0/db1/bin/oracle
-rwsr-s--x 1 oracle oinstall 323762228 Apr 20 21:06 /u02/app/oracle/product/12.1.0/db1/bin/oracle
#change the group of 12c's bin/oracle to asmadmin in both nodes
[grid@node1.:/u02/app/grid/12.1.0/bin]$ ./setasmgidwrap o=/u02/app/oracle/product/12.1.0/db1/bin/oracle
[grid@node2.:/home/grid]$ cd $ORACLE_HOME/bin
[grid@node2.:/u02/app/grid/12.1.0/bin]$ ./setasmgidwrap o=/u02/app/oracle/product/12.1.0/db1/bin/oracle

After changed the oracle binary attributes, the upgrade works now:

[Execute upgrade again]
1
2
3
4
5
6
7
8
9
10
SQL> startup upgrade pfile='/home/oracle/init.ora';
ORACLE instance started.
Total System Global Area 2483027968 bytes
Fixed Size 2927432 bytes
Variable Size 721421496 bytes
Database Buffers 1744830464 bytes
Redo Buffers 13848576 bytes
Database mounted.
Database opened.
SQL>

Execute upgrade utility:

1
2
3
[oracle@node1:/home/oracle]$ cd $ORACLE_HOME/rdbms/admin
[oracle@node1:/u02/app/oracle/product/12.1.0/db1/rdbms/admin]$
[oracle@node1:/u02/app/oracle/product/12.1.0/db1/rdbms/admin]$ $ORACLE_HOME/perl/bin/perl catctl.pl -n 4 -l /tmp catupgrd.sql

Post-upgrade tasks

Database will automatically shutdown once the previous command successfully completes. Then I need to perform some tasks to enable CLUSTER_DATABASE, enable ARCHIVE etc.:

1
2
3
4
5
6
7
8
#modify cluster_database to true, uncommet the remote_listener in the init file
SQL> startup mount pfile='/home/oracle/init.ora';
SQL> ALTER DATABASE ARCHIVELOG;
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP pfile='/home/oracle/init.ora';
SQL> create spfile='+DATA/RACDB/spfileracdb.ora' from pfile='/home/oracle/init.ora';
#add following entries to $ORACLE_HOME/dbs/initracdb1(2).ora to both nodes
SPFILE='+DATA/racdb/spfileracdb.ora'

Executing compile scripts:

1
2
3
4
5
6
SQL> execute dbms_stats.gather_fixed_objects_stats;
SQL> @?/rdbms/admin/utlrp.sql --recomiples all invalid objects on the database
SQL> @?/rdbms/admin/utluiobj.sql --verfies the validity of all packages/classes on the database
SQL> @?/rdbms/admin/catuppst.sql
SQL> @?/rdbms/admin/utlu121s.sql --displays database upgrade summary
SQL> SHUTDOWN IMMEDIATE;

Upgrade the database version in OCR by using the following command:

1
2
[oracle@node1:/home/oracle]$ srvctl upgrade database -d racdb -o /u02/app/oracle/product/12.1.0/db1
[oracle@node1:/home/oracle]$ srvctl start database -d racdb -o open

Run postupgrade_fixups.sql script

1
SQL> @/u01/app/oracle/cfgtoollogs/racdb/preupgrade/postupgrade_fixups.sql

Adjust the compatibility of ASM diskgroup's attribute "compatible.asm" and "compatible.rdbms" to 12.1 if necessary, for example, convert non-CDB to PDB, it's necessary to update these values to 12.1. For the convenience of downgrade, this step will be omitted.

[Executed under with GRID user]
1
2
ALTER DISKGROUP data SET ATTRIBUTE 'compatible.asm' = '12.1';
ALTER DISKGROUP data SET ATTRIBUTE 'compatible.rdbms' = '12.1',

Upgrade the TIMEZONE file, this can refer to previous post Upgrade Single Database to 12c.

Confirm the tnsnames file and the listener file in the new Oracle 12c home are correct, if necessary, copy them from 11g oracle home.

No comments:

Post a Comment

100 Oracle DBA Interview Questions and Answers

  Here are 100 tricky interview questions tailored for a Senior Oracle DBA role. These questions span a wide range of topics, including perf...