TimesTen的碎片整理-migrate

针对双向复制的tt数据进行碎片整理,有两个方式:

ttmigrate和ttrepadmin -duplicate

本文主要讲第一种使用迁移的方式进行碎片整理,前提是源库已经做过碎片整理了。

环境说明:

两台本地虚机,系统centos7.6,tt版本11.2.2.8.0:

复制器:

tt两个库都已经创建好用户ocs,密码ocs。

tt状态:

step for reduce tt permsize on main ocs server:

---降低permsize

step for reduce tt permsize on main ocs server

 

1、业务切到备机(通过集群操作) root

          Switch business to standby (through cluster operation)

确保业务正常切到备机,因为我们的此次的目标是改主机的permsize

Ensure the normal business migrate to standby ocs server, because our goal this time is to change the main host's tt permsize.

cli

service-migrate

 

check list :

检查清单

a、原主机tt

$ttisql ocs

>dssize

查询permsize当前已使用的值,缩小的值不能低于该值。

已检查,确认满足。

 

b、原主机

检查tt相关crontab,如果有停止掉,主要是避免连接。

业务确认。

 

c、原主机

检查tt删除数据脚本,不能在主节点运行,特别是切到备机后,防止tt双向同步。有可能是zmc清理,也有可能是crontab清理,需要确认如果是zmc清理,那么确认zmc是否是连的tt的浮动ip,如果是可以无需处理,否则需要停掉;如果是crontab清理,需要在原主机上停掉该crontab,在备机上起起来(切换后)。

业务确认。

 

d、原主机

停原主机的ocs进程,因为ocs进程会有连接连到tt,导致无法修改permsize参数。

业务确认。

 

e、原主机

停原主机的网管,确保tt切换后的tt无连接。

业务确认。

 

f、原主机

检查permsize当前生效参数(dssize)和参数文件(sys.odbc.ini)配置参数值是否一致,要以生效参数为准。

已检查,满足条件。

 

g、原主机

停掉复制器后,tt同步日志会在主节点积压,需要观察文件系统使用增长率,估算是否满足操作时间;

get_ttlogfile_increase.sh”可以获取最近一个小时内的TT事务日志文件增长大小。

#!/usr/bin/bash

cd /gfs01/tt/tmp/

echo "
set serveroutput on
spool awk_ttckpthistory.log
call ttckpthistory;
spool off
"|ttisql ocs;

ckptbytes=`awk -F"," '{a+=$16}END{print a}' awk_ttckpthistory.log`

maxtime=`awk -F"," '{ gsub(/<|>|-|:| |Command/,""); print $0 }' awk_ttckpthistory.log | awk -F"," '{if($4 != null ) print $0}' | awk -F"," '{y1= substr($1,1,4); m1=substr($1,5,2); d1=substr($1,7,2);h1=substr($1,9,2);M1=substr($1,11,2);s1=substr($1,13,2); time1 = strftime("%s",mktime(y1" "m1" "d1" "h1" "M1" "s1));{print time1}}'|head -n 1`
mintime=`awk -F"," '{ gsub(/<|>|-|:| |Command/,""); print $0 }' awk_ttckpthistory.log | awk -F"," '{if($4 != null ) print $0}' | awk -F"," '{y1= substr($1,1,4); m1=substr($1,5,2); d1=substr($1,7,2);h1=substr($1,9,2);M1=substr($1,11,2);s1=substr($1,13,2); time1 = strftime("%s",mktime(y1" "m1" "d1" "h1" "M1" "s1));{print time1}}'|tail -n 1`

difresult=$(($maxtime-$mintime))

sumbytes=$(($ckptbytes/$difresult*3600/1024/1024))
echo "Transaction logfile increase is:"$sumbytes" MB"

 

h、原主机

缩小tt perm的同时需要考虑缩小hugepages,避免内存浪费;

此次需要将主机的permsize调整跟备机一样,主机目前是26624MB,备机是21504MB

主机的vm.nr_hugepages15000,备机的vm.nr_hugepages13000.

 

i

 

2、查看状态 原主机 tt

          Check the main ocs server TT database status

$ ttstatus

 

3、停tt服务,主要是为了确保tt当前的连接都被断开。

$ttdaemonadmin -stopserver

 

4、停主机复制器,主备两个节点都停掉(主备机都停掉,tt

          stop the main ocs server replicator .

$ttadmin -reppolicy manual ocs

$ttadmin -repstop ocs

 

5、使用ttmigrate工具进行迁出到二进制文件中(原主机 tt)

          Migrate tt database to binaries file using the ttmigrate tool,note that the directory is modified as it is

$ttmigrate -c DSN=ocs  /ocs/tt_bak/ttocs01.dump

 

6、卸载内存(原主机 tt

          unload the tt database memory

$ttadmin -ramPolicy manual ocs

$ttadmin -ramUnload ocs

 

7、毁掉ocs(原主机 tt

          destroy the main ocs server tt database DSN called ocs

$ttdestroy ocs

 

8、修改主机permsize(原主机 tt

          Modify the main ocs server permsize size to target,notice that you must change the value of permsize below

$vi sys.odbc.ini

PermSize=21504

AutoCreate=1

 

9、调整大页(原主机 root)

vi /etc/sysctl.conf

修改:

vm.nr_hugepages=13000

sysctl -p

 

10、重建ocs(原主机 tt

          rebuild the ocs DS

$ttisql ocs

 Command>quit

 

11、改AutoCreate=0(原主机 tt

          Modify the value of autocreate to 0

$vi sys.odbc.ini

AutoCreate=0

 

12、迁移回数据(原主机 tt

           Restore tt database's ocs DS with previously backed up binary file,note that the directory is modified as it is

ttmigrate -r DSN=ocs /ocs/tt_bak/ttocs01.dump

 

13、启动复制器(主备机都执行 tt

           start replicator and modify the replication policy

$ttadmin -repstart ocs

$ttadmin -reppolicy always ocs

 

14、内存加载策略(原主机 tt

           Modify memory loading policy

$ttadmin -ramPolicy always ocs

 

15、起tt服务

ttdaemonadmin -startserver

 

16、检查表数据一致性,验证用户、权限、数据一致性

                   Check for table data consistency

 

17、验证tt同步情况

启动复制器后,需要验证tt的同步情况,必须数据同步后才能切机;

Command> call ttlogholds;

ttstatus;

 

18、手工checkpoint

操作完成后需要手工调整checkpoint,错开checkpoint时间点,错开IO,避免IO争用,如果是本地SSD,可以不用做这个操作;

                  

19、原来在主机上的服务切回到主机

                   migrate the services that were originally on the main ocs server back to the main ocs server through the cluster

cli

service-migrate

业务确认。

 

20、操作完成后恢复crontab,考虑job是否补跑,启动网管等;

业务确认。

发布了177 篇原创文章 · 获赞 43 · 访问量 46万+

猜你喜欢

转载自blog.csdn.net/kadwf123/article/details/97289754