How To : Create a Standby using RMAN and Enable Dataguard broker in 12c

It’s been a while when i configure #Oracle #Dataguard, today i’ll be doing it in 12c for our production database.

Primary : 111.11.111.103
Standby : 111.12.111.103

sid : systemx
port : 1521

1. Create the password file for both primary and secondary server.

	[oracle@dc1-systemx-db1 dbs]$ orapwd file=orapwsystemx password=Oracle2018 entries=12
	[oracle@dc1-systemx-db1 dbs]$ ls -l orapwsystemx
	-rw-r----- 1 oracle oinstall 8704 Feb 28 10:38 orapwsystemx
	[oracle@dc1-systemx-db1 dbs]$

2. update the location of archive log and update the archive format.

	SQL> archive log list;
	Database log mode              Archive Mode
	Automatic archival             Enabled
	Archive destination            USE_DB_RECOVERY_FILE_DEST
	Oldest online log sequence     45
	Next log sequence to archive   47
	Current log sequence           47
	SQL>
	SQL> alter system set log_archive_dest_1='LOCATION=/oraarch/archive' scope=both;
	System altered.
	SQL> archive log list;
	Database log mode              Archive Mode
	Automatic archival             Enabled
	Archive destination            /oraarch/archive
	Oldest online log sequence     45
	Next log sequence to archive   47
	Current log sequence           47
	SQL>
	SQL> alter system set log_archive_format='systemx_%t_%s_%r.arc' scope=spfile;
	System altered.
	SQL>

3. enable force logging.

	SQL> ALTER DATABASE FORCE LOGGING;
	Database altered.
	SQL> ALTER SYSTEM SWITCH LOGFILE;
	System altered.
	SQL> /
	System altered.
	SQL> /
	System altered.
	SQL>

4. add standby logfile

	ALTER DATABASE ADD STANDBY LOGFILE ('/oraredo01/systemx/redo/standby_redo01.log') SIZE 50M;
	ALTER DATABASE ADD STANDBY LOGFILE ('/oraredo01/systemx/redo/standby_redo02.log') SIZE 50M;
	ALTER DATABASE ADD STANDBY LOGFILE ('/oraredo01/systemx/redo/standby_redo03.log') SIZE 50M;

5. restart database …

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

	Total System Global Area 4781506560 bytes
	Fixed Size                  5293320 bytes
	Variable Size            1224739576 bytes
	Database Buffers         3539992576 bytes
	Redo Buffers               11481088 bytes
	Database mounted.
	Database opened.
	SQL>

	SQL> show parameter db_name;

	NAME                                 TYPE        VALUE
	------------------------------------ ----------- ------------------------------
	db_name                              string      systemx
	SQL> show parameter db_unique;

	NAME                                 TYPE        VALUE
	------------------------------------ ----------- ------------------------------
	db_unique_name                       string      systemx
	SQL> show parameter standby_file;

	NAME                                 TYPE        VALUE
	------------------------------------ ----------- ------------------------------
	standby_file_management              string      MANUAL
	SQL> alter system set standby_file_management=auto scope=both;

	System altered.

	SQL>

