Tuesday, February 25, 2025

Oracle to MSSQL Server DB Link

  • Introduction: In Oracle, a heterogeneous database link allows you to connect to non-Oracle databases from an Oracle database. This is useful for querying and manipulating data across different database systems, such as SQL Server, MySQL, or others. This guide will walk you through the creation of Oracle to MSSQL Server DB Link step-by-step.

  • Prerequisites: Below are the minimum requirements for Linux environment.
    1. Connectivity should be established between source and target environments. Crosscheck with ping or telnet command.
    2. MSSQL Server ODBC Drivers should be installed on Oracle DB server. Below are the list of packages.
    a) msodbcsql17
    b) mssql-tools
    c) unixODBC-devel

  • Environment:
  • ## Source Target
    Database Oracle MSSQL Server
    IP 192.168.80.33 10.50.19.5
    DB Name ORCLPRD MSSQLDB
    Port 1521 1433
    Username sys ViewSQL

  • Now start DB link configuration step by step:
1. Install MSSQL Server ODBC Drivers like below.

[root@oracle01 ~]# yum install -y msodbcsql17
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package msodbcsql17.x86_64 0:17.9.1.1-1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
Do you accept the license terms? (Enter YES or NO)
YES
  Installing : msodbcsql17-17.9.1.1-1.x86_64  1/1
  Verifying  : msodbcsql17-17.9.1.1-1.x86_64  1/1
Installed:
  msodbcsql17.x86_64 0:17.9.1.1-1
Complete!

[root@oracle01 ~]# yum install -y mssql-tools
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package mssql-tools.x86_64 0:17.9.1.1-1 will be installed
--> Finished Dependency Resolution
Do you accept the license terms? (Enter YES or NO)
YES
  Installing : mssql-tools-17.9.1.1-1.x86_64  1/1
  Verifying  : mssql-tools-17.9.1.1-1.x86_64  1/1
Installed:
  mssql-tools.x86_64 0:17.9.1.1-1
Complete!

[root@oracle01 ~]# yum install -y unixODBC-devel
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
  Installing : unixODBC-devel-2.3.7-1.rh.x86_64  2/3
  Cleanup    : unixODBC-2.3.1-14.0.1.el7.x86_64  3/3
  Verifying  : unixODBC-devel-2.3.7-1.rh.x86_64  1/3
  Verifying  : unixODBC-2.3.7-1.rh.x86_64  2/3
  Verifying  : unixODBC-2.3.1-14.0.1.el7.x86_64  3/3
Installed:
  unixODBC-devel.x86_64 0:2.3.7-1.rh

Dependency Updated:
  unixODBC.x86_64 0:2.3.7-1.rh

Complete!

[root@oracle01 ~]#

2. Now create odbc.ini file in /etc location with below contents. It will create the data source for MSSQL Server DB. If any existing file is there, then take the backup and add these entries. You may require root user access to edit this file.

[oracle@oracle01 ~]$ cat /etc/odbc.ini
[MSSQL]
Description = MSSQL
Driver = /usr/lib64/libmsodbcsql-17.so
Server = 10.50.19.5
User = ViewSQL
Password = T$eT$2025
Port = 1433
Database = MSSQLDB
[oracle@oracle01 ~]$

3. Now go to $ORACLE_HOME/hs/admin and create file “initMSSQL.ora”. Name of the file is initDATASOURCENAME.ora. Contents are shown below.

[oracle@oracle01 admin]$ pwd
/u01/app/oracle/product/19.0.0/dbhome_1/hs/admin

[oracle@oracle01 admin]$ cat initMSSQL.ora
# This is a sample agent init file that contains the HS parameters that are
# needed for the Database Gateway for ODBC

# HS init parameters
HS_FDS_CONNECT_INFO = MSSQL
HS_FDS_TRACE_LEVEL = user
HS_FDS_SHAREABLE_NAME = /usr/lib64/libmsodbcsql-17.so
HS_FDS_TRACE_FILE_NAME = /tmp/ora_hs_trace.log
HS_NLS_NCHAR = UCS2

# ODBC specific environment variables
set ODBCINI=/etc/odbc.ini

# Environment variables required for the non-Oracle system

[oracle@oracle01 admin]

4. Now go to $ORACLE_HOME/network/admin and do the changes in listener.ora and tnsnames.ora file for MSSQL Server DB data source. Contents are shown below.

[oracle@oracle01 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = oracle01)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER =
        (SID_LIST =
                (SID_DESC =
                        (GLOBAL_DBNAME = ORCLPRD)
                        (ORACLE_HOME = /u01/app/oracle/product/19.0.0/dbhome_1)
                        (SID_NAME = ORCLPRD)
                )
                (SID_DESC=
                        (SID_NAME=MSSQL)
                        (ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1)
                        (PROGRAM=dg4odbc)
                        (ENV="LD_LIBRARY_PATH=/opt/microsoft/msodbcsql17/lib64:/u01/app/oracle/product/19.0.0/dbhome_1/lib")
                )
        )
[oracle@oracle01 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORCLPRD =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = oracle01)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ORCLPRD)
    )
  )
MSSQL =
   (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST=192.168.80.33)(PORT=1521)) # IP Oracle Database
      (CONNECT_DATA=(SID=MSSQL))
      (HS=OK)
    )
[oracle@oracle01 admin]$

Now you need to take a restart of listener with lsnrctl reload LISTENER command. You can also create a separate listener with different port for MSSQL Server, in that case existing listener restart will not be required and you only need to start this new listener.

5. Check Listener status and test tnsping command.

[oracle@oracle01 admin]$ lsnrctl status
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 21-FEB-2025 11:50:17
Copyright (c) 1991, 2022, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle01)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                10-FEB-2025 11:50:17
Uptime                    1 days 8 hr. 10 min. 48 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/oracle01/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle01)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "ORCLPRD" has 2 instance(s).
  Instance "ORCLPRD", status UNKNOWN, has 1 handler(s) for this service...
  Instance "ORCLPRD", status READY, has 1 handler(s) for this service...
Service "ORCLPRDXDB" has 1 instance(s).
  Instance "ORCLPRD", status READY, has 1 handler(s) for this service...
Service "MSSQL" has 1 instance(s).
  Instance "MSSQL", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@oracle01 admin]$

[oracle@oracle01 admin]$ tnsping "MSSQL"
TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 21-FEB-2025 11:51:07
Copyright (c) 1997, 2022, Oracle.  All rights reserved.
Used parameter files:
/u01/app/oracle/product/19.0.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST=192.168.80.33)(PORT=1521)) (CONNECT_DATA=(SID=MSSQL)) (HS=OK))
OK (0 msec)

6. Now we can test our configuration wih isql & sqlcmd command prior to create DB link.

[oracle@oracle01 lib64]$ /opt/mssql-tools/bin/sqlcmd -D -S MSSQL -U ViewSQL
Password:
1> select count(*) from users
2> go
-----------
       1083

(1 rows affected)
1>
2> quit
[oracle@oracle01 lib64]$

[oracle@oracle01 lib64]$ isql -v MSSQL ViewSQL T$eT$2025
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> select count(*) from users
+------------+
|            |
+------------+
| 1083       |
+------------+
SQLRowCount returns 0
1 rows fetched
SQL>
[oracle@oracle01 lib64]$

Note: -U --> User
-D --> Quoted identifiers by default.
-S --> SQL Server instance &
-v --> Verbose

7. Now we will create the DB link. If you want to create a private DB link then you need to login in Oracle database with the user in which you want the DB link. Here we are creating Public DB link.

