Tuesday 1 December 2020

ORA-28759: failure to open file

If any program or query is failed with error ORA-28759, its should be access/permission issue to the wallets location in database server.

Ex:  In my database there is DB link which link to other schema, if i check the db link test i got the below error.

SQL> select count(*) from tab@TEST_DBL;

select count(*) from tab@TEST_DBL

                         *

ERROR at line 1:

ORA-28759: failure to open file


I find the tnsping is not working and got below error.

TNS-12560: TNS:protocol adapter error

i find there is permission issue to wallet location even directory owner is oracle

oracle@labserver:[DB->TEST]$cd /home/oracle/wallet
-bash: cd: /home/oracle/wallet: Permission denied

i check the permission is not sufficient.

drw-r----- 2 oracle oinstall  113 Nov  5 02:00 wallet

Changed to 755 to oracle and got access to directory and issue resolved. 
Like this for any reason if wallet is configured in listener/sqlnet.ora and does not have access wallet directory for oracle user then this issue arise.
Fix by fixing access issue to wallet location.




Tuesday 13 October 2020

How to disable Transparent HugePages


Disabling Transparent HugePages. 


1. check the status

In RHEL

cat /sys/kernel/mm/redhat_transparent_hugepage/enabled

in other OS

cat /sys/kernel/mm/transparent_hugepage/enabled

Output:

[always] madvise never

Its highlighted for always, so Transparent HugePages are enabled.

2. disable the transparent_hugepage.

To disable this modify/add line transparent_hugepage=never

as below:

#cat /etc/default/grub

GRUB_TIMEOUT=5

GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"

GRUB_DEFAULT=saved

GRUB_DISABLE_SUBMENU=true

GRUB_TERMINAL_OUTPUT="console"

GRUB_CMDLINE_LINUX="console=tty1 console=ttyS0 earlyprintk=ttyS0 rootdelay=300 transparent_hugepage=never"

GRUB_DISABLE_RECOVERY="true"

3. Run below command to make recreate file grub

 #grub2-mkconfig -o /boot/grub2/grub.cfg

4. Restart the server.


5. verification after restart the server.

After modification output will be as below, never  is highlighted, so its disabled.

#cat /sys/kernel/mm/transparent_hugepage/enabled

always madvise [never]


Monday 24 August 2020

ORA-27102: out of memory Linux-x86_64 Error: 28: No space left on device

 ORA-27102: out of memory Linux-x86_64 Error: 28: No space left on device


When i try to increase sga_target from 50GB to 60GB i got above error.

the reason is shmall value is not configured accordingly for the SGA size.

[root@test_db_LAB ~]$  cat /etc/sysctl.d/97-oracle-database-sysctl.conf|grep  kernel.shmmni

kernel.shmmni = 4096

[root@test_db_LAB ~]$  cat /etc/sysctl.d/97-oracle-database-sysctl.conf|grep  kernel.shmall

kernel.shmall = 23592960

[root@test_db_LAB ~]$  cat /etc/sysctl.d/97-oracle-database-sysctl.conf|grep  kernel.shmmax

kernel.shmmax = 105374182400


Calculation for kernel.shmall  should be (SGA in bytes)/4096(kernel.shmmni)  = 15728640

as root user, set value 15728640 for shmall in file /etc/sysctl.d/97-oracle-database-sysctl.conf.

as root user, apply the changes. 

/sbin/sysctl -p /etc/sysctl.d/97-oracle-database-sysctl.conf

start the database.


Wednesday 12 August 2020

How to generate trace file for a query in oracle database- tkprof creation for a query

 Most of the situation we may need to create a trace file for a query or a session which include PL/SQL block.

We can use below method to create trace file for the sql statements or PL/SQL blocks.


1. Enable tracing in a session where you are going to run a query with high level tracing 12.


ALTER SESSION SET EVENTS '10046 trace name context forever, level 12';


2. we will have number of tracefiles in database diag locaions, to identify the trace file generated by this session, you can set the identifier as below, so that file name includes identifier.


