Skip Headers
Oracle® TimesTen In-Memory Database TimesTen to TimesTen Replication Guide
Release 11.2.1

Part Number E13072-14
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

6 Altering an Active Standby Pair

This chapter includes the following sections:

Making DDL changes in an active standby pair

You can perform the following tasks in an active standby pair without stopping the replication agent:

Use the DDLReplicationLevel and DDLReplicationAction connection attributes to control what happens when you want to perform these tasks.

DDLReplicationLevel can be set as follows:

You can set the DDLReplicationLevel attribute by using the ALTER SESSION statement:

ALTER SESSION SET ddl_replication_level=2;

If you want to include a table in the active standby pair when the table is created, set the DDLReplicationAction connection attribute to 'INCLUDE'. If you do not want to include a table in the active standby pair when the table is created, set DDLReplicationAction='EXCLUDE'. The default is 'INCLUDE'.

You can set the DDLReplicationAction attribute by using the ALTER SESSION statement:

ALTER SESSION SET ddl_replication_action='EXCLUDE';

To add an existing table to an active standby pair, set DDLReplicationLevel=2 and use the ALTER ACTIVE STANDBY PAIR INCLUDE TABLE statement. The table must be empty.

When DDLCommitBehavior=0 (the default), DDL operations are automatically committed. When RETURN TWOSAFE has been specified, errors and timeouts may occur as described in "RETURN TWOSAFE". If a RETURN TWOSAFE timeout occurs, the DDL transaction is committed locally regardless of the LOCAL COMMIT ACTION that has been specified.

Restrictions on making DDL changes in an active standby pair

  • CREATE TABLE AS SELECT is not replicated.

  • The CREATE INDEX statement is replicated only when the index is created on an empty table.

Examples: Making DDL changes in an active standby pair

Example 6-1 Create a table and include it in the active standby pair

On the active database, set DDLReplicationLevel to 2 and DDLReplicationAction to 'INCLUDE'.

Command > ALTER SESSION SET ddl_replication_level=2;
Session altered.
Command > ALTER SESSION SET ddl_replication_action='INCLUDE';
Session altered.

Create a table. The table must have a primary key or index.

Command > CREATE TABLE tabinclude (col1 NUMBER NOT NULL PRIMARY KEY);
Table created.

Insert a row into tabinclude.

Command > INSERT INTO tabinclude VALUES (55);
1 row inserted.

On the standby database, verify that the INSERT statement has been replicated. This indicates that the tabinclude table has been included in the active standby pair.

Command > SELECT * FROM tabinclude;
< 55 >
1 row found.

Alternatively, use the ttIsql repschemes command to see what tables are included in the active standby pair.

Example 6-2 Create a table and add it to the active standby pair later

On the active database, set DDLReplicationLevel to 2 and DDLReplicationAction to 'EXCLUDE'.

Command> ALTER SESSION SET ddl_replication_level=2;
Session altered.
Command> ALTER SESSION SET ddl_replication_action='exclude';
Session altered.

Create a table that does not have a primary key or index. Try to include it in the active standby pair.

Command> CREATE TABLE newtab (a NUMBER NOT NULL);
Command> ALTER ACTIVE STANDBY PAIR INCLUDE TABLE newtab;
 8000: No primary or unique index on non-nullable column found for replicated 
 table TERRY.NEWTAB
The command failed.

Create an index on the table. Include the table in the active standby pair.

Command> CREATE UNIQUE INDEX ixnewtab ON newtab(a);
Command> ALTER ACTIVE STANDBY PAIR INCLUDE TABLE newtab;

Insert a row into the table.

Command> INSERT INTO newtab VALUES (5);
1 row inserted.

On the standby database, verify that the row was inserted.

Command> SELECT * FROM newtab;
< 5 >
1 row found.

This example illustrates that a table does not need a primary key to be part of an active standby pair.

Example 6-3 CREATE INDEX is replicated

On the active database, set DDLReplicationLevel=2 and DDLReplicationAction='INCLUDE'.

Command> ALTER SESSION SET ddl_replication_level=2;
Session altered.
Command> ALTER SESSION SET ddl_replication_action='include';
Session altered.

Create a table with a primary key. The table is automatically included in the active standby pair.

