Oracle 19c Database Upgrade From 11.2.0.4 to 19.2.0.0 Using DBUA

Description:-

There are different ways of upgrading to the latest release of Oracle database and Oracle provides multiple methods to upgrade. Few are listed below:

  • Database Upgrade Assistant (DBUA)
  • Manual Upgrade
  • Transportable Tablespaces
  • Datapump export/import
  • Oracle Streams
  • Oracle GoldenGate

Here I am going to choose DBUA to upgrade my database,

DBUA provides a graphical user interface to guide you through the upgrade of Oracle Database.

Oracle Database Releases That Support Direct Upgrade

Review the supported options for direct upgrades to the latest Oracle Database release.
You can perform a direct upgrade to the new release from the following releases:
• 11.2.0.4
• 12.1.0.1 and 12.1.0.2
• 12.2.0.1

Steps for upgrade from 11.2.0.4 to 19.2.0.0 using DBUA :-

Presteps for db upgrade :-

Take RMAN full backups before upgrade.

rman target / 

run {
allocate channel test_backup_disk1 type disk format '/u01/backup/%d_%U';
backup incremental level 0 tag 'ORCL_BEFORE_UPG'  database;
backup format  tag 'ORCL_CONTROL_FILE' current controlfile;
release channel test_backup_disk1;
}

Ensure backup is complete before upgrade.

SQL> SELECT * FROM v$backup WHERE status != 'NOT ACTIVE';

no rows selected

Empty Recycle bin.

SQL> PURGE DBA_RECYCLEBIN ;

DBA Recyclebin purged.

Run Gather statistics to finish upgrade soon.

SQL> EXEC DBMS_STATS.GATHER_DICTIONARY_STATS;

PL/SQL procedure successfully completed.

Remove EM Database Control :-

Copy the $ORACLE_HOME/rdbms/admin/emremove.sql script from the target 19.2.0.0.0 ORACLE_HOME into the source 11.2.0.4.0 ORACLE_HOME.

[oracle@19c ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Mar 14 20:56:29 2019

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> @emremove.sql
old 70: IF (upper('&LOGGING') = 'VERBOSE')
new 70: IF (upper('VERBOSE') = 'VERBOSE')

PL/SQL procedure successfully completed.

Remove OLAP Catalog :-

[oracle@19c ~]$ cd $ORACLE_HOME/olap/admin/

SQL> @catnoamd.sql

Purge Recyclebin :-

SQL> purge recyclebin;

Recyclebin purged.

Run the preupgrade tool.

The preupgrade.jar Pre-Upgrade Information Tool is supplied with Oracle Database 19c.
This tool has reside in new oracle home.
/u01/app/oracle/product/19.0.0/dbhome_1/rdbms/admin/preupgrade.jar

oracle@19c ~]$ /u01/app/oracle/product/11.2.0/dbhome_1/jdk/bin/java -jar /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/admin/preupgrade.jar FILE DIR /u01/preupgrade/
==================
PREUPGRADE SUMMARY
==================
/u01/preupgrade/preupgrade.log
/u01/preupgrade/preupgrade_fixups.sql
/u01/preupgrade/postupgrade_fixups.sql

Execute fixup scripts as indicated below:

Before upgrade:

Log into the database and execute the preupgrade fixups
@/u01/preupgrade/preupgrade_fixups.sql

After the upgrade:

Log into the database and execute the postupgrade fixups
@/u01/preupgrade/postupgrade_fixups.sql

Preupgrade complete: 2019-03-14T21:28:55

Run preupgrade fixups.sql

SQL> @/u01/preupgrade/preupgrade_fixups.sql
Executing Oracle PRE-Upgrade Fixup Script

Auto-Generated by: Oracle Preupgrade Script
Version: 19.0.0.0.0 Build: 1
Generated on: 2019-03-14 21:28:51

For Source Database: UPG19C
Source Database Version: 11.2.0.4.0
For Upgrade to Version: 19.0.0.0.0

Preup Preupgrade
Action Issue Is
Number Preupgrade Check Name Remedied Further DBA Action
------ ------------------------ ---------- --------------------------------
1. parameter_min_val NO Manual fixup recommended.
2. em_present NO Manual fixup recommended.
3. amd_exists NO Manual fixup recommended.
4. apex_manual_upgrade NO Manual fixup recommended.
5. dictionary_stats YES None.
6. trgowner_no_admndbtrg YES None.
7. mv_refresh NO Informational only.
Further action is optional.
8. pre_fixed_objects YES None.
9. tablespaces_info NO Informational only.
Further action is optional.
10. exf_rul_exists NO Informational only.
Further action is optional.
11. rman_recovery_version NO Informational only.
Further action is optional.