[oracle@oracle01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Feb 20 12:07:08 2025
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> CREATE PUBLIC DATABASE LINK ORACLE_TO_MSSQL_DBLINK CONNECT TO "ViewSQL" IDENTIFIED BY "T$eT$2025" USING 'MSSQL';
Database link created.

SQL> set lines 333 pages 333
col OWNER for a20
col DB_LINK for a80
col USERNAME for a20
col HOST for a30
col CREATED for a10
select OWNER,DB_LINK,USERNAME,HOST,CREATED from dba_db_links;

OWNER                DB_LINK                             USERNAME            HOST                           CREATED
-------------------- ------------------------------------ -------------------- ------------------------------ ----------
SYS                  SYS_HUB                             SEEDDATA             17-APR-19
PUBLIC               ORACLE_TO_MSSQL_DBLINK              ViewSQL              MSSQL                          21-FEB-25

SQL> select sysdate from dual@ORACLE_TO_MSSQL_DBLINK;

SYSDATE
---------
21-FEB-25

SQL> select * from dual@ORACLE_TO_MSSQL_DBLINK;

D
-
X

SQL>

What Next --> Oracle to MySQL DB Link


Thank you for reading!

I hope this content has been helpful to you. Your feedback and suggestions are always welcome — feel free to leave a comment or reach out with any queries.

Abhishek Shrivastava

📧 Email: oraeasyy@gmail.com
🌐 Website: www.oraeasy.com

Saturday, February 22, 2025

Oracle to MySQL DB Link

  • Introduction: In Oracle, a heterogeneous database link allows you to connect to non-Oracle databases from an Oracle database. This is useful for querying and manipulating data across different database systems, such as SQL Server, MySQL, or others. This article will walk you through the creation of Oracle to MySQL DB Link step-by-step.

  • Prerequisites: Below are the minimum requirements for Linux environment.
    1. Connectivity should be established between source and target environments. Crosscheck with ping or telnet command.
    2. MySQL connector odbc package should be installed on Oracle DB server. Crosscheck with
    “rpm -qa|grep mysql” command.
    mysql-community-client-8.0.35-1.el8.x86_64
    mysql-connector-odbc-8.0.26-1.el7.x86_64

  • Environment:
  • ## Source Target
    Database Oracle 19c MySQL
    IP 192.168.80.33 10.192.225.144
    DB Name ORCLPRD mysql_db
    Port 1521 5544
    Username sys datalake

  • Now start DB link configuration step by step:
1. Install MySQL connector odbc package like below. You can also download the rpm from Oracle Yum. Then install them using rpm -ivh "package" command root user.

[root@oracle01~]# yum install mysql-connector-odbc-8.0.26-1.el7.x86_64
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package mysql-connector-odbc.x86_64 0:8.0.26-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================
 Package                                      Arch                           Version                                Repository                                          Size
====================================================================================
Installing:
 mysql-connector-odbc                         x86_64                         8.0.26-1.el7                           mysql-connectors-community                         4.1M

Transaction Summary
====================================================================================
Install  1 Package
Total download size: 4.1 M
Installed size: 22 M
Is this ok [y/d/N]: y
Downloading packages:
mysql-connector-odbc-8.0.26-1.el7.x86_64.rpm                                                                                                          | 4.1 MB  00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql-connector-odbc-8.0.26-1.el7.x86_64                                                                                                                  1/1
Success: Usage count is 1
Success: Usage count is 1
  Verifying  : mysql-connector-odbc-8.0.26-1.el7.x86_64                                                                                                                  1/1
Installed:
  mysql-connector-odbc.x86_64 0:8.0.26-1.el7
Complete!
[root@oracle01~]#

Similarly you can install mysql-community-client-8.0.35-1.el8.x86_64 package.

2. Now create odbc.ini file in /etc location with below contents. It will create the data source for MySQL DB. If any existing file is there, then take the backup and add these entries. You may require root user access to edit this file.

[oracle@oracle01 admin]$ cat /etc/odbc.ini
[mysql_db]
Description = MYSQL
Driver = /usr/lib64/libmyodbc8a.so
Server = 10.192.225.144
User = datalake
Password = Admin@#1234
Port = 5544
Database = mysql_db
OPTION = 0
TRACE = OFF
[oracle@oracle01 admin]$

3. Now go to $ORACLE_HOME/hs/admin and create file “initmysql_db.ora”. Name of the file is initDATASOURCENAME.ora. Contents are shown below.

[oracle@oracle01 admin]$ pwd
/u01/app/oracle/product/19.0.0/dbhome_1/hs/admin
[oracle@oracle01 admin]$ cat initmysql_db.ora
HS_FDS_CONNECT_INFO = mysql_db
HS_FDS_TRACE_LEVEL = off
HS_FDS_SHAREABLE_NAME=/usr/lib64/libodbc.so
HS_FDS_FETCH_ROWS = 1
HS_FDS_SUPPORT_STATISTICS=FALSE
HS_LANGUAGE=american_america.we8iso8859P1
HS_NLS_NCHAR=UCS2

4. Now go to $ORACLE_HOME/network/admin and do the changes in listener.ora and tnsnames.ora file for mysql_db DB data source. Contents are shown below.

[oracle@oracle01 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = oracle01)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER =
        (SID_LIST =
                (SID_DESC =
                        (GLOBAL_DBNAME = ORCLPRD)
                        (ORACLE_HOME = /u01/app/oracle/product/19.0.0/dbhome_1)
                        (SID_NAME = ORCLPRD)
                )
                (SID_DESC=
                        (SID_NAME=mysql_db)
                        (ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1)
                        (PROGRAM=dg4odbc)
                        (ENV="LD_LIBRARY_PATH=/usr/lib64:/u01/app/oracle/product/19.0.0/dbhome_1/lib")
                )
        )

[oracle@oracle01 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORCLPRD =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = oracle01)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ORCLPRD)
    )
  )

mysql_db =
   (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST=192.168.80.33)(PORT=1521)) # IP Oracle Database
      (CONNECT_DATA=(SID=mysql_db))
      (HS=OK)
    )
[oracle@oracle01 admin]$

Now you need to take a restart of listener with lsnrctl reload LISTENER command. You can also create a separate listener with different port for MySQL, in that case existing listener restart will not be required and you only need to start this new listener.

5. Check Listener status and test tnsping command.

[oracle@oracle01 admin]$ lsnrctl status
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 20-FEB-2025 11:50:17
Copyright (c) 1991, 2022, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle01)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                20-FEB-2025 11:50:17
Uptime                    0 days 8 hr. 10 min. 48 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/oracle01/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle01)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "ORCLPRD" has 2 instance(s).
  Instance "ORCLPRD", status UNKNOWN, has 1 handler(s) for this service...
  Instance "ORCLPRD", status READY, has 1 handler(s) for this service...
Service "ORCLPRDXDB" has 1 instance(s).
  Instance "ORCLPRD", status READY, has 1 handler(s) for this service...
Service "mysql_db" has 1 instance(s).
  Instance "mysql_db", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@oracle01 admin]$ 
[oracle@oracle01 admin]$ tnsping "mysql_db"
TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 20-FEB-2025 11:51:07
Copyright (c) 1997, 2022, Oracle.  All rights reserved.
Used parameter files:
/u01/app/oracle/product/19.0.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST=192.168.80.33)(PORT=1521)) (CONNECT_DATA=(SID=mysql_db)) (HS=OK))
OK (0 msec)

6. Now we can test our configuration wih isql & mysql command prior to create DB link.

[oracle@oracle01 ~]$ isql -v mysql_db
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> show databases
+-----------------------------------------------------------------+
| Database                                                        |
+-----------------------------------------------------------------+
| information_schema                                              |
| daily_schedular_db                                              |
| mysql_db                                                        |
| mysql                                                           |
| performance_schema                                              |
| test                                                            |
+-----------------------------------------------------------------+
SQLRowCount returns 6
6 rows fetched
SQL> 

[oracle@oracle01 ~]$ mysql -udatalake -p -h10.192.225.144 -P5544
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1094140
Server version: 5.6.47 MySQL Community Server (GPL)
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| daily_schedular_db |
| mysql_db           |
| mysql              |
| performance_schema |
| test               |
+--------------------+
6 rows in set (0.00 sec)

Note: -u --> User
-p --> Password
-h --> Host
-P --> Port &
-v --> Verbose

7. Now we will create the DB link. If you want to create a private DB link then you need to login in Oracle database with the user in which you want the DB link. Here we are creating Public DB link.