alter session set tracefile_identifier = 'mysessiontrace';


3.  run the query or PL/SQL block.


4. turn off the tracing.


alter session set events '10046 trace name context off';


you can find the trace file generated with name mysessiontrace, search as below.

ls -lrth *mysessiontrace*


If you want to generate tkprof of this trace file. use below 

tkprof orcl_mysessiontrace.90222_53078.trc orcl_mysessiontrace.90222_53078.txt SYS=NO

Friday 7 August 2020

ORA-39083: Object type TYPE: failed to create with error, ORA-02304: invalid object identifier literal

 Error in import in logfile.


ORA-39083: Object type TYPE:"SCHEMA"."T_DKEG" failed to create with error:

ORA-02304: invalid object identifier literal


Failing sql is:

CREATE EDITIONABLE TYPE "SCHEMA"."T_DKEG"   OID '94C6DE8D33F322F1E0539417F30AF613' force as table of varchar2(32767);


Solution:

Your database have another object with OID already.

select owner,type_oid from dba_types where TYPE_OID='94C6DE8D33F322F1E0539417F30AF613';
 
OWNER           TYPE_OID
--------------- --------------------------------
SCHEMA          94C6DE8D33F322F1E0539417F30AF613


so , while import you have to provide below parameter to avoid this issue. and type will generate now OID whiel import.

TRANSFORM=oid:n

Monday 13 July 2020

Why in dataguard standby side RFS, LNS, LGWR or ARCn generate large trace file without any errors or issues

Why in dataguard standby side RFS, LNS, LGWR or ARCn generate large trace file without any errors or issues?

My standby database side i observed trace files for rfs process are growing in GBs always.
its due to parameter log_archive_trace value set in instance level in standby side.

if log_archive_trace value set for non zero, the trace files size will grow. resolution is to set it to  zero value.

In my case, i can see the value is 255.

SQL> show parameter log_archive_trace

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_trace                    integer     255


i set it to 0, its fixed the proble,.

SQL> alter system set log_archive_trace=0 scope=both;

System altered.


if you are using DB brocker. set this value also to consistent in instance level and DG brocker level.

DGMGRL> show instance 'ORCL' 'LogArchiveTrace';
  LogArchiveTrace = '255'

DGMGRL> edit instance 'ORCL' SET PROPERTY 'LogArchiveTrace'=0;
Property "LogArchiveTrace" updated
DGMGRL> show instance 'ORCL' 'LogArchiveTrace';
  LogArchiveTrace = '0'





Saturday 11 July 2020

OPatch failed with error code 2

When i check the patch conflict for a patch, got below error.

]$opatch prereq CheckConflictAgainstOHWithDetail -ph ./
Oracle Interim Patch Installer version 12.2.0.1.6
Copyright (c) 2020, Oracle Corporation.  All rights reserved.

PREREQ session

Oracle Home       : /u01/oracle/product/12.2.0.1/dbhome_1
Central Inventory : /u01/oracle/oraInventory
   from           : /u01/oracle/product/12.2.0.1/dbhome_1/oraInst.loc
OPatch version    : 12.2.0.1.6
OUI version       : 12.2.0.1.4
Log file location : /u01oracle/product/12.2.0.1/dbhome_1/cfgtoollogs/opatch/opatch2020-07-11_14-10-25PM_1.log

Invoking prereq "checkconflictagainstohwithdetail"

Prereq "checkConflictAgainstOHWithDetail" is not executed.

The details are:
Unable to create Patch Object.
Exception occured : /u01/oracle/psu/30783641/30886680/etc/config/actions.xml with Version field of the component "delete" in actions file cannot be <null> or empty. Please check patch metadata.

OPatch failed with error code 2

Solution:

its due to OPatch version is not compatible for the patch you are trying to apply. download latest opatch utility from metalink and unzip in ORACLE_HOME location. you can download latest OPatch  here

