Skip to main content

Using Master Replicates with Enterprise Replication

The benefits of using master replicates versus classic replicates

Pravin Kedia (kedia@us.ibm.com), Software Engineer--Informix/DB2 Products, IBM 
Pravin Kedia is a software developer who has been working on IBM Informix database servers and tools for several years. He has been involved in the development of the described Enterprise Replication features for the Dynamic Server Version 10.0 release.

Summary:  Master replicates are a new Enterprise Replication feature for IBM® Informix® Dynamic Server, Version 10.0. Master replicates are the preferred approach to replicating data between ER nodes. Explore the advantages that master replicates have over classic replicates, why ER customers should be using master replicates, and some additional information about using them.

Date:  26 May 2005
Level:  Introductory
Activity:  363 views

Master replicates and how to use them

Previous versions of Enterprise Replication did not have the capability to discover a data type mismatch at the source and target nodes at the time of replicate creation, and instead discovered any mismatches when data was corrupted. For example, using classic (non-master) replicates, it is possible to define a replicate with having an int8 column on the source node and an integer column on other nodes. This mismatch would not be detected until it had already caused data corruption. In Version 10.0, you can guarantee consistency between the nodes in your Enterprise Replication environment by defining master replicates. Master replicates store dictionary information about replicated column attributes for the participant tables so that Enterprise Replication can check for consistency between the master definition and local participant definitions when the replicates are defined. Using master replicates avoids runtime data corruption occurring due to data type mismatch on source and target nodes. Verification of replicate attributes also occurs each time the master replicate is started.

To specify a master replicate, use the --master option with the cdr define replicate command. The --master option (-M) requires you to specify the master node where the master table dictionary is located. The master table dictionary is used to compare schemas on all replicate participants to ensure consistency. You also have the option to create tables on target nodes using master replicates if those tables are not already present.

For more information about master replicates, see the Informix Dynamic Server Information Center.

Suppose you create a logged database and table:

>dbaccess - -
create database test with log;
create table tab1 (c1 integer primary key, c2 integer) with crcols;

Then you can define the master replicate using -M option to specify the master node as g_pkcdr.1:

>cdr define repl rep1 -M g_pkcdr1 -C "ignore" "test@g_pkcdr1:pravin.tab1" 
"select * from tab1" "test@g_pkcdr2:pravin.tab1" "select * from tab1"
Verification of test@g_pkcdr1:pravin.tab1 started 
Verification of test@g_pkcdr1:pravin.tab1 is successful
Verification of test@g_pkcdr2:pravin.tab1 started 
Verification of test@g_pkcdr2:pravin.tab1 is successful

cdr start repl rep1

These commands create a master replicate that first verifies the schema at two nodes. The cdr list repl command indicates that the replicate is a master replicate in the REPLTYPE field:

cdr list repl rep1

CURRENTLY DEFINED REPLICATES
---------------------------------------------------
REPLICATE:        rep1
STATE:            Active ON:pkcdr1
CONFLICT:         Ignore
FREQUENCY:        immediate
QUEUE SIZE:       0
PARTICIPANT:      test pravin.tab1
OPTIONS:          transaction,fullrow
REPLTYPE:         Master


Enterprise Replication features dependent on master replicates

The following new features for Version 10.0 require using master replicates:

  • Performing alter operations on replicated tables

    To support online schema changes (SQL alter operations) to a table that is undergoing replication, use master replicates. If necessary, change a classic replicate to a master replicate using the re-mastering process, described below. For more information about alter support in Version 10.0, see Performing Alter Operations on Replicated Tables in the Informix Dynamic Server Information Center.

  • Templates

    Templates provide a means of simplified large scale Enterprise Replication administration. Templates use master replicates internally. Master replicates provide the template the capability to do complete database replication including automatic creation of tables on target nodes. For more information, see Using Templates to Set up Replication in the Informix Dynamic Server Information Center.

  • Resynchronizing data using shadow replicates

    Repairing out-of-sync replicates can be performed even with classic replicates. This feature internally defines four different shadow replicates that are used to perform the repair process. These shadow replicates, however, are master replicates. For more information about resynchronization, see Resynchronizing Data Among Replication Servers in the Informix Dynamic Server Information Center.


Benefits of using master replicates

