您的位置:首页 > 产品设计 > UI/UE

TimesTen_创建序列(sequence)

2015-12-23 21:28 561 查看
    今日,有一个需求要在TimesTen内存数据库新建一个序列,主库和备库为active standby pair ,本以为很简单的一个操作。可是,真正做起来却

并非如你想象的那么简单,容易。以下为具体的测试过程:

---内存库版本

[timesten@orattm1 ~]$ ttversion

TimesTen Release 11.2.1.9.12 (64 bit Linux/x86_64) (tt1121:53388) 2014-06-16T21:37:16Z

  Instance admin: timesten

  Instance home directory: /home/timesten/TimesTen/tt1121

  Group owner: ttusers

  Daemon home directory: /home/timesten/TimesTen/tt1121/info

  PL/SQL enabled.

---主库创建序列

Command> alter session set ddl_replication_level=2;

Session altered.

Command> alter session set ddl_replication_action='EXCLUDE';

Session altered.

Command> create sequence user533.SEQ_REMIND10

       >     increment by 1

       >     minvalue 1

       >     maxvalue 999999999999999999

       >     start with 14201

       >     cache 1000;

 3098: User USER533 does not exist

The command failed.

Command> create sequence timesten.SEQ_REMIND10

       >     increment by 1

       >     minvalue 1

       >     maxvalue 999999999999999999

       >     start with 14201

       >     cache 1000;
Command> alter active standby pair include sequence timesten.SEQ_REMIND10;

---主库查询新建sequence状态

Command> allsequences;

  SYS.OBJECTSEQUENCE

  SYS.OBJECT_GRANT

  SYS.SYSTEM_GRANT

  SYS.USERSEQUENCE 
  TIMESTEN.SEQ_REMIND10

--备库查询新建sequence状态

Command> allsequences;

  SYS.OBJECTSEQUENCE

  SYS.OBJECT_GRANT

  SYS.SYSTEM_GRANT

  SYS.USERSEQUENCE

 备注:未发现新创建的sequence.

--查询官方文档 

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" on page 11-14.

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" on page 6-5.

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

replication agents" on page 11-14.

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" on page 4-2.

8. Set up the replication agent policy on the standby database and start the 

replication agent. See "Starting and stopping the replication agents" on page 11-14.

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" on page 11-8. 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" on page 4-2.

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" on 

page 11-14.

  --备注以上来自官方文件,意思是,必须将主库复制进程停止,创建完序列后,再重建备机操作。

依照以上步骤,汇总一下操作步骤:

1. Stop the replication agent on the active database --主库操作

Command>call ttrepstop;

2.create sequences--主库操作

Command>

create sequence CBEDATA.SEQ_REMIND

    increment by 1

    minvalue 1

    maxvalue 999999999999999999

    start with 14201

    cache 1000;

备注此处创建的sequence 不能采用cycle类型,否则。

3. Use the ALTER ACTIVE STANDBY PAIR statement to make changes  --主库操作

 to the replication scheme

Command> ALTER ACTIVE STANDBY PAIR  include sequence CBEDATA.SEQ_REMIND;

4.Start the replication agent on the active database --主库操作

Command>call ttrepstart;

5.Destroy the standby database and the subscribers  --备库操作

ttdaemonadmin -stop

ttdaemonadmin -start

ttdestroy DSN

6.Duplicate the active database to the standby database. --备库操作

ttrepadmin -duplicate -verbosity 2 -from dsn -host hostname -uid ttha -pwd 'xxxx' -ramload "dsn=xxxx"

 

7.设置启动策略

ttadmin -rampolicy manual -noautoreload cbedata

8.启动复制进程

ttisql -connStr "dsn=cbedata;uid=ttha;pwd=Lw<Bc7&3" -e "call ttrepstart;call ttrepstateget;call ttbookmark;quit;"

通过查询官方资料,发现TimesTen版本为11.2.2.8 以后的可以不用停止复制进程及重建备机便可以很方便的创建sequence;

---内存库版本

[xulq1a@orattm1 ~]$ ttversion

TimesTen Release 11.2.2.8.10 (64 bit Linux/x86_64) (xulq1a:53396) 2015-11-21T05:02:21Z

  Instance admin: xulq1a

  Instance home directory: /timesten/xulq1a/TimesTen/xulq1a

  Group owner: ttusers

  Daemon home directory: /timesten/xulq1a/TimesTen/xulq1a/info

  PL/SQL enabled.

具体操作步骤为:

--主库操作

Command> alter session set ddl_replication_level=3;

Session altered.

Command> 
Command> alter session set ddl_replication_action='INCLUDE';

Command> 

create sequence USER543.SEQ_REMIND10

    increment by 1

    minvalue 1

    maxvalue 999999999999999999

    start with 14201

    cache 1000;

Command> allsequences;

   USER543.SEQ_REMIND1
  USER543.SEQ_REMIND10

--备库查询

Command> allsequences;

   USER543.SEQ_REMIND1
  USER543.SEQ_REMIND10   --说明已同步到备库。

以上,操作,说明11.2.2.8 以后的版本在一定功能上有了很大提高。尤其,是序列的创建。无需在停止复制进行及重建备机操作了。

也希望,有维护TImesten内存库的朋友,在遇到此问题时可以做个参考。 谢谢!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: