Custom Search . . .

Sunday, December 23, 2007

Replication Troubleshooting

While transferring data from materialized view site end. I was faced the below error message.

ORA-12012: error on auto execute of job 2
ORA-23402: refresh was aborted because of conflicts caused by deferred txns
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 820
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 877
ORA-06512: at "SYS.DBMS_IREFRESH", line 683
ORA-06512: at "SYS.DBMS_REFRESH", line 195
ORA-06512: at line 1

Oracle suggest to fix this error automatically using “refresh_after_errors= true

MviewAdmin@Materialized view site.

BEGIN

DBMS_REFRESH.CHANGE(
name => '"MVIEWADMIN"."MIS_REFG"',
next_date => to_date('
01-01-2020 06:06:08','DD-MM-YYYY HH24:MI:SS'),
interval => 'SYSDATE + 1 + (1/24)',
implicit_destroy => FALSE,
rollback_seg => 'NULL',
push_deferred_rpc => TRUE,
refresh_after_errors => TRUE,
purge_option => 1,
parallelism => 0,
heap_size => 0);

END;

By logically it’s not good. You should be find why data’s not transfer? Any problem in your database?

Sys@MasterSite

Here you can find out those problems using the following data dictionary views,

SQL> select deferred_tran_id, destination, error_number, error_msg from deferror;

Using deferred transaction id, you can find out which transaction not updated in materialized view site. Fix those errors. After that only transfer your data’s.

Please post your comments.

Tuesday, December 18, 2007

AWR

The Oracle 10g database introduces a new framework for managing many tuning tasks automatically, for producing real-time information about the database's health, and for extending advisories to improve performance.

The new manageability infrastructure mainly focuses on four areas. They are as follows:

- Automatic Workload Repository - The ability to automatically collect and store database information at regular intervals is crucial. This information should be persistent and accurate. Oracle introduces a new internal data store called Automatic Workload Repository (AWR) to collect and store data. AWR is central to the whole framework of self and automatic management. It works with internal Oracle database components to process, maintain, and access performance statistics for problem detection and self-tuning.

- Automatic Database Diagnostic Monitor - The second key component is the advisory framework that provides expert recommendations to improve performance. The Automatic Database Diagnostic Monitor (ADDM) is a server-based performance expert in a box. It can perform real time root cause analysis of performance issues. It relies on the current statistics within the SGA and on the contents of the AWR. In addition, there are various advisory tools to help make tuning decisions.

- Next, are the Automatic Routine Administration tasks. By using the newly introduced Scheduler, you can delegate to the Oracle database some of the repetitive tasks that need to be performed to keep the database up-to-date.

- Server Generated Alerts - Oracle Database 10g is capable of automatically detecting many database alarm situations.

Use AWR instead of statspack report

You can disable the statspack capture as AWR will capture all the information.
To enable most of the new statistical gathering and advisors, ensure that the parameter.


STATISTICS_LEVEL is set to TYPICAL (recommended).

Running the awrrpt.sql Report

To generate an HTML or text report for a range of snapshot Ids, run the awrrpt.sql script at the SQL prompt:

Oracle provides two scripts to produce workload repository reports (awrrpt.sql and awrrpti.sql). They are similar in format to the statspack reports and give the option of HTML or plain text formats. The two reports give essential the same output but the awrrpti.sql allows you to select a single instance. The reports can be generated as follows:

@$ORACLE_HOME/rdbms/admin/awrrpt.sql
@$ORACLE_HOME/rdbms/admin/awrrpti.sql
 

The scripts prompt you to enter the report format (html or text), the start snapshot id, the end snapshot id and the report filename. The resulting report can be opend in a browser or text editor accordingly


SQL>@$ORACLE_HOME/rdbms/admin/awrrpt.sql

First, you need to specify whether you want an HTML or a text report.

Enter value for report_type: text

Specify the number of days for which you want to list snapshot Ids.

Enter value for num_days: 2


After the list displays, you are prompted for the beginning and ending snapshot Id for the
workload repository report.

Enter value for begin_snap: 150
Enter value for end_snap: 160


Next, accept the default report name or enter a report name. The default name is accepted in the
following example:

Enter value for report_name:
Using the report name awrrpt_1_150_160

...

...

….


The workload repository report is generated.

Thursday, November 29, 2007

Adding LOB Objects in Repliation

How to Add LOB Objects in Replication site.

If you want add lob objects in replication site. (You must be already done Advanced Replication “Click here “)

That objects must be contains primary key constraints.

In scott@US.edkal

SQL> DESC MASTER

Name Null? Type

----------------------------------------- -------- ----------------------------

COMPANY_CODE VARCHAR2(10)

COMPANY_NAME NOT NULL VARCHAR2(100)

COMPANYLOGO BLOB

SHORT_NAME NOT NULL VARCHAR2(10)

PRINT_NAME NOT NULL VARCHAR2(100)

In repadmin@US.edkal

Here you need temporary stop master site activity and add those objects in master site.

SQL> BEGIN

2 DBMS_REPCAT.SUSPEND_MASTER_ACTIVITY (

3 gname => 'us_rep'

4 );

5 END;

6 /

PL/SQL procedure successfully completed.

SQL> BEGIN

2 DBMS_REPCAT.CREATE_MASTER_REPOBJECT (

3 gname => 'us_rep',

4 sname => 'SCOTT',

5 oname => 'MASTER',

6 type => 'TABLE',

7 copy_rows => TRUE,

8 use_existing_object => TRUE );

9 END;

10 /

PL/SQL procedure successfully completed.

SQL> ED

Wrote file afiedt.buf

1 BEGIN

2 DBMS_REPCAT.CREATE_MASTER_REPOBJECT (

3 gname => 'us_rep',

4 sname => 'SCOTT',

5 oname => 'MASTER_PK',

6 type => 'INDEX',

7 copy_rows => TRUE,

8 use_existing_object => TRUE );

9* END;

SQL> /

PL/SQL procedure successfully completed.

SQL> CREATE MATERIALIZED VIEW LOG ON SCOTT.MASTER;

Materialized view log created.

SQL> BEGIN

2 DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (

3 sname => 'SCOTT',

4 oname => 'MASTER',

5 type => 'TABLE',

6 min_communication => true,

7 generate_80_compatible => FALSE);

8* END;

SQL> /

PL/SQL procedure successfully completed.

SQL> BEGIN

2 DBMS_REPCAT.RESUME_MASTER_ACTIVITY (

3 gname => 'us_rep'

4 );

5 END;

6 /

PL/SQL procedure successfully completed.

Once complete start your master activity.

Create materialized view’s in your replication site.

In scott@mv01.edkal

SQL> CREATE MATERIALIZED VIEW MASTER REFRESH FAST WITH PRIMARY KEY UPDATABLE AS SELECT * FROM SCOTT.MASTER@US.EDKAL;

Materialized view created.

In mviewadmin@mv01.edkal

SQL> BEGIN

DBMS_REPCAT.CREATE_SNAPSHOT_REPOBJECT(

gname => '"US_REP"',

sname => '"SCOTT"',

oname => '"MASTER"',

type => 'SNAPSHOT',

min_communication => TRUE);

END;

PL/SQL procedure successfully completed.

SQL> BEGIN

DBMS_REFRESH.ADD(

name => '"MVIEWADMIN"."US_REP"',

list => '"SCOTT"."MASTER"',

lax => TRUE);

END;

PL/SQL procedure successfully completed.

Saturday, November 24, 2007

ORA-01788

Oracle Server - Enterprise Edition - Version: 10.2.0.3
This problem can occur on any platform.
After upgrading to Oracle 10g, started getting an ORA-1788 error for a query that includes the LEVEL pseudo column. This query was running fine on 9i.

Example:

On 9i:

SQL> select level from dual;

LEVEL
----------
0

On 10g:

SQL> select level from dual;
select level from dual
*
ERROR at line 1:
ORA-01788: CONNECT BY clause required in this query block

Solution:

SQL> alter system set "_allow_level_without_connect_by"=true scope=spfile;

or if using a pfile add the line

_allow_level_without_connect_by=true

at the beginning of the pfile.


Both cases will require a restart of the database to take effect.

Friday, November 23, 2007

Replicaton Tuning Tool

The primary tools used to perform the FAST REFRESH analysis were:

1. Oracle provided DBMS_MVIEW.explain_mview procedure
2. MV_CAPABILITIES_TABLE table

The Oracle provided DBMS_MVIEW.explain_mview procedure was used to analyze each of the existing materialized views FAST REFRESH capabilities and write the results to the MV_CAPABILITIES_TABLE:

1. Lists the general capabilities of materialized view or materialized view query
2. Specifies whether each capability is possible (Y or N)
3. If a capability is not possible the reason (why) is written to the msgtxt column of the MV_CAPABILITIES_TABLE

The MV_CAPABILITIES TABLE is created in the owner’s schema by running the following Oracle 9i script:

SQL> @ $ORACLE_HOME/rdbms/admin/utlxmv.sql

Example:

After creating utlxmv.sql script execute the below command.

SQL> exec dbms_mview.explain_mview( 'GENERALISSUEARNO');


SQL> SELECT CAPABILITY_NAME,POSSIBLE,SUBSTR(MSGTXT,1,60) MSGTXT FROM MV_CAPABILITIES_TABLE WHERE CAPABILITY_NAME LIKE '%FAST%';

CAPABILITY_NAME P MSGTXT
------------------------------ - ------------------------------------------------------------
REFRESH_FAST Y
REFRESH_FAST_AFTER_INSERT Y
REFRESH_FAST_AFTER_ONETAB_DML Y
REFRESH_FAST_AFTER_ANY_DML Y
REFRESH_FAST_PCT N PCT is not possible on any of the detail tables in the mater
REFRESH_FAST_PCT N the materialized view is upgraded from a previous version th

6 rows selected.

Sunday, November 18, 2007

Upgrade Oracle 10.2.0.2 to 10.2.0.3


1. Patch Set Overview

Patch set release 10.2.0.3. Before installing this patch set you must be need 10.2.0.1 version.

2. Requirements

Oracle DB : Oracle 10.2.0.1 (later)
Operating System: Windows 2000 (Service Pack 2 or higher)

3. Pre - Installation Tasks

1. Identify prior installation

Before installing this patch you must install oracle 10.2.0.1 (or later version)

2. Download Patch set

Download and extract the p5337014_10203_WINNT.zip patch set installation archive to a directory that is not the Oracle home directory or under the Oracle home directory.

3. Shutdown oracle database.

C:\>set oracle_sid=DEVDB

C:\>sqlplus /nolog

SQL*Plus: Release 10.2.0.2.0 - Production on Tue Nov 13 10:49:26 2007

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

SQL> connect sys@DEVDB as sysdba
Enter password:
Connected.

SQL> SHUTDOWN
Database closed.
Database dismounted.
ORACLE instance shut down.

4. Stop all services

C:\>set oracle_sid=DEVDB

C:\>net stop OracleDBConsoleDEVDB
The OracleDBConsoleDEVDB service is stopping................
The OracleDBConsoleDEVDB service was stopped successfully.


C:\>net stop OracleServiceDEVDB
The OracleServiceDEVDB service is stopping.
The OracleServiceDEVDB service was stopped successfully.


C:\>net stop OracleOraDB10g_Home1iSQL*Plus..
The OracleOraDb10g_home1iSQL*Plus service was stopped successfully.

C:\>net stop OracleOraDB10g_Home1TNSListener
The OracleOraDb10g_home1TNSListener service is stopping.
The OracleOraDb10g_home1TNSListener service was stopped successfully.

Note: while patch installation time If you face Distributed Transaction Coordinator still running. You should be stop this service

C:\>net stop msdtc
The Distributed Transaction Coordinator service is stopping.
The Distributed Transaction Coordinator service was stopped successfully.

4. Backup your database.

Oracle recommends that you create a backup of the Oracle 10g installation before you install the patch set.

5. Check Tablespace Sizes and Set Parameter Values

Review the following sections before upgrading a database.

7. Check SYSTEM Tablespace Size

If JServer is part of the installation ensure that there is at least 50 MB of free space allocated to the SYSTEM tablespace.

6. Set the SHARED_POOL_SIZE and JAVA_POOL_SIZE Initialization Parameters

Users who have JVM (Java enabled) or JVM and XDB installed on their 10.2.0.1 databases should make sure that the init.ora parameters SHARED_POOL_SIZE and JAVA_POOL_SIZE are each 150 MB or more before running the catpatch.sql upgrade script. Failure to do so could result in an unrecoverable memory failure while running of the script. Please note that JVM and XML DB was shipped as part of the default 10.2.0.1 seed database, and will be present unless the user explicitly installed a 10.2.0.1 instance without them.
Set the value of the SHARED_POOL_SIZE and the JAVA_POOL_SIZE initialization parameters as follows:

C:\>set oracle_sid=DEVDB


C:\>sqlplus /nolog
SQL*Plus: Release 10.2.0.2.0 - Production on Tue Nov 13 10:49:26 2007
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

SQL> connect sys@DEVDB as sysdba
Enter password:
Connected.

SQL> STARTUP NOMOUNT
ORACLE instance started.
Total System Global Area 437329148 bytes
Fixed Size 453884 bytes
Variable Size 369098752 bytes
Database Buffers 67108864 bytes
Redo Buffers 667648 bytes
Database mounted.

Note:

If the system uses an initialization parameter file, if necessary change the values of the SHARED_POOL_SIZE and the JAVA_POOL_SIZE initialization parameters to at least 150 MB in the initialization parameter file (initsid.ora).

SQL> ALTER SYSTEM SET JAVA_POOL_SIZE=150M SCOPE=SPFILE;

System altered.

SQL> ALTER SYSTEM SET SHARED_POOL_SIZE=150M SCOPE=SPFILE;
System altered.

SQL> STARTUP FORCE
ORACLE instance started.
Total System Global Area 437329148 bytes
Fixed Size 453884 bytes
Variable Size 369098752 bytes
Database Buffers 67108864 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.

SQL> SHUTDOWN
Database closed.
Database dismounted.
ORACLE instance shut down.

8. Upgrade the Database

Install patch set, you must perform the following steps on every database associated with the upgraded Oracle home:

1. Start all services

2. Connect sys user

C:\> sqlplus /NOLOG

SQL> CONNECT SYS/SYS_password AS SYSDBA

3. Enter the following SQL*Plus commands:

SQL> STARTUP UPGRADE

SQL> SPOOL patch.log

SQL> @ORACLE_BASE\ORACLE_HOME\rdbms\admin\catupgrd.sql

SQL> SPOOL OFF

Review the patch.log file for errors and inspect the list of components that is displayed at the end of catupgrd.sql script.

This list provides the version and status of each SERVER component in the database.

If necessary, rerun the catupgrd.sql script after correcting any problems.

4. Restart the database:

SQL> SHUTDOWN
SQL> STARTUP

5. Compile Invalid Objects

Run the utlrp.sql script to recompile all invalid PL/SQL packages now instead of when the packages are accessed for the first time. This step is optional but recommended.

SQL> @ORACLE_BASE\ORACLE_HOME\rdbms\admin\utlrp.sql

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Release 10.2.0.3.0 - Production
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production

Please post your comments..

Tuesday, November 13, 2007

Patch Installation

Upgrade Oracle 9.2.0.2 to 9.2.0.8

1. Patch Set Overview

Patch set release 9.2.0.8 includes all fixes in patch sets 9.2.0.8 and earlier as well as new fixes for patch set 9.2.0.8. This means that unless the patch set documentation indicates otherwise, you can apply this patch set to any earlier release 9.2 installation. You do not have to install intermediate patch sets.

2. Requirements

Oracle DB : Oracle 9.2.0.1 (later)

Operating System: Windows 2000 (Service Pack 2 or higher)

3. Pre – Installation Tasks

  1. Identify prior installation

Before installing this patch you must install oracle 9.2.0.1 (or later version)

  1. Download Patch set

Download and extract the p4547809_9208_WINNT.zip patch set installation archive to a directory that is not the Oracle home directory or under the Oracle home directory

  1. Shutdown oracle database.

C:\>set oracle_sid=SNGDB

C:\>sqlplus /nolog

SQL*Plus: Release 9.2.0.2.0 - Production on Tue Nov 13 10:49:26 2007

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

SQL> connect sys@sngdb as sysdba

Enter password:

Connected.

SQL> SHUTDOWN

Database closed.

Database dismounted.

ORACLE instance shut down.

  1. Stop all services

C:\>net start OracleServiceSNGDB

The OracleServicesngdb service is starting.....................

The OracleServicesngdb service was started successfully.


C:\>net stop OracleServiceSNGDB

The OracleServicesngdb service is stopping...

The OracleServicesngdb service was stopped successfully.


C:\>net stop OracleOraHome92Agent

The OracleOraHome92Agent service is stopping..

The OracleOraHome92Agent service was stopped successfully.


C:\>net stop OracleOraHome92TNSListener

The OracleOraHome92TNSListener service is stopping.

The OracleOraHome92TNSListener service was stopped successfully.

C:\>net stop OracleOraHome92HTTPServer

The OracleOraHome92HTTPServer service is stopping....

The OracleOraHome92HTTPServer service was stopped successfully.

C:\>net stop OracleMTSRecoveryService

The OracleMTSRecoveryService service is stopping.

The OracleMTSRecoveryService service was stopped successfully.

Note: while patch installation time If you face Distributed Transaction Coordinator still running. You should be stop this service

C:\>net stop msdtc

The Distributed Transaction Coordinator service is stopping.

The Distributed Transaction Coordinator service was stopped successfully.

4. Backup your database.

Oracle recommends that you create a backup of the Oracle9i installation before you install the patch set.


5. Check Tablespace Sizes and Set Parameter Values

Review the following sections before upgrading a database.

6. Check SYSTEM Tablespace Size

If JServer is part of the installation ensure that there is at least 10 MB of free space allocated to the SYSTEM tablespace.

7. Check XDB Tablespace Size

For Oracle RAC installations, ensure that there is at least 50 MB of free space allocated to the XDB tablespace.

8. Set the SHARED_POOL_SIZE and JAVA_POOL_SIZE Initialization Parameters

Users who have JVM (Java enabled) or JVM and XDB installed on their 9.2.0.1 databases should make sure that the init.ora parameters SHARED_POOL_SIZE and JAVA_POOL_SIZE are each 150 MB or more before running the catpatch.sql upgrade script. Failure to do so could result in an unrecoverable memory failure while running of the script. Please note that JVM and XML DB was shipped as part of the default 9.2.0.1 seed database, and will be present unless the user explicitly installed a 9.2.0.1 instance without them.

Set the value of the SHARED_POOL_SIZE and the JAVA_POOL_SIZE initialization parameters as follows:

C:\>set oracle_sid=SNGDB

C:\>sqlplus /nolog

SQL*Plus: Release 9.2.0.2.0 - Production on Tue Nov 13 10:49:26 2007

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

SQL> connect sys@sngdb as sysdba

Enter password:

Connected.

Note:

If the system uses an initialization parameter file, if necessary change the values of the SHARED_POOL_SIZE and the JAVA_POOL_SIZE initialization parameters to at least 150 MB in the initialization parameter file (initsid.ora).

SQL> ALTER SYSTEM SET JAVA_POOL_SIZE=150M SCOPE=SPFILE;

System altered.

SQL> ALTER SYSTEM SET SHARED_POOL_SIZE=150M SCOPE=SPFILE;

System altered.

SQL> STARTUP FORCE

ORACLE instance started.

Total System Global Area 437329148 bytes

Fixed Size 453884 bytes

Variable Size 369098752 bytes

Database Buffers 67108864 bytes

Redo Buffers 667648 bytes

Database mounted.

Database opened.

SQL> SHUTDOWN

Database closed.

Database dismounted.

ORACLE instance shut down.

9. Upgrade the Database

After you install the patch set, you must perform the following steps on every database associated with the upgraded Oracle home:

1. Start all services

2.     Connect sys user
   C:\> sqlplus /NOLOG
        SQL> CONNECT SYS/SYS_password AS SYSDBA
   
3.     Enter the following SQL*Plus commands:
          SQL> STARTUP MIGRATE
          SQL> SPOOL patch.log
         SQL> @ORACLE_BASE\ORACLE_HOME\rdbms\admin\catpatch.sql
         SQL> SPOOL OFF
 

Review the patch.log file for errors and inspect the list of components that is displayed at the end of catpatch.sql script.

This list provides the version and status of each SERVER component in the database.

If necessary, rerun the catpatch.sql script after correcting any problems.

4. Restart the database:

SQL> SHUTDOWN
SQL> STARTUP
 

5. Compile Invalid Objects

Run the utlrp.sql script to recompile all invalid PL/SQL packages now instead of when the packages are accessed for the first time. This step is optional but recommended.

SQL> @ORACLE_BASE\ORACLE_HOME\rdbms\admin\utlrp.sql
 

11. If you are using the Oracle Recovery Manager catalog, enter the following command:

C:\> rman catalog username/password@orcl
RMAN> UPGRADE CATALOG; 

Friday, November 2, 2007

Adding Objects in Replication

Alter Replication:

If you want add objects in replication site. (You must be already done Advanced Replication “Click here “)

That objects must be contains primary key constraints.

In scott@US.edkal

SQL> CREATE TABLE U_MASTER

(UNO INT CONSTRAINT U_MASTER_PK PRIMARY KEY,

USERNAME VARCHAR2 (22),

U_PASSWORD VARCHAR2 (22));

Table created.

In repadmin@US.edkal

Here you need temporary stop master site activity and add those objects in master site.

SQL> BEGIN

2 DBMS_REPCAT.SUSPEND_MASTER_ACTIVITY (

3 gname => 'us_rep'

4 );

5 END;

6 /

PL/SQL procedure successfully completed.

SQL> BEGIN

2 DBMS_REPCAT.CREATE_MASTER_REPOBJECT (

3 gname => 'us_rep',

4 sname => 'SCOTT',

5 oname => 'U_MASTER',

6 type => 'TABLE',

7 copy_rows => TRUE,

8 use_existing_object => TRUE );

9 END;

10 /

PL/SQL procedure successfully completed.

SQL> ED

Wrote file afiedt.buf

1 BEGIN

2 DBMS_REPCAT.CREATE_MASTER_REPOBJECT (

3 gname => 'us_rep',

4 sname => 'SCOTT',

5 oname => 'U_MASTER_PK',

6 type => 'INDEX',

7 copy_rows => TRUE,

8 use_existing_object => TRUE );

9* END;

SQL> /

PL/SQL procedure successfully completed.

SQL> CREATE MATERIALIZED VIEW LOG ON SCOTT.U_MASTER;

Materialized view log created.

SQL> BEGIN

2 DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (

3 sname => 'SCOTT',

4 oname => 'U_MASTER',

5 type => 'TABLE',

6 min_communication => true,

7 generate_80_compatible => FALSE);

8* END;

SQL> /

PL/SQL procedure successfully completed.

SQL> BEGIN

2 DBMS_REPCAT.RESUME_MASTER_ACTIVITY (

3 gname => 'us_rep'

4 );

5 END;

6 /

PL/SQL procedure successfully completed.

Once complete start your master activity.

Create materialized view’s in your replication site.

In scott@mv01.edkal

SQL> CREATE MATERIALIZED VIEW U_MASTER REFRESH FAST WITH PRIMARY KEY UPDATABLE AS SELECT * FROM SCOTT.U_MASTER@US.EDKAL;

Materialized view created.

In mviewadmin@mv01.edkal

SQL> BEGIN

DBMS_REPCAT.CREATE_SNAPSHOT_REPOBJECT(

gname => '"US_REP"',

sname => '"SCOTT"',

oname => '"U_MASTER"',

type => 'SNAPSHOT',

min_communication => TRUE);

END;

PL/SQL procedure successfully completed.

SQL> BEGIN

DBMS_REFRESH.ADD(

name => '"MVIEWADMIN"."US_REP"',

list => '"SCOTT"."U_MASTER"',

lax => TRUE);

END;

PL/SQL procedure successfully completed.

Tuesday, October 23, 2007

Advanced Replication

This document only creating “Materialized View Replication ( You need one Master Site and more than on Materialized view site)” not for “Multimaster Replication”

Here I am using one master site called “US” and one materialized view site called “MV01

The general architecture for Advanced Replication is


The above architecture only helps to configure “Advanced Replication”

Replication environment primary condition:

Primary Keys and Replicated Tables

If possible, each replicated table should have a primary key. Where a primary key is not possible, each replicated table must have a set of columns that can be used as a unique identifier for each row of the table. If the tables that you plan to use in your replication environment do not have a primary key or a set of unique columns, then alter these tables accordingly. In addition, if you plan to create any primary key materialized views based on a master table or master materialized view, then that master must have a primary key.

Foreign Keys and Replicated Tables

When replicating tables with foreign key referential constraints, Oracle recommends that you always index foreign key columns and replicate these indexes, unless no updates and deletes are allowed in the parent table. Indexes are not replicated automatically. To replicate an index, add it to the master group containing its table using either the Replication Management tool or the CREATE_MASTER_REPOBJECT procedure in the DBMS_REPCAT package.

Data types:

· VARCHAR2

· NVARCHAR2

· NUMBER

· DATE

· TIMESTAMP

· TIMESTAMP WITH TIME ZONE

· TIMESTAMP LOCAL TIME ZONE

· INTERVAL YEAR TO MONTH

· INTERVAL DAY TO SECOND

· RAW

· ROWID

· CHAR

· NCHAR

· User-defined datatypes

Oracle also supports the replication of tables and materialized views with columns that use the following large object types:

· Binary LOB (BLOB)

· Character LOB (CLOB)

· National character LOB (NCLOB)

The deferred and synchronous remote procedure call mechanism used for multimaster replication propagates only the piece-wise changes to the supported LOB datatypes when piece-wise updates and appends are applied to these LOB columns. Also, you cannot reference LOB columns in a WHERE clause of a materialized view's defining query.

You can replicate tables and materialized views that use user-defined types, including column objects, object tables, REFs, varrays, and nested tables.

Oracle does not support the replication of columns that use the LONG and LONG RAW datatypes. You should convert LONG datatypes to LOBs.

Oracle also does not support the replication of external or file-based LOBs (BFILEs). Attempts to configure tables containing columns of this datatype as master tables return an error message.

Oracle also does not support the replication of UROWID columns in master tables or updatable materialized views. However, UROWID columns are allowed in read-only materialized views.

Initialization Parameters

Configure the bellow parameter in Master and Materialized view sites.

SQL> ALTER SYSTEM SET GLOBAL_NAMES=TRUE SCOPE=SPFILE;

System altered.

SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=10 SCOPE=SPFILE;

System altered.

SQL> ALTER SYSTEM SET PARALLEL_MAX_SERVERS=20 SCOPE=SPFILE;

System altered.

SQL> ALTER SYSTEM SET PARALLEL_MIN_SERVERS=0 SCOPE=SPFILE;

System altered.

Net Configuration:

Before you start replication you must configure master and replication site.

SQLNET.ORA

SQLNET.AUTHENTICATION_SERVICES= (NONE)

#NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

NAMES.DEFAULT_DOMAIN=EDKAL

SQLNET.EXPIRE_TIME=10

TNSNAMES.ORA

US.EDKAL =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.100.100.168)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = US.EDKAL)

)

)

