Modern business applications rely on timely and accurate data with increasing demand for real-time analytics. There is a growing need for efficient and scalable data storage solutions. Data at times is stored in different datasets and needs to be consolidated before meaningful and complete insights can be drawn from the datasets. This is where replication tools help move the data from its source to the target systems in real time and transform it as necessary to help businesses with consolidation.
In this post, we provide a step-by-step guide for installing and configuring Oracle GoldenGate for streaming data from relational databases to Amazon Simple Storage Service (Amazon S3) for real-time analytics using the Oracle GoldenGate S3 handler.
Oracle GoldenGate for Oracle Database and Big Data adapters Oracle GoldenGate is a real-time data integration and replication tool used for disaster recovery, data migrations, high availability. It captures and applies transactional changes in real time, minimizing latency and keeping target systems synchronized with source databases. It supports data transformation, allowing modifications during replication, and works with various database systems, including SQL Server, MySQL, and PostgreSQL. GoldenGate supports flexible replication topologies such as unidirectional, bidirectional, and multi-master configurations. Before using GoldenGate, make sure you have reviewed and adhere to the license agreement.
Oracle GoldenGate for Big Data provides adapters that facilitate real-time data integration from different sources to big data services like Hadoop, Apache Kafka, and Amazon S3. You can configure the adapters to control the data capture, transformation, and delivery process based on your specific requirements to support both batch-oriented and real-time streaming data integration patterns.
GoldenGate provides special tools called S3 event handlers to integrate with Amazon S3 for data replication. These handlers allow GoldenGate to read from and write data to S3 buckets. This option allows you to use Amazon S3 for GoldenGate deployments across on-premises, cloud, and hybrid environments.
Solution overview The following diagram illustrates our solution architecture.
In this post, we walk you through the following high-level steps:
Prerequisites You must have the following prerequisites in place:
Install GoldenGate software on Amazon EC2 You need to run GoldenGate on EC2 instances. The instances must have adequate CPU, memory, and storage to handle the anticipated replication volume. For more details, refer to Operating System Requirements. After you determine the CPU and memory requirements, select a current generation EC2 instance type for GoldenGate.
Use the following formula to estimate the required trail space:
trail disk space = transaction log volume in 1 hour x number of hours down x .4
When the EC2 instance is up and running, download the following GoldenGate software from the Oracle GoldenGate Downloads page:
Use the following steps to upload and install the file from your local machine to the EC2 instance. Make sure that your IP address is allowed in the inbound rules of the security group of your EC2 instance before starting a session. For this use case, we install GoldenGate for Classic Architecture and Big Data. See the following code:
scp -i pem-key.pem 213000_fbo_ggs_Linux_×64_Oracle_shiphome.zip ec2-user@hostname:~/.ssh -i pem-key.pem ec2-user@hostnameunzip 213000_fbo_ggs_Linux_×64_Oracle_shiphome.zip
Install GoldenGate 21.3.0.0 Complete the following steps to install GoldenGate 21.3 on an EC2 instance:
mkdir /u01/app/oracle/product/OGG_DB_ORACLE/fbo_ggs_Linux_x64_Oracle_shiphome/Disk1ls -lrttotal 8drwxr-xr-x. 4 oracle oinstall 187 Jul 29 2021 installdrwxr-xr-x. 12 oracle oinstall 4096 Jul 29 2021 stage-rwxr-xr-x. 1 oracle oinstall 918 Jul 29 2021 runInstallerdrwxrwxr-x. 2 oracle oinstall 25 Jul 29 2021 response[oracle@hostname Disk1]$ ./runInstallerStarting Oracle Universal Installer.Checking Temp space: must be greater than 120 MB. Actual 193260 MB PassedChecking swap space: must be greater than 150 B. Actual 15624 MB PassedA GUI window will pop up to install the software.
After the GoldenGate software installation is complete, you can create the GoldenGate processes that read the data from the source. First, you configure OGG EXTRACT.
[oracle@hostname Disk1]$vi eabc.prm-- Extract group nameEXTRACT EABCSETENV (TNS_ADMIN = "/u01/app/oracle/product/19.3.0/network/admin")-- Extract database user loginUSERID ggs_admin@mydb, PASSWORD "********"-- Local trail on the remote hostEXTTRAIL /u01/app/oracle/product/OGG_DB_ORACLE/dirdat/eaIGNOREREPLICATESGETAPPLOPSTRANLOGOPTIONS EXCLUDEUSER ggs_adminTABLE scott.emp;GGSCI> ADD EXTRACT EABC, TRANLOG, BEGIN NOWYou will see the EXTRACT status is in the STOPPED state, as shown in the following screenshot; this is expected.
The status changes to RUNNING. The following are the different statuses:
This will start the extract process and a trail file will be created in the location mentioned in the extract parameter file.
stats <<group_name>>, as shown in the following screenshot.Install GoldenGate for Big Data 21c In this step, we install GoldenGate for Big Data in the same EC2 instance where we installed the GoldenGate Classic Architecture.
mkdir /u01/app/oracle/product/OGG_BIG_DATAunzip 214000_ggs_Linux_x64_BigData_64bit.ziptar -xvf ggs_Linux_x64_BigData_64bit.tarGGSCI> CREATE SUBDIRSGGSCI> EDIT PARAM MGRPORT 7801GGSCI> START MGRThis will start the MANAGER program. Now you can install the dependencies required for the REPLICAT to run.
/u01/app/oracle/product/OGG_BIG_DATA/DependencyDownloader and run the sh file with the latest version of aws-java-sdk. This script downloads the AWS SDK, which provides client libraries for connectivity to the AWS Cloud.[oracle@hostname DependencyDownloader]$ ./aws.sh 1.12.748Configure the S3 handler To configure an GoldenGate Replicat to send data to an S3 bucket, you need to set up a Replicat parameter file and properties file that defines how data is handled and sent to Amazon S3.
AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are the access key and secret access key of your IAM user, respectively. Do not hardcode credentials or security keys in the parameter and properties file. There are several methods available to achieve this, such as the following:
```
``` You can set these environment variables in your shell configuration file (e.g., .bashrc, .bash_profile, .zshrc) or use a secure method to set them temporarily:
export AWS_ACCESS_KEY_ID="your_access_key_id"export AWS_SECRET_ACCESS_KEY="your_secret_access_key"
Configure the properties file Create a properties file for the S3 handler. This file defines how GoldenGate will interact with your S3 bucket. Make sure that you have added the correct parameters as shown in the properties file.
The following code is an example of an S3 handler properties file (dirprm/reps3.properties):
[oracle@hostname dirprm]$ cat reps3.propertiesgg.handlerlist=filewritergg.handler.filewriter.type=filewritergg.handler.filewriter.fileRollInterval=60sgg.handler.filewriter.fileNameMappingTemplate=${tableName}${currentTimestamp}.jsongg.handler.filewriter.pathMappingTemplate=./diroutgg.handler.filewriter.stateFileDirectory=./dirstagg.handler.filewriter.format=jsongg.handler.filewriter.finalizeAction=renamegg.handler.filewriter.fileRenameMappingTemplate=${tableName}${currentTimestamp}.jsongg.handler.filewriter.eventHandler=s3goldengate.userexit.writers=javawriter#TODO Set S3 Event Handler- please update as neededgg.eventhandler.s3.type=s3gg.eventhandler.s3.region=eu-west-1gg.eventhandler.s3.bucketMappingTemplate=s3bucketnamegg.eventhandler.s3.pathMappingTemplate=${tableName}_${currentTimestamp}gg.eventhandler.s3.accessKeyId=$AWS_ACCESS_KEY_IDgg.eventhandler.s3.secretKey=$AWS_SECRET_ACCESS_KEYgg.classpath=/u01/app/oracle/product/OGG_BIG_DATA/dirprm/:/u01/app/oracle/product/OGG_BIG_DATA/DependencyDownloader/dependencies/aws_sdk_1.12.748/gg.log=log4jgg.log.level=DEBUG#javawriter.bootoptions=-Xmx512m -Xms32m -Djava.class.path=.:ggjava/ggjava.jar -Daws.accessKeyId=my_access_key_id -Daws.secretKey=my_secret_keyjavawriter.bootoptions=-Xmx512m -Xms32m -Djava.class.path=.:ggjava/ggjava.jar
Configure GoldenGate REPLICAT Create the parameter file in /dirprm in the GoldenGate for Big Data home:
[oracle@hostname dirprm]$ vi rps3.prmREPLICAT rps3-- Command to add REPLICAT-- add replicat fw, exttrail AdapterExamples/trail/trSETENV(GGS_JAVAUSEREXIT_CONF = 'dirprm/rps3.props')TARGETDB LIBFILE libggjava.so SET property=dirprm/rps3.propsREPORTCOUNT EVERY 1 MINUTES, RATEMAP SCOTT.EMP, TARGET gg.handler.s3handler;;[oracle@hostname OGG_BIG_DATA]$ ./ggsciGGSCI > add replicat rps3, exttrail ./dirdat/tr/eaReplicat added.GGSCI > info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNINGREPLICAT STOPPED RPS3 00:00:00 00:00:39GGSCI > start *Sending START request to Manager ...Replicat group RPS3 starting.
Now you have successfully started the Replicat. You can verify this by running info and stats commands followed by the Replicat name, as shown in the following screenshot.
To confirm that the file has been replicated to an S3 bucket, open the Amazon S3 console and open the bucket you created. You can see that the table data has been replicated to Amazon S3 in JSON file format.
Best practices Make sure that you are following the best practices on performance, compression, and security.
Consider the following best practices for performance:
The following are best practices for compression:
Lastly, when implementing Oracle GoldenGate for streaming data to Amazon S3 for real-time analytics, it’s crucial to address various security considerations to protect your data and infrastructure. Follow the security best practices for Amazon S3 and security options available for GoldenGate Classic Architecture.
Clean up To avoid ongoing charges, delete the resources that you created as part of this post:
Conclusion In this post, we provided a step-by-step guide for installing and configuring GoldenGate for Oracle Classic Architecture and Big Data for streaming data from relational databases to Amazon S3. With these instructions, you can successfully set up an environment and take advantage of the real-time analytics using a GoldenGate handler for Amazon S3, which we will explore further in an upcoming post.
If you have any comments or questions, leave them in the comments section.
About the Authors Prasad Matkar is Database Specialist Solutions Architect at AWS based in the EMEA region. With a focus on relational database engines, he provides technical assistance to customers migrating and modernizing their database workloads to AWS.
Arun Sankaranarayanan is a Database Specialist Solution Architect based in London, UK. With a focus on purpose-built database engines, he assists customers in migrating and modernizing their database workloads to AWS.
Giorgio Bonzi is a Sr. Database Specialist Solutions Architect at AWS based in the EMEA region. With a focus on relational database engines, he provides technical assistance to customers migrating and modernizing their database workloads to AWS.