6. update the tnsnames.ora of both servers.

	systemx =
	  (DESCRIPTION =
		(ADDRESS_LIST =
		  (ADDRESS = (PROTOCOL = TCP)(HOST = 111.11.111.103)(PORT = 1521))
		)
		(CONNECT_DATA =
		  (SID = systemx)
		)
	  )

	systemx_stby =
	  (DESCRIPTION =
		(ADDRESS_LIST =
		  (ADDRESS = (PROTOCOL = TCP)(HOST = 111.12.111.103)(PORT = 1521))
		)
		(CONNECT_DATA =
		  (SID = systemx)
		)
	  )
	[oracle@dc2-systemx-db1 admin]$ tnsping systemx
	Used TNSNAMES adapter to resolve the alias
	Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 111.11.111.103)(PORT = 1521))) (CONNECT_DATA = (SID = systemx)))
	OK (0 msec)

	[oracle@dc2-systemx-db1 admin]$ tnsping systemx_stby
	Used TNSNAMES adapter to resolve the alias
	Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 111.12.111.103)(PORT = 1521))) (CONNECT_DATA = (SID = systemx)))
	OK (0 msec)
	[oracle@dc2-systemx-db1 admin]$

	[oracle@dc1-systemx-db1 admin]$ tnsping systemx
	Used TNSNAMES adapter to resolve the alias
	Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 111.11.111.103)(PORT = 1521))) (CONNECT_DATA = (SID = systemx)))
	OK (0 msec)

	[oracle@dc1-systemx-db1 admin]$ tnsping systemx_stby
	Used TNSNAMES adapter to resolve the alias
	Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 111.12.111.103)(PORT = 1521))) (CONNECT_DATA = (SID = systemx)))
	OK (10 msec)
	[oracle@dc1-systemx-db1 admin]$