MV01.EDKAL =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.100.100.105)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = MV01.EDKAL)

)

)

Master Site Replication:

Master site (US), I want to replicate “BABU” schema to Materialized view site (MV01).

Use the above diagram step by step you can configure Advanced Replication.

Step1: Master Site

SQL> connect system@US

Connected.

SQL> show parameter db_name

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

db_name string US

SQL> REM Create Replication administrator user and give necessary privilege to this user. This Replication must be create in each site.

SQL> CREATE USER REPADMIN IDENTIFIED BY REPADMIN;

User created.

SQL> REM Execute GRANT_ADMIN_ANY_SCHEMA privilege to Replication Administrator

SQL> BEGIN

2 DBMS_REPCAT_ADMIN.GRANT_ADMIN_ANY_SCHEMA (

3 username => 'repadmin' );

4 END;

5 /

PL/SQL procedure successfully completed.

SQL> REM If you want create any materialized view log in Replicaton administrator in master site. Execute the below privillege.

SQL> GRANT COMMENT ANY TABLE TO REPADMIN;

Grant succeeded.

SQL> GRANT LOCK ANY TABLE TO REPADMIN;

Grant succeeded.

SQL> REM If want connect Replication Management Tool, Execute the bellow privilege.

SQL> GRANT SELECT ANY DICTIONARY TO REPADMIN;