The primary benefits of using master replicates are that they:

  • Ensure data integrity by verifying that all participants in the replicate have table and replicated column attributes that match the master replicate definition.
  • Provide automatic table generation on participants that do not already contain the table specified in the master replicate. However, Enterprise Replication cannot create tables with user-defined data types unless the UDTs already exist on all source and target nodes.
  • Allow alter operations on the replicated tables
  • Provide the basis for templates
  • Provide the basis for future development of Enterprise Replication functionality that requires schema consistency

Caveats to using master replicates

Master replicates have the following restrictions that are not applicable to classic replicates:

  • Direct connections are required between all the nodes where master replicates are being defined. Enterprise Replication must connect to each of the servers directly to process the master schema verification and optional table creation. Therefore, in the sqlhosts file, entries for all the nodes need to be present.
  • Master replicates require all server participants to be running, because during definition the master and local dictionaries for the replicate tables are checked for consistency.
  • You cannot configure a leaf node as the master node because it does not have direct access to all the nodes other than its non-root server.

Shadow replicates

A shadow replicate is a copy of an existing, or primary, replicate. Enterprise Replication uses shadow replicates to manage alter and repair operations on replicated tables. Shadow replicates are present in the system for fairly short intervals and are deleted when no longer needed. You must create a shadow replicate to perform a transform a classic replicate to a master replicate. For information on how you can remaster a replicate, see Remastering a Replicate in the Informix Dynamic Server Information Center. After creating the shadow replicate, the next step in manual re-mastering is to switch the primary replicate and the shadow replicate using the cdr swap shadow command.

Create a shadow replicate using the cdr define replicate command with the --mirrors option, as described in cdr define replicate. When you define a shadow replicate, its state is always set to the same state as the primary replicate. If you change the state of the primary replicate, all its shadow replicates' states are also changed to the same state.

For more detailed information, see Defining Shadow Replicates in the Informix Dynamic Server Information Center.


Transforming classic replicates to master replicates

You can use the new cdr remaster command to transform an existing classic replicate to a master replicate. This is a recommended procedure, so that you can benefit from new Version 10.0 features.

For example, suppose you create a logged database and table:

>dbaccess - -
create database test with log;
create table tab1 (c1 integer primary key, c2 integer) with crcols;

Then you define the classic replicate:

>cdr define repl rep1 -C "ignore" "test@g_pkcdr1:pravin.tab1" "select * from tab1" 
"test@g_pkcdr2:pravin.tab1" "select * from tab1"
>cdr start rep rep1

Now you can change this classic replicate to a master replicate using the following command (you could have specified the list of columns in the SELECT statement to be replicated):

>cdr remaster -M g_pkcdr1 rep1 "select * from tab1"

The re-mastering internally creates a shadow replicate, Shadow_4_rep1_GMT1113917066_GID100_PID26153, that keeps track of the older classic replicate definition and then renames the new master replicate to the original replicate name. While the shadow replicate exists, you can see it with the cdr list repl command:

>cdr list repl

CURRENTLY DEFINED REPLICATES
-------------------------------
REPLICATE:        Shadow_4_rep1_GMT1113917066_GID100_PID26153
STATE:            Active ON:pkcdr2
CONFLICT:         Ignore
FREQUENCY:        immediate
QUEUE SIZE:       0
PARTICIPANT:      test:pravin.tab1
OPTIONS:          transaction,fullrow
REPLTYPE:         Shadow
PARENT REPLICATE: rep1

REPLICATE:        rep1
STATE:            Active ON:pkcdr2
CONFLICT:         Ignore
FREQUENCY:        immediate
QUEUE SIZE:       0
PARTICIPANT:      test:pravin.tab1
OPTIONS:          transaction,fullrow
REPLTYPE:         Master


After the log records pertaining to older schema no longer exist in the system, the shadow replicate is automatically deleted and system only has new master replicates.


Resources

About the author

Pravin Kedia is a software developer who has been working on IBM Informix database servers and tools for several years. He has been involved in the development of the described Enterprise Replication features for the Dynamic Server Version 10.0 release.

Comments (Undergoing maintenance)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Information Management
ArticleID=83924
ArticleTitle=Using Master Replicates with Enterprise Replication
publish-date=05262005
author1-email=kedia@us.ibm.com
author1-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Special offers