Professional Documents
Culture Documents
#Target
ENV file
Source
[oracle@src ~]$ cat DB19_src.env
PATH=/u01/app/oracle/product/19.0.0.0/dbhome_1/bin:/u01/app/oracle/
product/19.0.0.0/dbhome_1/OPatch:$PATH; export PATH
ORACLE_UNQNAME=DB19_iad2zj; export ORACLE_UNQNAME
ORACLE_SID=DB19; export ORACLE_SID
ORACLE_HOSTNAME=src.publicsn.dblabvcn.oraclevcn.com; export
ORACLE_HOSTNAME
LD_LIBRARY_PATH=/u01/app/oracle/product/19.0.0.0/dbhome_1/lib; export
LD_LIBRARY_PATH
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
OH=/u01/app/oracle/product/19.0.0.0/dbhome_1; export OH
ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_1; export
ORACLE_HOME
TNS_ADMIN=/u01/app/oracle/product/19.0.0.0/dbhome_1/network/admin;
export TNS_ADMIN
[oracle@src ~]$
Target
sqlplus / as sysdba
select log_mode from v$database ;
NAME OPEN_MODE
--------- --------------------
DB19 MOUNTED
Database altered.
SQL>
Step2:-Adding Redologfile for standby database
GROUP# THREAD# MB
---------- ---------- ----------
1 1 1024
2 1 1024
3 1 1024
THREAD# INSTANCE
---------- ----------------
1 DB19
Database altered.
Database altered.
SQL>
+RECO/DB19_IAD2ZJ/ONLINELOG/group_4.264.1100024425
+RECO/DB19_IAD2ZJ/ONLINELOG/group_5.265.1100024443
+RECO/DB19_IAD2ZJ/ONLINELOG/group_6.266.1100024453
+RECO/DB19_IAD2ZJ/ONLINELOG/group_7.270.1100156995
Check db_unique_name
SQL> show parameter db_unique_name
Set log_archive_config
Set log_archive_dest_2
System altered.
SQL>
Set fal_server
System altered.
Set standby_file_management
System altered.
How do you know the name and location of the password file for 12c
Database?
OR
OR
How to copy the shared ASM Password file to the Standby Server?
In the Data Guard environment, you have to copy the primary database
password file to the standby server.
Note that it is not sufficient to create a password file on the
standby with the same sys password.
The steps are as follows:
Copy the primary ASM PWD file from ASM to a temp location in filesystem (on the primary
node)
ASMCMD> pwcopy
+DATA/DB19_IAD2ZJ/PASSWORD/pwddb19_iad2zj.271.1100137729 /tmp
copying +DATA/DB19_IAD2ZJ/PASSWORD/pwddb19_iad2zj.271.1100137729 ->
/tmp/pwddb19_iad2zj.271.1100137729
ASMCMD>
Add to tnsnames.ora
##TARGET
DB19_TG=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=192.168.100.118)
(PORT=1521))
(CONNECT_DATA=
(SERVER=DEDICATED)
(SERVICE_NAME=DB19_iad27v.publicsn.dblabvcn.oraclevcn.com)))
##SOURCE
DB19_SRC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.67)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = DB19_iad2zj.publicsn.dblabvcn.oraclevcn.com)
)
)
tnsping DB19_SRC
tnsping DB19_TG
rman
connect target sys/WelC0me_123#@DB19_SRC --Source
connect auxiliary sys/WelC0me_123#@DB19_TG -- Target
Restart primary
Remember, the db_name will be the same in both the primary and the standby
database.
Copy the password file from the primary server to the standby server.
##TARGET
DB19_TG=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=192.168.100.118)
(PORT=1521))
(CONNECT_DATA=
(SERVER=DEDICATED)
(SERVICE_NAME=DB19_iad27v.publicsn.dblabvcn.oraclevcn.com)))
##SOURCE
DB19_SRC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.67)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = DB19_iad2zj.publicsn.dblabvcn.oraclevcn.com)
)
)
Make sure you have a static listener in the new server (I mean, where
will be the new standby). Also, this is very important because the
duplicate stop and start the new instance remotely, start of the
instance remotely is just possible when using static listener
You can use the following example in the listener.ora file. Just
change the value with your environment values.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC = (GLOBAL_DBNAME =
DB19_iad27v.publicsn.dblabvcn.oraclevcn.com)
(ORACLE_HOME =
/u01/app/oracle/product/19.0.0.0/dbhome_1)
(SID_NAME = DB19)
)
)
NOTE: GLOBAL_DBNAME = service name
For example, if my server has three $ORACLE_HOME, 11.2, 12.2 and 19.3
and I am using the listener.ora in the grid_home. Could be something
like it:
SID_LIST_LISTENER_NAME =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = service_one)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1 )
(SID_NAME = inst_1)
)
(SID_DESC =
(GLOBAL_DBNAME = service_two)
(ORACLE_HOME = /u01/app/oracle/product/12.2.0/dbhome_1 )
(SID_NAME = inst_2)
)
(SID_DESC =
(SID_NAME = service_three)
(ORACLE_HOME = /u01/app/oracle/product/19.3.0/dbhome_1 )
(SID_NAME = inst_3)
)
)
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 24-MAR-2022 01:23:34
Uptime 0 days 3 hr. 35 min. 3 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/19.0.0.0/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/tgt/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.118)(PORT=1521)))
Services Summary...
Service "+APX" has 1 instance(s).
Instance "+APX1", status READY, has 1 handler(s) for this service...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "+ASM_DATA" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "+ASM_RECO" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "DB19XDB.publicsn.dblabvcn.oraclevcn.com" has 1 instance(s).
Instance "DB19", status READY, has 1 handler(s) for this service...
Service "DB19_iad27v.publicsn.dblabvcn.oraclevcn.com" has 2 instance(s).
Instance "DB19", status UNKNOWN, has 1 handler(s) for this service...
Instance "DB19", status READY, has 2 handler(s) for this service...
Service "da5a491beb141ae2e0537664a8c04357.publicsn.dblabvcn.oraclevcn.com" has 1
instance(s).
Instance "DB19", status READY, has 2 handler(s) for this service...
Service "db19_pdb1.publicsn.dblabvcn.oraclevcn.com" has 1 instance(s).
Instance "DB19", status READY, has 2 handler(s) for this service...
The command completed successfully
[grid@tgt admin]$
# script duplicate_c.sh
date +"Duplicate iniciado em %d/%m/%Y as %H:%M:%S"
################
[oracle@tgt ~]$ chmod +x duplicate_c.sh
Now go to the primary and check the archivers too and do a switch logfile to generate a new
archiver
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL>
Now go to the standby database and check that the new archiver has been applied.
2022-03-24T16:59:45.203007+00:00
alter database switchover to DB19_iad27v verify
2022-03-24T16:59:48.709487+00:00
SWITCHOVER VERIFY: Send VERIFY request to switchover target
DB19_IAD27V
2022-03-24T16:59:51.285605+00:00
SWITCHOVER VERIFY COMPLETE: READY FOR SWITCHOVER
Completed: alter database switchover to DB19_iad27v verify
If you don’t get any error in the previous command then all is good.
If you do get errors, then check the alert file for more details.
STATUS GAP_STATUS
--------- ------------------------
VALID NO GAP
SQL>
Now go to srv2 (which is now the primary database) and open the database
Database altered.
SQL>
Now go to srv1 (the new standby database) and mount the database
DATABASE_ROLE
----------------
PHYSICAL STANDBY
18 rows selected.
SQL>
perform a switchback
on primary(tgt)
Database altered.
Database altered.
SQL>
Database altered.
SQL>
On tgt mount the database and start the recovery process again
Database altered.
SQL>
If you run into problems, check the parameters on the primary and the standby
database with this query.
1. Reset LOG_ARCHIVE_DEST_2
First you need to clear the value for LOG_ARCHIVE_DEST_2 on the primary and on the
standby database.
SQL> !hostname
src
System altered.
SQL>
SQL> !hostname
tgt
System altered.
SQL>
Set dg_broker_config_file
On Primary
System altered.
System altered.
SQL>
On standby
System altered.
System altered.
SQL>
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights
reserved.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC = (GLOBAL_DBNAME = DB19_iad2zj.publicsn.dblabvcn.oraclevcn.com)
(ORACLE_HOME = /u01/app/oracle/product/19.0.0.0/dbhome_1)
(SID_NAME = DB19)
)
(SID_DESC =
(GLOBAL_DBNAME=DB19_iad2zj_dgmgrl)
(ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_1)
(SID_NAME=DB19)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC = (GLOBAL_DBNAME =
DB19_iad27v.publicsn.dblabvcn.oraclevcn.com)
(ORACLE_HOME =
/u01/app/oracle/product/19.0.0.0/dbhome_1)
(SID_NAME = DB19)
)
(SID_DESC =
(GLOBAL_DBNAME=DB19_iad27v_dgmgrl)
(ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_1)
(SID_NAME=DB19)
)