Grant succeeded.

SQL> REM This is responsable for propagater deferred transaction queue.

SQL> BEGIN

2 DBMS_DEFER_SYS.REGISTER_PROPAGATOR ( username => 'repadmin') ;

3 END;

4 /

PL/SQL procedure successfully completed.

SQL> REM If want to recevie propagater deferred transaction sent by propagater.

SQL> BEGIN

2 DBMS_REPCAT_ADMIN.REGISTER_USER_REPGROUP (

3 username => 'repadmin',

4 privilege_type => 'receiver',

5 list_of_gnames => NULL );

6 END;

7 /

PL/SQL procedure successfully completed.

SQL> REM Connnect Replication Administrator

SQL> Connect repadmin/repadmin@US

Connected.

SQL> REM You need to schedule automated purge process.

SQL> BEGIN

2 DBMS_DEFER_SYS.SCHEDULE_PURGE (

3 next_date => SYSDATE,

4 interval => 'SYSDATE+1/24',

5 delay_seconds => 0);

6 END;

7 /

PL/SQL procedure successfully completed.

SQL> REM Connect System user in Master site.

SQL> Connect System@US

Connected.

SQL> REM If you plan create materialized view site based on master site you should be create proxy materialized view admin.

SQL>

SQL> CREATE USER proxy_mviewadmin identified by proxy_mviewadmin;

