How to check DB2 multiple archive path against to RAU

Basic knowledge of DB2 archive log

more details please go to DB2 logging official website

There are two types of logging in DB2, the circular logging and archive logging.

  • Circular logging
    Circular logging is the default logging strategy used for a database. In this strategy, once the last primary log file is filled in the log directory, new transactions will be written to the first log file thereby overwriting existing log data. These new transactions will continue to overwrite each old log file in sequence. This method of logging ensures data consistency for all committed transactions so that crash recovery is possible.
figure1.gif
  • Archival logging
    In contrast to circular logging, the archival logging process creates a new log file when the last log file is filled so that future transactions will not overwrite existing log files. When the database is initialized, the system allocates a certain number of primary log files of a specified size in the active log directory. This number is controlled by a database configuration parameter (discussed in the next section). When the primary log files are all full, secondary log files are created on an "as-needed" basis until the maximum number of secondary log files has been created. Once this number is reached, if additional log space is needed, an error is issued indicating no more log files are available and all database activity is stopped.
    With archival logging, it is possible to take an online database backup during which database activity continues to be logged. In the event of a database crash or failure, the database may be restored using a full backup image followed by a roll-forward operation using the archived logs to bring the database to a point-in-time state or to the most recent consistent state by rolling forward to the end of the logs.
    Archived logs are of two types:
    Online archived logs: These are the log files that reside in the database log directory ('online') and are no longer needed for normal database activity.
    Off-line archived logs: These are the log files that have been moved from the database log directory to an off-line storage location (such as a backup server) and are not needed for normal database activity.
figure2.gif

The physical log files store in the Disk with archive logging

There are 5 logging folders store the different period of archive logs. We can use blow db2 command to find all of the 5 logfolder path:

db2 get db cfg

You will see the 5 paths:


paths.png

Now, actually the 5 logging path blows to Online archived logs and Off-line archived logs.

** Online archived logs **

  • LOGPATH
    store the logprimary+logsecond online archive log, we can change the log file quantity by:
UPDATE DB CFG FOR db_name USING LOGPRIMARY 3
UPDATE DB CFG FOR db_name USING LOGSECOND 2
  • MIRRORLOGPATH
    If mirrorlogpath is configured, DB2 will create active log files in both the log path and the mirror log path. All log data will be written to both paths. The mirror log path has a duplicated set of active log files, such that if there is a disk error or human error that destroys active log files on one of the paths, the database can still function.

Off-line archived logs

  • LOGARCHMETH1
    You can use this parameter to specify the media type of the primary destination for archived logs.
  • LOGARCHMETH2
    This parameter specifies the media type of the secondary destination for archived logs.
  • FAILARCHPATH
    This parameter specifies a path to which DB2® will try to archive log files if the log files cannot be archived to either the primary or the secondary (if set) archive destinations because of a media problem affecting those destinations. This specified path must reference a disk.

How DB2 backup files with Archive logging

DB2 archive log backup.png

So,the key point is:

  • DB2 will store online logs in LOGPATH and MIRRORLOGPATH(if set),but the file quantity is limited.
  • If the online log files number is bigger than what you defined, will archive those online log files to LOGARCHMETH1 and LOGARCHMETH2.
  • If archive failed, DB2 will archive online log files to FAILARCHPATH.

How DB2 restore archive logs with Archive logging

DB2 archive log restore.png

So, the key point is:

  • DB2 will get log records from archive log files which in LOGPATH or MIRRORLOGPATH.
  • If the archive log file not in LOGPATH and MIRRORLOGPATH,will try to search from LOGARCHMETH1,LOGARCHMETH2 and FAILARCHPATH. If found, DB2 will copy those archive files to LOGPATH,and then read log record from those archive log files in LOGPATH.
  • In a short words, no matter what path contains the required archived log files, DB2 can restore or read log records correctly.

What situation can make RAU can't read archive logs

The only scenario is the required archived files not exist in all of five archive log paths. So If we want to ensure RAU run smoothly , I suggest to back up archive logs to at least one off-line log path. Recommend use the LOGARCHMETH1.

Test steps for the multiple archive path

  • First of all, Install or Find a DB2 instance,make sure you have administrator privilege.
  • Set the off-line log path
>db2
db2 =>connect to db_name 
db2 =>UPDATE DATABASE CONFIGURATION USING logarchmeth1 DISK:path1
db2 =>UPDATE DATABASE CONFIGURATION USING logarchmeth2 DISK:path2
  • Limit the online log files number