[oracle@oracle01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Feb 20 12:07:08 2025
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> CREATE PUBLIC DATABASE LINK ORACLE_TO_MYSQL_DBLINK CONNECT TO "datalake" IDENTIFIED BY "Admin@#1234" USING 'mysql_db';
Database link created.

SQL> set lines 333 pages 333
col OWNER for a20
col DB_LINK for a80
col USERNAME for a20
col HOST for a30
col CREATED for a10
select OWNER, DB_LINK, USERNAME, HOST, CREATED from dba_db_links;
SQL>

OWNER                DB_LINK                               USERNAME             HOST                           CREATED
-------------------- -------------------------------------- -------------------- ------------------------------ ----------
SYS                  SYS_HUB                                SEEDDATA                                          17-APR-19
PUBLIC               ORACLE_TO_MYSQL_DBLINK                 datalake             mysql_db                       20-FEB-25

SQL> select sysdate from dual@ORACLE_TO_MYSQL_DBLINK;
SYSDATE
---------
20-FEB-25

SQL> select * from dual@ORACLE_TO_MYSQL_DBLINK;
D
-
X

SQL>



What Next --> Oracle to MSSQL Server DB Link


Thank you for reading!

I hope this content has been helpful to you. Your feedback and suggestions are always welcome — feel free to leave a comment or reach out with any queries.

Abhishek Shrivastava

📧 Email: oraeasyy@gmail.com
🌐 Website: www.oraeasy.com

Monday, February 17, 2025

Oracle 23ai Free Installation

  • Introduction:
    Oracle Database 23ai, released in May 2024, is Oracle's latest long-term support release, introducing over 300 new features designed to integrate artificial intelligence (AI) capabilities directly into enterprise data management.
    Oracle offers a free version of Oracle Database 23ai, known as Oracle Database 23ai Free, which allows users to explore and develop with the latest features without incurring any costs. This guide will walk you through the Oracle Database 23ai installation process step-by-step.

  • Prerequisites: Below are the minimum requirements for Linux environment.
    1. CPU - 2core
    2. RAM - 2GB
    3. Disk space - 12GB
    4. Swap - 1.5 time of RAM
    5. OS - Oracle Linux 8/9, Red Hat Enterprise Linux 8/9.

  • Software Download:
    1. oracle-database-preinstall-23ai : For Linux 8 and for For Linux 9
    2. Oracle Database 23ai: Download RPM

  • Environment Used:
    1. Hostname: oracle23ai
    2. OS: OL9

  • Note:  Keep enough space in / mount point as ORACLE_HOME will be created in  /opt. you can also create a separate mount point with name /opt.

  • Now start installation step by step:
1. Install oracle-database-preinstall-23ai

[root@oracle23ai ~]# yum install -y oracle-database-preinstall-23ai
Oracle Linux 9 BaseOS Latest (x86_64) 2.2 MB/s | 50 MB 00:22
Oracle Linux 9 Application Stream Packages (x86_64) 2.1 MB/s | 50 MB 00:23
Oracle Linux 9 UEK Release 7 (x86_64) 3.2 MB/s | 58 MB 00:17
Last metadata expiration check: 0:00:10 ago on Sat 15 Feb 2025 06:50:29 PM IST.
Dependencies resolved.
========================================================================
 Package                       Architecture  Version            Repository         Size
========================================================================
Installing:
 oracle-database-preinstall-23ai  x86_64    1.0-2.el9          ol9_appstream      35 k
Installing dependencies:
 initscripts                      x86_64    10.11.7-1.0.1.el9  ol9_baseos_latest  285 k
 ksh                              x86_64    3:1.0.6-4.el9_5    ol9_appstream      889 k
 libnsl                           x86_64    2.34-100.0.1.el9   ol9_baseos_latest   69 k
Transaction Summary
========================================================================
Install  4 Packages
Total download size: 1.2 M
Installed size: 4.2 M
Downloading Packages:
(1/4): libnsl-2.34-100.0.1.el9.x86_64.rpm         38 kB/s |  69 kB 00:01
(2/4): initscripts-10.11.7-1.0.1.el9.x86_64.rpm  149 kB/s | 285 kB 00:01
(3/4): ksh-1.0.6-4.el9_5.x86_64.rpm              339 kB/s | 889 kB 00:02
(4/4): oracle-database-preinstall-23ai-1.0-2.el9.x86_64.rpm 31 kB/s |  35 kB 00:01
-------------------------------------------------------------------------------------------------------
Total                                            434 kB/s | 1.2 MB 00:02
Oracle Linux 9 BaseOS Latest (x86_64)             6.1 MB/s | 6.2 kB 00:00
Importing GPG key 0x8D8B756F:
Userid     : "Oracle Linux (release key 1) "
Fingerprint: 3E6D 826D 3FBA B389 C2F3 8E34 BC4D 06A0 8D8B 756F
From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Key imported successfully
Importing GPG key 0x8B4EFBE6:
Userid     : "Oracle Linux (backup key 1) "
Fingerprint: 9822 3175 9C74 6706 5D0C E9B2 A7DD 0708 8B4E FBE6
From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        : 1/1
  Installing       : ksh-3:1.0.6-4.el9_5.x86_64                   1/4
  Running scriptlet: ksh-3:1.0.6-4.el9_5.x86_64                   1/4
  Installing       : libnsl-2.34-100.0.1.el9.x86_64               2/4
  Installing       : initscripts-10.11.7-1.0.1.el9.x86_64         3/4
  Running scriptlet: initscripts-10.11.7-1.0.1.el9.x86_64         3/4
Created symlink /etc/systemd/system/sysinit.target.wants/import-state.service → /usr/lib/systemd/system/import-state.service.
Created symlink /etc/systemd/system/sysinit.target.wants/loadmodules.service → /usr/lib/systemd/system/loadmodules.service.
  Installing       : oracle-database-preinstall-23ai-1.0-2.el9.x86_64 4/4
  Running scriptlet: oracle-database-preinstall-23ai-1.0-2.el9.x86_64 4/4
  Verifying        : initscripts-10.11.7-1.0.1.el9.x86_64         1/4
  Verifying        : libnsl-2.34-100.0.1.el9.x86_64               2/4
  Verifying        : ksh-3:1.0.6-4.el9_5.x86_64                   3/4
  Verifying        : oracle-database-preinstall-23ai-1.0-2.el9.x86_64 4/4

Installed:
  initscripts-10.11.7-1.0.1.el9.x86_64
  ksh-3:1.0.6-4.el9_5.x86_64
  libnsl-2.34-100.0.1.el9.x86_64
  oracle-database-preinstall-23ai-1.0-2.el9.x86_64

Complete!
[root@oracle23ai ~]#

If you want to install preinstall-23ai rpm manually then run below command post downloading the rpm.
rpm -ivh oracle-database-preinstall-23ai-1.0-2.el9.x86_64.rpm
2. Now download the Oracle 23 ai RPM and keep it in /u01. Then start installing it.

[root@oracle23ai ~]# yum -y localinstall /u01/oracle-database-free-23ai-1.0-1.el9.x86_64.rpm
Last metadata expiration check: 0:08:51 ago on Sat 15 Feb 2025 06:50:43 PM IST.
Dependencies resolved.
========================================================================
Package                  Architecture  Version       Repository    Size
========================================================================
Installing:
oracle-database-free-23ai x86_64      1.0-1         @commandline  1.3 G
Transaction Summary
========================================================================
Install  1 Package
Total size: 1.3 G
Installed size: 3.5 G
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        : 1/1
  Running scriptlet: oracle-database-free-23ai-1.0-1.x86_64  1/1
  Installing       : oracle-database-free-23ai-1.0-1.x86_64  1/1
  Running scriptlet: oracle-database-free-23ai-1.0-1.x86_64  1/1
[INFO] Executing post installation scripts...
[INFO] Oracle home installed successfully and ready to be configured.
To configure Oracle Database Free, optionally modify the parameters in '/etc/sysconfig/oracle-free-23ai.conf' and then run '/etc/init.d/oracle-free-23ai configure' as root.
  Verifying        : oracle-database-free-23ai-1.0-1.x86_64  1/1

Installed:
  oracle-database-free-23ai-1.0-1.x86_64

Complete!

3. Change password of oracle user.

[root@oracle23ai ~]# passwd oracle
Changing password for user oracle.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.

4. Now locate ORACLE_HOME directory.

[root@oracle23ai ~]# cd /opt/oracle/product/23ai/dbhomeFree
[root@oracle23ai dbhomeFree]# pwd
/opt/oracle/product/23ai/dbhomeFree
[root@oracle23ai dbhomeFree]# ll
total 80
drwxr-xr-x.  2 oracle oinstall   102 Feb 15 19:05 addnode
drwxr-xr-x.  9 oracle oinstall    93 Feb 15 19:02 assistants
drwxr-xr-x.  2 oracle oinstall  8192 Feb 15 19:05 bin
drwxrwx---.  3 oracle oinstall    17 Feb 15 19:06 cfgtoollogs
drwxr-xr-x.  4 oracle oinstall    87 Feb 15 19:05 clone
drwxr-xr-x.  6 oracle oinstall    55 Feb 15 19:02 crs
drwxr-xr-x.  4 oracle oinstall    31 Feb 15 19:02 crypto
drwxr-xr-x.  3 oracle oinstall    18 Feb 15 19:02 css
drwxr-xr-x. 11 oracle oinstall   119 Feb 15 19:03 ctx
drwxr-xr-x.  7 oracle oinstall    71 Feb 15 19:03 cv
drwxr-xr-x.  3 oracle oinstall    20 Feb 15 19:03 data
drwxr-xr-x.  2 oracle oinstall    22 Feb 15 19:05 dbs
drwxr-xr-x.  5 oracle oinstall   173 Feb 15 19:05 deinstall
drwxr-xr-x.  3 oracle oinstall    20 Feb 15 19:03 demo
drwxr-xr-x.  3 oracle oinstall    20 Feb 15 19:03 diagnostics
drwxr-xr-x.  3 oracle oinstall    19 Feb 15 19:03 dv
-rw-r--r--.  1 oracle oinstall   852 Aug 18  2015 env.ora
drwxr-xr-x.  3 oracle oinstall    18 Feb 15 19:03 has
drwxr-xr-x.  5 oracle oinstall    41 Feb 15 19:03 hs
drwxrwx---. 11 oracle oinstall  4096 Feb 15 19:06 install
drwxr-xr-x.  2 oracle oinstall    29 Feb 15 19:05 instantclient
drwxr-x---. 12 oracle oinstall  4096 Feb 15 19:05 inventory
drwxr-xr-x.  9 oracle oinstall    94 Feb 15 19:03 javavm
drwxr-xr-x.  3 oracle oinstall    17 Feb 15 19:03 jdbc
drwxr-xr-x.  6 oracle oinstall    68 Feb 15 19:05 jdk
drwxr-xr-x.  2 oracle oinstall  4096 Feb 15 19:05 jlib
drwxr-xr-x. 10 oracle oinstall   112 Feb 15 19:04 ldap
drwxr-xr-x.  3 oracle oinstall 12288 Feb 15 19:05 lib
-rwxrwxr-x.  1 oracle oinstall  5780 Jan 31 07:30 LICENSE
drwxrwxr-x.  2 oracle oinstall     6 Jan 31 07:29 log
drwxr-xr-x.  5 oracle oinstall    42 Feb 15 19:04 md
drwxr-xr-x.  4 oracle oinstall    31 Feb 15 19:04 mgw
drwxr-xr-x. 11 oracle oinstall   118 Feb 15 19:04 network
drwxr-xr-x.  5 oracle oinstall    46 Feb 15 19:04 nls
drwxr-xr-x.  8 oracle oinstall   133 Feb 15 19:05 odbc
drwxr-xr-x.  5 oracle oinstall    42 Feb 15 19:04 olap
drwxr-xr-x.  4 oracle oinstall    35 Feb 15 19:04 oml4py
drwxr-xr-x. 13 oracle oinstall  4096 Feb 15 19:05 OPatch
drwxr-xr-x.  7 oracle oinstall    65 Feb 15 19:04 opmn
drwxr-xr-x.  5 oracle oinstall    45 Feb 15 19:05 oracore
-rw-r-----.  1 oracle oinstall   130 Feb 15 19:06 oraInst.loc
drwxr-xr-x.  4 oracle oinstall    29 Feb 15 19:05 ord
drwxr-xr-x.  3 oracle oinstall    19 Feb 15 19:05 oss
drwxr-xr-x.  8 oracle oinstall  4096 Feb 15 19:05 oui
drwxr-xr-x.  4 oracle oinstall    28 Feb 15 19:05 perl
drwxr-xr-x.  6 oracle oinstall   106 Feb 15 19:05 plsql
drwxr-xr-x.  7 oracle oinstall    88 Feb 15 19:05 precomp
drwxr-xr-x.  5 oracle oinstall    39 Feb 15 19:05 python
drwxr-xr-x.  2 oracle oinstall    26 Feb 15 19:05 QOpatch
drwxr-xr-x.  5 oracle oinstall    52 Feb 15 19:01 R
drwxr-xr-x.  4 oracle oinstall    29 Feb 15 19:05 racg
drwxr-xr-x. 13 oracle oinstall   140 Feb 15 19:05 rdbms
drwxr-xr-x.  3 oracle oinstall    21 Feb 15 19:05 relnotes
-rwx------.  1 oracle oinstall   525 Jan 31 07:29 root.sh
-rwxr-x---.  1 oracle oinstall  2957 Jun  7  2024 runInstaller
-rw-r--r--.  1 oracle oinstall  2927 Jul 20  2020 schagent.conf
drwxr-xr-x.  5 oracle oinstall   119 Feb 15 19:05 sdk
drwxr-xr-x.  3 oracle oinstall    18 Feb 15 19:05 slax
drwxr-xr-x.  4 oracle oinstall    28 Feb 15 19:05 sqlcl
drwxr-xr-x.  3 oracle oinstall    17 Feb 15 19:05 sqlj
drwxr-xr-x.  3 oracle oinstall  4096 Feb 15 19:05 sqlpatch
drwxr-xr-x.  6 oracle oinstall    53 Feb 15 19:05 sqlplus
drwxr-xr-x.  6 oracle oinstall    54 Feb 15 19:05 srvm
drwxr-xr-x.  3 oracle oinstall    17 Feb 15 19:05 ucp
drwxr-xr-x.  4 oracle oinstall    31 Feb 15 19:05 usm
drwxr-xr-x.  2 oracle oinstall    33 Feb 15 19:05 utl
drwxr-x---.  7 oracle oinstall    69 Feb 15 19:05 xdk

5. Now login with Oracle user and set .bash_profile.

[oracle@oracle23ai ~]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs
ORACLE_HOME=/opt/oracle/product/23ai/dbhomeFree
export ORACLE_HOME

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:.
export LD_LIBRARY_PATH

LIBPATH=$ORACLE_HOME/lib32:$ORACLE_HOME/lib:/usr/lib:/lib
export LIBPATH

TNS_ADMIN=${ORACLE_HOME}/network/admin
export TNS_ADMIN

PATH=$ORACLE_HOME/bin:$PATH:.
export PATH

6. Now run the DBCA and start DB installation.

[oracle@oracle23ai ~]$ dbca
Now you can create the database as you are doing for other Oracle DB version.



ORACLE SID will be always FREE as its Oracle 23ai Free. Global DB name and PDB can be modified as per need.
Customize the location of data files as per your setup and need.
Specify FRA location










7. Now set environment and do the login..

[oracle@oracle23ai ~]$ . oraenv
ORACLE_SID = [oracle] ? FREE
The Oracle base has been set to /opt/oracle
[oracle@oracle23ai ~]$
[oracle@oracle23ai ~]$ sqlplus / as sysdba
SQL*Plus: Release 23.0.0.0.0 - Production on Sat Feb 15 20:25:04 2025
Version 23.7.0.25.01
Copyright (c) 1982, 2025, Oracle.  All rights reserved.
Connected to:
Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.7.0.25.01
SQL>
SQL>
SQL>
SQL> set lines 200 pages 1000
col open_mode for a15
col HOST_NAME for a15
select NAME,DATABASE_ROLE,OPEN_MODE,INSTANCE_NUMBER,INSTANCE_NAME,HOST_NAME,VERSION,STARTUP_TIME,STATUS from gv$database,gv$instance;

SQL>
NAME      DATABASE_ROLE    OPEN_MODE       INSTANCE_NUMBER INSTANCE_NAME    HOST_NAME       VERSION           STARTUP_T STATUS
--------- ---------------- --------------- --------------- ---------------- --------------- ----------------- --------- ------------
APEXDB    PRIMARY          READ WRITE                    1 FREE             oracle23ai      23.0.0.0.0        15-FEB-25 OPEN
SQL> show pdbs
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 APEXPDB1                       READ WRITE NO
SQL> !lsnrctl status
LSNRCTL for Linux: Version 23.0.0.0.0 - Production on 15-FEB-2025 20:28:17
Copyright (c) 1991, 2025, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=laptop-fhsjip9c)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 23.0.0.0.0 - Production
Start Date                15-FEB-2025 19:45:57
Uptime                    0 days 0 hr. 42 min. 22 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/oracle/product/23ai/dbhomeFree/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/oracle23ai/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle23ai)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "2cf5fcb8b4ef1dc4e0631fc45e647325" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
Service "2e302888a2dbd35ee0630a65a8c0ae25" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
Service "FREEXDB" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
Service "apexdb" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
Service "apexpdb1" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
The command completed successfully