User created.

SQL> BEGIN

2 DBMS_REPCAT_ADMIN.REGISTER_USER_REPGROUP (

3 username => 'proxy_mviewadmin',

4 privilege_type => 'proxy_snapadmin',

5 list_of_gnames => NULL );

6 END;

7 /

PL/SQL procedure successfully completed.

SQL> GRANT SELECT_CATALOG_ROLE TO proxy_mviewadmin;

Grant succeeded.

SQL> REM Suppose you no need proxy materialized view administrator in your Replicatoin management tool, You should be create

SQL> REM Proxy refresher, It's usefull for refreshing master site and materialized view site.

SQL> CREATE USER proxy_refresher IDENTIFIED BY proxy_refresher;

User created.

SQL> GRANT CREATE SESSION TO proxy_refresher;

Grant succeeded.

SQL> GRANT SELECT ANY TABLE TO proxy_refresher;

Grant succeeded.

SQL> Spool off

Step2: Master Group

Before you start master group, Let us assume “BABU” Schema exist in US.Edkal. I want replicate following objects…

EMP – table

DEPT – table

And the above two objects dependent objects like ‘Index etc…”

SQL> REM Installation for master group

SQL> connect repadmin/repadmin@US

Connected.

SQL> REM Create master group in your replication administrator environment.

SQL> BEGIN

2 DBMS_REPCAT.CREATE_MASTER_REPGROUP ( gname => 'babu_rep' );

3 END;

4 /

PL/SQL procedure successfully completed.

SQL> REM Add objects in your master group.

SQL>

SQL>

SQL> BEGIN

2 DBMS_REPCAT.CREATE_MASTER_REPOBJECT (

3 gname => 'babu_rep',

4 sname => 'BABU',

5 oname => 'EMP',

6 type => 'TABLE',

7 use_existing_object => TRUE ,

8 copy_rows => FALSE );

9 END;

10 /

PL/SQL procedure successfully completed.

SQL> ED

Wrote file afiedt.buf

1 BEGIN

2 DBMS_REPCAT.CREATE_MASTER_REPOBJECT (

3 gname => 'babu_rep',

4 sname => 'BABU',

5 oname => 'DEPT',

6 type => 'TABLE',

7 use_existing_object => TRUE ,

8 copy_rows => FALSE );

9* END;

SQL> /

PL/SQL procedure successfully completed.

SQL> ED

Wrote file afiedt.buf

1 BEGIN

2 DBMS_REPCAT.CREATE_MASTER_REPOBJECT (

3 gname => 'babu_rep',

4 sname => 'BABU',

5 oname => 'pro_make_dt_script',

6 type => 'procedure',

7 use_existing_object => TRUE ,

8 copy_rows => FALSE );

