knightnibo
作者knightnibo·2017-04-10 13:09
数据库管理员·亚博科技

在RSS备节点进行外部备份

字数 4687阅读 1145评论 0赞 1

外部备份适用于生产环境大数据量下的备份方案,可以充分利用存储级别复制的强大性能,本文介绍一种生产环境实际应用场景外部备份流程,即在RSS备节点进行物理备份,结合主节点逻辑日志进行还原

备份流程

1.主节点onbar配置

此处以PSM为例配置onbar逻辑日志备份

onmode -wf BAR_BASELIB_PATH=$INFORMIXDIR/lib/libbsapsm.so
onmode -wf ALARMPROGRAM=$INFORMIXDIR/etc/log_full.sh
onmode -wf LTAPEDEV=/home/informix/logbak(非/dev/null即可,此处为一个link)

复制SM_VERSION

cp $INFORMIXDIR/etc/sm_version.std  $INFORMIXDIR/etc/sm_version

启用PSM(实际环境通过第三方存储进行)

-bash-4.2$ onpsm -D add /home/informix/logbak -g LOGPOOL -p HIGHEST -t FILE 
The __PSM__ catalog is not present in the '/home/informix/GBase8t/etc/psm/' directory. 
The system will try to create it.
 __PSM__ catalog creation in the '/home/informix/GBase8t/etc/psm/' directory succeeded.

查看PSM设备(实际环境可以查看相应池)

-bash-4.2$ onpsm -D list
__PSM__ Device List
Type   Prio     Block/Size (MB)  Pool Name     Device Name
FILE   HIGHEST      --/--        LOGPOOL       /home/informix/logbak

确认备份正常**

Onbar -b -l

确认onbar备份日志正常即可

2.RSS备节点参数调整

设置备机LOG_STAGING_DIR为某个目录(权限770,下级目录也要求为安全权限)
确认STOP_APPLY参数必须为0
确认DELAY_APPLY参数大于0 如600

3.阻塞RSS备节点

Onmode -c block ${TIME_OUT}

-bash-4.2$ onmode -c block 120
-bash-4.2$ onstat -
GBase 8t Database Server Version 12.10.FC4G1AEE -- Read-Only (RSS) -- Up 00:20:20 -- 318728 Kbytes
Blocked:ARCHIVE

4.备份chunk内容

实验环境本机为文件系统,通过tar进行备份(生产环境通过存储快照等技术完成,原理相同)

-bash-4.2$ tar -cvf chunk_bak.tar /home/informix/GBase8t/chunks/rootchk /home/informix/GBase8t/chunks/datachk /home/informix/GBase8t/chunks/idxchk
/home/informix/GBase8t/chunks/rootchk
/home/informix/GBase8t/chunks/datachk
/home/informix/GBase8t/chunks/idxchk

5.模拟主端继续操作

主端继续进行操作,并确保逻辑日志文件正常进行备份

6.恢复RSS状态

GBase 8t Database Server Version 12.10.FC4G1AEE -- Read-Only (RSS) -- Up 00:27:24 -- 318728 Kbytes
Blocked:ARCHIVE

-bash-4.2$ onmode -c unblock
-bash-4.2$ onstat -

GBase 8t Database Server Version 12.10.FC4G1AEE -- Read-Only (RSS) -- Up 00:27:43 -- 318728 Kbytes

备份完成

故障模拟

1.删除主端chunk

-bash-4.2$ cd chunks/
-bash-4.2$ ls -lrt
total 7768004
-rw-rw---- 1 informix informix 2097152000 Mar  6 19:28 datachk
-rw-rw---- 1 informix informix 2097152000 Mar  6 19:28 idxchk
-rw-rw---- 1 informix informix  307200000 Mar  6 19:31 rootchk
-bash-4.2$ rm  -rf *

2.模拟启动失败

shared memory not initialized for INFORMIXSERVER 'testserver2'

Message Log File: /home/informix/GBase8t/tmp/online.log
19:35:16  Booting Language  from module <>
19:35:16  Loading Module 
19:35:16  Booting Language  from module <>
19:35:16  Loading Module 
19:35:21  DR: DRAUTO is 0 (Off)
19:35:21  DR: ENCRYPT_HDR is 0 (HDR encryption Disabled)
19:35:21  Event notification facility epoll enabled.
19:35:21  Trusted host cache successfully built:/etc/hosts.equiv.
19:35:21  CCFLAGS2 value set to 0x200
19:35:21  SQL_FEAT_CTRL value set to 0x8008
19:35:21  SQL_DEF_CTRL value set to 0x4b0
19:35:21  GBase 8t Database Server Version 12.10.FC4G1AEE Software Serial Number AAA#B000000
19:35:21  Warning: stat() failed for chunk file /home/informix/GBase8t/chunks/rootchk
19:35:21  Cannot Open Primary Chunk '/home/informix/GBase8t/chunks/rootchk', errno = 2
19:35:21  oninit: Fatal error in shared memory initialization

19:35:21  GBase 8t Database Server Stopped.

19:35:21  Process exited with return code 126: /bin/sh /bin/sh -c /home/informix/GBase8t/etc/alarmprogram.sh 3 11 "Cannot open Chunk: '/home/informix/GBase8t/chunks/rootchk'." "Cannot Open Primary Chunk '/home/informix/GBase8t/chunks/rootchk', errno = 2" "" 11002
19:35:21  mt_shm_remove: WARNING: may not have removed all/correct segments

还原流程

1.抢救当前逻辑日志

onbar -b -l -s

2.还原chunk内容

实验环境是文件系统,解压缩文件放回原处(生产通过快照恢复完成)

-rw-rw-r-- 1 informix informix 4501514240 Mar  6 19:25 chunk_bak.tar
-bash-4.2$ tar -xvf chunk_bak.tar 
home/informix/GBase8t/chunks/rootchk
home/informix/GBase8t/chunks/datachk
home/informix/GBase8t/chunks/idxchk

-bash-4.2$ ls -la /home/informix/GBase8t/chunks/
total 4396004
drwxrwxr-x  2 informix informix         47 Mar  6 19:41 .
drwxr-xr-x 23 informix informix       4096 Mar  6 18:41 ..
-rw-rw----  1 informix informix 2097152000 Mar  6 19:21 datachk
-rw-rw----  1 informix informix 2097152000 Mar  6 19:21 idxchk
-rw-rw----  1 informix informix  307200000 Mar  6 19:21 rootchk

3.执行外部物理还原

Onbar -r -e -p [dbspace_list]

期间可以通过Online.log观察到数据库启动日志

物理还原完成会提示如下信息:

-bash-4.2$ onbar -r -e -p
(-43177) Physical restore complete. Logical restore required before work can 
continue. Use 'onbar -r -l' to do logical restore.
If the physical restore is from a whole-system backup that was not

performed on an RSS server, then a logical restore is not required.

数据库进入fastrecovery状态(此时可根据需求是否切换为RSS或HDR)

-bash-4.2$ onstat -

GBase 8t Database Server Version 12.10.FC4G1AEE -- Fast Recovery -- Up 00:01:19 -- 310536 Kbytes

4.执行逻辑恢复

准备逻辑恢复介质
装入对应备份磁带/复制对应逻辑日志文件

执行逻辑恢复

 Onbar -r -l [dbspace_list]

还原结束

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

1

添加新评论0 条评论

Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广