The fixup scripts have been run and resolved what they can. However,
there are still issues originally identified by the preupgrade that
have not been remedied and are still present in the database.
Depending on the severity of the specific issue, and the nature of
the issue itself, that could mean that your database is not ready
for upgrade. To resolve the outstanding issues, start by reviewing
the preupgrade_fixups.sql and searching it for the name of
the failed CHECK NAME or Preupgrade Action Number listed above.
There you will find the original corresponding diagnostic message
from the preupgrade which explains in more detail what still needs
to be done.

PL/SQL procedure successfully completed.

Run DBUA upgrade Utility :

Now run the dbua utility from 19c oracle_home location.

[oracle@19c ~]$ export PATH=$ORACLE_HOME/bin:$PATH
[oracle@19c ~]$ export ORACLE_SID=upg19c
[oracle@19c ~]$ export ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1
[oracle@19c ~]$ dbua
  • select the Upgrade Oracle Database option, then click the “Next” button.

  • If the prerequisite checks highlight any issues, take the appropriate action to fix the issues. If all the prerequisite checks are passed, click the “Next” button.

  • Amend the upgrade options if necessary, then click the “Next” button.

  • Select the recovery options for use in the event of an upgrade failure, then click the “Next” button.

  •  If the database is using the 11g listener and you need to upgraded, use existing listener or create new 19c listener

  • If you want configure EM database express enable it and provide port number or uncheck it.

Now the database upgrade is complete and the database is ready for normal use.

SQL> select VERSION,name,open_mode from v$instance,v$database;

VERSION    NAME   OPEN_MODE
---------  ------ ----------
19.0.0.0.0 UPG19C READ WRITE

SQL> SELECT * FROM v$timezone_file;

FILENAME             VERSION    CON_ID
-------------------- ---------- ----------
timezlrg_32.dat      32         0

SQL> select TZ_VERSION from registry$database;

TZ_VERSION
----------
32
Catch Me On:- Hariprasath Rajaram  Telegram:https://t.me/joinchat/I_f4DkeGfZuxgMIoJSpQZg LinkedIn:https://www.linkedin.com/in/hariprasathdba Facebook:https://www.facebook.com/HariPrasathdba                       FB Group:https://www.facebook.com/groups/894402327369506/              FB Page: https://www.facebook.com/dbahariprasath/?                 Twitter: https://twitter.com/hariprasathdba

Step by Step to configure Oracle 19c Data Guard Physical Standby

Environment Details

Parameters needs to configure both side for Data guard,

Primary side:
db_name:- Same name for all primary and standby database
db_unique_name:-a unique db name to uniquely identify primary and standby db because db_name is same
Log_archive_dest_1:-local archive destination
Log_archive_dest_2:-destination for standby database
Standby_file_management:-automatically  create file at standby db site

Standby Side:
db_unique_name:-it has to be different from DB_NAME parameter
db_file_name_convert:-specify the path name and datafile location of primary database datafile followed by standby location
log_file_name_convert:-specify the path name and redo logfile location of primary database redo logfile followed by standby location
log_archive_dest_1:-location of archives coming from primary database
fal_server:-to fetch archived log from primary site when log gap is detected at standby site.The parameter value is tns service name
fal_client:- to copies missing archive to standby database

Step 1:-Check FORCE LOGGING is enabled

Step 2:- Make sure primary is in archivelog mode

Step 3:- PFILE creation and copy to standby database

Step 4:-Edit the parameters and directories in created pfile

Step 5:- Parameters for primary database

Step 6:- Copy password file from primary to standby server

Step 7:- Make the respective directories for standby database

Step 8:- Keep the database in NOMOUNT stage to create standby database

Step 9:- Create spfile for standby database

Step 10:- Listener and TNS Configuration

Step 11:-Start the listener in Standby database and check the status

Step 12:-In standby side,check RMAN connection.Connect primary database as TARGET and standby database as AUXILIARY(creating new instance)

Step 13:-Active Duplication for creating standby database

Step 14:- Post check status for Standby database

Step 15:- Enable the recovery(MRP Process)

