DEV Community

Cover image for Creating a Standby on 21c [Single Instance]
Project-42
Project-42

Posted on

Creating a Standby on 21c [Single Instance]

For this post, I just wanted to test the same DBCA option we saw in the past to create Standby but this time on 21c.

The first thing I have to clarify is that I will be using rac1-node1 to host the 21c primary database (cdb21) and rac1-node2 to host our new Standby (cdbst21).

The installation of 21c DB_HOME is as simple as has been for last few versions, so I will skip it (you can see how to do it checking this 21c post)

Once we have the Oracle home, we need to setup tnsnames.ora file for the DBCA to be able to connect to our primary database service.

If you follow the news, you will notice that 21c is the first version that comes with read-only Oracle Home by default, which makes some of the old files location not possible. You can read more on this from this Fernando Simon's Post

For my test, I just copied the tnsnames.ora file I have in the Primary host to the standby host


-- Primary host

[oracle@rac1-node1 ~]$ scp -pr /u01/app/oracle/homes/OraDB21Home1/network/admin/tnsnames.ora rac1-node2:/u01/app/oracle/homes/OraDB21Home1/network/admin/tnsnames.ora

tnsnames.ora 100% 408 490.6KB/s 00:00

[oracle@rac1-node1 ~]$

-- Standby host

[oracle@rac1-node2 ~]$ cat /u01/app/oracle/homes/OraDB21Home1/network/admin/tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/oracle/homes/OraDB21Home1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

LISTENER_CDB21 =

(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-node1)(PORT = 1521))

CDB21 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-node1)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = cdb21)

)

)

[oracle@rac1-node2 ~]$

Enter fullscreen mode Exit fullscreen mode

Now that we got the tnsnames.ora file ready, we can create the standby using dbca.

The command I will be using is the same that worked back on 12.2 version and that you can see on this old post


[oracle@rac1-node2 ~]$ . oraenv

ORACLE_SID = [oracle] ? cdbst21

ORACLE_HOME = [/home/oracle] ? /u01/app/oracle/product/21.0.0/dbhome_1

The Oracle base has been set to /u01/app/oracle

[oracle@rac1-node2 ~]$

[oracle@rac1-node2 ~]$ tnsping cdb21

TNS Ping Utility for Linux: Version 21.0.0.0.0 - Production on 12-SEP-2021 17:40:12

Copyright (c) 1997, 2021, Oracle. All rights reserved.

Used parameter files:

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = rac1-node1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = cdb21)))

OK (0 msec)

[oracle@rac1-node2 ~]$

[oracle@rac1-node2 ~]$ dbca -silent -createDuplicateDB \

> -gdbname cdb21 -sid cdbst21 \

> -initParams db_create_file_dest='/u01/oradata/' \

> -primaryDBConnectionString rac1-node1:1521/cdb21 \

> -sysPassword "Welcome1" \

> -createAsStandby \

> -dbUniqueName cdbst21

Prepare for db operation

22% complete

Listener config step

44% complete

Auxiliary instance creation

67% complete

RMAN duplicate

89% complete

Post duplicate database operations

100% complete

Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdbst21/cdbst21.log" for further details.

[oracle@rac1-node2 ~]$

Enter fullscreen mode Exit fullscreen mode

In order for the primary database to be able to connect to the standby, we need to add the information into the Primary node tnsnames.ora file as you can see below:


[oracle@rac1-node1 ~]$ cat /u01/app/oracle/homes/OraDB21Home1/network/admin/tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/oracle/homes/OraDB21Home1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

LISTENER_CDB21 =

(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-node1)(PORT = 1521))

CDB21 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-node1)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = cdb21)

)

)

CDBST21 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-node2)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = cdbst21)

)

)

[oracle@rac1-node1 ~]$

Enter fullscreen mode Exit fullscreen mode

What we have to do now, is to create and enable (yes, I sometimes forget you have to enable it....) our Dataguard configuration on DG broker:


[oracle@rac1-node1 dbs]$ dgmgrl

DGMGRL for Linux: Release 21.0.0.0.0 - Production on Sun Sep 12 17:52:46 2021

Version 21.3.0.0.0

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

Welcome to DGMGRL, type "help" for information.

DGMGRL> connect sys/Welcome1@cdb21

Connected to "cdb21"

Connected as SYSDBA.

DGMGRL> CREATE CONFIGURATION DG_BROKER_CONFIG AS PRIMARY DATABASE IS "cdb21" CONNECT IDENTIFIER IS "cdb21";

