Informix表级恢复(分片表)的测试

Informix的表级恢复是基于0级备份(必须条件)和已经备份的逻辑日志(时间点等恢复)实现,关于简单的表级恢复参考:https://liaosnet.com/?post=13

以下介绍在使用分片表时进行的表级恢复的测试 。

1,准备工作

新增3个dbspace,分别是userdbs1,userdbs2,userdbs。
在测试库testdb中创建测试表tt,并导入100行测试记录。

create table tt
(
  id char(10),
  name char(20),
  primary key(id)
) fragment by round robin in userdbs1,userdbs2,userdbs3;

导入100行测试记录。

2,创建0级备份。 这里使用ontape方式

informix% ontape -s -L 0

3,创建用于表级恢复的模式命令文件 tt.cmd

SET COMMIT TO 100;         -- 设置物理恢复期间在提交前的插入记录数,缺省1000,这里使用100。
SET WORKSPACE to userdbs;  -- 设置工作空间,缺省是rootdbs。 或者是多个分片。
DATABASE testdb;                     -- 设置当前数据库
-- 以下设置源表结构,源表结构与备份中的表结构相同(忽略区段和锁表模式),分片表必须列明所有的区段
CREATE TABLE tt
(
  id char(10),
  name char(20),
  primary key(id)
) fragment by round robin in userdbs1,userdbs2,userdbs3;
-- 以下设置恢复目标表结构,若恢复目标表存在,则恢复表数据至该表(已存在的表结构须与命令文件中所述一致)中;若恢复目标表不存在,则创建之。 目标表的存储可与源表不一致,如目标表可以不再使用分片方式。
CREATE TABLE tt_new
(
  id char(10),
  name char(20),
  primary key(id)
) fragment by round robin in userdbs1,userdbs2,userdbs3;
-- 告知archecker恢复的具体操作
INSERT INTO tt_new SELECT * FROM tt;
-- 设置恢复选项(可选项),恢复到指定时间点或是最近的逻辑日志(CURRENT,默认)。若使用WITH NO LOG,将只进行物理恢复。
RESTORE TO CURRENT;

注:使用时间点恢复时,应当注意加载环境变量GL_DATETIME,例如:GL_DATETIME="%Y-%m-%d %H:%M:%S"

4,使用archecker进行恢复,以下使用的是ontape备份恢复

informix% archecker -tvs -f tt.cmd

-- 使用onbar备份时: archecker -bvs -f tt.cmd
预期正常的情况下,将按照模式命令文件恢复表tt至tt_new

后续操作则视需要进一步处理(或者是重命名为原表,或者是数据处理)

以下是此次表的恢复记录

informix@suse10:/opt/informix/tmp/test> archecker -tvs -f tt.cmd
IBM Informix Dynamic Server Version 11.50.UC6    
Program Name:   archecker
Version:        8.0
Released:       2009-12-15 21:59:36
CSDK:           IBM Informix CSDK Version 3.50
ESQL:           IBM Informix-ESQL Version 3.50.UC4 
Compiled:       12/15/09 21:59  on Linux 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:54:53 EST 2006 
 
AC_STORAGE               /tmp
AC_MSGPATH               /tmp/ac_msg.log
AC_VERBOSE               on
AC_TAPEDEV               /opt/informix/backup/fullbak/
AC_TAPEBLOCK             1024 KB
AC_LTAPEDEV              /opt/informix/backup/logbak/
AC_LTAPEBLOCK            32 KB
Dropping old log control tables
Extracting table testdb:tt into testdb:tt_new
Archive file /opt/informix/backup/fullbak/suse10_0_L0
Tape type:      Archive Backup Tape
OnLine version: IBM Informix Dynamic Server Version 11.50.UC6    
Archive date:   Sun Feb 20 17:25:45 2011
Archive level:  0
Tape blocksize:  1048576
Tape size:  2147483647
Tape number in series:  1
 
Scan PASSED
Control page checks PASSED
Table checks PASSED
Table extraction commands 1
Tables found on archive 1
LOADED: testdb:tt_new produced 100 rows.
Creating log control tables
Log file /opt/informix/backup/logbak/suse10_0_Log0000000060
Log tape backup date:   Sun Feb 20 17:28:40 2011
Tape blocksize: 32768
Tape size: 2147483647
Tape number in series: 2
Log file /opt/informix/backup/logbak/suse10_0_Log0000000061
Log tape backup date:   Sun Feb 20 17:28:44 2011
Tape blocksize: 32768
Tape size: 2147483647
Tape number in series: 3
Switching to log 61
 
Logically recovered testdb:tt_new Inserted 0 Deleted 0 Updated 0

标签: none

添加新评论

Free Web Hosting