8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | 23ai | Misc | PL/SQL | SQL | RAC | WebLogic | Linux
Dbvisit Replicate Installation on Oracle Linux 5 and 6
Dbvisit Replicate is an alternative to Oracle Streams or Golden Gate for replicating databases. It uses redo log Change Data Capture (CDC) technology and allows one-way or two-way replication between whole databases, schema or individual tables. It also support replication between Oracle and mySQL. In this article I'll focus on a simple example of one way schema replication between two Oracle servers, which is useful to help familiarize yourself with the technology. This is definitely not meant as a replacement for reading the Dbvisit Replicate 2.2 User Guide.
Assumptions
- You have two servers (physical or VMs) with an operating system and Oracle installed on them. In this case I've used Oracle Linux 5.7 and Oracle Database 11.2.0.3. The Oracle versions can be different.
- The servers are pingable using their hostnames (dbvisit1 and dbvisit2).
- A database is running in archivelog mode on each server. For one-way replication the destination server can be in noarchivelog mode if you prefer.
- The servers can make SQL*Net connections to each other. In this case the SQL*Net connection aliases are PRODA and PRODB.
The following information may help you to tailor the installation for your own installation.
ORACLE_BASE=/u01/app/oracle ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 Primary hostname : dbvisit1.localdomain ORACLE_SID=PRODA Secondary hostname: dbvisit2.localdomain ORACLE_SID=PRODB
The "tnsnames.ora" file on each server contains the following entries.
PRODA = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = dbvisit1)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = PRODA.WORLD) ) ) PRODB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = dbvisit2)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = PRODB.WORLD) ) )
The following user is created in each database.
CREATE USER test IDENTIFIED BY test DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp QUOTA UNLIMITED ON users; GRANT CREATE SESSION, CREATE TABLE TO test;
I made a few mistakes the first couple of times I ran through the process. If you are trying this out on virtual servers I would suggest you complete the basic setup of the OS and database on the servers, then take snapshots of them so you can revert back at any point and start again.
Installation
Install the DBvisit Replicate RPM on both servers as the "root" user.
# rpm -Uvh dbvisit_replicate-2.2.14-1.x86_64.rpm Preparing... ########################################### [100%] 1:dbvisit_replicate ########################################### [100%] #
As the "oracle" user, run the following commands on the first server.
$ cd /usr/dbvisit/replicate $ dbvrep
When requested, enter "setup wizard" at the prompt and answer the questions. There are quite a lot of questions to answer. Be careful when typing responses to the questions! If you need any explanation of these responses, check the Dbvisit Replicate 2.2 User Guide.
For this test I set up one-way schema replication from TEST@PRODA to TEST@PRODB. The replication process was called "PROD" and the configuration directory used on both servers was "/home/oracle/PROD".
Once the configuration is complete, navigate to the directory you chose to hold the configuration scripts and run the top-level script.
$ cd /home/oracle/PRODA $ ./PROD-all.sh Setting up Dbvisit Replicate configuration Configure database PRODA... Configure database PRODB... Object grants for database PRODA... Object grants for database PRODB... Setting up the configuration Initializing......done WARN-1850: No DDC DB available, dictionary table does not exist. DDC loaded from database (0 variables). OK-9056: Directory /home/oracle/PROD/ddc_backup set by variable DDC_BACKUP_DIR does not exist on this system. OK-9056: Directory /home/oracle/PROD/ddc_backup set by variable DDC_BACKUP_DIR does not exist on this system. Dbvisit Replicate version 2.2.14.1286 Copyright (C) Dbvisit Software Limited. All rights reserved. DDC file /home/oracle/PROD/PROD-onetime.ddc loaded. MINE: Cannot determine Dbvisit Replicate dictionary version. (no dictionary exists) APPLY: Cannot determine Dbvisit Replicate dictionary version. (no dictionary exists) dbvrep> set ON_WARNING SKIP Variable ON_WARNING set to SKIP for process *. dbvrep> set ON_ERROR EXIT Variable ON_ERROR set to EXIT for process *. dbvrep> ENGINE SETUP MINE DROP DICTIONARY 0 dictionary objects dropped. dbvrep> ENGINE SETUP MINE CREATE DICTIONARY dbvrep> ENGINE SETUP MINE LOAD DICTIONARY Supplemental logging on database set. Loading dictionary table DBRSCOL$ Loading dictionary table DBRSOBJ$ Loading dictionary table DBRSTAB$ Loading dictionary table DBRSUSER$ Loading dictionary table DBRSV_$DATABASE dbvrep> ENGINE SETUP APPLY DROP DICTIONARY 0 dictionary objects dropped. dbvrep> ENGINE SETUP APPLY CREATE DICTIONARY dbvrep> ENGINE SETUP APPLY LOAD DICTIONARY dbvrep> ENGINE PREPARE_DP SETUP CLEAR dbvrep> ENGINE SETUP PAIR MINE AND APPLY ID of mine proces is 69A7CC48-54B1-11E1-85ED-87AF35973BA3. If not using DDC in database, set MINE_UNIQUE_ID to this value. 1 applier SCN set. dbvrep> ENGINE SUPPLEMENTAL LOGGING SCHEMA TEST ENABLE PRIMARY KEY dbvrep> ENGINE SWITCH_REDOLOG dbvrep> PREPARE OFFLINE SCHEMA TEST dbvrep> ENGINE SWITCH_REDOLOG dbvrep> ENGINE PREPARE_DP WRITE DP_NETWORKLINK DIRECTORY DATA_PUMP_DIR FILE /home/oracle/PROD/APPLY.sh DBLINK PRODA USERID SYSTEM/password@PRODB Created Data Pump script /home/oracle/PROD/APPLY.sh, using network import. dbvrep> create ddcdb from ddcfile DDC loaded into database (151 variables). dbvrep> set ON_WARNING SKIP Variable ON_WARNING set to SKIP for process *. dbvrep> set ON_ERROR SKIP Variable ON_ERROR set to SKIP for process *. OK-0: Completed successfully. 1) Create the necessary directory(ies) on the servers: dbvisit1: /home/oracle/PROD dbvisit2: /home/oracle/PROD 2) Copy the DDC files to the server(s) where the processes will run: /home/oracle/PROD/PROD-APPLY.ddc /home/oracle/PROD/PROD-MINE.ddc 3) Review that path to dbvrep executable is correct in the run scripts: /home/oracle/PROD/PROD-run-dbvisit1.sh /home/oracle/PROD/PROD-run-dbvisit2.sh 4) Copy the run script to the server(s) where the processes will run: /home/oracle/PROD/PROD-run-dbvisit1.sh /home/oracle/PROD/PROD-run-dbvisit2.sh 5) Ensure firewall is open for listen interfaces dbvisit2:7902, dbvisit1:7901 used by the processes. 6) Make sure the data on apply are in sync as of time when setup was run. For Oracle targets, scripts for Data Pump were created: /home/oracle/PROD/APPLY.sh Create referenced database links before running the scripts. 7) Start the replication processes on all servers: /home/oracle/PROD/PROD-run-dbvisit1.sh /home/oracle/PROD/PROD-run-dbvisit2.sh 8) Start the console to monitor the progress: /usr/bin/dbvrep --ddcfile /home/oracle/PROD/PROD-MINE.ddc $
On successful completion the script lists 8 steps you should take to complete the setup. Since this is a simple test case they can be summarised as follows.
On the second server make the configuration directory and copy across the necessary files. The following operations are performed as the "oracle" user.
$ mkdir -p /home/oracle/PROD $ scp oracle@dbvisit1:/home/oracle/PROD/PROD-APPLY.ddc /home/oracle/PROD/PROD-APPLY.ddc $ scp oracle@dbvisit1:/home/oracle/PROD/PROD-run-dbvisit2.sh /home/oracle/PROD/PROD-run-dbvisit2.sh
In this case the users are already in sync, so we can ignore step 6. Run the following scripts as the "oracle" user on their respective servers.
$ # Run on dbvisit1 $ /home/oracle/PROD/PROD-run-dbvisit1.sh $ # Run on dbvisit2 $ /home/oracle/PROD/PROD-run-dbvisit2.sh
Start the console on the primary server to monitor the replication.
$ /usr/bin/dbvrep --ddcfile /home/oracle/PROD/PROD-MINE.ddc
Provided you have no errors, replication is now configured and running.
Test
Run the following script from SQL*Plus to create and populate a table in the primary database.
CONN test/test@PRODA CREATE TABLE tab1 ( id NUMBER, description VARCHAR2(50), CONSTRAINT tab1_pk PRIMARY KEY (id) ); INSERT INTO tab1 SELECT level, 'Description for ' || level FROM dual CONNECT BY level < 1000; COMMIT;
The console screen will now show the replication has taken place.
/MINE IS running. Currently at plog 10 and SCN 1046379 (02/11/2012 13:22:24). APPLY IS running. Currently at plog 10 and SCN 1046361 (02/11/2012 13:22:20). Progress of replication PROD:MINE->APPLY: total/this execution -------------------------------------------------------------------------------------------------------------------------------------------- TEST.TAB1: 100% Mine:999/999 Unrecov:0/0 Applied:999/999 Conflicts:0/0 Last:11/02/2012 13:21:42/OK -------------------------------------------------------------------------------------------------------------------------------------------- 1 tables listed.
For more information see:
- Dbvisit.com
- Dbvisit Replicate 2.2 User Guide
- Dbvisit Standby Installation on Oracle Linux 5 and 6
- Dbvisit Reporting Installation on Oracle Linux 5 and 6
Hope this helps. Regards Tim...