In my case, Opatch version is 12.2.0.1.6 but in patch read me file mentioned it required 12.2.0.1.19 or later 
after adding new OPatch version issue is resolved.

Monday 29 June 2020

OMS 13.4 silent installation

Below process describe how to install OEM 13.4


Download OEM software for linux 64bit from OTN  here  download all the files and copy to the server.


Step 1: install  12c or 19c database in the server before going to install OEM software.

step 2: install OEM software software only using below rsp file.

RESPONSEFILE_VERSION=2.2.1.0.0
UNIX_GROUP_NAME=linstall
INVENTORY_LOCATION=/u01/app/oracle
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
INSTALL_UPDATES_SELECTION=skip
ORACLE_MIDDLEWARE_HOME_LOCATION=/u01/app/oracle/middleware
ORACLE_HOSTNAME=omsserver
AGENT_BASE_DIR=/u01/app/oracle/agent
b_upgrade=false
EM_INSTALL_TYPE=NOSEED
CONFIGURATION_TYPE=LATER
CONFIGURE_SHARED_LOCATION_BIP=false

Execute the command after creating rsp file.

./em13300_linux64.bin -silent -responseFile /tmp/install.rsp

If you dont have /tmp space sufficient, use temporary location in another FS as below.

./em13300_linux64.bin -silent -responseFile /tmp/install.rsp -J-Djava.io.tmpdir=/u01/tmp/

run root script.

$MW_HOME/allroot.sh

step 3: configure OEM, create rsp file.

RESPONSEFILE_VERSION=2.2.1.0.0
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oracle/oraInstall
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
INSTALL_UPDATES_SELECTION=skip
ORACLE_MIDDLEWARE_HOME_LOCATION=/u01/app/oracle/middleware
ORACLE_HOSTNAME=omsserver
AGENT_BASE_DIR=/u01/app/oracle/agent
WLS_ADMIN_SERVER_USERNAME=weblogic
WLS_ADMIN_SERVER_PASSWORD=weblogic123
WLS_ADMIN_SERVER_CONFIRM_PASSWORD=weblogic1
NODE_MANAGER_PASSWORD=nodemgr987
NODE_MANAGER_CONFIRM_PASSWORD=nodemgr987
ORACLE_INSTANCE_HOME_LOCATION=/u01/app/oracle/gc_inst
CONFIGURE_ORACLE_SOFTWARE_LIBRARY=true
SOFTWARE_LIBRARY_LOCATION=/u01/app/oracle/swlib
DATABASE_HOSTNAME=omsserver
LISTENER_PORT=1521
SERVICENAME_OR_SID=EMDB
SYS_PASSWORD=oradbpwd123
SYSMAN_PASSWORD=orapwd123
SYSMAN_CONFIRM_PASSWORD=orapwd123
DEPLOYMENT_SIZE=MEDIUM
AGENT_REGISTRATION_PASSWORD=orapwd123
AGENT_REGISTRATION_CONFIRM_PASSWORD=orapwd123
PLUGIN_SELECTION={}
b_upgrade=false
EM_INSTALL_TYPE=NOSEED
CONFIGURATION_TYPE=ADVANCED
CONFIGURE_SHARED_LOCATION_BIP=false
MANAGEMENT_TABLESPACE_LOCATION=/u01/app/oracle/oradata/mgmt.dbf
CONFIGURATION_DATA_TABLESPACE_LOCATION=/u01/app/oracle/oradata/mgmt_ecm_depot1.dbf
JVM_DIAGNOSTICS_TABLESPACE_LOCATION=/u01/app/oracle/oradata/mgmt_deepdive.dbf

Run below command to configure OEM.

$MW_HOME/sysman/install/ConfigureGC.sh -silent -responseFile /tmp/config.rsp

It take time around 30 min, at the end you will get the links to OEM cloud console.




Friday 26 June 2020

steps to change sysman password in OEM 13.4

Below are the process to change sysman password in for OEM, in oms server.

