X

一线数据库工程师的精彩案例分享、新特性介绍、诊断工具和诊断方法、以及常用的测试案例 -- 欢迎光临Oracle数据库中文技术支持官方微博

双向多主复制环境下的timesten升级测试

背景
===========
客户升级应用,但应用打包了timesten,所以升级应用过程中涉及timesten的重装,所以如何避免升级过程中因升级而写入升级库的数据不被复制到另一边的未升级环境就成了问题。本测试步骤用升级过程中插入数据 application upgrade来模拟应用升级的数据插入。
环境
=============
两个虚拟机,ADG和ADG2,重装(升级)ADG的timesten,升级过程中(恢复ADG2到ADG复制之前)的数据不复制到ADG。
配置(双向多主复制)
===================
ADG1:
create replication REP.REPSCHEME1
element "COMPLETE1" datastore
master "ACTIVE" on "ADG2"
subscriber "ACTIVE" on "ADG"
element "COMPLETE2" datastore
master "ACTIVE" on "ADG"
subscriber "ACTIVE" on "ADG2"
store "ACTIVE" on "ADG2"
port 16090
store "ACTIVE" on "ADG"
port 16093
;
CALL ttRepStart;
ttAdmin -repPolicy always active
ADG2:
ttRepAdmin -duplicate -from active -host adg -uid repl -pwd repl "dsn=active"
ttAdmin -repPolicy always active
<<<<adg:
Command> call ttrepstop;
Command> drop replication REP.REPSCHEME1;
Command> drop replication REP.REPSCHEME2;
Command> create replication REP.REPSCHEME1
> element "COMPLETE1" datastore
> master "ACTIVE" on "ADG2"
> subscriber "ACTIVE" on "ADG"
> element "COMPLETE2" datastore
> master "ACTIVE" on "ADG"
> subscriber "ACTIVE" on "ADG2"
> store "ACTIVE" on "ADG2"
> port 16090
> store "ACTIVE" on "ADG"
> port 16093
> ;
Command> CALL ttRepStart;
Command> create user repl identified by 'repl';
15004: User REPL already exists
The command failed.
Command> exit
Disconnecting...
Done.
[oracle@adg bin]$ ./ttAdmin -repPolicy always active
RAM Residence Policy : inUse
Replication Agent Policy : always
Cache Agent Policy : manual
Cache Agent Manually Started : False
[oracle@adg bin]$ ./ttisql active
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=active";
Connection successful:
DSN=active;UID=oracle;DataStore=/home/oracle/TimesTen/tt1122/info/active;DatabaseCharacterSet=WE8MSWIN1252;ConnectionCharacterSet=US7ASCII;DRIVER=/home/oracle/TimesTen
/tt1122/lib/libtten.so;PermSize=64;TypeMode=0;
(Default setting AutoCommit=1)
Command> insert into rep.t1 values(1,'test2');
907: Unique constraint (T1 on REP.T1) violated at Rowid <BMUFVUAAACZAAAAKDR>
The command failed.
Command> insert into rep.t1 values(3,'test3');
1 row inserted.
Command> commit;
Command> select * from rep.t1;
< 1, test >
< 2, test >
< 3, test3 >
< 4, test4 >
4 rows found.
Command>
<<<<adg2
[oracle@adg2 bin]$ ./ttdestroy active
[oracle@adg2 bin]$ ./ttRepAdmin -duplicate -from active -host adg -localhost adg2 -uid repl -pwd repl "dsn=active"
[oracle@adg2 bin]$ ttIsql -e "call ttrepstart;exit;" active
-bash: ttIsql: command not found
[oracle@adg2 bin]$ ./ttIsql -e "call ttrepstart;exit;" active
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=active";
Connection successful:
DSN=active;UID=oracle;DataStore=/home/oracle/TimesTen/tt1122/info/active;DatabaseCharacterSet=WE8MSWIN1252;ConnectionCharacterSet=US7ASCII;DRIVER=/home/oracle/TimesTen
/tt1122/lib/libtten.so;PermSize=64;TypeMode=0;
(Default setting AutoCommit=1)
call ttrepstart;
exit;
Disconnecting...
Done.
[oracle@adg2 bin]$ ./ttAdmin -repPolicy always active
RAM Residence Policy : inUse
Replication Agent Policy : always
Cache Agent Policy : manual
Cache Agent Manually Started : False
[oracle@adg2 bin]$ ./ttisql active
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=active";
Connection successful:
DSN=active;UID=oracle;DataStore=/home/oracle/TimesTen/tt1122/info/active;DatabaseCharacterSet=WE8MSWIN1252;ConnectionCharacterSet=US7ASCII;DRIVER=/home/oracle/TimesTen
/tt1122/lib/libtten.so;PermSize=64;TypeMode=0;
(Default setting AutoCommit=1)
Command> select * from rep.t1;
< 1, test >
< 2, test >
< 3, test3 >
3 rows found.
Command> insert into rep.t1 values(4,'test4');
1 row inserted.
Command> commit;
==========
升级过程
=================
<<<Step 1 配置静态复制端口,跳过,因为已经使用了静态端口复制
<<<Step 2&3,停止待升级的adg上的应用连接,并在adg2上pause adg2到adg的复制,不是直接停掉复制,这样可以等待transaction log上的事务在停复制前复制到adg上而不是丢失(因为升级后第10步是reset receiver,会清掉bookmark)。
<--adg
[oracle@adg2 bin]$ ./ttRepAdmin -receiver -name active -state pause active
[oracle@adg2 bin]$ ./ttisql active
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=active";
Connection successful:
DSN=active;UID=oracle;DataStore=/home/oracle/TimesTen/tt1122/info/active;DatabaseCharacterSet=WE8MSWIN1252;ConnectionCharacterSet=US7ASCII;DRIVER=/home/oracle/TimesTen
/tt1122/lib/libtten.so;PermSize=64;TypeMode=0;
(Default setting AutoCommit=1)
Command> select * from rep.t1;
< 1, test >
< 2, test >
< 3, test3 >
< 4, test4 >
< 5, upgrade_step3 >
5 rows found.
Command> insert into rep.t1 values(6,'upgrade_step3_adg2');<===pause复制后,在adg2插入一条数据
1 row inserted.
Command> commit;
Command> select * from rep.t1;
< 1, test >
< 2, test >
< 3, test3 >
< 4, test4 >
< 5, upgrade_step3 >
< 6, upgrade_step3_adg2 >
6 rows found.
[oracle@adg bin]$ ./ttisql active
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=active";
Connection successful:
DSN=active;UID=oracle;DataStore=/home/oracle/TimesTen/tt1122/info/active;DatabaseCharacterSet=WE8MSWIN1252;ConnectionCharacterSet=US7ASCII;DRIVER=/home/oracle/TimesTen
/tt1122/lib/libtten.so;PermSize=64;TypeMode=0;
(Default setting AutoCommit=1)
Command> insert into rep.t1 values(5,'upgrade_step3');
1 row inserted.
Command> commit;
Command> select * from rep.t1;
< 1, test >
< 2, test >
< 3, test3 >
< 4, test4 >
< 5, upgrade_step3 ><====在adg2 pause receiver之后,adg2新插入的记录没有传播到adg
5 rows found.
<<<Step4 停止两边的rep agent,从此没有更新发送到对方
<---adg
[oracle@adg bin]$ ./ttAdmin -repStop active
*** [TimesTen][TimesTen 11.2.2.8.18 ODBC Driver][TimesTen]TT10016: Replication Agent was not stopped due to repPolicy setting.
*** ODBC Error = S1000, TimesTen Error = 10016
[oracle@adg bin]$ ./ttAdmin -repPolicy manual active
RAM Residence Policy : inUse
Replication Agent Policy : manual
Replication Manually Started : True
Cache Agent Policy : manual
Cache Agent Manually Started : False
[oracle@adg bin]$ ./ttAdmin -repStop active
RAM Residence Policy : inUse
Replication Agent Policy : manual
Replication Manually Started : False
Cache Agent Policy : manual
Cache Agent Manually Started : False
<---adg2
[oracle@adg2 bin]$ ./ttAdmin -repPolicy manual active
RAM Residence Policy : inUse
Replication Agent Policy : manual
Replication Manually Started : True
Cache Agent Policy : manual
Cache Agent Manually Started : False
[oracle@adg2 bin]$ ./ttAdmin -repStop active
RAM Residence Policy : inUse
Replication Agent Policy : manual
Replication Manually Started : False
Cache Agent Policy : manual
Cache Agent Manually Started : False
<<<Step5<===防止adg2上有积压的更新发送到adg
[oracle@adg bin]$ ./ttRepAdmin -receiver -name active -state stop active
[oracle@adg bin]$
<<<Step6<==备份
[oracle@adg bin]$ ./ttMigrate -c active /home/oracle/backup.dat
Saving user PUBLIC
User successfully saved.
Saving user REP
User successfully saved.
Saving user REPL
User successfully saved.
Saving table REP.T1
Saving rows...
5/5 rows saved.
Table successfully saved.
Saving table REP.T2
Saving rows...
0/0 rows saved.
Table successfully saved.
<<<Step7<===adg删库;adg2重启repagent
<--adg删库
[oracle@adg bin]$ ./ttdestroy active
[oracle@adg bin]$
<--adg2
重启repagent
[oracle@adg2 bin]$ ./ttAdmin -repStart active
RAM Residence Policy : inUse
Replication Agent Policy : manual
Replication Manually Started : True
Cache Agent Policy : manual
Cache Agent Manually Started : False
[oracle@adg2 bin]$
<<<Step8
<--adg,重装(或升级)
[oracle@adg bin]$ ./ttdaemonadmin -stop
TimesTen Daemon stopped.
[oracle@adg ~]$ cd
[oracle@adg ~]$ rm -rf TimesTen
[oracle@adg linux8664]$ rm -rf /etc/TimesTen/instance_info
[oracle@adg ~]$ cd install/linux8664/
[oracle@adg linux8664]$ ./setup.sh
There is 1 TimesTen instance installed locally :
1) tt1122 (TimesTen11.2.2.8)
Of the following options :
[1] Install a new instance
[2] Upgrade an existing instance
[3] Display information about an existing instance
[q] Quit the installation
Which would you like to perform? [ 1 ] 1
* The default instance name 'tt1122' is in use.
...
The 11.2.2.8 Release Notes are located here :
'/home/oracle/TimesTen/tt1122/README.html'
Starting the daemon ...
TimesTen Daemon startup OK.
End of TimesTen installation.
<--adg2,恢复从adg2到adg的replication,并插入一条测试数据
[oracle@adg2 bin]$ ./ttRepAdmin -receiver -name active -state start active
[oracle@adg2 bin]$ ./ttisql active
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=active";
Connection successful: DSN=active;UID=oracle;DataStore=/home/oracle/TimesTen/tt1122/info/active;DatabaseCharacterSet=WE8MSWIN1252;ConnectionCharacterSet=US7ASCII;DRIVER=/home/oracle/TimesTen/tt1122/lib/libtten.so;PermSize=64;TypeMode=0;
(Default setting AutoCommit=1)
Command> insert into rep.t1 values(8,'during upgrade');
1 row inserted.
Command> commit;
<<<Step9,adg导回备份
将active的dsn加回info/sys.odbc.ini:
[active]
Driver=/home/oracle/TimesTen/tt1122/lib/libtten.so
DataStore=/home/oracle/TimesTen/tt1122/info/active
PermSize=64
DatabaseCharacterSet=WE8MSWIN1252
然后还原备份:
[oracle@adg bin]$ ./ttmigrate -r active /home/oracle/backup.dat
Restoring user REP
Restoring privileges...
Privileges restored.
User successfully restored.
Restoring user REPL
Restoring privileges...
Privileges restored.
User successfully restored.
Restoring table REP.T1
Restoring rows...
5/5 rows restored.
Table successfully restored.
Restoring table REP.T2
Restoring rows...
0/0 rows restored.
Table successfully restored.
Restoring replication schema (supports replicated sequences) REP.REPSCHEME1
Replication schema (supports replicated sequences) successfully restored.
[oracle@adg bin]$ ./ttisql active
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=active";
Connection successful: DSN=active;UID=oracle;DataStore=/home/oracle/TimesTen/tt1122/info/active;DatabaseCharacterSet=WE8MSWIN1252;ConnectionCharacterSet=US7ASCII;DRIVER=/home/oracle/TimesTen/tt1122/lib/libtten.so;PermSize=64;TypeMode=0;
(Default setting AutoCommit=1)
Command> insert into rep.t1 values(9,'application upgrade');《----插入数据模拟应用升级过程中的数据写入,这条数据不应该被复制到adg2
1 row inserted.
Command> commit;
<<<Step10, 通过把adg2的receiver state重置来清空adg的replication bookmark和txn logs,并重启replication
[oracle@adg bin]$ ./ttRepAdmin -receiver -name active -reset active
[oracle@adg bin]$ ./ttRepAdmin -receiver -name active -state stop active
[oracle@adg bin]$ ./sleep 10
[oracle@adg bin]$ ./ttRepAdmin -receiver -name active -state start active
<<<Step11 启动adg到adg2的复制
[oracle@adg bin]$ ./ttAdmin -repStart active
RAM Residence Policy : inUse
Replication Agent Policy : manual
Replication Manually Started : True
Cache Agent Policy : manual
Cache Agent Manually Started : False
<<<Step12 两节点插入数据并检查
<--adg
[oracle@adg bin]$ ./ttisql active
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=active";
Connection successful: DSN=active;UID=oracle;DataStore=/home/oracle/TimesTen/tt1122/info/active;DatabaseCharacterSet=WE8MSWIN1252;ConnectionCharacterSet=US7ASCII;DRIVER=/home/oracle/TimesTen/tt1122/lib/libtten.so;PermSize=64;TypeMode=0;
(Default setting AutoCommit=1)
Command> select * from rep.t1;
< 1, test >
< 2, test >
< 3, test3 >
< 4, test4 >
< 5, upgrade_step3 >
< 8, during upgrade >
< 9, application upgrade >
7 rows found.
Command> insert into rep.t1 values(11,'after upgrade');
1 row inserted.
Command> commit;
Command> select * from rep.t1;
< 1, test >
< 2, test >
< 3, test3 >
< 4, test4 >
< 5, upgrade_step3 >
< 8, during upgrade >
< 9, application upgrade >
< 10, after upgrade >
< 11, after upgrade >
9 rows found.
Command>
<--adg2
[oracle@adg2 bin]$ ./ttisql active
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=active";
Connection successful: DSN=active;UID=oracle;DataStore=/home/oracle/TimesTen/tt1122/info/active;DatabaseCharacterSet=WE8MSWIN1252;ConnectionCharacterSet=US7ASCII;DRIVER=/home/oracle/TimesTen/tt1122/lib/libtten.so;PermSize=64;TypeMode=0;
(Default setting AutoCommit=1)
Command> insert into rep.t1 values(10,'after upgrade');
1 row inserted.
Command> commit;
Command> select * from rep.t1;
< 1, test >
< 2, test >
< 3, test3 >
< 4, test4 >
< 5, upgrade_step3 >
< 6, upgrade_step3_adg2 >
< 8, during upgrade ><===可以看到第9条数据“application upgrade”没有写入adg2节点
< 10, after upgrade >
< 11, after upgrade >
9 rows found.
Command>
结论
======
这个步骤虽然是用于双向多主复制的timesten升级的,但同样适用于Application升级。
通过如上测试记录可见,第9步导回数据库后插入的记录,在第10步重置adg到adg2的replication bookmark&txn log并启动复制后,是没有被复制到adg2的。
注:我这里将两边的datastore名称都设置为active了,所以执行ttRepAdmin -receiver的时候容易弄错节点,这个命令应该在它所修改的复制方向的主库上运行(例如adg到adg2就在adg上跑)。

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.