Thank you for reading!

I hope this content has been helpful to you. Your feedback and suggestions are always welcome — feel free to leave a comment or reach out with any queries.

Abhishek Shrivastava

📧 Email: oraeasyy@gmail.com
🌐 Website: www.oraeasy.com

Monday, February 10, 2025

Switchover to Standby

  • Introduction: In Oracle, a switchover is a role transition operation between the primary and standby databases in a Data Guard environment. A switchover allows you to switch roles between the primary and standby databases in a planned manner, without data loss. This is typically done for maintenance, testing, or load balancing.

  • Prerequisites:
  • o Downtime required at Database end for 30 mins.
    o Application and Database connectivity for Standby site.
    o Primary and Standby databases should be in sync.

  • Environment:
  • Server Primary Standby
    Hostname Source Target
    IP 192.168.80.51 192.168.80.111
    OS OEL 9 OEL 9
    SID ORCLDC ORCLDR
    Service Name ORCLDC ORCLDR

  • Now start Switchover activity step by step:

1. Check DB status and sync between Primary and Standby

==> At Primary:

SQL> select NAME, DB_UNIQUE_NAME, DATABASE_ROLE, OPEN_MODE, SWITCHOVER_STATUS from v$database; NAME DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE SWITCHOVER_STATUS -------- ---------------------- ----------------- ---------------- -------------------- ORCL ORCLDC PRIMARY READ WRITE TO STANDBY SQL> set lines 200 pages 300 SQL> alter session set nls_date_format= 'DD-MON-YYYY HH24:MI:SS'; SQL> select d.db_unique_name, d.database_role, a.thread#, b.last_seq, a.applied_seq, a.last_app_timestamp, b.last_seq - a.applied_seq ARC_DIFF FROM (select thread#, MAX(sequence#) applied_seq, MAX(next_time) last_app_timestamp from gv$archived_log where applied='YES' group by thread#) a, (select thread#, MAX(sequence#) last_seq from gv$archived_log group by thread#) b, (select db_unique_name, database_role from v$database) d where a.thread#=b.thread#; SQL> Session altered. DB_UNIQUE_NAME DATABASE_ROLE THREAD# LAST_SEQ APPLIED_SEQ LAST_APP_TIMESTAMP ARC_DIFF ------------------ ---------------- -------- ---------- ----------- --------------------- ---------- ORCLDC PRIMARY 1 103 103 08-FEB-2025 20:24:32 0

==> At Standby:

SQL> select NAME, DB_UNIQUE_NAME, DATABASE_ROLE, OPEN_MODE, SWITCHOVER_STATUS from v$database; NAME DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE SWITCHOVER_STATUS ------- ---------------- ------------------ ------------------------ -------------------- ORCL ORCLDR PHYSICAL STANDBY READ ONLY WITH APPLY NOT ALLOWED SQL> set lines 200 pages 300 SQL> alter session set nls_date_format= 'DD-MON-YYYY HH24:MI:SS'; SQL> select d.db_unique_name, d.database_role, a.thread#, b.last_seq, a.applied_seq, b.last_seq - a.applied_seq ARC_DIFF, a.last_app_timestamp, round((sysdate - a.last_app_timestamp) * 24 * 60, 2) Gap_in_Mins, round((sysdate - a.last_app_timestamp) * 24 * 60 * 60, 2) Gap_in_Seconds FROM (select thread#, MAX(sequence#) applied_seq, MAX(next_time) last_app_timestamp from gv$archived_log where REGISTRAR='RFS' and applied='YES' group by thread#) a, (select thread#, MAX(sequence#) last_seq from gv$archived_log group by thread#) b, (select db_unique_name, database_role from v$database) d where a.thread# = b.thread#; SQL> Session altered. DB_UNIQUE_NAME DATABASE_ROLE THREAD# LAST_SEQ APPLIED_SEQ ARC_DIFF LAST_APP_TIMESTAMP GAP_IN_MINS GAP_IN_SECONDS --------------- ------------------ -------- ---------- ----------- ---------- --------------------- ------------ --------------- ORCLDR PHYSICAL STANDBY 1 103 103 0 08-FEB-2025 20:24:32 12.85 771
2. Now run verify command on Primary to check switchover status

 SQL>  alter database switchover to orcldr verify;
 
 Database altered.
 
If no error is showing then proceed for Switchover.
If you receive any warning message like below then check DB alert log and take action accordingly.

 SQL>  alter database switchover to orcldr verify
  alter database switchover to orcldr verify
  *
ERROR at line 1:
ORA-16475: succeeded with warnings, check alert log for more details
  
3. Switchover to Standby. Monitor DB alert log for any issue

SQL> alter database switchover to orcldr;
Database altered.
4. Now start new Standby (orcldc) in mount state and new Primary (orcldr) in read/write state

==> At new Primary:

SQL> startup ORACLE instance started. Total System Global Area 1459616616 bytes Fixed Size 9177960 bytes Variable Size 905969664 bytes Database Buffers 536870912 bytes Redo Buffers 7598080 bytes Database mounted. Database opened. SQL> select NAME, DB_UNIQUE_NAME, DATABASE_ROLE, OPEN_MODE, LOG_MODE from v$database; NAME DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE LOG_MODE ------- ---------------- --------------- ---------------- ------------ ORCL ORCLDR PRIMARY READ WRITE ARCHIVELOG