7. update the listener of both servers.

	[oracle@dc1-systemx-db1 admin]$ cat listener.ora
	LISTENER =
	  (DESCRIPTION_LIST =
		(DESCRIPTION =
		  (ADDRESS_LIST =
			(ADDRESS = (PROTOCOL = TCP)(HOST = 111.11.111.103)(PORT = 1521))
		  )
		  (ADDRESS_LIST =
			(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
		  )
		)
	  )

	SID_LIST_LISTENER =
	  (SID_LIST =
		(SID_DESC =
		  (SID_NAME = PLSExtProc)
		  (ORACLE_HOME = /opt/oracle/product/12.1.0/db_1)
		  (PROGRAM = extproc)
		)
		(SID_DESC =
		  (GLOBAL_DBNAME = systemx)
		  (ORACLE_HOME =/opt/oracle/product/12.1.0/db_1)
		  (SID_NAME = systemx)
		)
		(SID_DESC =
		  (GLOBAL_DBNAME = systemx_stbyMGRL)
		  (ORACLE_HOME =/opt/oracle/product/12.1.0/db_1)
		  (SID_NAME = systemx)
		)

	  )

	[oracle@dc1-systemx-db1 admin]$

	[oracle@dc2-systemx-db1 admin]$ cat listener.ora
	LISTENER =
	  (DESCRIPTION_LIST =
		(DESCRIPTION =
		  (ADDRESS_LIST =
			(ADDRESS = (PROTOCOL = TCP)(HOST = 111.12.111.103)(PORT = 1521))
		  )
		  (ADDRESS_LIST =
			(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
		  )
		)
	  )

	SID_LIST_LISTENER =
	  (SID_LIST =
		(SID_DESC =
		  (SID_NAME = PLSExtProc)
		  (ORACLE_HOME = /opt/oracle/product/12.1.0/db_1)
		  (PROGRAM = extproc)
		)
		(SID_DESC =
		  (GLOBAL_DBNAME = systemx)
		  (ORACLE_HOME =/opt/oracle/product/12.1.0/db_1)
		  (SID_NAME = systemx)
		)
		(SID_DESC =
		  (GLOBAL_DBNAME = systemx_stby_DGMGRL)
		  (ORACLE_HOME =/opt/oracle/product/12.1.0/db_1)
		  (SID_NAME = systemx)
		)

	  )
	[oracle@dc2-systemx-db1 admin]$

8. create pfile for the standby.

	SQL> create pfile='/tmp/forstandby.ora' from spfile;
	File created.
	SQL>
	[oracle@dc1-systemx-db1 tmp]$ scp forstandby.ora 111.12.111.103:/tmp/
	oracle@111.12.111.103's password:
	forstandby.ora                                                                                                                       100% 1241   808.0KB/s   00:00
	[oracle@dc1-systemx-db1 tmp]$

9. on standby server, make sure all directory are same. as for all are same.

	[oracle@dc2-systemx-db1 tmp]$ cat forstandby.ora
	*.audit_file_dest='/opt/oracle/admin/systemx/adump'
	*.audit_trail='db'
	*.compatible='12.1.0.2.0'
	*.control_files='/oradata/systemx/control01.ctl','/oraredo01/systemx/controlfile/control02.ctl','/oraredo02/systemx/controlfile/control03.ctl'#Restore Controlfile
	*.db_block_size=8192
	*.db_domain=''
	*.db_name='systemx'
	*.db_recovery_file_dest='/oraarch/fast_recovery_area'
	*.db_recovery_file_dest_size=4560m
	*.dg_broker_start=FALSE
	*.diagnostic_dest='/opt/oracle'
	*.dispatchers='(PROTOCOL=TCP) (SERVICE=systemxXDB)'
	*.log_archive_dest_1='LOCATION=/oraarch/archive'
	*.log_archive_format='systemx_%t_%s_%r.arc'
	*.open_cursors=300
	*.pga_aggregate_target=1518m
	*.processes=300
	*.remote_login_passwordfile='EXCLUSIVE'
	*.sga_target=4554m
	*.standby_file_management='AUTO'
	*.undo_tablespace='UNDOTBS1'
	[oracle@dc2-systemx-db1 tmp]$

	[oracle@dc2-systemx-db1 tmp]$ df -h | grep ora
	/dev/mapper/rhel-lv_orabin           30G  8.8G   22G  30% /opt/oracle
	/dev/mapper/vg_oracle-lv_oradata    100G  4.8G   96G   5% /oradata
	/dev/mapper/vg_oracle-lv_oraredo01  5.0G   42M  5.0G   1% /oraredo01
	/dev/mapper/vg_oracle-lv_oraredo02  5.0G   42M  5.0G   1% /oraredo02
	/dev/mapper/vg_oracle-lv_oragg       30G  5.3G   25G  18% /oragg12
	/dev/mapper/vg_oracle-lv_orabackup  100G   18G   83G  18% /orabackup
	/dev/mapper/vg_oracle-lv_oraarch     50G   42M   50G   1% /oraarch
	/dev/mapper/vg_oracle-lv_oraidx      50G   33M   50G   1% /oraidx
	[oracle@dc2-systemx-db1 tmp]$

	[oracle@dc2-systemx-db1 dbs]$ orapwd file=orapwsystemx password=Oracle2018 entries=12
	[oracle@dc2-systemx-db1 dbs]$

10. Starup nomount the standby.

	
	SQL> startup nomount pfile='/tmp/forstandby.ora';
	ORACLE instance started.
	Total System Global Area 4781506560 bytes
	Fixed Size                  5293320 bytes
	Variable Size            1224739576 bytes
	Database Buffers         3539992576 bytes
	Redo Buffers               11481088 bytes
	SQL>

11. using rman duplicate the primary database for standby.

	[oracle@dc2-systemx-db1 ~]$ rman target  sys/Oracle2018@systemx auxiliary sys/Oracle2018@systemx_stby
	Recovery Manager: Release 12.1.0.2.0 - Production on Wed Feb 28 14:02:29 2018
	Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.
	connected to target database: systemx (DBID=231828643)
	connected to auxiliary database: systemx (not mounted)

— now lets execute the duplicate command.

	RMAN> DUPLICATE TARGET DATABASE
	  FOR STANDBY
	  FROM ACTIVE DATABASE
	  DORECOVER
	  SPFILE
		SET db_unique_name='systemx_stby' COMMENT 'Is standby'
	  NOFILENAMECHECK;2> 3> 4> 5> 6> 7>

	Starting Duplicate Db at 28-FEB-18
	using target database control file instead of recovery catalog
	allocated channel: ORA_AUX_DISK_1
	channel ORA_AUX_DISK_1: SID=331 device type=DISK
	current log archived
	contents of Memory Script:
	{
	   backup as copy reuse
	   targetfile  '/opt/oracle/product/12.1.0/db_1/dbs/orapwsystemx' auxiliary format
	 '/opt/oracle/product/12.1.0/db_1/dbs/orapwsystemx'   ;
	   restore clone from service  'systemx' spfile to
	 '/opt/oracle/product/12.1.0/db_1/dbs/spfilesystemx.ora';
	   sql clone "alter system set spfile= ''/opt/oracle/product/12.1.0/db_1/dbs/spfilesystemx.ora''";
	}
	executing Memory Script
	Starting backup at 28-FEB-18
	allocated channel: ORA_DISK_1
	channel ORA_DISK_1: SID=156 device type=DISK
	Finished backup at 28-FEB-18
	Starting restore at 28-FEB-18
	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 systemx
	channel ORA_AUX_DISK_1: restoring SPFILE
	output file name=/opt/oracle/product/12.1.0/db_1/dbs/spfilesystemx.ora
	channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
	Finished restore at 28-FEB-18
	sql statement: alter system set spfile= ''/opt/oracle/product/12.1.0/db_1/dbs/spfilesystemx.ora''
	contents of Memory Script:
	{
	   sql clone "alter system set  db_unique_name =
	 ''systemx_stby'' comment=
	 ''Is standby'' scope=spfile";
	   shutdown clone immediate;
	   startup clone nomount;
	}
	executing Memory Script

	sql statement: alter system set  db_unique_name =  ''systemx_stby'' comment= ''Is standby'' scope=spfile
	Oracle instance shut down
	connected to auxiliary database (not started)
	Oracle instance started
	Total System Global Area    4781506560 bytes
	Fixed Size                     5293320 bytes
	Variable Size               1224739576 bytes
	Database Buffers            3539992576 bytes
	Redo Buffers                  11481088 bytes
	contents of Memory Script:
	{
	   restore clone from service  'systemx' standby controlfile;
	}
	executing Memory Script
	Starting restore at 28-FEB-18
	allocated channel: ORA_AUX_DISK_1
	channel ORA_AUX_DISK_1: SID=211 device type=DISK
	channel ORA_AUX_DISK_1: starting datafile backup set restore
	channel ORA_AUX_DISK_1: using network backup set from service systemx
	channel ORA_AUX_DISK_1: restoring control file
	channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
	output file name=/oradata/systemx/control01.ctl
	output file name=/oraredo01/systemx/controlfile/control02.ctl
	output file name=/oraredo02/systemx/controlfile/control03.ctl
	Finished restore at 28-FEB-18

	contents of Memory Script:
	{
	   sql clone 'alter database mount standby database';
	}
	executing Memory Script
	sql statement: alter database mount standby database
	RMAN-05538: WARNING: implicitly using DB_FILE_NAME_CONVERT
	contents of Memory Script:
	{
	   set newname for tempfile  1 to
	 "/oradata/systemx/temp01.dbf";
	   switch clone tempfile all;
	   set newname for datafile  1 to
	 "/oradata/systemx/system01.dbf";
	   set newname for datafile  3 to
	 "/oradata/systemx/sysaux01.dbf";
	   set newname for datafile  4 to
	 "/oradata/systemx/undotbs01.dbf";
	   set newname for datafile  6 to
	 "/oradata/systemx/users01.dbf";
	   restore
	   from service  'systemx'   clone database
	   ;
	   sql 'alter system archive log current';
	}
	executing Memory Script
	executing command: SET NEWNAME
	renamed tempfile 1 to /oradata/systemx/temp01.dbf in control file
	executing command: SET NEWNAME
	executing command: SET NEWNAME
	executing command: SET NEWNAME
	executing command: SET NEWNAME
	Starting restore at 28-FEB-18
	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 systemx
	channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
	channel ORA_AUX_DISK_1: restoring datafile 00001 to /oradata/systemx/system01.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 systemx
	channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
	channel ORA_AUX_DISK_1: restoring datafile 00003 to /oradata/systemx/sysaux01.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 systemx
	channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
	channel ORA_AUX_DISK_1: restoring datafile 00004 to /oradata/systemx/undotbs01.dbf
	channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
	channel ORA_AUX_DISK_1: starting datafile backup set restore
	channel ORA_AUX_DISK_1: using network backup set from service systemx
	channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
	channel ORA_AUX_DISK_1: restoring datafile 00006 to /oradata/systemx/users01.dbf
	channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
	Finished restore at 28-FEB-18

	sql statement: alter system archive log current
	current log archived

	contents of Memory Script:
	{
	   restore clone force from service  'systemx'
			   archivelog from scn  5517851;
	   switch clone datafile all;
	}
	executing Memory Script

	Starting restore at 28-FEB-18
	using channel ORA_AUX_DISK_1

	channel ORA_AUX_DISK_1: starting archived log restore to default destination
	channel ORA_AUX_DISK_1: using network backup set from service systemx
	channel ORA_AUX_DISK_1: restoring archived log
	archived log thread=1 sequence=58
	channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
	channel ORA_AUX_DISK_1: starting archived log restore to default destination
	channel ORA_AUX_DISK_1: using network backup set from service systemx
	channel ORA_AUX_DISK_1: restoring archived log
	archived log thread=1 sequence=59
	channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
	Finished restore at 28-FEB-18

	datafile 1 switched to datafile copy
	input datafile copy RECID=5 STAMP=969285819 file name=/oradata/systemx/system01.dbf
	datafile 3 switched to datafile copy
	input datafile copy RECID=6 STAMP=969285819 file name=/oradata/systemx/sysaux01.dbf
	datafile 4 switched to datafile copy
	input datafile copy RECID=7 STAMP=969285819 file name=/oradata/systemx/undotbs01.dbf
	datafile 6 switched to datafile copy
	input datafile copy RECID=8 STAMP=969285819 file name=/oradata/systemx/users01.dbf
	contents of Memory Script:
	{
	   set until scn  5517934;
	   recover
	   standby
	   clone database
		delete archivelog
	   ;
	}
	executing Memory Script
	executing command: SET until clause
	Starting recover at 28-FEB-18
	using channel ORA_AUX_DISK_1
	starting media recovery
	archived log for thread 1 with sequence 58 is already on disk as file /oraarch/archive/systemx_1_58_968837351.arc
	archived log for thread 1 with sequence 59 is already on disk as file /oraarch/archive/systemx_1_59_968837351.arc
	archived log file name=/oraarch/archive/systemx_1_58_968837351.arc thread=1 sequence=58
	archived log file name=/oraarch/archive/systemx_1_59_968837351.arc thread=1 sequence=59
	media recovery complete, elapsed time: 00:00:00
	Finished recover at 28-FEB-18
	Finished Duplicate Db at 28-FEB-18

	RMAN>

12. check the newly create standby.

	Instance                Host                                  Startup              Database                     Shutdown Active
	Name / Number  Thread # Name                         Status   Time                 Status   Archiver Logins?    Pending? State  Version
	------------- --------- ---------------------------- -------- -------------------- -------- -------- ---------- -------- ------ -----------------
	systemx (1)          1 dc2-systemx-db1             MOUNTED  28-FEB-2018 02:02:56 ACTIVE   STARTED  ALLOWED    NO       NORMAL 12.1.0.2.0

	SQL>

13. On both server Enable Broker

	SQL> alter system set dg_broker_config_file1='/oradata/param/dr1systemx.dat' scope=both;
	System altered.
	SQL>  alter system set dg_broker_config_file2='/oraarch/param/dr2systemx.dat' scope=both;
	System altered.
	SQL>
	SQL> alter system set dg_broker_start=true;
	System altered.
	SQL>

14. on primary configure dataguard broker.

	[oracle@dc1-systemx-db1 param]$ dgmgrl sys/Oracle2018@systemx
	DGMGRL for Linux: Version 12.1.0.2.0 - 64bit Production
	Copyright (c) 2000, 2013, Oracle. All rights reserved.
	Welcome to DGMGRL, type "help" for information.
	Connected as SYSDBA.
	DGMGRL> create configuration systemx_stby as primary database is systemx connect identifier is systemx;
	Configuration "systemx_stby" created with primary database "systemx"

	DGMGRL> add database systemx_stby as connect identifier is systemx_stby maintained as physical;
	Database "systemx_stby" added
	DGMGRL>

	DGMGRL> enable configuration;
	Enabled.
	DGMGRL> show configuration;
	Configuration - systemx_stby
	  Protection Mode: MaxPerformance
	  Members:
	  systemx      - Primary database
		systemx_stby - Physical standby database
	Fast-Start Failover: DISABLED
	Configuration Status:
	SUCCESS   (status updated 12 seconds ago)

	DGMGRL>
	DGMGRL> show database systemx;
	Database - systemx
	  Role:               PRIMARY
	  Intended State:     TRANSPORT-ON
	  Instance(s):
		systemx
	Database Status:
	SUCCESS
	DGMGRL> show database systemx_stby;
	Database - systemx_stby
	  Role:               PHYSICAL STANDBY
	  Intended State:     APPLY-ON
	  Transport Lag:      0 seconds (computed 1 second ago)
	  Apply Lag:          0 seconds (computed 1 second ago)
	  Average Apply Rate: 4.00 KByte/s
	  Real Time Query:    OFF
	  Instance(s):
		systemx
	Database Status:
	SUCCESS
	DGMGRL>

15. Enable database flashback on both servers. useful when you reinstate the old primary after failover.

	SQL> show parameter db_flash;
	NAME                                 TYPE        VALUE
	------------------------------------ ----------- ------------------------------
	db_flash_cache_file                  string
	db_flash_cache_size                  big integer 0
	db_flashback_retention_target        integer     1440
	SQL> alter system set db_flashback_retention_target=2880;
	System altered.
	SQL> show parameter db_recover;

	NAME                                 TYPE        VALUE
	------------------------------------ ----------- ------------------------------
	db_recovery_file_dest                string      /oraarch/fast_recovery_area
	db_recovery_file_dest_size           big integer 4560M
	SQL> alter system set db_recovery_file_dest_size=50G scope=both;
	System altered.
	SQL> show parameter undo;
	NAME                                 TYPE        VALUE
	------------------------------------ ----------- ------------------------------
	temp_undo_enabled                    boolean     FALSE
	undo_management                      string      AUTO
	undo_retention                       integer     900
	undo_tablespace                      string      UNDOTBS1
	SQL> alter system set undo_retention=86400;
	System altered.
	SQL> alter database flashback on;
	Database altered.
	SQL>	

16. Let’s test Database Switchover and switch back.

	[oracle@dc1-systemx-db1 param]$ dgmgrl sys/Oracle2018@systemx
	DGMGRL for Linux: Version 12.1.0.2.0 - 64bit Production
	Copyright (c) 2000, 2013, Oracle. All rights reserved.
	Welcome to DGMGRL, type "help" for information.
	Connected as SYSDBA.
	DGMGRL> switchover to systemx_stby;
	Performing switchover NOW, please wait...
	Operation requires a connection to instance "systemx" on database "systemx_stby"
	Connecting to instance "systemx"...
	Connected as SYSDBA.
	New primary database "systemx_stby" is opening...
	Operation requires start up of instance "systemx" on database "systemx"
	Starting instance "systemx"...
	ORACLE instance started.
	Database mounted.
	Switchover succeeded, new primary is "systemx_stby"
	DGMGRL> 

	DGMGRL> show configuration;
	Configuration - systemx_stby
	  Protection Mode: MaxPerformance
	  Members:
	  systemx_stby - Primary database
	    systemx      - Physical standby database
	Fast-Start Failover: DISABLED
	Configuration Status:
	SUCCESS   (status updated 32 seconds ago)
	DGMGRL>

	--Switch back to original
	[oracle@dc2-systemx-db1 ~]$ dgmgrl sys/Oracle2018@systemx_stby
	DGMGRL for Linux: Version 12.1.0.2.0 - 64bit Production
	Copyright (c) 2000, 2013, Oracle. All rights reserved.
	Welcome to DGMGRL, type "help" for information.
	Connected as SYSDBA.
	DGMGRL>
	DGMGRL> show configuration;

	Configuration - systemx_stby
	  Protection Mode: MaxPerformance
	  Members:
	  systemx_stby - Primary database
	    systemx      - Physical standby database
	Fast-Start Failover: DISABLED
	Configuration Status:
	SUCCESS   (status updated 28 seconds ago)

	DGMGRL> switchover to systemx;
	Performing switchover NOW, please wait...
	Operation requires a connection to instance "systemx" on database "systemx"
	Connecting to instance "systemx"...
	Connected as SYSDBA.
	New primary database "systemx" is opening...
	Operation requires start up of instance "systemx" on database "systemx_stby"
	Starting instance "systemx"...
	ORACLE instance started.
	Database mounted.
	Switchover succeeded, new primary is "systemx"
	DGMGRL> show configuration;
	Configuration - systemx_stby
	  Protection Mode: MaxPerformance
	  Members:
	  systemx      - Primary database
	    systemx_stby - Physical standby database
	Fast-Start Failover: DISABLED
	Configuration Status:
	SUCCESS   (status updated 28 seconds ago)
	DGMGRL>

17. Now lets try do the failover.

— shutdown abort the primary.

	
	[oracle@dc1-systemx-db1 ~]$ sqlplus '/ as sysdba'

	SQL*Plus: Release 12.1.0.2.0 Production on Wed Feb 28 15:35:17 2018
	Copyright (c) 1982, 2014, Oracle.  All rights reserved.
	Connected to:
	Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
	With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
	SQL> shutdown abort;
	ORACLE instance shut down.
	SQL>

— on standby db.

	[oracle@dc2-systemx-db1 ~]$ dgmgrl sys/Oracle2018@systemx_stby
	DGMGRL for Linux: Version 12.1.0.2.0 - 64bit Production
	Copyright (c) 2000, 2013, Oracle. All rights reserved.
	Welcome to DGMGRL, type "help" for information.
	Connected as SYSDBA.
	DGMGRL> show configuration;
	Configuration - systemx_stby
	  Protection Mode: MaxPerformance
	  Members:
	  systemx      - Primary database
		Error: ORA-01034: ORACLE not available
		systemx_stby - Physical standby database
	Fast-Start Failover: DISABLED
	Configuration Status:
	ERROR   (status updated 0 seconds ago)

	DGMGRL> failover to systemx_stby;
	Performing failover NOW, please wait...
	Failover succeeded, new primary is "systemx_stby"
	DGMGRL>

	+------------------------------------------------------------------------+
	| Report   : Oracle Instances                                            |
	| Instance : systemx                                                     |
	+------------------------------------------------------------------------+
	Instance                Host                                Startup              Database                     Shutdown Active
	Name / Number  Thread # Name                         Status Time                 Status   Archiver Logins?    Pending? State  Version
	------------- --------- ---------------------------- ------ -------------------- -------- -------- ---------- -------- ------ -----------------
	systemx (1)          1 dc2-systemx-db1             OPEN   28-FEB-2018 03:19:42 ACTIVE   STARTED  ALLOWED    NO       NORMAL 12.1.0.2.0

	SQL>

18. Now let’s start the old primary

	[oracle@dc1-systemx-db1 ~]$ sqlplus '/ as sysdba'
	SQL*Plus: Release 12.1.0.2.0 Production on Wed Feb 28 15:38:16 2018
	Copyright (c) 1982, 2014, Oracle.  All rights reserved.
	Connected to an idle instance.

	SQL> startup
	ORACLE instance started.
	Total System Global Area 4781506560 bytes
	Fixed Size                  5293320 bytes
	Variable Size            1224739576 bytes
	Database Buffers         3539992576 bytes
	Redo Buffers               11481088 bytes
	Database mounted.
	ORA-16649: possible failover to another database prevents this database from
	being opened
	SQL>

19. since we enable the flashback, we can automatically reinstate the old primary without recreating it.

	[oracle@dc2-systemx-db1 ~]$ dgmgrl sys/Oracle2018@systemx_stby
	DGMGRL for Linux: Version 12.1.0.2.0 - 64bit Production
	Copyright (c) 2000, 2013, Oracle. All rights reserved.
	Welcome to DGMGRL, type "help" for information.
	Connected as SYSDBA.
	DGMGRL> show configuration;
	Configuration - systemx_stby
	  Protection Mode: MaxPerformance
	  Members:
	  systemx_stby - Primary database
		systemx      - Physical standby database (disabled)
		  ORA-16661: the standby database needs to be reinstated
	Fast-Start Failover: DISABLED
	Configuration Status:
	SUCCESS   (status updated 14 seconds ago)

	DGMGRL> reinstate database systemx;
	Reinstating database "systemx", please wait...
	Reinstatement of database "systemx" succeeded
	DGMGRL>
	DGMGRL> show configuration;
	Configuration - systemx_stby
	  Protection Mode: MaxPerformance
	  Members:
	  systemx_stby - Primary database
		systemx      - Physical standby database
	Fast-Start Failover: DISABLED
	Configuration Status:
	SUCCESS   (status updated 24 seconds ago)
	DGMGRL>

— finally let make the original primary as primary.

	DGMGRL> switchover to systemx;
	Performing switchover NOW, please wait...
	Operation requires a connection to instance "systemx" on database "systemx"
	Connecting to instance "systemx"...
	Connected as SYSDBA.
	New primary database "systemx" is opening...
	Operation requires start up of instance "systemx" on database "systemx_stby"
	Starting instance "systemx"...
	ORACLE instance started.
	Database mounted.
	Switchover succeeded, new primary is "systemx"
	DGMGRL>

20. Lastly, let’s try convert to snapshot standby for testing purposes.

	[oracle@dc1-systemx-db1 ~]$ dgmgrl sys/Oracle2018@systemx
	DGMGRL for Linux: Version 12.1.0.2.0 - 64bit Production
	Copyright (c) 2000, 2013, Oracle. All rights reserved.
	Welcome to DGMGRL, type "help" for information.
	Connected as SYSDBA.
	DGMGRL> show configuration;
	Configuration - systemx_stby
	  Protection Mode: MaxPerformance
	  Members:
	  systemx      - Primary database
		systemx_stby - Physical standby database
	Fast-Start Failover: DISABLED
	Configuration Status:
	SUCCESS   (status updated 8 seconds ago)

	DGMGRL> convert database systemx_stby to snapshot standby;
	Converting database "systemx_stby" to a Snapshot Standby database, please wait...
	Database "systemx_stby" converted successfully
	DGMGRL> show configuration;
	Configuration - systemx_stby
	  Protection Mode: MaxPerformance
	  Members:
	  systemx      - Primary database
		systemx_stby - Snapshot standby database
	Fast-Start Failover: DISABLED
	Configuration Status:
	SUCCESS   (status updated 38 seconds ago)
	DGMGRL>
	DGMGRL> convert database systemx_stby to physical standby;
	Converting database "systemx_stby" to a Physical Standby database, please wait...
	Operation requires shut down of instance "systemx" on database "systemx_stby"
	Shutting down instance "systemx"...
	Database closed.
	Database dismounted.
	ORACLE instance shut down.
	Operation requires start up of instance "systemx" on database "systemx_stby"
	Starting instance "systemx"...
	ORACLE instance started.
	Database mounted.
	Continuing to convert database "systemx_stby" ...
	Database "systemx_stby" converted successfully
	DGMGRL> show configuration;
	Configuration - systemx_stby
	  Protection Mode: MaxPerformance
	  Members:
	  systemx      - Primary database
		systemx_stby - Physical standby database
	Fast-Start Failover: DISABLED
	Configuration Status:
	SUCCESS   (status updated 11 seconds ago)
	DGMGRL>

all done. thanks for checking my blog. hope it helps.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s