9* END;

SQL> /

PL/SQL procedure successfully completed.

SQL> ed

Wrote file afiedt.buf

1 BEGIN

2 DBMS_REPCAT.CREATE_MASTER_REPOBJECT (

3 gname => 'babu_rep',

4 sname => 'BABU',

5 oname => 'Fun_ExperimentName',

6 type => 'function',

7 use_existing_object => TRUE ,

8 copy_rows => FALSE );

9* END;

SQL> /

PL/SQL procedure successfully completed.

SQL> COMMIT;

Commit complete.

SQL> ED

Wrote file afiedt.buf

1 BEGIN

2 DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (

3 sname => 'BABU',

4 oname => 'RDSECURITY',

5 type => 'TABLE',

6 min_communication => TRUE);

7* END;

SQL> /

PL/SQL procedure successfully completed.

1 BEGIN

2 DBMS_REPCAT.DROP_MASTER_REPOBJECT (

3 sname => 'BABU',

4 oname => 'SWSETTINGS',

5 type => 'TABLE');

6* END;

SQL> /

PL/SQL procedure successfully completed.

SQL> BEGIN

2 DBMS_REPCAT.CREATE_MASTER_REPOBJECT (

3 gname => 'babu_rep',

4 sname => 'BABU',

5 oname => 'SWSETTINGS',

6 type => 'TABLE',

7 use_existing_object => TRUE ,

8 copy_rows => FALSE );