db2 =>UPDATE DB CFG FOR db_name USING SOFTMAX 200
db2 =>UPDATE DB CFG FOR db_name USING LOGPRIMARY 3
db2 =>UPDATE DB CFG FOR db_name USING LOGSECOND 2
db2 =>BACKUP  DATABASE  db_name TO path1
db2 =>db2stop force
db2 =>db2start
  • start RAU instance and config the RAU instance to connect to DB2
ra_config pds_host_name,localhost
go
ra_config pds_database_name,db_name 
go
ra_config pds_port_number,50000
go
ra_config pds_username,pds_user
go
ra_config pds_password,Sybase123
go
ra_config pds_datasource_name,db_name 
go
test_connection PDS
go
ra_admin init
go
trace LTITRACELTL,true 
go
ra_config connect_to_rs,false  
go
ra_config use_rssd,false 
go
  • create a test table in DB2
db2 =>create table chartest(pkey int,varchar(20))
  • mark test table and move truncption in RA
pdb_setreptable chartest,mark
go
ra_locator move_truncpt
go
  • write down all file names in LOGPATH
    for example S0000167 ~ S0000171, the db2 current log locator is in S0000167 file.
  • insert mass data into test table
    insert into mass test data into test table, this action will update the online log file in LOGPATH and backup S0000167 ~ S0000171 to logarchmeth1 .Keep insert data until the online archive files' name bigger than S0000171, then stop insert data. Please use blow sql with "KKKKKK" keyword as the test sqls:
insert into chartest values(1,'KKKKKK')

recommend you use DB2 procedure or write a script to insert mass data

  • insert mass test data again
    Suppose the current log file names are S0000172 ~ S0000176, then insert mass test sql data until all file names in LOGPATH is bigger than S0000176. The step just make sure we make a lot of archive files. Test sql is :
insert into chartest values(1,'KKKKKK')
  • insert another mass data into test table
    This step just to ensure DB2 put all archive log files that contains “KKKKK” keyword are archived to off-line log path logarchmeth1 and logarchmeth2. Suppose the current log files' name are S0000177 ~ S0000181 in LOGPATH, then insert mass data until all log files' name bigger than S0000181.Test Sql is :
insert into chartest values(1,'HHHHHH')

now lets look at all archive log path, in LOGPATH is S0000182 ~S0000186, in MIRRORLOGPATH is S0000182 ~S0000186 too (those are online logs), in LOGARCHMETH1 and LOGARCHMETH2 are S0000167 ~ S0000181(those are archived logs).

  • Try to restore off-line archived log(For RAU ,is read the archived log record)
    For online log S0000182 ~S0000186, they don't contains the keyword 'KKKKK' .The ra_locator is point to S0000167, For the S0000167~ S0000181,some archived log files contains keyword 'KKKKK'.
    Let's delete all archived log files in LOGARCHMETH1 and check whether the LOGARCHMETH2 can restore S0000167 ~ S0000181. After delete all archived log file in LOGARCHMETH1,then run RA command:
resume
go

after resume RAU, you can see the off-line archived log file is coping to LOGPATH. And then ,open the LTITRACELL.log file in RAU instance folder,you will find the keyword 'KKKKK'.
Run RA command:

suspend
go
  • Test no archived files
    backup the LOGARCHMETH2 to a new folder.Delete all archived files in LOGARCHMETH1 and LOGARCHMETH2. Then run RA command:
resume
go

you will find ra stoped replication due to error,no LTL log output.
The error log like LogReader encountered exception with unknown error: <An attempt to read transaction log data failed because the Log containing the requested Log Sequence Number can not be found...
The error occurs because the log locator can't match any exist on-line archive files and off-line archived files.

Summary

We should suggest customer to enable LOGARCHMETH1 or enable LOGARCHMETH1 and LOGARCHMETH2 to ensure all archive files archived to off-line.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 206,602评论 6 481
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 88,442评论 2 382
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 152,878评论 0 344
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 55,306评论 1 279
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 64,330评论 5 373
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,071评论 1 285
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,382评论 3 400
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,006评论 0 259
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,512评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,965评论 2 325
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,094评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,732评论 4 323
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,283评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,286评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,512评论 1 262
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,536评论 2 354
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,828评论 2 345

推荐阅读更多精彩内容