==> At new Standby:

SQL> startup mount; ORACLE instance started. Total System Global Area 1459616616 bytes Fixed Size 9177960 bytes Variable Size 1157627904 bytes Database Buffers 285212672 bytes Redo Buffers 7598080 bytes Database mounted. SQL> select NAME, DB_UNIQUE_NAME, DATABASE_ROLE, OPEN_MODE, LOG_MODE from v$database; NAME DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE LOG_MODE ------- ---------------- ----------------- ----------------- ------------ ORCL ORCLDC PHYSICAL STANDBY MOUNTED ARCHIVELOG SQL> alter database recover managed standby database disconnect from session; Database altered.
5. Now do some log switches on new Primary and check the sync.

SQL> alter system switch logfile;

System altered.

SQL> /

System altered.
   
  
Similarly you can do switchback activity. Just change the service name from ORCLDR  to ORCLDC while running switchover command.

Thank you for reading!

I hope this content has been helpful to you. Your feedback and suggestions are always welcome — feel free to leave a comment or reach out with any queries.

Abhishek Shrivastava

📧 Email: oraeasyy@gmail.com
🌐 Website: www.oraeasy.com

Sunday, February 2, 2025

Standby Database set up || Oracle Data Guard (ODG)

  • Introduction: Oracle Data Guard (ODG) is a high-availability, disaster recovery, and data protection feature or solution provided by Oracle Database. It ensures the availability of critical data by maintaining one or more synchronized standby databases as replicas of a primary database. These standby databases can be used for disaster recovery, reporting, or backups, minimizing downtime and data loss in the event of unexpected failures. So here we will do Standby database set up in an easy and step by step manner.

  • Prerequisites:

  • o Primary server with Oracle database Software installed and running database.
    o Standby server with Oracle database Software installed.
    o Connectivity between Primary and Standby server.

  • Environment:
  • Server Primary Standby
    Hostname Source Target
    IP 192.168.80.51 192.168.80.111
    OS OEL 9 OEL 9
    SID ORCLDC ORCLDR
    Service Name ORCLDC ORCLDR

  • Now start configuring the ODG:

1. Connectivity Test

==> From Source to Target:

[oracle@source ~]$ ping -c 3 target.localdomain PING target.localdomain (192.168.80.111) 56(84) bytes of data. 64 bytes from target.localdomain (192.168.80.111): icmp_seq=1 ttl=64 time=0.678 ms 64 bytes from target.localdomain (192.168.80.111): icmp_seq=2 ttl=64 time=0.456 ms 64 bytes from target.localdomain (192.168.80.111): icmp_seq=3 ttl=64 time=0.924 ms --- target.localdomain ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2107ms rtt min/avg/max/mdev = 0.456/0.686/0.924/0.191 ms

==> From Target to Source:

[oracle@target ~]$ ping -c 3 source.localdomain PING source.localdomain (192.168.80.51) 56(84) bytes of data. 64 bytes from source.localdomain (192.168.80.51): icmp_seq=1 ttl=64 time=0.690 ms 64 bytes from source.localdomain (192.168.80.51): icmp_seq=2 ttl=64 time=6.61 ms 64 bytes from source.localdomain (192.168.80.51): icmp_seq=3 ttl=64 time=0.315 ms --- source.localdomain ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2002ms rtt min/avg/max/mdev = 0.315/2.536/6.605/2.880 ms
2. Primary Database setup
First fetch some details about Primary Database:

[oracle@source ~]$ sqlplus / as sysdba

SQL> def
DEFINE _DATE              = "22-JAN-25" (CHAR)
DEFINE _CONNECT_IDENTIFIER = "orcldc" (CHAR)
DEFINE _USER              = "SYS" (CHAR)
DEFINE _PRIVILEGE         = "AS SYSDBA" (CHAR)
DEFINE _SQLPLUS_RELEASE   = "1924000000" (CHAR)
DEFINE _EDITOR            = "vi" (CHAR)
DEFINE _O_VERSION         = "Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.24.0.0.0" (CHAR)
DEFINE _O_RELEASE         = "1924000000" (CHAR)

SQL> set lines 200 pages 1000
col open_mode for a15
col HOST_NAME for a15

NAME      DATABASE_ROLE    OPEN_MODE       LOG_MODE
--------  ---------------- --------------- ------------
ORCL      PRIMARY          READ WRITE      ARCHIVELOG

SQL> select banner, banner_full from v$version;

BANNER
--------------------------------------------------------------------------------
BANNER_FULL
--------------------------------------------------------------------------------
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.24.0.0.0

SQL> col name for a70
SQL> select file#, name from v$datafile;

FILE# NAME
----- ----------------------------------------------------------------------
1     /u01/app/oracle/oradata/ORCL/system01.dbf
3     /u01/app/oracle/oradata/ORCL/sysaux01.dbf
4     /u01/app/oracle/oradata/ORCL/undotbs01.dbf
5     /u01/app/oracle/oradata/ORCL/pdbseed/system01.dbf
6     /u01/app/oracle/oradata/ORCL/pdbseed/sysaux01.dbf
7     /u01/app/oracle/oradata/ORCL/users01.dbf
8     /u01/app/oracle/oradata/ORCL/pdbseed/undotbs01.dbf
9     /u01/app/oracle/oradata/ORCL/orclpdb/system01.dbf
10    /u01/app/oracle/oradata/ORCL/orclpdb/sysaux01.dbf
11    /u01/app/oracle/oradata/ORCL/orclpdb/undotbs01.dbf
12    /u01/app/oracle/oradata/ORCL/orclpdb/users01.dbf

11 rows selected.

SQL> select name from v$controlfile;

NAME
----------------------------------------------------------------------
/u01/app/oracle/oradata/ORCL/control01.ctl
/u01/app/oracle/fast_recovery_area/ORCL/control02.ctl

SQL> col MEMBER for a40
SQL> select group#, type, MEMBER from v$logfile order by group#;

GROUP# TYPE    MEMBER
------ ------- ----------------------------------------
1      ONLINE  /u01/app/oracle/oradata/ORCL/redo01.log
2      ONLINE  /u01/app/oracle/oradata/ORCL/redo02.log
3      ONLINE  /u01/app/oracle/oradata/ORCL/redo03.log

** If database is in NOARCHIVELOG mode then do below steps:

ALTER SYSTEM SET db_recovery_file_dest='/u01/app/oracle/fast_recovery_area' SCOPE=BOTH;
ALTER SYSTEM SET db_recovery_file_dest_size=50G SCOPE=BOTH;
SHUT IMMEDIATE;
STARTUP MOUNT;
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;

Now let's do changes in Primary Database for ODG:

SQL> SELECT name, force_logging, log_mode FROM v$database;
NAME    FORCE_LOGGING  LOG_MODE
------- -------------- ------------
ORCL    NO             ARCHIVELOG

SQL> ALTER DATABASE FORCE LOGGING;
Database altered.

SQL> SELECT name, force_logging, log_mode FROM v$database;
NAME    FORCE_LOGGING  LOG_MODE
------- -------------- ------------
ORCL    YES            ARCHIVELOG

SQL> SHOW PARAMETER db_name;
NAME        TYPE    VALUE
----------- ------- ------------------------------
db_name     string  orcl

SQL> SHOW PARAMETER db_unique_name;
NAME             TYPE    VALUE
---------------- ------- ------------------------------
db_unique_name   string  ORCLDC

SQL> ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(ORCLDC,ORCLDR)';
System altered.

SQL> SHOW PARAMETER LOG_ARCHIVE_CONFIG;
NAME                TYPE    VALUE
------------------- ------- ------------------------------
log_archive_config  string  DG_CONFIG=(ORCLDC,ORCLDR)

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=ORCLDR NOAFFIRM ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORCLDR';
System altered.

SQL> SHOW PARAMETER LOG_ARCHIVE_DEST_2;
NAME                  TYPE    VALUE
--------------------- ------- -------------------------------------------------------
log_archive_dest_2    string  SERVICE=ORCLDR NOAFFIRM ASYNC
                               VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
                               DB_UNIQUE_NAME=ORCLDR

log_archive_dest_20   string
log_archive_dest_21   string
log_archive_dest_22   string
log_archive_dest_23   string
log_archive_dest_24   string
log_archive_dest_25   string
log_archive_dest_26   string
log_archive_dest_27   string
log_archive_dest_28   string
log_archive_dest_29   string

SQL> SHOW PARAMETER LOG_ARCHIVE_FORMAT;
NAME                  TYPE    VALUE
--------------------- ------- ------------------------------
log_archive_format    string  %t_%s_%r.dbf

SQL> ALTER SYSTEM SET LOG_ARCHIVE_FORMAT='%t_%s_%r.arc' SCOPE=SPFILE;
System altered.

SQL> SHOW PARAMETER LOG_ARCHIVE_FORMAT;
NAME                  TYPE    VALUE
--------------------- ------- ------------------------------
log_archive_format    string  %t_%s_%r.dbf

SQL> ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=30 SCOPE=SPFILE;
System altered.

SQL> ALTER SYSTEM SET REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE SCOPE=SPFILE;
System altered.

SQL> ALTER SYSTEM SET FAL_SERVER=ORCLDR;
System altered.

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;
System altered.

SQL> ALTER SYSTEM SET archive_lag_target=900;
System altered.

Now we need to set DB_FILE_NAME_CONVERT & LOG_FILE_NAME_CONVERT parameter so that datafile and logfile locations will be converted automatically from Primary to Standby and vice-versa.

SQL> ALTER SYSTEM SET DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/ORCLDR','/u01/app/oracle/oradata/ORCL' SCOPE=SPFILE;
System altered.