9 END;

10 /

PL/SQL procedure successfully completed.

SQL> BEGIN

2 DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (

3 sname => 'BABU',

4 oname => 'SWSETTINGS',

5 type => 'TABLE',

6 min_communication => TRUE);

7 END;

8 /

PL/SQL procedure successfully completed.

SQL> BEGIN

2 DBMS_REPCAT.RESUME_MASTER_ACTIVITY ( gname => 'babu_rep' );

3 end;

4 /

PL/SQL procedure successfully completed.

SQL> commit;

Commit complete.

SQL> spool off

Step3: Materialized view Site configuration

SQL> connect system@MV01

Connected.

SQL> CREATE USER mviewadmin IDENTIFIED BY mviewadmin;

User created.

SQL> BEGIN

2 DBMS_REPCAT_ADMIN.GRANT_ADMIN_ANY_SCHEMA ( username => 'mviewadmin' );

3 END;

4 /

PL/SQL procedure successfully completed.

SQL> GRANT COMMENT ANY TABLE, LOCK ANY TABLE TO mviewadmin;

Grant succeeded.

SQL> GRANT SELECT ANY DIcTIONARY TO mviewadmin;

Grant succeeded.

SQL> CREATE USER propagator IDENTIFIED BY propagator;

User created.

SQL> BEGIN

2 DBMS_DEFER_SYS.REGISTER_PROPAGATOR ( username => 'propagator' );

3 END;

4 /

PL/SQL procedure successfully completed.

SQL> rem he refresher is responsible for "pulling" changes made to the replicated tables at the target master site to the materialized view site. This user refreshes one or more materialized views. If you want the mviewadmin user to be the refresher, then this step is not required.

SQL> CREATE USER refresher IDENTIFIED BY refresher;

User created.

SQL> GRANT CREATE SESSION, ALTER ANY MATERIALIZED VIEW TO refresher;

Grant succeeded.

SQL> REM Register

SQL> REM It's recevie propagator deferred transaction sent by propagator.

SQL> BEGIN

2 DBMS_REPCAT_ADMIN.REGISTER_USER_REPGROUP (

3 username => 'mviewadmin',

4 privilege_type => 'receiver',

5 list_of_gnames => NULL );

6 END;

7 /

PL/SQL procedure successfully completed.

SQL> REM Create DB Link for master site.

SQL> CONNECT SYSTEM@MV01

Connected.

SQL> CREATE PUBLIC DATABASE LINK US.EDKAL USING 'US.EDKAL';

Database link created.

