Prerequisites
Perform the following steps to configure your Generic Oracle Source:
Create a Database User and Grant Privileges
Connect to your Oracle server as a Database Administrator (DBA) using any SQL client tool and create a database user with the privileges required by Hevo to:
This user is used by Hevo to capture data changes from the Oracle database. The steps for creating the database user depend on the deployment type you are using.
Create a database user for a Single Instance Database
Run the following script to create a database user and grant the privileges required by Hevo:
-- Create a Database User
CREATE USER <username> IDENTIFIED BY <password>;
-- Grant Privileges to the Database User
GRANT CREATE SESSION TO <username>;
GRANT SELECT ON V_$DATABASE TO <username>;
GRANT FLASHBACK ANY TABLE TO <username>;
GRANT SELECT ANY TABLE TO <username>;
GRANT SELECT ANY TRANSACTION TO <username>;
-- Grant Roles to the Database User
GRANT SELECT_CATALOG_ROLE TO <username>;
GRANT EXECUTE_CATALOG_ROLE TO <username>;
-- Grant Permission to run LogMiner
GRANT LOGMINING TO <username>;
GRANT EXECUTE ON DBMS_LOGMNR TO <username>;
GRANT EXECUTE ON DBMS_LOGMNR_D TO <username>;
GRANT SELECT ON V_$LOG TO <username>;
GRANT SELECT ON V_$LOG_HISTORY TO <username>;
GRANT SELECT ON V_$LOGMNR_LOGS TO <username>;
GRANT SELECT ON V_$LOGMNR_CONTENTS TO <username>;
GRANT SELECT ON V_$LOGMNR_PARAMETERS TO <username>;
GRANT SELECT ON V_$LOGFILE TO <username>;
GRANT SELECT ON V_$ARCHIVED_LOG TO <username>;
GRANT SELECT ON V_$ARCHIVE_DEST_STATUS TO <username>;
GRANT SELECT ON V_$TRANSACTION TO <username>;
GRANT SELECT ON V_$MYSTAT TO <username>;
GRANT SELECT ON V_$STATNAME TO <username>;
Note: Replace the placeholder values in the commands above with your own. For example, <username> with hevo.
Refer to the table below for more information about these commands:
| Command |
Grants access to |
| GRANT CREATE SESSION TO <username>; |
Connect to the database and create sessions. |
| GRANT SELECT ON V_$DATABASE TO <username>; |
Query information about the database, such as the current System Change Number (SCN) and log mode, from the V_$DATABASE view. |
| GRANT FLASHBACK ANY TABLE TO <username>; |
Restore past versions of any table in the database. |
| GRANT SELECT ANY TABLE TO <username>; |
Retrieve data from any table in the database. |
| GRANT SELECT ANY TRANSACTION TO <username>; |
Query data from any transaction in the database. |
| GRANT SELECT_CATALOG_ROLE TO <username>; |
Query various data dictionary and performance views, containing metadata about database objects. |
| GRANT EXECUTE_CATALOG_ROLE TO <username>; |
Run procedures and functions within the data dictionary. |
| GRANT LOGMINING TO <username>; |
Use LogMiner to analyze and extract information from the redo log files. |
| GRANT EXECUTE ON DBMS_LOGMNR TO <username>; |
Run procedures and functions from the DBMS_LOGMNR package.
Note: This package is required for starting and stopping LogMiner, adding redo log files for analysis, querying change data, and managing LogMiner sessions effectively. |
| GRANT EXECUTE ON DBMS_LOGMNR_D TO <username>; |
Run procedures and functions defined in the DBMS_LOGMNR_D package.
Note: This package is required for managing LogMiner dictionary data, which LogMiner uses to translate redo logs during log switches. |
| GRANT SELECT ON V_$LOG TO <username>; |
Query information about redo logs, such as their status and group details, from the V_$LOG view. |
| GRANT SELECT ON V_$LOG_HISTORY TO <username>; |
Query information about archived redo logs and their sequences from the V_$LOG_HISTORY view. |
| GRANT SELECT ON V_$LOGMNR_LOGS TO <username>; |
Query information about the redo logs added to a LogMiner session from the V_$LOGMNR_LOGS view. |
| GRANT SELECT ON V_$LOGMNR_CONTENTS TO <username>; |
Query transaction details retrieved during a LogMiner session from the V_$LOGMNR_CONTENTS view. |
| GRANT SELECT ON V_$LOGMNR_PARAMETERS TO <username>; |
Query configuration details for the LogMiner session from the V_$LOGMNR_PARAMETERS view. |
| GRANT SELECT ON V_$LOGFILE TO <username>; |
Query information about redo logs, such as their type and status, from the V_$LOGFILE view. |
| GRANT SELECT ON V_$ARCHIVED_LOG TO <username>; |
Query metadata about archived redo logs, such as file names and timestamps, from the V_$ARCHIVED_LOG view. |
| GRANT SELECT ON V_$ARCHIVE_DEST_STATUS TO <username>; |
Query configuration details for archived redo log destinations from the V_$ARCHIVE_DEST_STATUS view. |
| GRANT SELECT ON V_$TRANSACTION TO <username>; |
Query information about active transactions in the database from the V_$TRANSACTION view. |
| GRANT SELECT ON V_$MYSTAT TO <username>; |
Query performance statistics specific to the current session from the V_$MYSTAT view. |
| GRANT SELECT ON V_$STATNAME TO <username>; |
Query details about performance monitoring statistics from the V_$STATNAME view. |
Create a database user for RAC or CDB/PDB
If your Oracle database is deployed using RAC or the multitenant architecture (CDB/PDB), you must create a common database user in the CDB root container (CDB$ROOT) and grant the required privileges across all containers.
In Oracle multitenant databases:
-
The Container Database (CDB) is the primary database container.
-
The CDB root container (CDB$ROOT) stores common users and shared metadata.
-
One or more Pluggable Databases (PDBs) reside within the CDB.
-
A user created in CDB$ROOT can be granted privileges that allow access to multiple containers.
Note: A user created in the CDB root container must be a common user with the prefix C##. A common user can access multiple containers depending on the granted privileges. If the user is created without this prefix, it becomes a local user that exists only within a single PDB. In such cases, the required privileges may not be applied correctly across containers, which can cause the setup to fail.
Perform the following steps to create a common database user and grant the required privileges:
-
Run the following command to verify that you are connected to the CDB root container:
If the result is CDB$ROOT, proceed to step 2. Else, run the following command to switch to the root container:
ALTER SESSION SET CONTAINER = CDB$ROOT;
-
Run the following script to create a common database user and grant the privileges required by Hevo:
-- Create a common Database User
CREATE USER C##<username> IDENTIFIED BY <password>;
-- Grant Privileges to the Database User across Containers
GRANT CREATE SESSION TO C##<username> CONTAINER=ALL;
GRANT SELECT ON V_$DATABASE TO C##<username> CONTAINER=ALL;
GRANT FLASHBACK ANY TABLE TO C##<username> CONTAINER=ALL;
GRANT SELECT ANY TABLE TO C##<username> CONTAINER=ALL;
GRANT SELECT ANY TRANSACTION TO C##<username> CONTAINER=ALL;
-- Grant Roles to the Database User
GRANT SELECT_CATALOG_ROLE TO C##<username> CONTAINER=ALL;
GRANT EXECUTE_CATALOG_ROLE TO C##<username> CONTAINER=ALL;
-- Grant Permission to run LogMiner
GRANT LOGMINING TO C##<username> CONTAINER=ALL;
GRANT EXECUTE ON DBMS_LOGMNR TO C##<username> CONTAINER=ALL;
GRANT EXECUTE ON DBMS_LOGMNR_D TO C##<username> CONTAINER=ALL;
GRANT SELECT ON V_$LOG TO C##<username> CONTAINER=ALL;
GRANT SELECT ON V_$LOG_HISTORY TO C##<username> CONTAINER=ALL;
GRANT SELECT ON V_$LOGMNR_LOGS TO C##<username> CONTAINER=ALL;
GRANT SELECT ON V_$LOGMNR_CONTENTS TO C##<username> CONTAINER=ALL;
GRANT SELECT ON V_$LOGMNR_PARAMETERS TO C##<username> CONTAINER=ALL;
GRANT SELECT ON V_$LOGFILE TO C##<username> CONTAINER=ALL;
GRANT SELECT ON V_$ARCHIVED_LOG TO C##<username> CONTAINER=ALL;
GRANT SELECT ON V_$ARCHIVE_DEST_STATUS TO C##<username> CONTAINER=ALL;
GRANT SELECT ON V_$TRANSACTION TO C##<username> CONTAINER=ALL;
GRANT SELECT ON V_$MYSTAT TO C##<username> CONTAINER=ALL;
GRANT SELECT ON V_$STATNAME TO C##<username> CONTAINER=ALL;
-- Grant Permission to switch containers
GRANT SET CONTAINER TO C##<username> CONTAINER=ALL;
Note: Replace the placeholder values in the commands above with your own. For example, <username> with hevo.
Refer to the table below for more information about these commands:
| Command |
Grants access to |
| GRANT CREATE SESSION TO C##<username> CONTAINER=ALL; |
Connect to the database and create sessions across all containers. |
| GRANT SELECT ON V_$DATABASE TO C##<username> CONTAINER=ALL; |
Query information about the database, such as the current System Change Number (SCN) and log mode, from the V_$DATABASE view. |
| GRANT FLASHBACK ANY TABLE TO C##<username> CONTAINER=ALL; |
Restore past versions of any table in the database. |
| GRANT SELECT ANY TABLE TO C##<username> CONTAINER=ALL; |
Retrieve data from any table in the database. |
| GRANT SELECT ANY TRANSACTION TO C##<username> CONTAINER=ALL; |
Query data from any transaction in the database. |
| GRANT SELECT_CATALOG_ROLE TO C##<username> CONTAINER=ALL; |
Query various data dictionary and performance views, containing metadata about database objects. |
| GRANT EXECUTE_CATALOG_ROLE TO C##<username> CONTAINER=ALL; |
Run procedures and functions within the data dictionary. |
| GRANT LOGMINING TO C##<username> CONTAINER=ALL; |
Use LogMiner to analyze and extract information from the redo log files. |
| GRANT EXECUTE ON DBMS_LOGMNR TO C##<username> CONTAINER=ALL; |
Run procedures and functions from the DBMS_LOGMNR package.
Note: This package is required for starting and stopping LogMiner, adding redo log files for analysis, querying change data, and managing LogMiner sessions effectively. |
| GRANT EXECUTE ON DBMS_LOGMNR_D TO C##<username> CONTAINER=ALL; |
Run procedures and functions defined in the DBMS_LOGMNR_D package.
Note: This package is required for managing LogMiner dictionary data, which LogMiner uses to translate redo logs during log switches. |
| GRANT SELECT ON V_$LOG TO C##<username> CONTAINER=ALL; |
Query information about redo logs, such as their status and group details, from the V_$LOG view. |
| GRANT SELECT ON V_$LOG_HISTORY TO C##<username> CONTAINER=ALL; |
Query information about archived redo logs and their sequences from the V_$LOG_HISTORY view. |
| GRANT SELECT ON V_$LOGMNR_LOGS TO C##<username> CONTAINER=ALL; |
Query information about the redo logs added to a LogMiner session from the V_$LOGMNR_LOGS view. |
| GRANT SELECT ON V_$LOGMNR_CONTENTS TO C##<username> CONTAINER=ALL; |
Query transaction details retrieved during a LogMiner session from the V_$LOGMNR_CONTENTS view. |
| GRANT SELECT ON V_$LOGMNR_PARAMETERS TO C##<username> CONTAINER=ALL; |
Query configuration details for the LogMiner session from the V_$LOGMNR_PARAMETERS view. |
| GRANT SELECT ON V_$LOGFILE TO C##<username> CONTAINER=ALL; |
Query information about redo logs, such as their type and status, from the V_$LOGFILE view. |
| GRANT SELECT ON V_$ARCHIVED_LOG TO C##<username> CONTAINER=ALL; |
Query metadata about archived redo logs, such as file names and timestamps, from the V_$ARCHIVED_LOG view. |
| GRANT SELECT ON V_$ARCHIVE_DEST_STATUS TO C##<username> CONTAINER=ALL; |
Query configuration details for archived redo log destinations from the V_$ARCHIVE_DEST_STATUS view. |
| GRANT SELECT ON V_$TRANSACTION TO C##<username> CONTAINER=ALL; |
Query information about active transactions in the database from the V_$TRANSACTION view. |
| GRANT SELECT ON V_$MYSTAT TO C##<username> CONTAINER=ALL; |
Query performance statistics specific to the current session from the V_$MYSTAT view. |
| GRANT SELECT ON V_$STATNAME TO C##<username> CONTAINER=ALL; |
Query details about performance monitoring statistics from the V_$STATNAME view. |
| GRANT SET CONTAINER TO C##<username> CONTAINER=ALL; |
Switch between containers, such as the root container and a pluggable database (PDB), when accessing redo logs. |
Set up Redo Logs for Replication
A redo log is a collection of log files that record information about modifications made to data objects on an Oracle server instance. Oracle LogMiner uses redo logs to track these modifications and determine the rows requiring updates in the Destination system.
Connect to your Oracle server as a user with SYSDBA privileges using SQL Developer or any other SQL client tool and perform the following steps:
1. Enable Archive Log
Archive logs are essential for backup and recovery processes of a database management system.
Enter the command below to verify the current archive log mode:
SELECT LOG_MODE FROM V$DATABASE;
This query returns either of the following values:
If the archive mode is NOARCHIVELOG, enable it using the following commands:
-
Enter the command below to initiate the shutdown process without waiting for active sessions or transactions to complete. It forcefully terminates existing connections.
-
Enter the command below to start the Oracle database instance in a mounted state:
-
Enter the command below to alter the database and enable archive log mode. This command instructs the database to start archiving the redo log files:
ALTER DATABASE ARCHIVELOG;
-
Enter the command below to open the database for operations after enabling ARCHIVELOG mode:
The fast recovery area in Oracle serves as a centralized storage space for all database recovery-related files. Consolidating these files into a single location simplifies backup and recovery management.
Set appropriate values for the following parameters:
-
DB_RECOVERY_FILE_DEST_SIZE: Sets the size of the fast recovery area.
-
DB_RECOVERY_FILE_DEST: Sets the location of the fast recovery area. This area contains the redo logs.
-
ARCHIVE_LAG_TARGET: Sets a non-zero target value in seconds for the maximum acceptable delay between log switches.
Configure these parameters using the following commands:
-
Enter the command below to specify the size of the fast recovery area:
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = <size>;
-
Enter the command below to specify the location of the fast recovery area:
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = '<path>';
-
Enter the command below to specify a non-zero value in seconds to force a log switch:
ALTER SYSTEM SET ARCHIVE_LAG_TARGET = <value>;
Note: Replace the placeholder values in the commands above with your own. For example, <size> with 10G.
The Recovery Manager (RMAN) settings determine how long the database holds backlogs and archive logs.
-
Enter the command below to connect to the RMAN:
RMAN
CONNECT TARGET <username> -- (to connect to your database)
Note: Replace the placeholder values in the commands above with your own. For example, <username> with jacobs.
-
Configure the log retention policy to 3 days (72 hours):
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 DAYS;
Note: The minimum value for archive log retention hours is 3 days (72 hours). This avoids any data loss that may occur due to downtimes in the Source database.
4. Enable Supplemental Logging
Supplemental logging ensures that any changes in columns are logged in redo log files, which is essential for LogMiner to access the activity history of a database.
-
Check if supplemental logging is enabled:
SELECT SUPPLEMENTAL_LOG_DATA_MIN FROM "V$DATABASE";
This query returns one of the following values:
-
YES: Indicates that supplemental logging is enabled.
-
IMPLICIT: Indicates that supplemental logging is automatically enabled by the database based on certain conditions or configurations.
-
NO: Indicates that supplemental logging is disabled.
-
If the result of the above query is NO, enable supplemental logging with one of the following commands:
- Enable supplemental logging at the database level for all columns:
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
Note: Enabling supplemental logging at the database level will increase redo log data.
- Enable minimal supplemental logging at the database level:
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
-
Enter the following command to retrieve the status of table-level supplemental logging:
SELECT COUNT(*) FROM ALL_LOG_GROUPS
WHERE LOG_GROUP_TYPE='ALL COLUMN LOGGING'
AND OWNER= '<group_name>'
AND TABLE_NAME='<table_name>';
Note: Replace the placeholder values in the commands above with your own. For example, <group_name> with jacobs.
This returns one of the following values:
-
If the result of the above query is zero, enable supplemental logging for all columns of a table in your Source database which you want to replicate:
ALTER TABLE <SCHEMA_NAME>.<TABLE_NAME> ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
Oracle Buffers
In Oracle, buffers refer to memory storage for caching data to enhance database performance. When LogMiner reads data from redo log files, it utilizes the native in-memory Oracle buffer to cache ongoing transactions (ones that have not been committed or rolled back).
Data Manipulation Language (DML) operations within a transaction are buffered until a commit or rollback is detected. A long-running transaction can have a negative impact on the database performance. It can lead to increased lag in processing change events and memory usage on the database server.
This accumulation of data in the Oracle LogMiner buffers can lead to increased Program Global Area (PGA) memory consumption in your database. Therefore, it is essential to appropriately set the PGA memory size based on your database workload. Read Check PGA/SGA Memory Settings to review the memory settings and configure the PGA_AGGREGATE_LIMIT to prevent server OutOfMemory (OOM) errors.
Only your DBA can determine if your database has long-running transactions with a large number of changes. If so, set the PGA_AGGREGATE_LIMIT to an appropriate value to process these transactions.
5. Check PGA/SGA Memory Settings (Recommended)
In Oracle, the PGA memory settings allow you to manage and optimize memory usage for individual user processes involved in SQL execution.
-
Enter the command below to retrieve information about the initialization parameters ‘pga_aggregate_limit’ and ‘pga_aggregate_target’ from the V$PARAMETER view:
SELECT NAME, VALUE/1024/1024 as VALUE_MB
FROM V$PARAMETER
WHERE NAME IN ('pga_aggregate_limit', 'pga_aggregate_target');
The following is an explanation of the command above:
-
SELECT NAME, VALUE/1024/1024 as VALUE_MB: This part retrieves data for the columns NAME and VALUE from the dynamic performance view V$PARAMETER. It retrieves the NAME column as is and calculates the VALUE column divided by 1024 twice to convert the value from bytes to megabytes. It aliases the result as VALUE_MB.
-
WHERE NAME IN ('pga_aggregate_limit', 'pga_aggregate_target'): This part filters the results to include only the rows where the NAME column is either pga_aggregate_limit or pga_aggregate_target.
-
Enter the command below to monitor the current PGA memory usage in your Oracle database:
SELECT NAME, VALUE, UNIT
FROM V$PGASTAT
WHERE NAME IN ('total PGA inuse','total PGA allocated');
The following is an explanation of the command above:
-
SELECT NAME, VALUE, UNIT: This part retrieves data for the columns NAME, VALUE, and UNIT from the dynamic performance view V$PGASTAT. It retrieves the PGA statistic name, its value, and the unit for the value.
-
WHERE NAME IN ('total PGA inuse', 'total PGA allocated'): This part filters the results to include only the rows where the NAME column is either total PGA inuse or total PGA allocated.
It is important to set up the PGA aggregate limit for managing and controlling memory usage in individual user sessions and queries. Depending on your database workload, you can set the pga_aggregate_limit parameter to prevent out-of-memory errors. To do this, enter the following command:
ALTER SYSTEM SET pga_aggregate_limit = <new value> SCOPE=BOTH;
Note:
-
Replace the placeholder value in the command above with your own. For example, <new value> with 1G.
-
You can set the above value in one of the following units of measurement:
-
K represents kilobytes.
-
M represents megabytes.
-
G represents gigabytes.
Retrieve the Database Name
The database name represents the Oracle database to which Hevo connects for replicating data. To retrieve it, connect to your Oracle server in any SQL client tool as a masteruser and run the appropriate command based on the Oracle deployment type you are using.
Single-instance deployment
Run the following command to retrieve the database name:
SELECT NAME FROM V$DATABASE;
Multitenant architecture (CDB/PDB)
Run the following command to list the available Pluggable Databases (PDBs) in your Container Database (CDB):