Step 16:- Check the Standby database sync status with primary

PRIMARY SIDE CONFIGURATION:-

[oracle@ram ~]$ export ORACLE_SID=dbwr
[oracle@ram ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Mar 13 18:58:05 2019
Version 19.2.0.0.0

Copyright (c) 1982, 2018, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup 
ORACLE instance started.

Total System Global Area 2415917872 bytes
Fixed Size 8899376 bytes
Variable Size 654311424 bytes
Database Buffers 1744830464 bytes
Redo Buffers 7876608 bytes
Database mounted.
Database opened.

SQL> select force_logging from v$database;

FORCE_LOGGING
------------------
NO

SQL> ALTER DATABASE FORCE LOGGING;

Database altered.

SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Current log sequence 3
SQL> shut immediate 
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 2415917872 bytes
Fixed Size 8899376 bytes
Variable Size 654311424 bytes
Database Buffers 1744830464 bytes
Redo Buffers 7876608 bytes
Database mounted.
SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

SQL> create pfile from spfile;

File created.


Check the Datafiles,Log files location in Primary side:

SQL> show parameter db_name;

NAME                     TYPE            VALUE
---------------------- ----------- ------------------
db_name                  string          dbwr

SQL> show parameter db_unique_name;

NAME TYPE VALUE
---------------------- ----------- --------------------
db_unique_name            string         dbwr

SQL> select file_name from dba_data_files;

FILE_NAME
-----------------------------------------------------------------------
/u01/app/oracle/product/19.0.0/dbhome_1/dbs/DBWR/datafile/o1_mf_system_g78vt7wo_.dbf

/u01/app/oracle/product/19.0.0/dbhome_1/dbs/DBWR/datafile/o1_mf_sysaux_g78vx8f6_.dbf

/u01/app/oracle/product/19.0.0/dbhome_1/dbs/DBWR/datafile/o1_mf_users_g78vyq0c_.dbf

/u01/app/oracle/product/19.0.0/dbhome_1/dbs/DBWR/datafile/o1_mf_undotbs1_g78vyor1_.dbf

Dynamically change parameter and Configure it in Primary side:

SQL> alter system set log_archive_config='dg_config=(dbwr,standby)';

System altered.

SQL> alter system set log_archive_dest_2='service=standby noaffirm async valid_for=(online_logfiles,primary_role) db_unique_name=standby';

System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;

System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_FORMAT='%t_%s_%r.arc' SCOPE=SPFILE;

System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=30;

System altered.

SQL> ALTER SYSTEM SET REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE SCOPE=SPFILE;

System altered.

SQL> ALTER SYSTEM SET FAL_SERVER=STANDBY;

System altered.

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;

System altered.

Create standby controlfile:

SQL> alter database add standby logfile ('/u01/app/oracle/product/19.0.0/dbhome_1/dbs/DBWR/redo1.log') size 50m;

Database altered.

SQL> alter database add standby logfile ('/u01/app/oracle/product/19.0.0/dbhome_1/dbs/DBWR/redo2.log') size 50m;

Database altered.

SQL> alter database add standby logfile ('/u01/app/oracle/product/19.0.0/dbhome_1/dbs/DBWR/redo3.log') size 50m;

Database altered.

SQL> alter database add standby logfile ('/u01/app/oracle/product/19.0.0/dbhome_1/dbs/DBWR/redo4.log') size 50m;

Database altered.

PRIMARY SIDE:

[oracle@ram admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

DBWR =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ram.doyen.com)(PORT = 1521))
)
)
[oracle@ram admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

DBWR =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ram.doyen.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = dbwr)
(UR = A)
)
)

STANDBY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = standby.doyen.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = STANDBY)
(UR = A)
)
)
[oracle@ram admin]$ lsnrctl status

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 16-MAR-2019 00:43:46

Copyright (c) 1991, 2018, Oracle. All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias DBWR
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 15-MAR-2019 22:54:24
Uptime 0 days 1 hr. 49 min. 21 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/ram/dbwr/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ram.doyen.com)(PORT=1521)))
Services Summary...
Service "dbwr" has 1 instance(s).
Instance "dbwr", status READY, has 1 handler(s) for this service...
Service "dbwrXDB" has 1 instance(s).
Instance "dbwr", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@ram admin]$

STANDBY SIDE:

[oracle@standby ~]$ cd $ORACLE_HOME
[oracle@standby dbhome_1]$ cd network/admin/
[oracle@standby admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_STANDBY =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = dbwr)
(ORACLE_HOME = /u01/app/oracle/product/19.0.0/dbhome_1)
(SID_NAME = dbwr)
)
)

STANDBY =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = standby.doyen.com)(PORT = 1521))
)
)
[oracle@standby admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

DBWR =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ram.doyen.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = dbwr)
(UR = A)
)
)

STANDBY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = standby.doyen.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = STANDBY)
(UR = A)
)
)

[oracle@standby admin]$ lsnrctl status

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 16-MAR-2019 00:57:37

Copyright (c) 1991, 2018, Oracle. All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias STANDBY
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 16-MAR-2019 00:00:08
Uptime 0 days 0 hr. 57 min. 29 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/standby/standby/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=standby.doyen.com)(PORT=1521)))
Services Summary...
Service "dbwr" has 1 instance(s).
Instance "dbwr", status UNKNOWN, has 1 handler(s) for this service...
Service "standby" has 1 instance(s).
Instance "dbwr", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@standby admin]$

In standby side,check RMAN connection.Connect primary database as TARGET and standby database as AUXILIARY(creating new instance)

Active Duplication for creating standby database:

[oracle@standby ~]$ export ORACLE_SID=dbwr
[oracle@standby ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Mar 16 00:34:57 2019
Version 19.2.0.0.0

Copyright (c) 1982, 2018, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 2415917872 bytes
Fixed Size 8899376 bytes
Variable Size 654311424 bytes
Database Buffers 1744830464 bytes
Redo Buffers 7876608 bytes
SQL> !
[oracle@standby ~]$ rman target sys/oracle@dbwr auxiliary sys/oracle@standby

Recovery Manager: Release 19.0.0.0.0 - Production on Sat Mar 16 00:35:46 2019
Version 19.2.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.

connected to target database: DBWR (DBID=1335353556)
connected to auxiliary database: DBWR (not mounted)

RMAN> duplicate target database for standby from active database nofilenamecheck;

Starting Duplicate Db at 16-MAR-19
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=39 device type=DISK

contents of Memory Script:
{
backup as copy reuse
passwordfile auxiliary format '/u01/app/oracle/product/19.0.0/dbhome_1/dbs/orapwdbwr' ;
}
executing Memory Script

Starting backup at 16-MAR-19
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=121 device type=DISK
Finished backup at 16-MAR-19

contents of Memory Script:
{
restore clone from service 'dbwr' standby controlfile;
}
executing Memory Script

Starting restore at 16-MAR-19
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service dbwr
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/admin/standby/control1.ctl
output file name=/u01/app/oracle/admin/standby/control2.ctl
Finished restore at 16-MAR-19

contents of Memory Script:
{
sql clone 'alter database mount standby database';
}
executing Memory Script

sql statement: alter database mount standby database

contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/admin/standby/o1_mf_temp_g78w14cc_.tmp";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/app/oracle/admin/standby/o1_mf_system_g78vt7wo_.dbf";
set newname for datafile 3 to
"/u01/app/oracle/admin/standby/o1_mf_sysaux_g78vx8f6_.dbf";
set newname for datafile 4 to
"/u01/app/oracle/admin/standby/o1_mf_undotbs1_g78vyor1_.dbf";
set newname for datafile 7 to
"/u01/app/oracle/admin/standby/o1_mf_users_g78vyq0c_.dbf";
restore
from non sparse from service
'dbwr' clone database
;
sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/admin/standby/o1_mf_temp_g78w14cc_.tmp in control file

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 16-MAR-19
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service dbwr
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/admin/standby/o1_mf_system_g78vt7wo_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:04:59
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service dbwr
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/admin/standby/o1_mf_sysaux_g78vx8f6_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:04:09
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service dbwr
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/admin/standby/o1_mf_undotbs1_g78vyor1_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service dbwr
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00007 to /u01/app/oracle/admin/standby/o1_mf_users_g78vyq0c_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 16-MAR-19

sql statement: alter system archive log current

contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=1 STAMP=1003020439 file name=/u01/app/oracle/admin/standby/o1_mf_system_g78vt7wo_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=1003020439 file name=/u01/app/oracle/admin/standby/o1_mf_sysaux_g78vx8f6_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=1003020439 file name=/u01/app/oracle/admin/standby/o1_mf_undotbs1_g78vyor1_.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=4 STAMP=1003020439 file name=/u01/app/oracle/admin/standby/o1_mf_users_g78vyq0c_.dbf
............
............
............
Finished Duplicate Db at 16-MAR-19

RMAN> exit


Enable the recovery

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

Database altered.

Post check status for Standby database

SQL> select name,database_role,open_mode from v$database;

NAME               DATABASE_ROLE                 OPEN_MODE
---------          ----------------          ----------------
DBWR               PHYSICAL STANDBY              MOUNTED

Check the Standby database sync status with primary:

SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

SEQUENCE#         APPLIED
----------        ---------
    9               YES
Catch Me On:- Hariprasath Rajaram

LinkedIn:   https://www.linkedin.com/in/hari-prasath-aa65bb19/
Facebook:   https://www.facebook.com/HariPrasathdba
FB Group:   https://www.facebook.com/groups/894402327369506/
FB Page:    https://www.facebook.com/dbahariprasath/?
Twitter:    https://twitter.com/hariprasathdba

Oracle 19c-Step by Step Manual Data Guard Switchover

Switchover Operation Procedure: 

After configuring data guard, databases would be either primary and standby database role, and we can altered these roles without loss of data or without resetting logs  called Switchover.

A database can be in one of two mutually exclusive modes (primary or standby). These roles can be altered at runtime without loss of data or resetting of redo logs. This process is known as a Switchover and can be performed using the following statements.

Data guard Configuration Details:-

Step 1:- Check database role and database name

Primary database:-

SQL> select name,open_mode,database_role from v$database;

NAME         OPEN_MODE           DATABASE_ROLE
--------- -------------------- ----------------
DBWR         READ WRITE           PRIMARY

Standby database:-

SQL> select name,open_mode,database_role from v$database;

NAME        OPEN_MODE           DATABASE_ROLE
--------- -------------------- ----------------
DBWR        MOUNTED             PHYSICAL STANDBY

Precheck for Switchover:- (PRIMARY SIDE)

Before performing switchover, kindly verify the state of data guard on both the instances by following SQL queries:

Step 2:-

SQL> ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS';

Session altered.
SQL> SELECT sequence#, first_time, next_time, applied FROM v$archived_log ORDER BY sequence#;

SEQUENCE#      FIRST_TIME         NEXT_TIME           APPLIED
---------- -------------------- -------------------- ---------
3          13-MAR-2019 18:59:20 13-MAR-2019 23:55:09   NO
4          13-MAR-2019 23:55:09 14-MAR-2019 20:04:18   NO
5          14-MAR-2019 20:04:18 14-MAR-2019 20:43:17   NO
6          14-MAR-2019 20:43:17 15-MAR-2019 01:35:09   NO
7          15-MAR-2019 01:35:09 15-MAR-2019 22:57:54   NO
8          15-MAR-2019 22:57:54 16-MAR-2019 00:11:18   NO
8          15-MAR-2019 22:57:54 16-MAR-2019 00:11:18   YES
9          16-MAR-2019 00:11:18 16-MAR-2019 00:47:08   NO
9          16-MAR-2019 00:11:18 16-MAR-2019 00:47:08   YES
10         16-MAR-2019 00:47:08 16-MAR-2019 01:54:56   NO
10         16-MAR-2019 00:47:08 16-MAR-2019 01:54:56   YES

11 rows selected.

Step 3:- 

SQL> select switchover_status from v$database;

SWITCHOVER_STATUS
--------------------
TO STANDBY

Note: This command will give you appropriate message about the data guard current status.

After getting confirmation on data guard smooth activity, we can instantiate switchover activity by issuing following sort of commands:

The switchover_status column of v$database can have the following values:

Not Allowed:-Either this is a standby database and the primary database has not been switched first, or this is a primary database and there are no standby databases
Session Active:- Indicates that there are active SQL sessions attached to the primary or standby database that need to be disconnected before the switchover operation is permitted
Switchover Pending:- This is a standby database and the primary database switchover request has been received but not processed.
Switchover Latent:- The switchover was in pending mode, but did not complete and went back to the primary database
To Primary:- This is a standby database, with no active sessions, that is allowed to switch over to a primary database
To Standby:- This is a primary database, with no active sessions, that is allowed to switch over to a standby database
Recovery Needed:- This is a standby database that has not received the switchover request

On Primary database:-

Step 4:

SQL> alter database commit to switchover to standby;

Database altered.

Step 5:-

shutdown immediate

startup nomount

alter database mount standby database

[oracle@ram dbs]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Mar 16 02:20:17 2019
Version 19.2.0.0.0

Copyright (c) 1982, 2018, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.

Total System Global Area 2415917872 bytes
Fixed Size 8899376 bytes
Variable Size 654311424 bytes
Database Buffers 1744830464 bytes
Redo Buffers 7876608 bytes
SQL> alter database mount standby database;

Database altered.

SQL> alter database recover managed standby database disconnect from session;

Database altered.

Step 6:-

SQL> select name,open_mode,database_role from v$database;

NAME         OPEN_MODE           DATABASE_ROLE
--------- -------------------- ----------------
DBWR         READ WRITE          PRIMARY

On Standby database:

Step 7:-alter database commit to switchover to primary;

SQL> alter database commit to switchover to primary;

Database altered.

Step 8:-

SQL> select name,open_mode,database_role from v$database;

NAME          OPEN_MODE          DATABASE_ROLE
--------- -------------------- ----------------
DBWR          MOUNTED            PRIMARY

Switch over activity have completed successfully, our old primary database has become standby and old standby database has become primary database.

Note:-To test above switchover activity, generate multiple archive logs on primary database and verify those archive logs being transferred on standby database.

After switchover activity,

Catch Me On:- Hariprasath Rajaram

LinkedIn:https://www.linkedin.com/in/hari-prasath-aa65bb19/
Facebook:https://www.facebook.com/HariPrasathdba
FB Group:https://www.facebook.com/groups/894402327369506/
FB Page: https://www.facebook.com/dbahariprasath/?
Twitter: https://twitter.com/hariprasathdba

oracle Gather stats for a table

BEGIN
DBMS_STATS.GATHER_TABLE_STATS (
ownname => ‘HR’,
tabname => ‘EMP’,
cascade => true, —- For collecting stats for respective indexes
method_opt=>’for all indexed columns size 1′,
granularity => ‘ALL’,
estimate_percent =>dbms_stats.auto_sample_size,
degree => 4);
END;
/

— For a single table partition
BEGIN
DBMS_STATS.GATHER_TABLE_STATS (
ownname => ‘HR’,
tabname => ‘EMP’, — TABLE NAME
partname => ‘EMP_P1’ — PARTITOIN NAME
method_opt=>’for all indexed columns size 1′,
GRANULARITY => ‘APPROX_GLOBAL AND PARTITION’,
degree => 8);
END;
/

Oracle Archivelog generation per hour

set lines 300
SELECT TO_CHAR(TRUNC(FIRST_TIME),’Mon DD’) “DG Date”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’00’,1,0)),’9999′) “12AM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’01’,1,0)),’9999′) “01AM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’02’,1,0)),’9999′) “02AM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’03’,1,0)),’9999′) “03AM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’04’,1,0)),’9999′) “04AM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’05’,1,0)),’9999′) “05AM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’06’,1,0)),’9999′) “06AM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’07’,1,0)),’9999′) “07AM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’08’,1,0)),’9999′) “08AM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’09’,1,0)),’9999′) “09AM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’10’,1,0)),’9999′) “10AM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’11’,1,0)),’9999′) “11AM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’12’,1,0)),’9999′) “12PM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’13’,1,0)),’9999′) “1PM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’14’,1,0)),’9999′) “2PM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’15’,1,0)),’9999′) “3PM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’16’,1,0)),’9999′) “4PM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’17’,1,0)),’9999′) “5PM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’18’,1,0)),’9999′) “6PM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’19’,1,0)),’9999′) “7PM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’20’,1,0)),’9999′) “8PM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’21’,1,0)),’9999′) “9PM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’22’,1,0)),’9999′) “10PM”,
TO_CHAR(SUM(DECODE(TO_CHAR(FIRST_TIME,’HH24′),’23’,1,0)),’9999′) “11PM”
FROM V$LOG_HISTORY
GROUP BY TRUNC(FIRST_TIME)
ORDER BY TRUNC(FIRST_TIME) DESC
/