SQL> ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/ORCLDR','/u01/app/oracle/oradata/ORCL' SCOPE=SPFILE;
System altered.

Now just take a bounce of Database so that all parameter will get reflects.

SQL> SHUT IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> STARTUP;
ORACLE instance started.
Total System Global Area     1459616616 bytes
Fixed Size                      9177960 bytes
Variable Size                 905969664 bytes
Database Buffers              536870912 bytes
Redo Buffers                    7598080 bytes
Database mounted.
Database opened.

SQL> SHOW PDBS;
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ORCLPDB                        READ WRITE NO

SQL> SHOW PARAMETER LOG_ARCHIVE_FORMAT;
NAME                  TYPE     VALUE
--------------------- -------- ------------------------------
log_archive_format    string   %t_%s_%r.arc

SQL> SHOW PARAMETER LOG_ARCHIVE_MAX_PROCESSES;
NAME                       TYPE     VALUE
-------------------------- -------- ------------------------------
log_archive_max_processes  integer  30

SQL> SHOW PARAMETER REMOTE_LOGIN_PASSWORDFILE;
NAME                        TYPE     VALUE
--------------------------- -------- ------------------------------
remote_login_passwordfile   string   EXCLUSIVE

Now add standby redo logfiles which will be used to apply the changes whenever primary becomes standby. Number of Standby logs should be one more than the number of Online logs.

SQL> ALTER DATABASE ADD STANDBY LOGFILE ('/u01/app/oracle/oradata/ORCL/standby_redo01.log') SIZE 200M;
Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE ('/u01/app/oracle/oradata/ORCL/standby_redo02.log') SIZE 200M;
Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE ('/u01/app/oracle/oradata/ORCL/standby_redo03.log') SIZE 200M;
Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE ('/u01/app/oracle/oradata/ORCL/standby_redo04.log') SIZE 200M;
Database altered.

SQL> SELECT group#, type, member FROM v$logfile ORDER BY group#;
GROUP#  TYPE     MEMBER
------  -------  -------------------------------------------------------------------------------
1       ONLINE   /u01/app/oracle/oradata/ORCL/redo01.log
2       ONLINE   /u01/app/oracle/oradata/ORCL/redo02.log
3       ONLINE   /u01/app/oracle/oradata/ORCL/redo03.log
4       STANDBY  /u01/app/oracle/oradata/ORCL/standby_redo01.log
5       STANDBY  /u01/app/oracle/oradata/ORCL/standby_redo02.log
6       STANDBY  /u01/app/oracle/oradata/ORCL/standby_redo03.log
7       STANDBY  /u01/app/oracle/oradata/ORCL/standby_redo04.log

7 rows selected.

3. Primary Service setup

[oracle@source ~]$ cd $ORACLE_HOME/network/admin
[oracle@source admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORCLDC =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = source.localdomain)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcldc)
    )
  )

ORCLDR =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = target.localdomain)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcldr)
    )
  )

4.Primary Database and files backup
Create pfile:

SQL> create pfile='/u01/app/oracle/rmandc/initorcldc.ora' from spfile;
  
Copy password file:

[oracle@source rmandc]$ cd $ORACLE_HOME/dbs
[oracle@source dbs]$ cp orapworcldc /u01/app/oracle/rmandc/
 
  
Take full database backup using RMAN:

RMAN> run
{
  allocate channel ch1 device type disk;
  allocate channel ch2 device type disk;
  backup as compressed backupset database format '/u01/app/oracle/rmandc/Fullback_%T_%U';
  backup as compressed backupset archivelog all format '/u01/app/oracle/rmandc/Archive_%T_%U';
  backup current controlfile for standby format '/u01/app/oracle/rmandc/StbyControlback_%T_%U';
  release channel ch1;
  release channel ch2;
}
using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: SID=299 device type=DISK
allocated channel: ch2
channel ch2: SID=55 device type=DISK
Starting backup at 22-JAN-25
channel ch1: starting compressed full datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/ORCL/system01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/ORCL/undotbs01.dbf
channel ch1: starting piece 1 at 22-JAN-25
channel ch2: starting compressed full datafile backup set
channel ch2: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/app/oracle/oradata/ORCL/sysaux01.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/ORCL/users01.dbf
channel ch2: starting piece 1 at 22-JAN-25
channel ch2: finished piece 1 at 22-JAN-25
piece handle=/u01/app/oracle/rmandc/Fullback_20250122_353fsduj_101_1_1 tag=TAG20250122T113235 comment=NONE
channel ch2: backup set complete, elapsed time: 00:01:36
channel ch2: starting compressed full datafile backup set
channel ch2: specifying datafile(s) in backup set
input datafile file number=00009 name=/u01/app/oracle/oradata/ORCL/orclpdb/system01.dbf
input datafile file number=00011 name=/u01/app/oracle/oradata/ORCL/orclpdb/undotbs01.dbf
channel ch2: starting piece 1 at 22-JAN-25
channel ch1: finished piece 1 at 22-JAN-25
piece handle=/u01/app/oracle/rmandc/Fullback_20250122_343fsduj_100_1_1 tag=TAG20250122T113235 comment=NONE
channel ch1: backup set complete, elapsed time: 00:02:54
channel ch1: starting compressed full datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00006 name=/u01/app/oracle/oradata/ORCL/pdbseed/sysaux01.dbf
input datafile file number=00008 name=/u01/app/oracle/oradata/ORCL/pdbseed/undotbs01.dbf
channel ch1: starting piece 1 at 22-JAN-25
channel ch2: finished piece 1 at 22-JAN-25
piece handle=/u01/app/oracle/rmandc/Fullback_20250122_363fse1l_102_1_1 tag=TAG20250122T113235 comment=NONE
channel ch2: backup set complete, elapsed time: 00:01:17
channel ch2: starting compressed full datafile backup set
channel ch2: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/app/oracle/oradata/ORCL/pdbseed/system01.dbf
channel ch2: starting piece 1 at 22-JAN-25
channel ch1: finished piece 1 at 22-JAN-25
piece handle=/u01/app/oracle/rmandc/Fullback_20250122_373fse42_103_1_1 tag=TAG20250122T113235 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:45
channel ch1: starting compressed full datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00010 name=/u01/app/oracle/oradata/ORCL/orclpdb/sysaux01.dbf
input datafile file number=00012 name=/u01/app/oracle/oradata/ORCL/orclpdb/users01.dbf
channel ch1: starting piece 1 at 22-JAN-25
channel ch2: finished piece 1 at 22-JAN-25
piece handle=/u01/app/oracle/rmandc/Fullback_20250122_383fse42_104_1_1 tag=TAG20250122T113235 comment=NONE
channel ch2: backup set complete, elapsed time: 00:01:01
channel ch1: finished piece 1 at 22-JAN-25
piece handle=/u01/app/oracle/rmandc/Fullback_20250122_393fse5g_105_1_1 tag=TAG20250122T113235 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:25
Finished backup at 22-JAN-25
Starting backup at 22-JAN-25
current log archived
channel ch1: starting compressed archived log backup set
channel ch1: specifying archived log(s) in backup set
input archived log thread=1 sequence=14 RECID=1 STAMP=1191028331
input archived log thread=1 sequence=15 RECID=2 STAMP=1191064037
channel ch1: starting piece 1 at 22-JAN-25
channel ch2: starting compressed archived log backup set
channel ch2: specifying archived log(s) in backup set
input archived log thread=1 sequence=16 RECID=3 STAMP=1191064563
input archived log thread=1 sequence=17 RECID=4 STAMP=1191065457
input archived log thread=1 sequence=18 RECID=5 STAMP=1191065813
channel ch2: starting piece 1 at 22-JAN-25
channel ch2: finished piece 1 at 22-JAN-25
piece handle=/u01/app/oracle/rmandc/Archive_20250122_3b3fse6m_107_1_1 tag=TAG20250122T113653 comment=NONE
channel ch2: backup set complete, elapsed time: 00:00:15
channel ch1: finished piece 1 at 22-JAN-25
piece handle=/u01/app/oracle/rmandc/Archive_20250122_3a3fse6m_106_1_1 tag=TAG20250122T113653 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:25
Finished backup at 22-JAN-25
Starting backup at 22-JAN-25
channel ch1: starting full datafile backup set
channel ch1: specifying datafile(s) in backup set
including standby control file in backup set
channel ch1: starting piece 1 at 22-JAN-25
channel ch1: finished piece 1 at 22-JAN-25
piece handle=/u01/app/oracle/rmandc/StbyControlback_20250122_3c3fse7h_108_1_1 tag=TAG20250122T113721 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:03
Finished backup at 22-JAN-25
Starting Control File and SPFILE Autobackup at 22-JAN-25
piece handle=/u01/app/oracle/fast_recovery_area/ORCLDC/autobackup/2025_01_22/o1_mf_s_1191065849_ms12s1os_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 22-JAN-25
released channel: ch1
released channel: ch2
RMAN> exit
5.Transfer backup and other files from Primary to Standby