Command> CREATE TABLE tab2 (a NUMBER NOT NULL, b NUMBER NOT NULL, 
       > PRIMARY KEY (a));

Create an index on the table.

Command> CREATE UNIQUE INDEX ixtab2 ON tab2 (b);

On the standby database, verify that the CREATE INDEX statement has been replicated.

Command> indexes;
 
Indexes on table TERRY.TAB2:
  IXTAB2: unique T-tree index on columns:
    B
  TAB2: unique T-tree index on columns:
    A
  2 indexes found.
 
Indexes on table TERRY.NEWTAB:
  NEWTAB: unique T-tree index on columns:
    A
  1 index found.
 
Indexes on table TERRY.TABINCLUDE:
  TABINCLUDE: unique T-tree index on columns:
    A
  1 index found.
4 indexes found on 3 tables.

Example 6-4 CREATE SYNONYM is replicated

On the active database, set DDLReplicationLevel to 2 and DDLReplicationAction to 'INCLUDE'.

Command > ALTER SESSION SET ddl_replication_level=2;
Session altered.
Command > ALTER SESSION SET ddl_replication_action='INCLUDE';
Session altered.

Create a synonym for tabinclude.

Command> CREATE SYNONYM syntabinclude FOR tabinclude;
Synonym created.

On the standby database, use the ttIsql synonyms command to verify that the CREATE SYNONYM statement has been replicated.

Command> synonyms;
TERRY.SYNTABINCLUDE
1 synonym found.

Making other changes to an active standby pair

You must stop the replication agent to make these changes to an active standby pair:

To alter an active standby pair according to the preceding list, complete the following tasks:

  1. Stop the replication agent on the active database. See "Starting and stopping the replication agents".

  2. If the active standby pair includes cache groups, stop the cache agent on the active database.

  3. Use the ALTER ACTIVE STANDBY PAIR statement to make changes to the replication scheme. See "Examples: Altering an active standby pair".

  4. Start the replication agent on the active database. See "Starting and stopping the replication agents".

  5. If the active standby pair includes cache groups, start the cache agent on the active database.

  6. Destroy the standby database and the subscribers.

  7. Duplicate the active database to the standby database. You can use either the ttRepAdmin -duplicate utility or the ttRepDuplicateEx C function to duplicate a database. If the active standby pair includes cache groups, use the -keepCG command line option with ttRepAdmin to preserve the cache group. See "Duplicating a database".

  8. Set up the replication agent policy on the standby database and start the replication agent. See "Starting and stopping the replication agents".

  9. Wait for the standby database to enter the STANDBY state. Use the ttRepStateGet procedure to check the state.

  10. If the active standby pair includes cache groups, start the cache agent for the standby database using the ttCacheStart procedure or the ttAdmin -cacheStart utility.

  11. Duplicate all of the subscribers from the standby database. See "Copying a master database to a subscriber". If the active standby pair includes cache groups, use the -noKeepCG command line option with ttRepAdmin in order to convert the cache group to regular TimesTen tables on the subscribers. See "Duplicating a database".

  12. Set up the replication agent policy on the subscribers and start the agent on each of the subscriber databases. See "Starting and stopping the replication agents".

Examples: Altering an active standby pair

Example 6-5 Adding a subscriber to an active standby pair

Add a subscriber database to the active standby pair.

ALTER ACTIVE STANDBY PAIR
  ADD SUBSCRIBER sub1;

Example 6-6 Dropping subscribers from an active standby pair

Drop subscriber databases from the active standby pair.

ALTER ACTIVE STANDBY PAIR
  DROP SUBSCRIBER sub1
  DROP SUBSCRIBER sub2;

Example 6-7 Changing the PORT and TIMEOUT settings for subscribers

Alter the PORT and TIMEOUT settings for subscribers sub1 and sub2.

ALTER ACTIVE STANDBY PAIR
  ALTER STORE sub1 SET PORT 23000 TIMEOUT 180
  ALTER STORE sub2 SET PORT 23000 TIMEOUT 180;

Example 6-8 Adding a cache group to an active standby pair

Add a cache group to the active standby pair.

ALTER ACTIVE STANDBY PAIR
  INCLUDE CACHE GROUP cg0;