CREATE REPLICATION
This statement is not supported in TimesTen Scaleout.
In TimesTen Classic:
The CREATE REPLICATION
statement:
-
Defines a classic replication scheme on a participating database.
-
Installs the specified configuration in the executing database's replication system tables.
-
Typically consists of one or more replication element specifications and zero or more
STORE
specifications.
TimesTen SQL configuration for replication also provides a programmable way to configure a classic replication scheme. The configuration can be embedded in C, C++ or Java code. Replication can be configured locally or from remote systems using client/server.
In addition, you need to use the ttRepAdmin
utility to maintain operations not covered by the supported SQL statements. Use ttRepAdmin
to change replication state, duplicate databases, list the replication configuration, and view replication status.
Required Privilege
ADMIN
Usage with TimesTen Scaleout
This statement is not supported with TimesTen Scaleout.
Definitions
A replication element is an entity that TimesTen synchronizes between databases. A replication element can be a whole table or a database. A database can include most types of tables and sequences. It can include only specified tables and sequences, or include all tables except specified tables and sequences. It cannot include temporary tables or views, whether materialized or nonmaterialized.
A replication scheme is a set of replication elements, as well as the databases that maintain copies of these elements.
For more detailed information on SQL configuration for classic replication, see Defining a Classic Replication Scheme in the Oracle TimesTen In-Memory Database Replication Guide.
SQL Syntax
CREATE REPLICATION [Owner.]ReplicationSchemeName { ELEMENT ElementName { DATASTORE | { TABLE [Owner.]TableName [CheckConflicts]} | SEQUENCE [Owner.]SequenceName} { MASTER | PROPAGATOR } FullStoreName [TRANSMIT { NONDURABLE | DURABLE }] { SUBSCRIBER FullStoreName [,...] [ReturnServiceAttribute] } [,...] } [...] [{INCLUDE | EXCLUDE} {TABLE [[Owner.]TableName[,...]] | SEQUENCE [[Owner.]SequenceName[,...]} [,...]] [ STORE FullStoreName [StoreAttribute [... ]]] [...] [ NetworkOperation[...]]
See CHECK CONFLICTS for CheckConflicts
syntax.
Syntax for ReturnServiceAttribute
:
{ RETURN RECEIPT [BY REQUEST] | RETURN TWOSAFE [BY REQUEST] | NO RETURN }
Syntax for StoreAttribute
:
DISABLE RETURN {SUBSCRIBER | ALL} NumFailures RETURN SERVICES {ON | OFF} WHEN [REPLICATION] STOPPED DURABLE COMMIT {ON | OFF} RESUME RETURN Milliseconds LOCAL COMMIT ACTION {NO ACTION | COMMIT} RETURN WAIT TIME Seconds COMPRESS TRAFFIC {ON | OFF} PORT PortNumber TIMEOUT Seconds FAILTHRESHOLD Value CONFLICT REPORTING SUSPEND AT Value CONFLICT REPORTING RESUME AT Value TABLE DEFINITION CHECKING {RELAXED|EXACT}
Syntax for NetworkOperation
:
ROUTE MASTER FullStoreName SUBSCRIBER FullStoreName { { MASTERIP MasterHost | SUBSCRIBERIP SubscriberHost } PRIORITY Priority } [...]
Parameters
Parameter | Description |
---|---|
|
Name assigned to the new classic replication scheme. Classic replication schemes should have names that are unique from all other database objects. |
|
Check for replication conflicts when simultaneously writing to bidirectionally replicated databases. See CHECK CONFLICTS for information on |
|
Compress replicated traffic to reduce the amount of network bandwidth. |
|
Suspends conflict resolution reporting.
This clause is valid for table level replication. |
|
Resumes conflict resolution reporting.
This clause is valid for table level replication. |
|
Define entire database as element. This type of element can only be defined for a master database that is not configured with an element of type |
|
|
|
Set the return service failure policy so that return service blocking is disabled after the number of timeouts specified by If |
|
Overrides the |
|
The entity that TimesTen synchronizes between databases. TimesTen supports the entire database (
See Defining Replication Elements in Oracle TimesTen In-Memory Database Replication Guide for details. |
|
The number of log files that can accumulate for a subscriber database. If this value is exceeded, the subscriber is set to the See Setting the Transaction Log Failure Threshold in Oracle TimesTen In-Memory Database Replication Guide. |
|
The database, specified as one of the following:
For example, if the database path is This is the database file name specified in the
|
|
Specifies the default action to be taken for a return twosafe transaction in the event of a timeout. Note: This attribute is only valid when the
This setting can be overridden for specific transactions by calling the |
|
The database on which applications update the specified element. The |
|
Specifies that no return service is to be used. This is the default. For details on the use of the return services, see Using a Return Service in Oracle TimesTen In-Memory Database Replication Guide. |
|
The TCP/IP port number on which the replication agent for the database listens for connections. If not specified, the replication agent automatically allocates a port number. |
|
The database that receives replicated updates and passes them on to other databases. The |
|
If return service blocking has been disabled by If |
|
Enables the return receipt service, so that applications that commit a transaction to a master database are blocked until the transaction is received by all subscribers.
|
|
Sets return services on or off when replication is disabled (stopped or paused state).
|
|
Enables the return twosafe service, so that applications that commit a transaction to a master database are blocked until the transaction is committed on all subscribers. Note: This service can only be used in a bidirectional replication scheme where the elements are defined as Specifying |
|
Specifies the number of seconds to wait for return service acknowledgment. The default value is 10 seconds. A value of 0 (zero) means that there is no timeout. Your application can override this timeout setting by calling the |
|
Define the sequence specified by |
|
Defines the attributes for a given database. Attributes include |
|
A database that receives updates from the |
|
Define the table specified by |
|
The maximum number of seconds the replication agent waits for a response from remote replication agents. The default is 120 seconds. Note: For large transactions that may cause a delayed response from the remote replication agent, the agent scales the timeout based on the size of the transaction. This scaling is disabled if you set |
|
Specifies whether to flush the master log to the file system before sending a batch of committed transactions to the subscribers.
Note: Note: See Setting Transmit Durability on DATASTORE Element in Oracle TimesTen In-Memory Database Replication Guide for more information. |
|
Specifies type of table definition checking that occurs on the subscriber:
The default is Note: If you use |
|
Denotes the Can be specified more than once. For |
|
Clause can be specified more than once. |
|
Variable expressed as an integer from 1 to 99. Denotes the priority of the IP address. Lower integral values have higher priority. An error is returned if multiple addresses with the same priority are specified. Controls the order in which multiple IP addresses are used to establish peer connections. Required syntax of |
CHECK CONFLICTS
Syntax
The syntax for CHECK CONFLICTS
is:
{NO CHECK | CHECK CONFLICTS BY ROW TIMESTAMP COLUMN ColumnName [ UPDATE BY { SYSTEM | USER } ] [ ON EXCEPTION { ROLLBACK [ WORK ] | NO ACTION } ] [ {REPORT TO 'FileName' [ FORMAT { XML | STANDARD } ] | NO REPORT } ] }
Note:
A CHECK CONFLICT
clause can only be used for elements of type TABLE
.
Parameters
The CHECK CONFLICTS
clause of the CREATE REPLICATION
or ALTER REPLICATION
statement has the following parameters:
Parameter | Description |
---|---|
|
Indicates that all update and uniqueness conflicts are to be detected. Conflicts are resolved in the manner specified by the It also detects delete conflicts with |
|
Indicates the column in the replicated table to be used for timestamp comparison. The table is specified in the
|
|
Specify to suppress conflict resolution for a given element. |
|
Specifies whether the timestamp values are maintained by TimesTen ( |
|
Specifies how to resolve a detected conflict.
The default is |
|
Specifies the file to log updates that fail the timestamp comparison. |
|
Optionally specifies the conflict report format for an element. The default format is |
|
Specify to suppress logging of failed timestamp comparisons. |
Description
-
The names of all databases on the same host must be unique for each classic replication scheme for each TimesTen instance.
-
Replication elements can only be updated (by normal application transactions) through the
MASTER
database.PROPAGATOR
andSUBSCRIBER
databases are read-only. -
If you define a classic replication scheme that permits multiple databases to update the same table, see Resolving Replication Conflicts in Oracle TimesTen In-Memory Database Replication Guide for recommendations on how to avoid conflicts when updating rows.
-
SELF
is intended for classic replication schemes where all participating databases are local. Do not useSELF
for a distributed classic replication scheme in a production environment, where spelling out the host name for each database in a script enables it to be used at each participating database. -
Each attribute for a given
STORE
may be specified only once, or not at all. -
Specifying the
PORT
of a database for one classic replication scheme specifies it for all classic replication schemes. All other connection attributes are specific to the classic replication scheme specified in the command. -
For replication schemes,
DataStoreName
is always the prefix of the TimesTen database checkpoint file names. These are the files with the.ds0
and.ds1
suffixes that are saved on the file system by checkpoint operations. -
If a row with a default
NOT INLINE VARCHAR
value is replicated, the receiver creates a copy of this value for each row instead of pointing to the default value if and only if the default value of the receiving node is different from the sending node. -
To use timestamp comparison on replicated tables, you must specify a nullable column of type
BINARY(8)
to hold the timestamp value. Define the timestamp column when you create the table. You cannot add the timestamp column with theALTER TABLE
statement. In addition, the timestamp column cannot be part of a primary key or index. -
If you specify the XML report format, two XML documents are generated:
-
FileName
.xml
: This file contains the DTD for the report and the root node for the report. It includes the document definition and the include directive. -
FileName
.include
: This file is included inFileName
.xml
and contains all the actual conflicts. -
The
FileName
.include
file can be truncated. Do not truncate theFileName
.xml
file. -
For a complete description of the XML format, including examples of each conflict, see Reporting Conflicts to an XML File in Oracle TimesTen In-Memory Database Replication Guide.
-
-
If you specify a report format for an element and then drop the element, the corresponding report files are not deleted.
-
Use the
CONFLICT REPORTING SUSPEND AT
clause to specify a high water mark threshold at which the reporting of conflict resolution is suspended. -
Use the
CONFLICT REPORTING RESUME AT
clause to specify a low water mark threshold where the reporting of conflict resolution is resumed. When the rate of conflict falls below the low water mark threshold, conflict resolution reporting is resumed. -
The state of whether conflict reporting is suspended or not by a replication agent does not persist across the local replication agent and the peer agent stop and restart.
-
Do not use the
CREATE REPLICATION
statement to replicate cache groups. Only active standby pairs can replicate cache groups. See theCREATE ACTIVE STANDBY PAIR
statement.
Examples
Replicate the contents of repl.tab
from masterds
to two subscribers, subscriber1ds
and subscriber2ds
.
CREATE REPLICATION repl.twosubscribers ELEMENT e TABLE repl.tab MASTER masterds ON "server1" SUBSCRIBER subscriber1ds ON "server2", subscriber2ds ON "server3";
Replicate the entire masterds
database to the subscriber, subscriber1ds
. The FAILTHRESHOLD
specifies that a maximum of 10 log files can accumulate on masterds
before it decides that subscriber1ds
has failed.
CREATE REPLICATION repl.wholestore ELEMENT e DATASTORE MASTER masterds ON "server1" SUBSCRIBER subscriber1ds ON "server2" STORE masterds FAILTHRESHOLD 10;
Bidirectionally replicate the entire westds
and eastds
databases and enable the RETURN TWOSAFE
service.
CREATE REPLICATION repl.biwholestore ELEMENT e1 DATASTORE MASTER westds ON "westcoast" SUBSCRIBER eastds ON "eastcoast" RETURN TWOSAFE ELEMENT e2 DATASTORE MASTER eastds ON "eastcoast" SUBSCRIBER westds ON "westcoast" RETURN TWOSAFE;
Enable the return receipt service for select transaction updates to the subscriber1ds
subscriber.
CREATE REPLICATION repl.twosubscribers ELEMENT e TABLE repl.tab MASTER masterds ON "server1" SUBSCRIBER subscriber1ds ON "server2" RETURN RECEIPT BY REQUEST SUBSCRIBER subscriber2ds ON "server3";
Replicate the contents of the customerswest
table from the west
database to the ROUNDUP
database and the customerseast
table from the east
database. Enable the return receipt service for all transactions.
CREATE REPLICATION r ELEMENT west TABLE customerswest MASTER west ON "serverwest" SUBSCRIBER roundup ON "serverroundup" RETURN RECEIPT ELEMENT east TABLE customerseast MASTER east ON "servereast" SUBSCRIBER roundup ON "serverroundup" RETURN RECEIPT;
Replicate the contents of the repl.tab
table from the centralds
database to the propds
database, which propagates the changes to the backup1ds
and backup2ds
databases.
CREATE REPLICATION repl.propagator ELEMENT a TABLE repl.tab MASTER centralds ON "finance" SUBSCRIBER proprds ON "nethandler" ELEMENT b TABLE repl.tab PROPAGATOR proprds ON "nethandler" SUBSCRIBER backup1ds ON "backupsystem1" bakcup2ds ON "backupsystem2";
Bidirectionally replicate the contents of the repl.accounts
table between the eastds
and westds
databases. Each database is both a master and a subscriber for the repl.accounts
table.
Because the repl.accounts
table can be updated on either the eastds
or westds
database, it includes a timestamp column (tstamp
). The CHECK CONFLICTS
clause establishes automatic timestamp comparison to detect any update conflicts between the two databases. In the event of a comparison failure, the entire transaction that includes an update with the older timestamp is rolled back (discarded).
CREATE REPLICATION repl.r1 ELEMENT elem_accounts_1 TABLE repl.accounts CHECK CONFLICTS BY ROW TIMESTAMP COLUMN tstamp UPDATE BY SYSTEM ON EXCEPTION ROLLBACK MASTER westds ON "westcoast" SUBSCRIBER eastds ON "eastcoast" ELEMENT elem_accounts_2 TABLE repl.accounts CHECK CONFLICTS BY ROW TIMESTAMP COLUMN tstamp UPDATE BY SYSTEM ON EXCEPTION ROLLBACK MASTER eastds ON "eastcoast" SUBSCRIBER westds ON "westcoast";
Replicate the contents of the repl.accounts
table from the activeds
database to the backupds
database, using the return twosafe service, and using TCP/IP port 40000 on activeds
and TCP/IP port 40001 on backupds
. The transactions on activeds
need to be committed whenever possible, so configure replication so that the transaction is committed even after a replication timeout using LOCAL COMMIT
ACTION
, and so that the return twosafe service is disabled when replication is stopped. To avoid significant delays in the application if the connection to the backupds
database is interrupted, configure the return service to be disabled after five transactions have timed out, but also configure the return service to be re-enabled when the backupds
database's replication agent responds in under 100 milliseconds. Finally, the bandwidth between databases is limited, so configure replication to compress the data when it is replicated from the activeds
database.
CREATE REPLICATION repl.r ELEMENT elem_accounts_1 TABLE repl.accounts MASTER activeds ON "active" SUBSCRIBER backupds ON "backup" RETURN TWOSAFE ELEMENT elem_accounts_2 TABLE repl.accounts MASTER activeds ON "active" SUBSCRIBER backupds ON "backup" RETURN TWOSAFE STORE activeds ON "active" PORT 40000 LOCAL COMMIT ACTION COMMIT RETURN SERVICES OFF WHEN REPLICATION STOPPED DISABLE RETURN SUBSCRIBER 5 RESUME RETURN 100 COMPRESS TRAFFIC ON STORE backupds ON "backup" PORT 40001;
Illustrate conflict reporting suspend and conflict reporting resume clauses for table level replication. Use these clauses for table level replication not database replication. Issue repschemes
command to show that replication scheme is created.
Command> CREATE TABLE repl.accounts (tstamp BINARY (8) NOT NULL PRIMARY KEY, tstamp1 BINARY (8)); Command> CREATE REPLICATION repl.r2 ELEMENT elem_accounts_1 TABLE repl.accounts CHECK CONFLICTS BY ROW TIMESTAMP COLUMN tstamp1 UPDATE BY SYSTEM ON EXCEPTION ROLLBACK WORK MASTER westds ON "west1" SUBSCRIBER eastds ON "east1" ELEMENT elem_accounts_2 TABLE repl.accounts CHECK CONFLICTS BY ROW TIMESTAMP COLUMN tstamp1 UPDATE BY SYSTEM ON EXCEPTION ROLLBACK WORK MASTER eastds ON "east1" SUBSCRIBER westds ON "west1" STORE westds CONFLICT REPORTING SUSPEND AT 20 CONFLICT REPORTING RESUME AT 10; Command> REPSCHEMES; Replication Scheme REPL.R2: Element: ELEM_ACCOUNTS_1 Type: Table REPL.ACCOUNTS Conflict Check Column: TSTAMP1 Conflict Exception Action: Rollback Work Conflict Timestamp Update: System Conflict Report File: (none) Master Store: WESTDS on WEST1 Transmit Durable Subscriber Store: EASTDS on EAST1 Element: ELEM_ACCOUNTS_2 Type: Table REPL.ACCOUNTS Conflict Check Column: TSTAMP1 Conflict Exception Action: Rollback Work Conflict Timestamp Update: System Conflict Report File: (none) Master Store: EASTDS on EAST1 Transmit Durable Subscriber Store: WESTDS on WEST1 Store: EASTDS on EAST1 Port: (auto) Log Fail Threshold: (none) Retry Timeout: 120 seconds Compress Traffic: Disabled Store: WESTDS on WEST1 Port: (auto) Log Fail Threshold: (none) Retry Timeout: 120 seconds Compress Traffic: Disabled Conflict Reporting Suspend: 20 Conflict Reporting Resume: 10 1 replication scheme found.
Example of NetworkOperation
clause with 2 MASTERIP
and SUBSCRIBERIP
clauses:
CREATE REPLICATION r ELEMENT e DATASTORE MASTER rep1 SUBSCRIBER rep2 RETURN RECEIPT MASTERIP "1.1.1.1" PRIORITY 1 SUBSCRIBERIP "2.2.2.2" PRIORITY 1 MASTERIP "3.3.3.3" PRIORITY 2 SUBSCRIBERIP "4.4.4.4" PRIORITY 2;
Example of NetworkOperation
clause. Use the default sending interface but a specific receiving network:
CREATE REPLICATION r ELEMENT e DATASTORE MASTER rep1 SUBSCRIBER rep2 ROUTE MASTER rep1 ON "machine1" SUBSCRIBER rep2 ON "machine2" SUBSCRIBERIP "rep2nic2" PRIORITY 1;
Example of using the NetworkOperation
clause with multiple subscribers:
CREATE REPLICATION r ELEMENT e DATASTORE MASTER rep1 SUBSCRIBER rep2,rep3 ROUTE MASTER rep1 ON "machine1" SUBSCRIBER rep2 ON "machine2" MASTERIP "1.1.1.1" PRIORITY 1 SUBSCRIBERIP "2.2.2.2" PRIORITY 1 ROUTE MASTER Rep1 ON "machine1" SUBSCRIBER Rep3 ON "machine2" MASTERIP "3.3.3.3" PRIORITY 2 SUBSCRIBERIP "4.4.4.4";