分类: DB2/Informix
2008-04-13 21:54:30
一,安装操作系统(redhat3u6)
1,调整内核参数
echo '
kernel.shmmax=536870912
kernel.shmmni=4096
kernel.shmall=2097152
kernel.sem=500 32000 200 256
fs.file-max=65536
net.ipv4.ip_local_port_range=1024 65000' >> /etc/sysctl.conf
2,建立用户名和组
groupadd informix
groupadd bargroup
useradd -g informix -d /home/informix -p rrlrrl informix
useradd -g bargroup -d /home/tapeback -p rrlrrl tapeback
3,分区,测试只分一个rootdbs分区就可以了
[root@test06 installfiles]# fdisk -l
Disk /dev/sda: 45.4 GB, 45492469760 bytes
255 heads, 63 sectors/track, 5530 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2624 20972857+ 83 Linux
/dev/sda3 2625 2755 1052257+ 82 Linux swap
/dev/sda4 2756 5530 22290187+ 5 Extended
/dev/sda5 2756 2771 128488+ 83 Linux
[root@test06 installfiles]#
4,设置raw文件
echo '
#store spaces for informix server
/dev/raw/raw1 /dev/sda5' >> /etc/sysconfig/rawdevices
5,修改/etc/init.d/rawdevices文件,设置系统启动时raw文件的属主信息
此处为修改vi /etc/init.d/rawdevices文件
case "$1" in
start)
# Assign devices
echo $"Assigning devices: "
assign_raw
sleep 1
chown informix:informix /dev/raw/*
chmod 660 /dev/raw/*
chown tapeback:bargroup /dev/nst0
echo $"done"
;;
stop)
# No action to be taken here
;;
6,设置数据库块文件
mkdir /informix.links
ln -s /dev/raw/raw1 /informix.links/rootdbs
7, 根据实际情况配置/etc/services,/etc/hosts,/home/informix/.rhosts
8,设置Informix用户环境变量
echo '
INFORMIXDIR=/home/informix
INFORMIXSERVER=ontest
DBDATE=Y4MD0
ONCONFIG=test.cfg
export LANG=en_US.ISO8859-1
export INFORMIXDIR INFORMIXSERVER DBDATE ONCONFIG
export TERMINFO=/home/informix/etc/typetab
export TERMCAP=$INFORMIXDIR/etc/termcap
PATH=$PATH:$HOME/bin:$INFORMIXDIR/bin:.
NSR_DATA_VOLUME_POOL=DBMIData
NSR_LOG_VOLUME_POOL=DBMIData
export NSR_DATA_VOLUME_POOL NSR_LOG_VOLUME_POOL PATH
'>>/home/informix/.bashrc
9,修改/etc/nsswitch.conf文件
#hosts: db files nisplus nis dns
hosts: files dns
删除dns就好了
二,安装数据库,安装networker
cp /home/informix/etc/onconfig.std /home/informix/etc/test.cfg
cp /home/informix/etc/sm_versions.std /home/informix/etc/sm_versions
cp /home/informix/etc/sqlhosts.std /home/informix/etc/sqlhosts
修改上面的3个文件后初始化数据库
建立一个库作为测试的内容
第一次备份,没有改onbar配置文件,第一次备份日志信息:
2008-03-25 09:00:44 8562 8560 /home/informix/bin/onbar_d -b -L 0
2008-03-25 09:00:44 8562 8560 Archive started on rootdbs (Requested Level 0).
2008-03-25 09:00:45 8562 8560 Begin level 0 backup rootdbs.
2008-03-25 09:00:45 8562 8560 Successfully connected to Storage Manager.
2008-03-25 09:00:47 8562 8560 Completed level 0 backup rootdbs (Storage Manager copy ID: 1206406845 1206406846).
2008-03-25 09:00:47 8562 8560 Archive on rootdbs Completed (Requested Level 0).
2008-03-25 09:00:48 8562 8560 Begin backup logical log 4.
2008-03-25 09:00:48 8562 8560 Successfully connected to Storage Manager.
2008-03-25 09:00:51 8562 8560 Completed backup logical log 4 (Storage Manager copy ID: 1206406848 1206406849).
2008-03-25 09:00:51 8562 8560 /home/informix/bin/onbar_d complete, returning 0 (0x00)
第二次备份,更改Onbar配置文件,增加:
save -b ${POOL} -l full /nsr >> ${BAR_ACT_LOG} 2>&1
save -b ${POOL} -l full ${INFORMIXDIR}/etc/ixbar.* ${INFORMIXDIR}/etc/oncfg* ${INFORMIXDIR}/etc/${ONCONFIG} >> ${BAR_ACT_LOG} 2>&1
第二次备份日志信息:
2008-03-25 09:02:37 8711 8709 /home/informix/bin/onbar_d -b -L 0
2008-03-25 09:02:37 8711 8709 Archive started on rootdbs (Requested Level 0).
2008-03-25 09:02:38 8711 8709 Begin level 0 backup rootdbs.
2008-03-25 09:02:38 8711 8709 Successfully connected to Storage Manager.
2008-03-25 09:02:40 8711 8709 Completed level 0 backup rootdbs (Storage Manager copy ID: 1206406958 1206406959).
2008-03-25 09:02:40 8711 8709 Archive on rootdbs Completed (Requested Level 0).
2008-03-25 09:02:40 8711 8709 Begin backup logical log 5.
2008-03-25 09:02:40 8711 8709 Successfully connected to Storage Manager.
2008-03-25 09:02:40 8711 8709 Completed backup logical log 5 (Storage Manager copy ID: 1206406960 1206406961).
2008-03-25 09:02:41 8711 8709 /home/informix/bin/onbar_d complete, returning 0 (0x00)
save: Using test06 as server
/nsr/res/nsrla.res
/nsr/res/servers
/nsr/res/nsrwizclnt.res
/nsr/res/.nsr
/nsr/res/nsrdb/: Permission denied
/nsr/res/
/nsr/lic/res/lgtolm.res
/nsr/lic/res/lictype.res
/nsr/lic/res/
/nsr/lic/tmp/lic_res.lck
/nsr/lic/tmp/lgtolm.res.lck
/nsr/lic/tmp/ofd256
/nsr/lic/tmp/lictype.res.lck
/nsr/lic/tmp/
/nsr/lic/logs/lgtolmd.log
/nsr/lic/logs/
/nsr/lic/cores/: Permission denied
/nsr/lic/
/nsr/index/test06/: Permission denied
/nsr/index/
/nsr/mm/
/nsr/tmp/
/nsr/applogs/xbsa.messages
/nsr/applogs/
/nsr/rap/
/nsr/logs/messages
/nsr/logs/summary
/nsr/logs/daemon.log
/nsr/logs/.nsr
/nsr/logs/
/nsr/cores/: Permission denied
/nsr/debug/
/nsr/
/
save: /nsr level=full, 32 KB 00:00:00 30 files
save: Using test06 as server
/home/informix/etc/ixbar.0
/home/informix/etc/oncfg_ontest.0
/home/informix/etc/test.cfg
/home/informix/etc/
/home/informix/
/home/
/
save: /home/informix/etc/ level=full, 18 KB 00:00:01 7 files
第三次备份,备份先修改一下nsr目录的属性:
chown informix:bargroup -R /nsr
chmod g+rx -R /nsr
备份的日志信息:
2008-03-25 09:06:17 8837 8835 /home/informix/bin/onbar_d -b -L 0
2008-03-25 09:06:18 8837 8835 Archive started on rootdbs (Requested Level 0).
2008-03-25 09:06:18 8837 8835 Begin level 0 backup rootdbs.
2008-03-25 09:06:18 8837 8835 Successfully connected to Storage Manager.
2008-03-25 09:06:20 8837 8835 Completed level 0 backup rootdbs (Storage Manager copy ID: 1206407178 1206407179).
2008-03-25 09:06:20 8837 8835 Archive on rootdbs Completed (Requested Level 0).
2008-03-25 09:06:20 8837 8835 Begin backup logical log 6.
2008-03-25 09:06:20 8837 8835 Successfully connected to Storage Manager.
2008-03-25 09:06:20 8837 8835 Completed backup logical log 6 (Storage Manager copy ID: 1206407180 1206407181).
2008-03-25 09:06:20 8837 8835 /home/informix/bin/onbar_d complete, returning 0 (0x00)
save: Using test06 as server
/nsr/res/nsrla.res
/nsr/res/servers
/nsr/res/nsrwizclnt.res
/nsr/res/.nsr
/nsr/res/nsrdb/00/0a00ed1f0f4de847ac190174
/nsr/res/nsrdb/00/1400ed1f0f4de847ac190174
/nsr/res/nsrdb/00/1e00ed1f0f4de847ac190174
/nsr/res/nsrdb/00/2800ed1f0f4de847ac190174
/nsr/res/nsrdb/00/3200ed1f0f4de847ac190174
/nsr/res/nsrdb/00/3c00ed1f0f4de847ac190174
/nsr/res/nsrdb/00/4600ed1f0f4de847ac190174
/nsr/res/nsrdb/00/5000ed1f0f4de847ac190174
/nsr/res/nsrdb/00/5a00ed1f0f4de847ac190174
/nsr/res/nsrdb/00/6400ed1f0f4de847ac190174
/nsr/res/nsrdb/00/
/nsr/res/nsrdb/01/0b00ed1f0f4de847ac190174
/nsr/res/nsrdb/01/1500ed1f0f4de847ac190174
/nsr/res/nsrdb/01/6500ed1f0f4de847ac190174
/nsr/res/nsrdb/01/4700ed1f0f4de847ac190174
/nsr/res/nsrdb/01/5100ed1f0f4de847ac190174
/nsr/res/nsrdb/01/
/nsr/res/nsrdb/02/0c00ed1f0f4de847ac190174
:$
/nsr/res/nsrdb/09/0900ed1f0f4de847ac190174
/nsr/res/nsrdb/09/1300ed1f0f4de847ac190174
/nsr/res/nsrdb/09/1d00ed1f0f4de847ac190174
/nsr/res/nsrdb/09/2700ed1f0f4de847ac190174
/nsr/res/nsrdb/09/3100ed1f0f4de847ac190174
/nsr/res/nsrdb/09/4500ed1f0f4de847ac190174
/nsr/res/nsrdb/09/4f00ed1f0f4de847ac190174
/nsr/res/nsrdb/09/5900ed1f0f4de847ac190174
/nsr/res/nsrdb/09/6300ed1f0f4de847ac190174
/nsr/res/nsrdb/09/
/nsr/res/nsrdb/
/nsr/res/
/nsr/lic/res/lgtolm.res
/nsr/lic/res/lictype.res
/nsr/lic/res/
/nsr/lic/tmp/lic_res.lck
/nsr/lic/tmp/lgtolm.res.lck
/nsr/lic/tmp/ofd256
/nsr/lic/tmp/lictype.res.lck
/nsr/lic/tmp/
/nsr/lic/logs/lgtolmd.log
/nsr/lic/logs/
/nsr/lic/cores/lgtolmd/.nsr
/nsr/lic/cores/lgtolmd/
/nsr/lic/cores/
/nsr/lic/
/nsr/index/test06/
/nsr/index/
/nsr/mm/
/nsr/tmp/
/nsr/applogs/xbsa.messages
/nsr/applogs/
/nsr/rap/
/nsr/logs/messages
/nsr/logs/summary
/nsr/logs/daemon.log
/nsr/logs/.nsr
/nsr/logs/
/nsr/cores/nsrexecd/.nsr
/nsr/cores/nsrexecd/
/nsr/cores/nsrd/.nsr
/nsr/cores/nsrd/
/nsr/cores/nsrmmdbd/.nsr
/nsr/cores/nsrmmdbd/
/nsr/cores/nsrindexd/.nsr
/nsr/cores/nsrindexd/
/nsr/cores/nsrck/.nsr
/nsr/cores/nsrck/
/nsr/cores/nsrmmd/.nsr
/nsr/cores/nsrmmd/
/nsr/cores/
/nsr/debug/
/nsr/
/
save: /nsr level=full, 80 KB 00:00:00 139 files
save: Using test06 as server
/home/informix/etc/ixbar.0
/home/informix/etc/oncfg_ontest.0
/home/informix/etc/test.cfg
/home/informix/etc/
/home/informix/
/home/
/
save: /home/informix/etc/ level=full, 18 KB 00:00:01 7 files
三,恢复测试
1,首先关闭数据库,停止networker,移动informix目录和/nsr演示数据库坏和networker坏
2,删除networker重新安装,重新安装informix
安装完networker后,放进去磁带,此时的状态为:
[root@test06 installfiles]# nsrmm -m
nsrmm: RAP error: 4mm 20GB tape test.01 not in media index
[root@test06 installfiles]# mminfo -m
mminfo: no matches found for the query
[root@test06 installfiles]# mt -f /dev/nst0 status
SCSI 2 tape drive:
File number=10, block number=2, partition=0.
Tape block size 0 bytes. Density code 0x25 (DDS-3).
Soft error count since last status=0
General status bits on (1010000):
ONLINE IM_REP_EN
[root@test06 installfiles]#
3,scanner重建磁带媒体和索引信息
[root@test06 installfiles]# scanner -i /dev/nst0
scanner: scanning 4mm 20GB tape test.01 on /dev/nst0
scanner: adding 4mm 20GB tape test.01 to pool DBMIData
scanner: ssid 4293414589: scan complete
scanner: ssid 4293414589: 5023 KB, 1 file(s)
scanner: ssid 4276637376: scan complete
scanner: ssid 4276637376: 1865 KB, 1 file(s)
scanner: ssid 4259860270: scan complete
scanner: ssid 4259860270: 5023 KB, 1 file(s)
scanner: ssid 4243083056: scan complete
scanner: ssid 4243083056: 19 KB, 1 file(s)
scanner: ssid 4226305842: scan complete
scanner: ssid 4226305842: 32 KB, 30 file(s)
scanner: ssid 4209528626: scan complete
scanner: ssid 4209528626: 18 KB, 7 file(s)
scanner: ssid 4192751626: scan complete
scanner: ssid 4192751626: 5023 KB, 1 file(s)
scanner: ssid 4175974412: scan complete
scanner: ssid 4175974412: 17 KB, 1 file(s)
scanner: ssid 4159197198: scan complete
scanner: ssid 4159197198: 80 KB, 139 file(s)
scanner: ssid 4142419982: scan complete
scanner: ssid 4142419982: 18 KB, 7 file(s)
scanner: done with 4mm 20GB tape test.01
[root@test06 installfiles]#
常用的scanner参数:
-m 设备 为存储卷内的所有内容重建媒体数据库项
-i 设备 为存储卷内的所有内容重建媒体数据库项和客户机文件索引项。
-S 存储集ID -m 设备 为存储卷内的特定存储集重建媒体数据库项
-S 存储集ID -i 设备 为存储卷内的特定存储集重建媒体数据库项和客户机文件索引项。
-c client_name 只处理来自指定NetWorker客户机的存储集。
-N 存储集名 只处理有存储集名指定的存储集。
-S 存储集ID 向标准输出发送一个特定的存储集
-x 针对每个存储集引入进一步的处理命令。
-B 在卷上定位引导数据库存储集。
4,此时可以加载磁带信息:
[root@test06 installfiles]# nsrmm -m
4mm 20GB tape test.01 mounted on /dev/nst0, write protected
[root@test06 installfiles]# watch
volume written (%) expires read mounts capacity
test.01 17 MB 0.1% 03/26/09 0 KB 1 20 GB
Current tape test.01 MB is used!
[root@test06 installfiles]#
5,用recover恢复备份的配置文件
[root@test06 installfiles]# recover /home/informix/etc
recover: Current working directory is /home/informix/etc/
recover> list
0 file(s) marked for recovery
recover> lf
ixbar.0 oncfg_ontest.0 test.cfg
recover> add ixbar.0
1 file(s) marked for recovery
recover> add oncfg_ontest.0
2 file(s) marked for recovery
recover> add test.cfg
3 file(s) marked for recovery
recover> recover
recover: Total estimated disk space needed for recover is 24 KB.
Recovering 3 files into their original locations
Volumes needed (all on-line):
test.01 at /dev/nst0
Requesting 3 file(s), this may take a while...
./ixbar.0
./oncfg_ontest.0
./test.cfg
Received 3 file(s) from NSR server `test06'
Recover completion time: Tue Mar 25 09:33:18 2008
recover> quit
[root@test06 installfiles]#
onbar恢复失败,查看bar_act.log文件,信息如下:
2008-03-25 09:42:48 22836 22834 /home/informix/bin/onbar_d -r
2008-03-25 09:42:48 22836 22834 (-43078) Open or close failed on file '/home/informix/etc/ixbar.0', errno = 13 .
Permission denied
2008-03-25 09:42:53 22836 22834 /home/informix/bin/onbar_d complete, returning 142 (0x8e)
修改这些文件的属主信息:
[root@test06 etc]# chown informix:informix ixbar.0
[root@test06 etc]# chown informix:informix oncfg_ontest.0
[root@test06 etc]# chown informix:informix test.cfg
重新恢复也是失败,查看bar_act.log得到日志信息:
2008-03-25 09:46:40 22940 22938 /home/informix/bin/onbar_d -r
2008-03-25 09:46:40 22940 22938 Successfully connected to Storage Manager.
2008-03-25 09:47:04 22940 22938 Begin cold level 0 restore rootdbs (Storage Manager copy ID: 1206407178 1206407179).
2008-03-25 09:47:04 22940 22938 Unable to write storage space restore data to the database server: Error opening file /informix.links/rootdbs.
errno=13.
2008-03-25 09:47:04 22940 22938 (-43391) Skipped backup/restore of space 'rootdbs'.
2008-03-25 09:47:09 22940 22938 (-43140) Due to the previous error, logical restore will not be attempted.
2008-03-25 09:47:09 22940 22938 /home/informix/bin/onbar_d complete, returning 131 (0x83)
~
原因:
刚才删除infomrix用户后重新建立了,此时用户的uid和gid与现在的不同,造就/dev/raw/raw1文件的权限不对,修改:
[root@test06 etc]# chown informix.informix /dev/raw/raw1
[root@test06 etc]# chmod 660 /dev/raw/raw1
此时恢复可以成功(服务器没有变化,是同一台服务器)
四,恢复测试
上面的恢复步骤有点担心和服务器没有重新安装有关系,把这台服务器重新安装,然后重新做恢复。
1,scanner重建磁带媒体和索引信息
[root@test06 installfiles]# scanner -i /dev/nst0
scanner: scanning 4mm 20GB tape test.02 on /dev/nst0
scanner: adding 4mm 20GB tape test.02 to pool DBMIData
scanner: ssid 4293417871: scan complete
scanner: ssid 4293417871: 63 KB, 1 file(s)
scanner: ssid 4276789414: scan complete
scanner: ssid 4276789414: 5023 KB, 1 file(s)
scanner: ssid 4260012200: scan complete
scanner: ssid 4260012200: 23 KB, 1 file(s)
scanner: ssid 4243235126: scan complete
scanner: ssid 4243235126: 5023 KB, 1 file(s)
scanner: ssid 4226457912: scan complete
scanner: ssid 4226457912: 17 KB, 1 file(s)
scanner: ssid 4209680848: scan complete
scanner: ssid 4209680848: 5023 KB, 1 file(s)
scanner: ssid 4192903634: scan complete
scanner: ssid 4192903634: 17 KB, 1 file(s)
scanner: ssid 4176126419: scan complete
scanner: ssid 4176126419: 104 KB, 30 file(s)
scanner: ssid 4159349203: scan complete
scanner: ssid 4159349203: 20 KB, 7 file(s)
scanner: ssid 4142572070: scan complete
scanner: ssid 4142572070: 5023 KB, 1 file(s)
scanner: ssid 4125794856: scan complete
scanner: ssid 4125794856: 17 KB, 1 file(s)
scanner: ssid 4109017641: scan complete
scanner: ssid 4109017641: 153 KB, 141 file(s)
scanner: ssid 4092240425: scan complete
scanner: ssid 4092240425: 20 KB, 7 file(s)
scanner: done with 4mm 20GB tape test.02
[root@test06 installfiles]#
2,加载磁带
[root@test06 installfiles]# nsrmm -m
4mm 20GB tape test.02 mounted on /dev/nst0, write protected
[root@test06 installfiles]# watch
volume written (%) expires read mounts capacity
test.02 21 MB 0.1% 03/28/09 0 KB 1 20 GB
Current tape test.02 MB is used!
[root@test06 installfiles]#
3,用recover恢复备份的配置文件
[root@test06 installfiles]# recover /home/informix/etc
recover: Current working directory is /home/informix/etc/
recover> lf
ixbar.0 oncfg_ontest.0 test.cfg
recover> add ixbar.0
1 file(s) marked for recovery
recover> add oncfg_ontest.0
2 file(s) marked for recovery
recover> add test.cfg
3 file(s) marked for recovery
recover> recover
recover: Total estimated disk space needed for recover is 24 KB.
Recovering 3 files into their original locations
Volumes needed (all on-line):
test.02 at /dev/nst0
Requesting 3 file(s), this may take a while...
./ixbar.0
./oncfg_ontest.0
./test.cfg
Received 3 file(s) from NSR server `test06'
Recover completion time: Thu Mar 27 06:33:44 2008
recover> quit
[root@test06 installfiles]#
4,
[informix@test06 informix]$ onbar -r
[informix@test06 informix]$ echo $?
131
[informix@test06 informix]$
2008-03-27 06:47:05 15306 15304 /home/informix/bin/onbar_d -r
2008-03-27 06:47:05 15306 15304 Successfully connected to Storage Manager.
2008-03-27 06:47:33 15306 15304 Begin cold level 0 restore rootdbs (Storage Manager copy ID: 1206559269 1206559270).
2008-03-27 06:47:33 15306 15304 Unable to write storage space restore data to the database server: Error opening file /informix.links/rootdbs.
errno=13.
2008-03-27 06:47:33 15306 15304 (-43391) Skipped backup/restore of space 'rootdbs'.
2008-03-27 06:47:38 15306 15304 (-43140) Due to the previous error, logical restore will not be attempted.
2008-03-27 06:47:38 15306 15304 /home/informix/bin/onbar_d complete, returning 131 (0x83)
当时的raw文件权限不对,重新onbar -r 恢复也是可以成功的!
转自:http://tonykorn97.itpub.net/post/6414/458421
说实话,感觉他写的比较悬乎,具体能 不能用就自己测试去吧。