TimesTen 数据库复制学习:6. 利用STORE关键字设定复制网络传输的属性

利用STORE关键字,可以在CREATE ACTIVE STANDBY PAIR, ALTER ACTIVE STANDBY PAIR, CREATE REPLICATION, 和 ALTER REPLICATION 设置复制的属性,如超时,压缩,commit行为,表定义检查,return service,对于classic复制,还可以设置表一级的数据冲突

设定return service的超时

缺省的超时为10秒,可用RETURN WAIT TIME设定超时,例如:

Command> ALTER ACTIVE STANDBY PAIR
 > ALTER STORE master1 SET RETURN WAIT TIME 25;

当然,在应用中也可以用ttRepSyncSet达到同样效果:

Command> CALL ttRepSyncSet (0x01, 25, 1);

将超时恢复为缺省:

Command> CALL ttRepSyncSet(NULL, 45, NULL);

以下是classic复制中一个双向复制的例子:

CREATE REPLICATION bidirect
ELEMENT a DATASTORE
    MASTER databaseA ON "system1"
    SUBSCRIBER databaseB ON "system2"
      RETURN TWOSAFE
ELEMENT b DATASTORE
    MASTER databaseB ON "system2"
    SUBSCRIBER databaseA ON "system1"
      RETURN TWOSAFE
STORE databaseA RETURN WAIT TIME 30
STORE databaseB RETURN WAIT TIME 30;

DISABLE RETURN

DISABLE RETURN设定当复制的错误达到一定阈值时,停止return service

Command> ALTER ACTIVE STANDBY PAIR
 > ALTER STORE master1 SET DISABLE RETURN ALL 10;

RESUME RETURN

当从commit到acknowledge的时间小于RESUME RETURN设定的值时(milliseconds),恢复return service,例如:

Command> CREATE ACTIVE STANDBY PAIR 
 > master1, 
 > master2 
 > RETURN RECEIPT
 > STORE master1
 > DISABLE RETURN ALL 5
 > RESUME RETURN 8;

RETURN SERVICES {ON | OFF} WHEN [REPLICATION] STOPPED

当复制停止时,设定是继续保持return service打开还是关闭return service。
无论如何,都不会影响通讯恢复后,数据的同步

DURABLE COMMIT

一般在return service被DISABLE RETURN掉后,可以设置DURABLE COMMIT以保证数据不丢失。例如:

Command> CREATE ACTIVE STANDBY PAIR 
 > master1, 
 > master2 
 > RETURN RECEIPT
 > STORE master1
 > DISABLE RETURN ALL 5
 > DURABLE COMMIT ON
 > RESUME RETURN 8;

LOCAL COMMIT ACTION

只对TWOSAFE有效,可以设置为缺省的 NO ACTION或本地提交:COMMIT

 复制表的列定义

参与复制的表的列定义可以不必完全一致,指的是列的顺序,物理定义可以不一致(通过alter table增加列达到一致的定义),但列名,列数据类型,key定义必须一致。
如果TABLE DEFINITION CHECKING设为EXACT,则必须完全一致;如果设置为RELAX,则可以不一致。
EXACT的性能比RELAX性能更好,并且是缺省的设置。
用处不大,略过。

复制压缩

只对STORE中指定的数据库发出的数据流进行压缩,例如:

CREATE ACTIVE STANDBY PAIR dsn1 ON "host1", dsn2 ON "host2" SUBSCRIBER dsn3 ON "host3" STORE dsn1 ON "host1" COMPRESS TRAFFIC ON;

CREATE ACTIVE STANDBY PAIR dsn1 ON "host1", dsn2 ON "host2" SUBSCRIBER dsn3 ON "host3" STORE dsn1 ON "host1" COMPRESS TRAFFIC ON STORE dsn2 ON "host2" COMPRESS TRAFFIC ON;

端口设置

使用PORT设定侦听从对方传来的更新的端口,缺省是动态分配的。

设定从远端复制代理的等待超时

缺省的超时为120秒。推荐使用。略过

设定transaction log错误阈值

缺省是0,表示没有限制。

You can establish a threshold value that, when exceeded, sets an unavailable database to the failed state before the available transaction log space is exhausted

看来与日志空间有关
少用,略过

配置网络

网络带宽的需求与数据更新的频率与量有关。

Transactions are sent between replicated databases in batches. A batch is created whenever there is no more data in the transaction log buffer in the master database, or when the current batch is roughly 256 KB.
这句说的应该是异步模式

复制使用的TCP/IP协议
在复制中,必须指定主机名,操作系统将主机名转换为1个或多个IP 地址。

When specifying the host for a database in a replication element, you should always use the name returned by the hostname command, as replication uses the same host name to verify that the current host is involved in the replication scheme. Replication schemes may not be created that do not include the current host.

若主机有多个网络接口,可以用ROUTE 来指定复制用接口。通过IP地址指定
设定不同的网络端口,一是为了负载均衡,二则可用来做错误切换。
以下是一个错误切换的例子,当PRIORITY 1的一对接口失效时,可以用作为备份的PRIORITY 2接口来接管:

CREATE ACTIVE STANDBY PAIR dns1, dns2 ROUTE MASTER dsn1 ON "host1" SUBSCRIBER dsn2 ON "host2" MASTERIP "192.168.1.100" PRIORITY 1 MASTERIP "192.168.1.101" PRIORITY 2 SUBSCRIBERIP "192.168.1.200" PRIORITY 1 SUBSCRIBERIP "192.168.1.201" PRIORITY 2;

你可能感兴趣的:(timesten,数据库复制)