Oracle Database Size

col “Database Size” format a20
col “Free space” format a20
col “Used space” format a20
select round(sum(used.bytes) / 1024 / 1024 / 1024 ) || ‘ GB’ “Database Size”
, round(sum(used.bytes) / 1024 / 1024 / 1024 ) –
round(free.p / 1024 / 1024 / 1024) || ‘ GB’ “Used space”
, round(free.p / 1024 / 1024 / 1024) || ‘ GB’ “Free space”
from (select bytes
from v$datafile
union all
select bytes
from v$tempfile
union all
select bytes
from v$log) used
, (select sum(bytes) as p
from dba_free_space) free
group by free.p
/

Oracle 19c-Step by Step Manual Data Guard Failover

Failover:-

In case of worst situation with data guard primary database, or not available for production than we can activated standby database as a primary production database.

Data guard Configuration details:-

Login in to Standby Server:-

Step:1 Check the database role and open_mode
Select name,open_mode,database_role from v$database;

SQL> select database_role from v$database;

DATABASE_ROLE
----------------
PHYSICAL STANDBY

Step:2 Cancel the MRP process

[oracle@standby dbs]$ ps -ef | grep mrp
oracle 79976 1 0 03:19 ? 00:00:02 ora_mrp0_dbwr
oracle 81638 81585 0 03:43 pts/2 00:00:00 grep --color=auto mrp
[oracle@standby dbs]$ !sq
sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Mar 16 03:43:18 2019
Version 19.2.0.0.0

