Skip Headers
Oracle® TimesTen In-Memory Database Replication Guide
11g Release 2 (11.2.2)

E21635-07
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
PDF · Mobi · ePub

7 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. In addition, these statements are replicated to the standby master.

  • Create, alter, or drop a user with the CREATE USER, ALTER USER, and DROP USER statements.

  • Grant or revoke privileges from a user with the GRANT and REVOKE statements.

  • Alter a table to add or drop a column with the ALTER TABLE ... ADD COLUMN or ALTER TABLE ... DROP COLUMN statements. These are the only ALTER TABLE clauses that are replicated.

  • Create or drop a table, including global temporary tables with the CREATE TABLE and DROP TABLE statements. The new table is also included in the active standby pair.

  • Create or drop a synonym with the CREATE SYNONYM and DROP SYNONYM statements.

  • Create or drop an index with the CREATE INDEX and DROP INDEX statements.

You can perform the following tasks in an active standby pair only after stopping the replication agent. These statements are not replicated to the standby master, so you must execute these statements on all nodes after the replication agents are stopped. After execution, restart the replication agents.

  • The DDL statements for creating, dropping, or altering a materialized view.

You can perform the following tasks in an active standby pair without stopping the replication agent. However, these statements are not replicated to the standby master, so you must manually execute each statement on active, standby, and subscriber nodes in the replication scheme.

  • Create or drop a view, a PL/SQL function, PL/SQL procedure, PL/SQL package, or PL/SQL package body. You do not need to stop the replication agents for these objects. See "Creating a new PL/SQL object in an existing active standby pair" for more information on PL/SQL objects.

  • Any other DDL statements that are not replicated (except for materialized views).

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

DDLReplicationLevel can be set as follows:

  • DDLReplicationLevel=1. CREATE or DROP statements for tables, indexes, or synonyms are not replicated to the standby database. However, you can add to or drop columns from a replicated table, and those actions are replicated to the standby database.

  • DDLReplicationLevel=2 is the default, which enables replication of creating and dropping of tables, indexes, and synonyms.

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

ALTER SESSION SET ddl_replication_level=1;

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.

Creating a new PL/SQL object in an existing active standby pair

To add a new PL/SQL procedure, package, package body or function to an existing active standby pair, complete these tasks:

  1. Create the PL/SQL object on the active database. The CREATE statement is not replicated to the standby database.

  2. Create the PL/SQL object on the standby database.

  3. Grant privileges to the new PL/SQL object on the active database. The GRANT statement is replicated to the standby database.

Restrictions on making DDL changes in an active standby pair

  • CREATE TABLE ... AS SELECT, ALTER TABLE ... ADD CONSTRAINT, ALTER TABLE ... ADD UNIQUE and ALTER TABLE ... MODIFY statements are not replicated.

  • The CREATE INDEX statement is replicated only when the index is created on an empty table. To create a new index on populated tables, set DDLReplicationLevel to a value less than 2 and create the index manually on both the active and standby.

  • These statements cannot be executed on the standby database when DDLReplicationLevel=2:

    • CREATE USER, ALTER USER, DROP USER

    • GRANT, REVOKE

    • CREATE SYNONYM, DROP SYNONYM

Examples: Making DDL changes in an active standby pair

Example 7-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 7-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 7-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 7-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:

  • Include or exclude a sequence.

  • Include or exclude a cache group.

  • Add or drop a subscriber.

  • Change values in the STORE clause.

  • Change network operations (ADD ROUTE or DROP ROUTE clause).

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 "Duplicating 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 7-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 7-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 7-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 7-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;