Connected to "cdb21"

Configuration "dg_broker_config" created with primary database "cdb21"

DGMGRL>

DGMGRL> ADD DATABASE "cdbst21" AS CONNECT IDENTIFIER IS "cdbst21" MAINTAINED AS PHYSICAL;

Database "cdbst21" added

DGMGRL>

DGMGRL> show configuration

Configuration - dg_broker_config

Protection Mode: MaxPerformance

Members:

cdb21 - Primary database

cdbst21 - Physical standby database

Fast-Start Failover: Disabled

Configuration Status:

DISABLED

DGMGRL> enable configuration

Enabled.

DGMGRL>

Enter fullscreen mode Exit fullscreen mode

And voilà!, our 21c Standby is ready for use :)


-- Standby Alerlog:

2021-09-12T17:55:55.215081+01:00

TT02 (PID:31812): All non-current ORLs have been archived [krsy.c:2195]

2021-09-12T17:55:55.229840+01:00

PR00 (PID:31769): Media Recovery Log /u01/oradata/CDB21/FRA/CDBST21/archivelog/2021_09_12/o1_mf_1_9_jmwd8on0_.arc [krd.c:9408]

2021-09-12T17:55:55.447581+01:00

Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT NODELAY

2021-09-12T17:55:55.733940+01:00

Resize operation completed for file# 3, fname /u01/oradata/CDB21/CDBST21/datafile/o1_mf_sysaux_jmwch9nb_.dbf, old size 614400K, new size 634880K

PR00 (PID:31769): Media Recovery Waiting for T-1.S-10 (in transit) [krsm.c:6185]

2021-09-12T17:55:55.852791+01:00

Recovery of Online Redo Log: Thread 1 Group 4 Seq 10 Reading mem 0

Mem# 0: /u01/oradata/CDB21/CDBST21/onlinelog/o1_mf_4_jmwcjhq1_.log

Mem# 1: /u01/oradata/CDB21/FRA/CDBST21/onlinelog/o1_mf_4_jmwcjj2p_.log

-- Swithed logs on primary to make sure is all fine

SQL> select thread#,max(sequence#) from v$archived_log where first_time > sysdate -1 and status ='A' group by thread# order by thread#;

THREAD# MAX(SEQUENCE#)

---------- --------------

1 9

SQL> alter system archive log current;

System altered.

SQL> /

System altered.

SQL> /

System altered.

SQL> select thread#,max(sequence#) from v$archived_log where first_time > sysdate -1 and status ='A' group by thread# order by thread#;

THREAD# MAX(SEQUENCE#)

---------- --------------

1 12

SQL>

2021-09-12T18:01:03.917829+01:00

Recovery of Online Redo Log: Thread 1 Group 5 Seq 12 Reading mem 0

Mem# 0: /u01/oradata/CDB21/CDBST21/onlinelog/o1_mf_5_jmwcjjyj_.log

Mem# 1: /u01/oradata/CDB21/FRA/CDBST21/onlinelog/o1_mf_5_jmwcjk8o_.log

2021-09-12T18:01:08.841412+01:00

rfs (PID:32296): Opened LNO:4 for DBID:2834326897 B-1080656818.T-1.S-13 [krsr.c:18143]

2021-09-12T18:01:08.841639+01:00

ARC2 (PID:30356): Archived Log entry 6 added for B-1080656818.T-1.S-12 ID 0x7ff9a8eff571 LAD:1 [krse.c:4933]

2021-09-12T18:01:08.901532+01:00

PR00 (PID:31769): Media Recovery Waiting for T-1.S-13 (in transit) [krsm.c:6185]

2021-09-12T18:01:08.902611+01:00

Recovery of Online Redo Log: Thread 1 Group 4 Seq 13 Reading mem 0

Mem# 0: /u01/oradata/CDB21/CDBST21/onlinelog/o1_mf_4_jmwcjhq1_.log

Mem# 1: /u01/oradata/CDB21/FRA/CDBST21/onlinelog/o1_mf_4_jmwcjj2p_.log

DGMGRL> show database cdbst21

Database - cdbst21

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: 30.00 KByte/s

Real Time Query: ON

Instance(s):

cdbst21

Database Status:

SUCCESS

DGMGRL>

Enter fullscreen mode Exit fullscreen mode

As mentioned, nothing particular different than didnt work already on previous versions.

Hope you've enjoyed the post and be ready for more posts about Oracle Database 21c :)

Top comments (0)