[oracle@source dbs]$ cd /u01/app/oracle/rmandc/
[oracle@source rmandc]$ ls -lrth
total 1.3G
-rw-r--r--. 1 oracle oinstall 1.6K Jan 22 11:28 initorcldc.ora
-rw-r-----. 1 oracle oinstall  94M Jan 22 11:33 Fullback_20250122_353fsduj_101_1_1
-rw-r-----. 1 oracle oinstall 409M Jan 22 11:35 Fullback_20250122_343fsduj_100_1_1
-rw-r-----. 1 oracle oinstall 237M Jan 22 11:35 Fullback_20250122_363fse1l_102_1_1
-rw-r-----. 1 oracle oinstall 134M Jan 22 11:36 Fullback_20250122_373fse42_103_1_1
-rw-r-----. 1 oracle oinstall 227M Jan 22 11:36 Fullback_20250122_383fse42_104_1_1
-rw-r-----. 1 oracle oinstall  64M Jan 22 11:36 Fullback_20250122_393fse5g_105_1_1
-rw-r-----. 1 oracle oinstall  49M Jan 22 11:37 Archive_20250122_3b3fse6m_107_1_1
-rw-r-----. 1 oracle oinstall  69M Jan 22 11:37 Archive_20250122_3a3fse6m_106_1_1
-rw-r-----. 1 oracle oinstall  18M Jan 22 11:37 StbyControlback_20250122_3c3fse7h_108_1_1
-rw-r-----. 1 oracle oinstall 2.0K Jan 22 11:39 orapworcldc
[oracle@source rmandc]$ scp * oracle@target:/u01/app/oracle/rmandr
The authenticity of host 'target (192.168.80.111)' can't be established.
ED25519 key fingerprint is SHA256:u1O6svnS8kY1i6Mv88TDIlYsvqDyISi2Uz3ZBc8kKfY.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'target' (ED25519) to the list of known hosts.
oracle@target's password:
Archive_20250122_3a3fse6m_106_1_1             100%   68MB    58.5MB/s   00:01
Archive_20250122_3b3fse6m_107_1_1             100%   49MB    52.0MB/s   00:00
Fullback_20250122_343fsduj_100_1_1            100%  409MB    24.7MB/s   00:16
Fullback_20250122_353fsduj_101_1_1            100%   93MB    20.9MB/s   00:04
Fullback_20250122_363fse1l_102_1_1            100%  237MB    25.4MB/s   00:09
Fullback_20250122_373fse42_103_1_1            100%  134MB    21.0MB/s   00:06
Fullback_20250122_383fse42_104_1_1            100%  226MB    25.7MB/s   00:08
Fullback_20250122_393fse5g_105_1_1            100%   63MB    33.5MB/s   00:01
initorcldc.ora                                100%   1632    52.9KB/s   00:00
orapworcldc                                   100%   2048   105.3KB/s   00:00
StbyControlback_20250122_3c3fse7h_108_1_1     100%   18MB    57.8MB/s   00:00
   
6.Standby Database setup
Do the changes in Primary pfile and create pfile initorcldr.ora for Standby. Below parameters have been modified. Sample file is shown further below:

*.audit_file_dest='/u01/app/oracle/admin/orcldr/adump'
*.control_files='/u01/app/oracle/oradata/ORCLDR/control01.ctl','/u01/app/oracle/fast_recovery_area/ORCLDR/control02.ctl'
*.db_file_name_convert='/u01/app/oracle/oradata/ORCL','/u01/app/oracle/oradata/ORCLDR'
*.db_unique_name='ORCLDR'
*.log_file_name_convert='/u01/app/oracle/oradata/ORCL','/u01/app/oracle/oradata/ORCLDR'
*.fal_server='ORCLDC'
*.log_archive_dest_2='SERVICE=ORCLDC NOAFFIRM ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORCLDC'



orcldr.__data_transfer_cache_size=0
orcldr.__db_cache_size=486539264
orcldr.__inmemory_ext_roarea=0
orcldr.__inmemory_ext_rwarea=0
orcldr.__java_pool_size=16777216
orcldr.__large_pool_size=16777216
orcldr.__oracle_base='/u01/app/oracle'  # ORACLE_BASE set from environment
orcldr.__pga_aggregate_target=587202560
orcldr.__sga_target=872415232
orcldr.__shared_io_pool_size=50331648
orcldr.__shared_pool_size=285212672
orcldr.__streams_pool_size=0
orcldr.__unified_pga_pool_size=0
*.archive_lag_target=900
*.audit_file_dest='/u01/app/oracle/admin/orcldr/adump'
*.audit_trail='db'
*.compatible='19.0.0'
*.control_files='/u01/app/oracle/oradata/ORCLDR/control01.ctl','/u01/app/oracle/fast_recovery_area/ORCLDR/control02.ctl'
*.db_block_size=8192
*.db_file_name_convert='/u01/app/oracle/oradata/ORCL','/u01/app/oracle/oradata/ORCLDR'
*.db_name='orcl'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=8192m
*.db_unique_name='ORCLDR'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orcldcXDB)'
*.enable_pluggable_database=true
*.fal_server='ORCLDC'
*.log_archive_config='DG_CONFIG=(ORCLDC,ORCLDR)'
*.log_archive_dest_2='SERVICE=ORCLDC NOAFFIRM ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORCLDC'
*.log_archive_format='%t_%s_%r.arc'
*.log_archive_max_processes=30
*.log_file_name_convert='/u01/app/oracle/oradata/ORCL','/u01/app/oracle/oradata/ORCLDR'
*.memory_target=1384m
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'

Create required directories:

[oracle@target rmandr]$ mkdir -p /u01/app/oracle/admin/orcldr/adump
[oracle@target rmandr]$ mkdir -p /u01/app/oracle/oradata/ORCLDR/
[oracle@target rmandr]$ mkdir -p /u01/app/oracle/fast_recovery_area/ORCLDR/

Copy password file in $ORACLE_HOME/dbs :

[oracle@target rmandr]$ cp orapworcldc $ORACLE_HOME/dbs/orapworcldr
[oracle@target rmandr]$ ls -lrth $ORACLE_HOME/dbs/orapworcldr
-rw-r-----. 1 oracle oinstall 2.0K Jan 22 12:02 /u01/app/oracle/product/19.0.0/dbhome_1/dbs/orapworcldr

Create listener using NETCA. Start it. Also add TNS service entries for Primary & Standby in tnsnames.ora file.

Refer Create listener using NETCA


[oracle@target ~]$ lsnrctl start
Copyright (c) 1991, 2024, Oracle.  All rights reserved.
Starting /u01/app/oracle/product/19.0.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/target/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=target.localdomain)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=target.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                22-JAN-2025 12:09:54
Uptime                    0 days 0 hr. 0 min. 2 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/target/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=target.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
[oracle@target ~]$
[oracle@target admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORCLDC =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = source.localdomain)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcldc)
    )
  )

ORCLDR =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = target.localdomain)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcldr)
    )
  )

7.Startup Standby instance and restore the backup
Startup in nomount:

[oracle@target ~]$ . oraenv
ORACLE_SID = [orcl] ? orcldr
ORACLE_HOME = [/home/oracle] ? /u01/app/oracle/product/19.0.0/dbhome_1
The Oracle base remains unchanged with value /u01/app/oracle