$OMS_HOME/emctl stop oms

$OMS_HOME/emctl start oms -admin_only

$OMS_HOME/emctl config oms -change_repos_pwd -use_sys_pwd -sys_pwd <sys password> -new_pwd <new sysman passowd>

$OMS_HOME/emctl stop oms

$OMS_HOME/emctl start oms


No need to change sysman password in database level.

Wednesday 17 June 2020

finding queries executed between two timings in oracle 12.2

As DBA we always come accross situation when request comes for queries executed or activities done between two timings. below query works only in enterprise edition and with in awr retention time. modify the timings in the query according to your requirement.


set long 900000
col sql_text for a32767 word_wrapped
COLUMN Sample_Time FOR A25
COLUMN username FOR A20
col MACHINE for a10
COLUMN program FOR A40
COLUMN module FOR A40
SELECT
   sample_time,
   h.MACHINE,
   u.username,
   h.program,
   h.module,
   s.sql_text
FROM
   DBA_HIST_ACTIVE_SESS_HISTORY h,
   DBA_USERS u,
   DBA_HIST_SQLTEXT s
WHERE  sample_time
BETWEEN '10/JUN/2020 08:20:00.000' and '10/JUN/2020 08:30:00.000'
AND
   INSTANCE_NUMBER=1
   AND h.user_id=u.user_id
   AND h.sql_id = s.sql_iD
ORDER BY 1
/

kkjcre1p: unable to spawn jobq slave process,ORA-01034: ORACLE not available,ORA-03114: not connected to ORACLE

I observed the database connections and rman backups failing with below error.

ORA-01034: ORACLE not available 
ORA-27102: out of memory  Linux-x86_64 Error: 12: Cannot allocate memory 

and rman backups failing as below.


RMAN-12001: could not open channel ORA_DISK_1
RMAN-10008: could not create channel context
RMAN-10003: unable to connect to target database
ORA-03114: not connected to ORACLE

But database is running fine, when i check alertlog i found the message like below.

Process J000 died, see its trace file

2020-06-17T07:29:21.805339+02:00
kkjcre1p: unable to spawn jobq slave process



Cause: you might have set MEMORY_TARGET parameter and you may not have sufficient swap space required for the instance. 
Solution: as per oracle note 2356025.1, we need to allocate swap 0.75 times of memory_target size or you may need apply patch 24921392.

In my case i have reduced MEMORY_TARGET. issue got fixed.

Thursday 28 May 2020

configuring standby database using rman duplicate command without backup


configuring standby database using rman duplicate command without backup

Servers details:


Environments
hostname
Ip address
instance
Primary server
Prim-host
primdb

Standby Server
Stdby-host
stdbydb


-        Install 18c grid standalone software in the DR server
-        Install the RDBMS home similar version as prod 12.2.0

Prepare primary server:


1.      Check database is in archivelog mode or not.

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     123816
Next log sequence to archive   123818
Current log sequence           123818

2.      Check the force logging is enabled or not in primary database.
SQL> select force_logging from v$database;

FORCE_LOGGING
---------------------------------------
NO
Enable force logging using below command.

SQL> ALTER DATABASE FORCE LOGGING;

Database altered.

SQL> select force_logging from v$database;

FORCE_LOGGING
---------------------------------------
YES

3.      Create password file in primary database.
orapwd file=orapwPRIMDB password=Ora935#kfd


4.      Create standby redologs in primary database to enable real time apply.

set lines 180
col MEMBER for a60
select b.thread#, a.group#, a.member, b.bytes FROM v$logfile a, v$log b WHERE a.group# = b.group#;

   THREAD#     GROUP# MEMBER                                                       B.BYTES/1024/1024
