作業系統和informix資料庫全部損壞恢復測試

tonykorn97發表於2008-03-27

一,安裝作業系統(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 恢復也是可以成功的!

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/312079/viewspace-245845/,如需轉載,請註明出處,否則將追究法律責任。

相關文章