SQL> Connect mviewadmin/mviewadmin@MV01

Connected.

SQL> CREATE DATABASE LINK US.EDKAL CONNECT TO proxy_mviewadmin IDENTIFIED BY proxy_mviewadmin USING 'US.EKDAL';

Database link created.

SQL> REM You need to create a database link from the propagator at the materialized view site to the receiver at the master site. The receiver was defined when you created the master site.

SQL> connect propagator/propagator@MV01

Connected.

SQL> CREATE DATABASE LINK US.EDKAL CONNECT TO repadmin IDENTIFIED BY repadmin USING 'US.EKDAL';

Database link created.

SQL> connect mviewadmin/mviewadmin@MV01

Connected.

SQL> ED

Wrote file afiedt.buf

1 BEGIN

2 DBMS_DEFER_SYS.SCHEDULE_PURGE (

3 next_date => SYSDATE,

4 interval => 'SYSDATE+1/24',

5 delay_seconds => 0,

6 rollback_segment => '');

7* END;

SQL> /

PL/SQL procedure successfully completed.

SQL> CONNECT MVIEWADMIN/MVIEWADMIN@MV01

Connected.

SQL> BEGIN

2 DBMS_DEFER_SYS.SCHEDULE_PUSH (

3 destination => 'US.EDKAL',

4 interval => 'SYSDATE+1/24',

5 next_date => SYSDATE,

6 stop_on_error => FALSE,

7 delay_seconds => 0,

8 parallelism => 0 );

9 END;

10 /

PL/SQL procedure successfully completed.

SQL> CONNECT SYSTEM@MV01

Connected.

SQL> CREATE USER proxy_mviewadmin IDENTIFIED BY proxy_mviewadmin;

User created.

SQL> BEGIN

2 DBMS_REPCAT_ADMIN.REGISTER_USER_REPGROUP (

3 username => 'proxy_mviewadmin',

4 privilege_type => 'proxy_snapadmin',

5 list_of_gnames => NULL);

6 END;

7 /

PL/SQL procedure successfully completed.

SQL> GRANT SELECT_CATALOG_ROLE TO proxy_mviewadmin;

Grant succeeded.

SQL> CREATE USER proxy_refresher IDENTIFIED BY proxy_refresher;

User created.

SQL> GRANT CREATE SESSION TO proxy_refresher;

Grant succeeded.

SQL> GRANT SELECT ANY TABLE TO proxy_refresher;

Grant succeeded.

STEP4: Setup Materialized view Group Configuration

Before that you can create materialized view in your master site.

SQL> SHOW PARAMETER DB_NAME

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

db_name string MV01

SQL>

SQL>

SQL> ED

Wrote file afiedt.buf

1 BEGIN

2 DBMS_REPCAT.CREATE_MVIEW_REPGROUP (

3 gname => 'US_REP',

4 master => 'US.EDKAL',

5 propagation_mode => 'ASYNCHRONOUS');

6* END;

SQL> /

PL/SQL procedure successfully completed.

SQL> ED

Wrote file afiedt.buf

1 BEGIN

2 DBMS_REFRESH.MAKE (

3 name => 'mviewadmin.us_rep',

4 list => '',

5 next_date => SYSDATE,

6 interval => 'SYSDATE + 1/24',

7 implicit_destroy => FALSE,

8 rollback_seg => '',

9 push_deferred_rpc => TRUE,

10 refresh_after_errors => FALSE);

11* END;

SQL> /

PL/SQL procedure successfully completed.

SQL> CREATE MATERIALIZED VIEW BABU.EMP REFRESH FAST WITH PRIMARY KEY AS SELECT * FROM SCOTT.EMP@US.EDKAL;

Materialized view created.

SQL> CREATE MATERIALIZED VIEW BABU.DEPT REFRESH FAST WITH PRIMARY KEY AS SELECT * FROM SCOTT.DEPT@US.EDKAL;

Materialized view created.

SQL> CREATE MATERIALIZED VIEW BABU.SALGRADE REFRESH FAST WITH PRIMARY KEY AS SELECT * FROM SCOTT.SALGRADE@US.EDKAL;

Materialized view created.

SQL> SHOW USER

USER is "MVIEWADMIN"

SQL> BEGIN

2 DBMS_REPCAT.CREATE_MVIEW_REPOBJECT (

3 gname => 'us_rep',

4 sname => 'SCOTT',

5 oname => 'EMP',

6 type => 'SNAPSHOT',

7 min_communication => TRUE);

8 END;

9 /

PL/SQL procedure successfully completed.

SQL> ED

Wrote file afiedt.buf

1 BEGIN

2 DBMS_REPCAT.CREATE_MVIEW_REPOBJECT (

3 gname => 'us_rep',

4 sname => 'SCOTT',

5 oname => 'DEPT',

6 type => 'SNAPSHOT',

7 min_communication => TRUE);

8* END;

SQL> /

PL/SQL procedure successfully completed.

Monitoring Replication:

DBA_REPQUESTS – It’s administration purpose, you can able to find out administration error, no of deferred transaction etc.

DBA_REPCATLOG – Contains the interim status of any asynchronous administrative requests and any error messages generated at each master site

DBA_REPGROUP - Find out master group in your master site.

DBA_REPOBJECT – Find out objects in mater group

DEFERROR - It’s transaction error msg.

DEFTRANDEST - Find out total number transaction.