[oracle@target ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jan 22 12:13:03 2025
Version 19.24.0.0.0

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

Connected to an idle instance.
SQL> startup nomount pfile='/u01/app/oracle/rmandr/initorcldr.ora';
ORACLE instance started.

Total System Global Area 1459616616 bytes
Fixed Size                  9177960 bytes
Variable Size             905969664 bytes
Database Buffers          536870912 bytes
Redo Buffers                7598080 bytes
SQL>

SQL> def
DEFINE _DATE           = "22-JAN-25" (CHAR)
DEFINE _CONNECT_IDENTIFIER = "orcldr" (CHAR)
DEFINE _USER           = "SYS" (CHAR)
DEFINE _PRIVILEGE      = "AS SYSDBA" (CHAR)
DEFINE _SQLPLUS_RELEASE = "1924000000" (CHAR)
DEFINE _EDITOR         = "vi" (CHAR)
DEFINE _O_VERSION      = "Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.24.0.0.0" (CHAR)
DEFINE _O_RELEASE      = "1924000000" (CHAR)
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.24.0.0.0
[oracle@target ~]$

Restore the controlfile from backup. Then mount the standby database instance:

[oracle@target ~]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Wed Jan 22 12:14:09 2025
Version 19.24.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (not mounted)

RMAN> restore controlfile from '/u01/app/oracle/rmandr/StbyControlback_20250122_3c3fse7h_108_1_1';
Starting restore at 22-JAN-25
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=21 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/ORCLDR/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/ORCLDR/control02.ctl
Finished restore at 22-JAN-25

RMAN> alter database mount;
released channel: ORA_DISK_1
Statement processed

RMAN>

Login into database and verify:

[oracle@target ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jan 22 12:15:19 2025
Version 19.24.0.0.0
Copyright (c) 1982, 2024, Oracle.  All rights reserved.

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.24.0.0.0

SQL> select NAME,DATABASE_ROLE,OPEN_MODE,LOG_MODE from v$database;

NAME      DATABASE_ROLE    OPEN_MODE            LOG_MODE
--------- ---------------- -------------------- ------------
ORCL      PHYSICAL STANDBY MOUNTED              ARCHIVELOG

SQL> show parameter db_unique_name

NAME            TYPE        VALUE
--------------- ----------- ------------
db_unique_name  string      ORCLDR

Now catalog the backup files and start the database restoration:

[oracle@target rmandr]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Wed Jan 22 12:18:34 2025
Version 19.24.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1718803653, not open)

RMAN> 
RMAN> catalog start with '/u01/app/oracle/rmandr';
using target database control file instead of recovery catalog
searching for all files that match the pattern /u01/app/oracle/rmandr

List of Files Unknown to the Database
=====================================
File Name: /u01/app/oracle/rmandr/Archive_20250122_3a3fse6m_106_1_1
File Name: /u01/app/oracle/rmandr/Archive_20250122_3b3fse6m_107_1_1
File Name: /u01/app/oracle/rmandr/Fullback_20250122_343fsduj_100_1_1
File Name: /u01/app/oracle/rmandr/Fullback_20250122_353fsduj_101_1_1
File Name: /u01/app/oracle/rmandr/Fullback_20250122_363fse1l_102_1_1
File Name: /u01/app/oracle/rmandr/Fullback_20250122_373fse42_103_1_1
File Name: /u01/app/oracle/rmandr/Fullback_20250122_383fse42_104_1_1
File Name: /u01/app/oracle/rmandr/Fullback_20250122_393fse5g_105_1_1
File Name: /u01/app/oracle/rmandr/StbyControlback_20250122_3c3fse7h_108_1_1
File Name: /u01/app/oracle/rmandr/initorcldr.ora

Do you really want to catalog the above files (enter YES or NO)? YES
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/app/oracle/rmandr/Archive_20250122_3a3fse6m_106_1_1
File Name: /u01/app/oracle/rmandr/Archive_20250122_3b3fse6m_107_1_1
File Name: /u01/app/oracle/rmandr/Fullback_20250122_343fsduj_100_1_1
File Name: /u01/app/oracle/rmandr/Fullback_20250122_353fsduj_101_1_1
File Name: /u01/app/oracle/rmandr/Fullback_20250122_363fse1l_102_1_1
File Name: /u01/app/oracle/rmandr/Fullback_20250122_373fse42_103_1_1
File Name: /u01/app/oracle/rmandr/Fullback_20250122_383fse42_104_1_1
File Name: /u01/app/oracle/rmandr/Fullback_20250122_393fse5g_105_1_1
File Name: /u01/app/oracle/rmandr/StbyControlback_20250122_3c3fse7h_108_1_1

List of Files Which Were Not Cataloged
=======================================
File Name: /u01/app/oracle/rmandr/initorcldr.ora
RMAN-07517: Reason: The file header is corrupted

RMAN> run
{
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
restore database;
switch datafile all;
switch tempfile all;
recover database;
release channel ch1;
release channel ch2;
}

allocated channel: ch1
channel ch1: SID=41 device type=DISK
allocated channel: ch2
channel ch2: SID=276 device type=DISK

Starting restore at 22-JAN-25
channel ch1: starting datafile backup set restore
channel ch1: specifying datafile(s) to restore from backup set
channel ch1: restoring datafile 00001 to /u01/app/oracle/oradata/ORCLDR/system01.dbf
channel ch1: restoring datafile 00004 to /u01/app/oracle/oradata/ORCLDR/undotbs01.dbf
channel ch1: reading from backup piece /u01/app/oracle/rmandr/Fullback_20250122_343fsduj_100_1_1

channel ch2: starting datafile backup set restore
channel ch2: specifying datafile(s) to restore from backup set
channel ch2: restoring datafile 00003 to /u01/app/oracle/oradata/ORCLDR/sysaux01.dbf
channel ch2: restoring datafile 00007 to /u01/app/oracle/oradata/ORCLDR/users01.dbf
channel ch2: reading from backup piece /u01/app/oracle/rmandr/Fullback_20250122_353fsduj_101_1_1

Finished restore at 22-JAN-25

Starting recover at 22-JAN-25
starting media recovery
archived log for thread 1 with sequence 19 is already on disk as file /u01/app/oracle/fast_recovery_area/ORCLDR/archivelog/2025_01_22/o1_mf_1_19_ms14zky5_.arc
archived log for thread 1 with sequence 20 is already on disk as file /u01/app/oracle/fast_recovery_area/ORCLDR/archivelog/2025_01_22/o1_mf_1_20_ms14zl0q_.arc
archived log for thread 1 with sequence 21 is already on disk as file /u01/app/oracle/fast_recovery_area/ORCLDR/archivelog/2025_01_22/o1_mf_1_21_ms15d21o_.arc

channel ch1: starting archived log restore to default destination
channel ch1: restoring archived log
archived log thread=1 sequence=18
channel ch1: reading from backup piece /u01/app/oracle/rmandr/Archive_20250122_3b3fse6m_107_1_1
channel ch1: piece handle=/u01/app/oracle/rmandr/Archive_20250122_3b3fse6m_107_1_1 tag=TAG20250122T113653
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:15

archived log file name=/u01/app/oracle/fast_recovery_area/ORCLDR/archivelog/2025_01_22/o1_mf_1_18_ms160js6_.arc thread=1 sequence=18
media recovery complete, elapsed time: 00:00:05
Finished recover at 22-JAN-25

released channel: ch1
released channel: ch2

RMAN> 
RMAN> exit

8. Now start real time apply
Start log shipment on Primary:

SQL> alter system set log_archive_dest_state_2= ENABLE scope=both;

SQL> show parameter log_archive_dest_state_2;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_2             string      ENABLE
log_archive_dest_state_20            string      enable
log_archive_dest_state_21            string      enable
log_archive_dest_state_22            string      enable
log_archive_dest_state_23            string      enable
log_archive_dest_state_24            string      enable
log_archive_dest_state_25            string      enable
log_archive_dest_state_26            string      enable
log_archive_dest_state_27            string      enable
log_archive_dest_state_28            string      enable
log_archive_dest_state_29            string      enable

SQL> set lines 200 pages 1000
col DEST_NAME for a20
col DESTINATION for a20
col error for a30

SQL> select DEST_ID, DEST_NAME, STATUS, ERROR from v$archive_dest where DEST_NAME='LOG_ARCHIVE_DEST_2';

DEST_ID DEST_NAME            STATUS    ERROR
------- -------------------- --------- ------------------------------
      2 LOG_ARCHIVE_DEST_2   VALID     

SQL> select DEST_ID, DEST_NAME, DESTINATION, STATUS, ERROR 
     from v$archive_dest_status where status not in ('INVALID','INACTIVE');

DEST_ID DEST_NAME            DESTINATION          STATUS    ERROR
------- -------------------- -------------------- --------- ------------------------------
      1 LOG_ARCHIVE_DEST_1   /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch VALID     
      2 LOG_ARCHIVE_DEST_2   ORCLDR               VALID     

Start Apply At Standby:

SQL> alter database recover managed standby database disconnect from session;
SQL> select process,status,thread#,sequence#,block# from v$managed_standby where process like '%MRP%';

PROCESS   STATUS          THREAD#  SEQUENCE#     BLOCK#
--------- ------------ ---------- ---------- ----------
MRP0      APPLYING_LOG          1         26        903

Now do some log switches on Primary and check the sync.

==> On Primary:

SQL> alter system switch logfile; System altered. SQL> / System altered. SQL> / System altered. SQL> set lines 200 pages 300 alter session set nls_date_format= 'DD-MON-YYYY HH24:MI:SS'; select d.db_unique_name, a.thread#, b.last_seq, a.applied_seq, a.last_app_timestamp, b.last_seq - a.applied_seq ARC_DIFF FROM (select thread#, MAX(sequence#) applied_seq, MAX(next_time) last_app_timestamp from gv$archived_log where applied='YES' group by thread#) a, (select thread#, MAX(sequence#) last_seq from gv$archived_log group by thread#) b, (select db_unique_name from v$database) d where a.thread#=b.thread#; Session altered. DB_UNIQUE_NAME THREAD# LAST_SEQ APPLIED_SEQ LAST_APP_TIMESTAMP ARC_DIFF ------------------------------ ---------- ---------- ----------- -------------------- ---------- ORCLDC 1 29 27 22-JAN-2025 12:57:12 2

==> On Standby:

SQL> select d.db_unique_name, a.thread#, b.last_seq, a.applied_seq, b.last_seq - a.applied_seq ARC_DIFF, a.last_app_timestamp, round((sysdate - a.last_app_timestamp)*24*60,2) Gap_in_Mins, round((sysdate - a.last_app_timestamp)*24*60*60,2) Gap_in_Seconds FROM (select thread#, MAX(sequence#) applied_seq, MAX(next_time) last_app_timestamp from v$archived_log where REGISTRAR='RFS' and applied='YES' group by thread#) a, (select thread#, MAX(sequence#) last_seq from gv$archived_log group by thread#) b, (select db_unique_name from v$database) d where a.thread#=b.thread#; DB_UNIQUE_NAME THREAD# LAST_SEQ APPLIED_SEQ ARC_DIFF LAST_APP_TIMESTAMP GAP_IN_MINS GAP_IN_SECONDS ------------------------------ ---------- ---------- ----------- ---------- -------------------- ----------- -------------- ORCLDR 1 29 29 0 22-JAN-2025 12:57:18 3.78 227
9.Create tablespace on Primary and check on Standby

==> On Primary:

SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 ORCLPDB READ WRITE NO SQL> alter session set container=ORCLPDB; Session altered. SQL> create tablespace test datafile '/u01/app/oracle/oradata/ORCL/orclpdb/test01.dbf' size 1g; Tablespace created.

==> On Standby:

SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED MOUNTED 3 ORCLPDB MOUNTED SQL> alter session set container=ORCLPDB; Session altered. SQL> select name from v$datafile; NAME ---------------------------------------------------------------------- /u01/app/oracle/oradata/ORCLDR/orclpdb/system01.dbf /u01/app/oracle/oradata/ORCLDR/orclpdb/sysaux01.dbf /u01/app/oracle/oradata/ORCLDR/orclpdb/undotbs01.dbf /u01/app/oracle/oradata/ORCLDR/orclpdb/users01.dbf /u01/app/oracle/oradata/ORCLDR/orclpdb/test01.dbf SQL> select name from v$tablespace; NAME ---------------------------------------------------------------------- SYSTEM SYSAUX UNDOTBS1 TEMP USERS TEST 6 rows selected.


Thank you for reading!

I hope this content has been helpful to you. Your feedback and suggestions are always welcome — feel free to leave a comment or reach out with any queries.

Abhishek Shrivastava

📧 Email: oraeasyy@gmail.com
🌐 Website: www.oraeasy.com