Copyright (c) 1982, 2018, Oracle. All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.2.0.0.0

SQL> recover managed standby database cancel;
Media recovery complete.

Step 3:

The below commands will help to bring up standby as primary

alter database recover managed standby database finish;

SQL> recover managed standby database cancel;
Media recovery complete.
SQL> alter database recover managed standby database finish;

Database altered.

SQL> select name,open_mode,database_role from v$database;

NAME        OPEN_MODE           DATABASE_ROLE
--------- -------------------- ----------------
DBWR        MOUNTED             PHYSICAL STANDBY

SQL> alter database activate standby database;

Database altered.

Managed recovery process has been stopped between primary and standby database and standby becomes primary database.

Step 5:

 Bounce your database and verify database name its open mode and its role.

shutdown immediate;

Startup

Step 6:

select name,open_mode,database_role from v$database;

SQL> select database_role from v$database;

DATABASE_ROLE
----------------
PRIMARY

Now your old standby database is become primary database

It is highly recommended to consider immediate full backup of primary database.

The original primary database can now be configured as a standby.

If Flashback Database was enabled on the primary database.If not, the whole setup process must be followed, but this time using the original primary server as the standby.

After failover activity,

Catch Me On:- Hariprasath Rajaram

LinkedIn:https://www.linkedin.com/in/hari-prasath-aa65bb19/
Facebook:https://www.facebook.com/HariPrasathdba
FB Group:https://www.facebook.com/groups/894402327369506/
FB Page: https://www.facebook.com/dbahariprasath/?
Twitter:  https://twitter.com/hariprasathdba

Oracle 19c-Step by Step Configure Snapshot Standby Database

Description:-

  • Oracle Database 11g introduced the Snapshot Standby feature in Data Guard
  • A snapshot standby database is a fully updateable standby database created by converting a physical standby database into a snapshot standby database.
  • A snapshot standby database receives and archives, but does not apply,
    redo data from a primary database.
  • The redo data received from the primary database is applied once a snapshot standby database is converted back into a physical standby database, after discarding all local updates to the snapshot standby database.

Dataguard Configuration:-

Step:1 Check both primary and standby role.

Primary:-

SQL> select status,instance_name,database_role,open_mode from v$database,v$Instance;

STATUS       INSTANCE_NAME     DATABASE_ROLE     OPEN_MODE
------------ ---------------- ---------------- --------------------
OPEN            class             PRIMARY         READ WRITE

Standby:-

SQL> select status,instance_name,database_role,open_mode from v$database,v$Instance;

STATUS         INSTANCE_NAME    DATABASE_ROLE        OPEN_MODE
------------ ---------------- ----------------   --------------------
MOUNTED        class            PHYSICAL STANDBY     MOUNTED

Step 2:- Check the archived sequence in standby,

select thread#,max(sequence#) from v$archived_log group by thread#;

SQL> select thread#,max(sequence#) from v$archived_log group by thread#;

THREAD#     MAX(SEQUENCE#)
---------- --------------
1              37

Step 3:- Check the flashback status and db_recovery_file_set location,

select flashback_on from v$database;

show parameter db_recovery_file_dest

SQL> show parameter db_recovery_file_dest

