INSTALLARE RAC PHYSICAL STANDBY DATABASE 18C USANDO RMAN ACTIVE DUPLICATION
Oracle Archives Linux Misc About
Create RAC physical standby database using RMAN Active Duplication – 18c
RAC standby database and its database instances must be added manually to Oracle Cluster Registry (OCR) as new resources with srvctl command at the end
Environment
Primary (Cluster Database):
Operating System: Oracle Linux 7.6 (x64) (Red Hat Enterprise Linux Server release 7.6 )
Oracle Release: 18c (18.3.0.0.0)
Node(s): exa1node1, exa1node2
Database Name (DB_NAME): TREVDB1N
Database Unique Name (DB_UNIQUE_NAME): TREVDB1N
Instances: TREVDB1N1, TREVDB1N2
SCAN Name: exa1node-scan
Diskgroup(s): +OCR, +DATI, +RECO
Standby (Cluster Database):
Operating System:Oracle Linux 7.6 (x64) (Red Hat Enterprise Linux Server release 7.6 )
Oracle Release: 12c (12.1.0.2)
Node(s): exa2node1, exa2node2
Database Name (DB_NAME): TREVDB1N
Database Unique Name (DB_UNIQUE_NAME): TREVDB2N
Instances: TREVDB2N1, TREVDB2N2
SCAN Name: exa2node-scan
Diskgroup(s): +DG_OCR, +DG_DATI, +DG_RECO
Take a note of the differences in DB_UNIQUE_NAME (must be unique), .
In my setup, two clusters have already been configured and the primary database (TREVDB1N) is up and running. In this demonstration, I have setup the same DNS server (centroserver.trevdom.lab) to resolve primary and standby hosts.
Primary Cluster:
grid@exa1node1 ~]$ crsctl status res -t
Name Target State Server State details
Local Resources
ora.ACFSDATA.dg
ora.ACFSDATA.dg
ONLINE ONLINE exa1node1 STABLE
ONLINE ONLINE exa1node2 STABLE
ora.ASMNET1LSNR_ASM.lsnr
ONLINE ONLINE exa1node1 STABLE
ONLINE ONLINE exa1node2 STABLE
ora.CRS.dg
ONLINE ONLINE exa1node1 STABLE
ONLINE ONLINE exa1node2 STABLE
ora.DATI.dg
ONLINE ONLINE exa1node1 STABLE
ONLINE ONLINE exa1node2 STABLE
ora.LISTENER.lsnr
ONLINE ONLINE exa1node1 STABLE
ONLINE ONLINE exa1node2 STABLE
ora.RECO.dg
ONLINE ONLINE exa1node1 STABLE
ONLINE ONLINE exa1node2 STABLE
ora.chad
ONLINE ONLINE exa1node1 STABLE
ONLINE ONLINE exa1node2 STABLE
ora.net1.network
ONLINE ONLINE exa1node1 STABLE
ONLINE ONLINE exa1node2 STABLE
ora.ons
ONLINE ONLINE exa1node1 STABLE
ONLINE ONLINE exa1node2 STABLE
Cluster Resources
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE exa1node2 STABLE
ora.LISTENER_SCAN2.lsnr
1 ONLINE ONLINE exa1node1 STABLE
ora.LISTENER_SCAN3.lsnr
1 ONLINE ONLINE exa1node1 STABLE
ora.MGMTLSNR
1 ONLINE ONLINE exa1node2 169.254.17.206 192.1
68.9.12,STABLE
ora.asm
1 ONLINE ONLINE exa1node1 Started,STABLE
2 ONLINE ONLINE exa1node2 Started,STABLE
3 OFFLINE OFFLINE STABLE
ora.cvu
1 OFFLINE OFFLINE STABLE
ora.exa1node1.vip
1 ONLINE ONLINE exa1node1 STABLE
ora.exa1node2.vip
1 ONLINE ONLINE exa1node2 STABLE
ora.mgmtdb
1 ONLINE ONLINE exa1node2 Open,STABLE
ora.qosmserver
1 ONLINE ONLINE exa1node1 STABLE
ora.scan1.vip
1 ONLINE ONLINE exa1node2 STABLE
ora.scan2.vip
1 ONLINE ONLINE exa1node1 STABLE
ora.scan3.vip
1 ONLINE ONLINE exa1node1 STABLE
ora.trevdb1n.db
1 ONLINE ONLINE exa1node1 Open,HOME=/u01/app/o
racle/product/18.3.0
/db_1,STABLE
2 ONLINE ONLINE exa1node2 Open,HOME=/u01/app/o
racle/product/18.3.0
/db_1,STABLE
ora.trevdb1n.service_ro_n.svc
1 OFFLINE OFFLINE STABLE
2 OFFLINE OFFLINE STABLE
ora.trevdb1n.service_rw_n.svc
1 ONLINE ONLINE exa1node1 STABLE
2 ONLINE ONLINE exa1node2 STABLE
Configuring the Primary
Ensure the primary database is in ARCHIVELOG mode and FORCE LOGGING is enabled.
SQL> select name, db_unique_name, log_mode, force_logging, database_role from v$database;
NAME DB_UNIQUE_NAME LOG_MODE FORCE_LOGGING DATABASE_ROLE
TREVDB1N TREVDB1N ARCHIVELOG YES PRIMARY
Set Dataguard Parameters:
alter system set log_archive_config=’DG_CONFIG=(TREVDB1N,TREVDB2N)’ scope=spfile;
alter system set log_archive_dest_1=’location=USE_DB_RECOVERY_FILE_DEST arch reopen=60 max_failure=0 mandatory valid_for=(ALL_LOGFILES,ALL_ROLES) db_unique_name=TREVDB1N’ scope=spfile;
alter system set log_archive_dest_2=’service=TREVDB2N LGWR ASYNC NOAFFIRM max_failure=10 max_connections=2 reopen=400 valid_for=(online_logfiles,primary_role) db_unique_name=TREVDB2N’ scope=both;
alter system set log_archive_max_processes=12 scope=spfile;
alter system set fal_server=TREVDB2N scope=spfile;
alter system set db_file_name_convert=’+DG_DATI’,’+DATI’,’+DG_RECO’,’+RECO’ scope=spfile ;
alter system set log_file_name_convert=’+DG_DATI’,’+DATI’,’+DG_RECO’,’+RECO’ scope=spfile ;
alter system set standby_file_management=AUTO scope=spfile;
reboot
srvctl stop database -database TREVDB1N
srvctl start database -database TREVDB1N
Creating the Standby Redo Logs (SRLs)
Standby Redo Logs enable the changes occurring in the primary database to be reflected in almost real time in the standby, a concept known as Real Time Apply (RTA).
So, here we create the standby redo logs on the primary database. There should be minimum of (threads)*(groups per threads + 1) SRLs created on the standby database.
There are 2 threads with 3 groups per thread in this configuration on the primary side so there should be total of 8 SLRs at minimum needs to be created.
The primary database is having 3 groups for each thread.
select thread#,group#,status,bytes/1024/1024 from v$log;
THREAD# GROUP# STATUS BYTES/1024/1024
1 1 CURRENT 200
1 2 INACTIVE 200
2 3 CURRENT 200
2 4 INACTIVE 200
alter database add standby logfile thread 1 size 200m;
alter database add standby logfile thread 1 size 200m;
alter database add standby logfile thread 1 size 200m;
alter database add standby logfile thread 2 size 200m;
alter database add standby logfile thread 2 size 200m;
alter database add standby logfile thread 2 size 200m;
alter database add standby logfile thread 2 size 200m
select thread#,group#,status,bytes/1024/1024 from v$standby_log;
Password File
Copy password file from primary node to standby nodes (exa2node1, exa2node2):
ASMCMD > pwcopy +DATI/TREVDB1N/PASSWORD/pwdtrevdb1n.258.1000876277 /tmp
copying +DATI/TREVDB1N/PASSWORD/pwdtrevdb1n.258.1000876277 -> /tmp/pwdtrevdb1n.258.1000876277
$ ls -l pwdphoenix*
[root@exa1node1 tmp]# chown oracle:oinstall /tmp/pwdtrevdb1n.258.1000876277
oracle@exa1node1 tmp
$ scp -p /tmp/pwdtrevdb1n.258.1000876277 exa2node1:/u01/app/oracle/product/18.3.0/db_1/dbs/orapwTREVDB2N1
oracle@exa1node1 tmp
$ scp -p /tmp/pwdtrevdb1n.258.1000876277 exa2node2:/u01/app/oracle/product/18.3.0/db_1/dbs/orapwTREVDB2N2
Oracle Net Configuration
Configure TNS in the ORACLE_HOMEs as below in both primary and standby node(s):
TREVDB1N =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = exa1node-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TREVDB1N)
)
)
TREVDB2N =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = exa2node-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TREVDB2N)
)
)
A listener static entry must be defined for first cluster node standby database instance on first cluster node because this is required by RMAN active duplication
when running on first cluster node. I have added in first standby cluster node GI listener.ora (exa2node1:/u01/app/12.1.0/grid/network/admin/listener.ora):
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = aux)
(ORACLE_HOME=/u01/app/oracle/product/18.3.0/db_1)
(SID_NAME = TREVDB2N1)
)
)
Reload listener configuration.
$ lsnrctl reload
$ lsnrctl status
Copyright (c) 1991, 2018, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
Alias LISTENER
Version TNSLSNR for Linux: Version 18.0.0.0.0 – Production
Start Date 25-APR-2019 10:51:37
Uptime 3 days 4 hr. 39 min. 48 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/18.3.0/grid/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/exa2node1/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.11.21)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.11.23)(PORT=1521)))
Services Summary…
Service “+ASM” has 1 instance(s).
Instance “+ASM1”, status READY, has 1 handler(s) for this service…
Service “aux” has 1 instance(s).
Instance “TREVDB2N1”, status UNKNOWN, has 1 handler(s) for this service…
The command completed successfully
Configuring the Standby
Create PFILE for standby instance
On first standby cluster node. Just the DB_NAME is enough.
$ cat initTREVDB2N1.ora
*.db_name=’aux’
I have created specific directory for AUDIT_DEST_DUMP directory first set by primary SPFILE on each standby cluster node:
$ mkdir -p $ORACLE_BASE/admin/TREVDB2N/adump
$ mkdir -p $ORACLE_BASE/admin/TREVDB2N/adump
Remember, ‘TREVDB2N’ (DB_UNIQUE_NAME) in the directory structure, in this case, is case sensitive.
Startup the standby instance (first node) in NOMOUNT
$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Sun Jul 2 07:26:51 2017
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 260046848 bytes
Fixed Size 2923192 bytes
Variable Size 201327944 bytes
Database Buffers 50331648 bytes
Redo Buffers 5464064 bytes
RMAN Active Duplication
Come back to the primary node (exa1node1) and connect to RMAN.
$ rman target sys/xxxxx_xxxxx@TREVDB1N
Recovery Manager: Release 18.0.0.0.0 – Production on Sun Apr 28 10:08:57 2019
Version 18.3.0.0.0
Copyright (c) 1982, 2018, Oracle and/or its affiliates. All rights reserved.
connected to target database: TREVDB1N (DBID=3575456184)
RMAN> connect auxiliary sys/xxxxx_xxxxx@exa2node1:1521/aux
connected to auxiliary database: AUX (not mounted)
Then, execute this within a block:
RMAN> run {
allocate channel p1 type disk;
allocate auxiliary channel s1 type disk;
duplicate target database for standby from active database
spfile
set db_unique_name=’TREVDB2N’
set instance_name=’TREVDB2N1′
set instance_number=’1′
set compatible=’18.0.0′
set control_files=’+DG_DATI’,’+DG_RECO’
set db_file_name_convert=’+DATI’,’+DG_DATI’,’+RECO’,’+DG_RECO’
set log_file_name_convert=’+DATI’,’+DG_DATI’,’+RECO’,’+DG_RECO’
set db_recovery_file_dest=’+DG_RECO’
set DB_CREATE_ONLINE_LOG_DEST_1=’+DG_DATI’
set DB_CREATE_ONLINE_LOG_DEST_2=’+DG_RECO’
set DB_CREATE_ONLINE_LOG_DEST_3=’+DG_RECO’
set fal_server=’TREVDB1N’
set log_archive_dest_1=’location=USE_DB_RECOVERY_FILE_DEST arch reopen=60 max_failure=0 mandatory valid_for=(ALL_LOGFILES,ALL_ROLES) db_unique_name=TREVDB2N’
set log_archive_dest_2=’service=TREVDB1N LGWR ASYNC NOAFFIRM max_failure=10 max_connections=2 reopen=400 valid_for=(online_logfiles,primary_role) db_unique_name=TREVDB1N’
;
}
Modify db_file_name_convert parameter
alter system set db_file_name_convert=’+DG_DATI’,’+DATI’,’+DG_RECO’,’+RECO’ scope=spfile ;
sys@TREVDB2N SQL> select name, db_unique_name, database_role, open_mode from v$database;
NAME DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE
TREVDB1N TREVDB2N PHYSICAL STANDBY MOUNTED
Set DB_CREATE_FILE_DEST and instance initialization parameters.
sys@TREVDB2N SQL> alter system set db_create_file_dest=’+DG_DATI’ scope=spfile;
System altered.
sys@TREVDB2N SQL> alter system set instance_number=2 sid=’TREVDB2N2′ scope=spfile;
System altered.
sys@TREVDB2N SQL> alter system set instance_name=’TREVDB2N1′ sid=’TREVDB2N1′ scope=spfile;
System altered.
sys@TREVDB2N SQL> alter system set instance_name=’TREVDB2N2′ sid=’TREVDB2N2′ scope=spfile;
System altered.
Move the SPFILE to ASM
sys@TREVDB2N SQL> create pfile from spfile;
File created.
sys@TREVDB2N SQL> create spfile=’+DG_DATI’ from pfile;
File created.1004141223
SQL> show parameters spfile;
NAME TYPE VALUE
spfile string +DG_DATI/TREVDB2N/PARAMETERFILE/spfile.274.1004141223
$ echo “SPFILE=’+DG_DATI/TREVDB2N/PARAMETERFILE/spfile.274.1004141223′” > initTREVDB2N1.ora
oracle@exa2node1 dbs
$ scp -p initTREVDB2N1.ora exa2node2:/u01/app/oracle/product/12.1.0/db_1/dbs/initTREVDB2N2.ora
Shutdown the instance
sys@TREVDB2N SQL> shut immediate;
Remove the SPFILE from the file system as we have already moved the SPFILE to ASM.
$ rm spfileTREVDB2N1.ora
Add the database and instance(s) to the cluster
$ srvctl add database -db TREVDB2N -oraclehome $ORACLE_HOME -role physical_standby -startoption mount -spfile +DG_DATI/TREVDB2N/PARAMETERFILE/spfile.274.1004141223
$ srvctl add instance -db TREVDB2N -instance TREVDB2N1 -node exa2node1
$ srvctl add instance -db TREVDB2N -instance TREVDB2N2 -node exa2node2
[oracle@exa2node1 dbs]$ srvctl config database -database TREVDB2N
Nome univoco del database: TREVDB2N
Nome database:
Oracle home: /u01/app/oracle/product/18.3.0/db_1
Utente Oracle: oracle
Spfile: +DG_DATI/TREVDB2N/PARAMETERFILE/spfile.274.1005863703
Password file:
Dominio:
Opzioni di avvio: mount
Opzioni di arresto: immediate
Ruolo del database: PHYSICAL_STANDBY
Criterio di gestione: AUTOMATIC
Pool di server:
Gruppi di dischi: DG_DATI,DG_RECO
Percorsi del punto di accesso:
Servizi:
Tipo: RAC
Contemporaneità di avvio:
Contemporaneità di arresto:
Gruppo OSDBA: dba
Gruppo OSOPER: oinstall
Istanze di database: TREVDB2N1,TREVDB2N2
Nodi configurati: exa2node1,exa2node2
Di importanza critica per CSS: no
Conteggio CPU: 0
Memoria destinazione: 0
Memoria massima: 0
Numero di rete predefinito per i servizi di database:
Il database è gestito da un amministratore
We can startup both standby instances…
$ srvctl status database -database TREVDB2N
Instance TREVDB2N1 is not running on node exa2node1
Instance TREVDB2N2 is not running on node exa2node2
$ srvctl start database -database TREVDB2N
$ srvctl status database -database TREVDB2N
Instance TREVDB2N1 is running on node exa2node1
Instance TREVDB2N2 is running on node exa2node2
grid@exa2node1 ~]$ crsctl status res -t
Name Target State Server State details
Local Resources
ora.ASMNET1LSNR_ASM.lsnr
ONLINE ONLINE exa2node1 STABLE
ONLINE ONLINE exa2node2 STABLE
ora.DG_CRS.dg
ONLINE ONLINE exa2node1 STABLE
ONLINE ONLINE exa2node2 STABLE
ora.DG_DATI.dg
ONLINE ONLINE exa2node1 STABLE
ONLINE ONLINE exa2node2 STABLE
ora.DG_RECO.dg
ONLINE ONLINE exa2node1 STABLE
ONLINE ONLINE exa2node2 STABLE
ora.LISTENER.lsnr
ONLINE ONLINE exa2node1 STABLE
ONLINE ONLINE exa2node2 STABLE
ora.chad
ONLINE ONLINE exa2node1 STABLE
ONLINE ONLINE exa2node2 STABLE
ora.net1.network
ONLINE ONLINE exa2node1 STABLE
ONLINE ONLINE exa2node2 STABLE
ora.ons
ONLINE ONLINE exa2node1 STABLE
ONLINE ONLINE exa2node2 STABLE
Cluster Resources
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE exa2node2 STABLE
ora.LISTENER_SCAN2.lsnr
1 ONLINE ONLINE exa2node1 STABLE
ora.LISTENER_SCAN3.lsnr
1 ONLINE ONLINE exa2node1 STABLE
ora.MGMTLSNR
1 ONLINE ONLINE exa2node1 169.254.26.84 192.16
8.8.11,STABLE
ora.asm
1 ONLINE ONLINE exa2node1 Started,STABLE
2 ONLINE ONLINE exa2node2 Started,STABLE
3 OFFLINE OFFLINE STABLE
ora.cvu
1 ONLINE ONLINE exa2node1 STABLE
ora.exa2node1.vip
1 ONLINE ONLINE exa2node1 STABLE
ora.exa2node2.vip
1 ONLINE ONLINE exa2node2 STABLE
ora.mgmtdb
1 ONLINE ONLINE exa2node1 Open,STABLE
ora.qosmserver
1 ONLINE ONLINE exa2node1 STABLE
ora.scan1.vip
1 ONLINE ONLINE exa2node2 STABLE
ora.scan2.vip
1 ONLINE ONLINE exa2node1 STABLE
ora.scan3.vip
1 ONLINE ONLINE exa2node1 STABLE
ora.trevdb2n.db
1 ONLINE ONLINE exa2node1 mounted,closed,HOME=/
u01/app/oracle/produ
ct/18.3.0/db_1,STABL
E
2 ONLINE ONLINE exa2node2 mounted,closed,HOME=/
u01/app/oracle/produ
ct/18.3.0/db_1,STABL
E
$