---------- ---------- ------------------------------------------------------------ -----------------
         1          1 +DATA/PRIMDB/ONLINELOG/group_1.259.1028024215                           200
         1          1 +DATA/PRIMDB/ONLINELOG/group_1.260.1028024217                           200
         1          2 +DATA/PRIMDB/ONLINELOG/group_2.261.1028024219                           200
         1          2 +DATA/PRIMDB/ONLINELOG/group_2.262.1028024221                           200
         1          3 +DATA/PRIMDB/ONLINELOG/group_3.263.1028024223                           200
         1          3 +DATA/PRIMDB/ONLINELOG/group_3.264.1028024223                           200

ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 SIZE 200M;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 SIZE 200M;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 SIZE 200M;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 SIZE 200M;

SQL> select a.group#, a.member, b.bytes FROM v$logfile a, v$standby_log b WHERE a.group# = b.group#;

    GROUP# MEMBER                                                            BYTES
---------- ------------------------------------------------------------ ----------
         4 +DATA/PRIMDB/ONLINELOG/group_4.801.1041440071              209715200
         4 +DATA/PRIMDB/ONLINELOG/group_4.478.1041440071              209715200
         6 +DATA/PRIMDB/ONLINELOG/group_6.545.1041439901              209715200
         6 +DATA/PRIMDB/ONLINELOG/group_6.368.1041439901              209715200
         5 +DATA/PRIMDB/ONLINELOG/group_5.311.1041440081              209715200
         5 +DATA/PRIMDB/ONLINELOG/group_5.567.1041440081              209715200
         7 +DATA/PRIMDB/ONLINELOG/group_7.474.1041440103              209715200
         7 +DATA/PRIMDB/ONLINELOG/group_7.771.1041440105              209715200

8 rows selected.

5.      Set parameter in primary database.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(PRIMDB,STDBYDB)' scope=both;

System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=+DATA VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=PRIMDB' scope=both;

System altered.
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=STDBYDB LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=STDBYDB' scope=both;

System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_1=ENABLE scope=both;

System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE scope=both;

System altered.

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;

System altered.

SQL> ALTER SYSTEM SET fal_server=STDBYDB scope=both;

System altered.

6.      Take pfile as backup

SQL> create pfile='/tmp/primpfile.ora' from spfile;

File created.
7.      Copy pfile and password file to standby server $ORACLE_HOME/dbs location.

Standby server configuration:


1.      Rename the pfile as initSTDBYDB and Modify as below.

*.audit_file_dest='/opt/oracle/oracle_base/admin/STDBYDB/adump'
*.audit_trail='db'
*.compatible='12.2.0'
*.control_file_record_keep_time=38
*.control_files='+DATA/STDBYDB/CONTROLFILE/current.257.1041446223','+DATA/STDBYDB/CONTROLFILE/current.258.1041446227'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_name='PRD2020D'
*.db_recovery_file_dest='+DATA'
*.db_recovery_file_dest_size=107374182400
*.db_unique_name='STDBYDB'
*.diagnostic_dest='/opt/oracle/oracle_base'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=STDBYDBXDB)'
*.fal_server='PRIMDB'
*.local_listener=''
*.log_archive_config='DG_CONFIG=(PRIMDB,STDBYDB)'
*.log_archive_dest_1='LOCATION=+DATA VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=STDBYDB'
*.log_archive_dest_2='SERVICE=PRIMDB LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PRIMDB'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.pga_aggregate_target=15G
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=1400
*.sga_max_size=50G
*.sga_target=50G
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'

2.      rename the password file as orapwSTDBYDB
3.      add entry in /etc/oratab file.

vi /etc/oratab
STDBYDB:/opt/oracle/product/12.2.0.1/dbhome_1:N

4.      start the instance in nomount

$. oraenv
STDBYDB
$sqlplus / as sysdba
startup nomount

configuring network:

              
1.      add tns entry in both primary and standby (in RDBMS home)
tnsnames.ora in primary

PRIMDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = prim-host)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = PRIMDB)
    )
  )

STDBYDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = stdby-host )(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = STDBYDB)
      (UR=A)
    )
  )

tnsnames.ora in standby (RDBMS home)

PRIMDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = prim-host)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = PRIMDB)
    )
  )

STDBYDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = stdby-host )(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = STDBYDB)
      (UR=A)
    )
  )

2.      configure listener in standby server.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = stdby-host)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = STDBYDB_DGMGRL)
      (ORACLE_HOME = /opt/oracle/product/18.0.0/grid)
      (SID_NAME = STDBYDB)
    )
  )

3.      Tnsping check.

oracle@Stdby-host:~[DB->STDBYDB]$tnsping STDBYDB

TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 27-MAY-2020 10:39:52

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

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = stdby-host)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = STDBYDB) (UR=A)))
OK (10 msec)
oracle@Stdby-host:~[DB->STDBYDB]$tnsping PRIMDB

TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 27-MAY-2020 10:39:57

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

Used parameter files:

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = prim-host)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = PRIMDB)))
OK (30 msec)
4.      Password file authentication check from standby server
oracle@Stdby-host:~[DB->STDBYDB]$sqlplus sys/Ora935#kfd@STDBYDB as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed May 27 10:47:20 2020

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

Last Successful login time: Wed May 27 2020 08:32:16 +00:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select host_name from v$instance;

HOST_NAME
----------------------------------------------------------------
Stdby-host
oracle@Stdby-host:~[DB->STDBYDB]$sqlplus sys/Ora935#kfd@PRIMDB  as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed May 27 10:49:11 2020

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

Last Successful login time: Wed May 27 2020 10:48:48 +00:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select host_name from v$instance;

HOST_NAME
----------------------------------------------------------------
Prim-host
5.      Password file authentication check from primary server.
oracle@Prim-host:~[DB->PRIMDB]$sqlplus sys/Ora935#kfd@PRIMDB  as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed May 27 12:50:33 2020

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

Last Successful login time: Wed May 27 2020 12:50:26 +02:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select host_name from v$instance;

HOST_NAME
----------------------------------------------------------------
Prim-host

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
oracle@Prim-host:~[DB->PRIMDB]$sqlplus sys/AppleT0p#^1@STDBYDB as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed May 27 12:51:07 2020

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

Last Successful login time: Wed May 27 2020 12:47:21 +02:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select host_name from v$instance;

HOST_NAME
----------------------------------------------------------------
Stdby-host


Database restore for standby:


1.      Prepare script restore_stdby_db.sh
$cat restore_stdby_db.sh

rman target sys/Ora935#kfd@PRIMDB AUXILIARY sys/AppleT0p#^1@STDBYDB  log= RMAN_restore.log << EOF
run
{
DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE NOFILENAMECHECK;
}
EOF

If file location is different in standby use file convert as below in command.
DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE DORECOVER SPFILE
SET db_unique_name='stdbydb'
SET db_file_name_convert='/u01/primdb/','/u01/stdbydb'
SET log_file_name_convert='/u01/primdb/','/u01/stdbydb'
SET job_queue_processes='0'
NOFILENAMECHECK;

2.      Put database in recovery mode.
SQL> SELECT NAME,OPEN_MODE,DB_UNIQUE_NAME,DATABASE_ROLE,PROTECTION_MODE FROM V$DATABASE;

NAME      OPEN_MODE            DB_UNIQUE_NAME                 DATABASE_ROLE    PROTECTION_MODE
--------- -------------------- ------------------------------ ---------------- --------------------
PRD2020D  MOUNTED              STDBYDB                      PHYSICAL STANDBY MAXIMUM PERFORMANCE
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

3.      Add DR database to HA(standalone grid infrastructure).

$. oraenv
+ASM
$srvctl add database -d STDBYDB -o /opt/oracle/product/12.2.0.1/dbhome_1 -p +DATA/STDBYDB/PARAMETERFILE/spfile.644.1041511849
4.      Modify startup option and database role.
Export grid home/ASM.
$. oraenv
+ASM
srvctl modify database -d STDBYDB -role PHYSICAL_STANDBY -startoption MOUNT