NAME                          TYPE            VALUE
-------------------------- ----------- ------------------------------
db_recovery_file_dest       string      /u01/app/oracle/recovery_dest/
db_recovery_file_dest_size  big integer            2G


SQL> select flashback_on from v$database;

FLASHBACK_ON
------------------
YES

Step:4 In standby side,stop the mrp process.

 alter database recover managed standby database cancel;

SQL> recover managed standby database cancel;
Media recovery complete.

Step:5 Bounce the database and keep in mount stage,

shut immediate

startup mount

SQL> shu immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 943716968 bytes
Fixed Size 8903272 bytes
Variable Size 583008256 bytes
Database Buffers 348127232 bytes
Redo Buffers 3678208 bytes
Database mounted.

Step:6 Convert to snapshot standby database

alter database convert to snapshot standby

SQL> alter database convert to snapshot standby;

Database altered.

Step:7 Open the standby database in READ/WRITE mode

alter database open

SQL> alter database open;

Database altered.

Step:8 Check the DATABASE_ROLE and OPEN_MODE,

select status,instance_name,database_role,open_mode from v$database,v$Instance

SQL> select status,instance_name,database_role,open_mode from v$database,v$Instance;

STATUS        INSTANCE_NAME     DATABASE_ROLE       OPEN_MODE
------------ ----------------  ----------------  --------------------
OPEN            class          SNAPSHOT STANDBY    READ WRITE

Step:9 Testing on the snapshot standby database,

create user test identified by test;
grant connect,resource to test;
conn test/test
create table t1(sno number, name varchar2(20));
insert into t1 values (1,’example’);
commit;

SQL> alter user test quota unlimited on USERS;

User altered.

SQL> conn test/test;
Connected.

SQL> create table t1(sno number, name varchar2(20));

Table created.

SQL> insert into t1 values (1,'example');

1 row created.

SQL> commit;

Commit complete.

SQL> select * from t1;

SNO           NAME
---------- --------------------
1             example

SQL>

Step:10 Both side verify the archived sequence

Primary side
select thread#,max(sequence#) from v$archived_log group by thread#;

SQL> select thread#,max(sequence#) from v$archived_log group by thread#;

THREAD#     MAX(SEQUENCE#)
----------  --------------
1              47

Standby side

select thread#,max(sequence#) from v$archived_log group by thread#;
select process,status,sequence# from v$managed_standby;

SQL> select thread#,max(sequence#) from v$archived_log group by thread#;

THREAD#     MAX(SEQUENCE#)
---------- --------------
1               47

Step 11: In Standby Side,bounce and mount the database

shut immediate
startup mount

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 943716968 bytes
Fixed Size 8903272 bytes
Variable Size 759169024 bytes
Database Buffers 171966464 bytes
Redo Buffers 3678208 bytes
Database mounted.

Step:12 Convert the snapshot standby database to physical standby database,

alter database convert to physical standby;

SQL> alter database convert to physical standby;

Database altered.

Step:13 Bounce the database,

shut immediate
startup

SQL> shu immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 943716968 bytes
Fixed Size 8903272 bytes
Variable Size 759169024 bytes
Database Buffers 171966464 bytes
Redo Buffers 3678208 bytes
Database mounted.
Database opened.

Step:14 Check the standby database_role and mode.

select status,instance_name,database_role,open_mode from v$database,v$Instance;

SQL> select status,instance_name,database_role,open_mode from v$database,v$Instance;

STATUS        INSTANCE_NAME    DATABASE_ROLE      OPEN_MODE
------------ ---------------- ---------------- --------------------
OPEN          class           PHYSICAL STANDBY    READ ONLY

Step:15 Enable the MRP process
alter database recover managed standby database disconnect from session;

SQL> alter database recover managed standby database disconnect from session;

Database altered.

Step:16 After convert to physical standby database,check the table status

Note:  After convert back to Physical standby database  once again restart the MRP process.

SQL> select * from test.t1;
select * from test.t1
*
ERROR at line 1:
ORA-00942: table or view does not exist

Catch Me On:- Hariprasath Rajaram

LinkedIn:https://www.linkedin.com/in/hari-prasath-aa65bb19/
Facebook:https://www.facebook.com/HariPrasathdba
FB Group:https://www.facebook.com/groups/894402327369506/
FB Page: https://www.facebook.com/dbahariprasath/?
Twitter:  https://twitter.com/hariprasathdba