DM8实操经验 dmrman备份还原遇到的问题及解决方法
1、脱机备份
保证数据库在脱机状态:
[dmdba@localhost bin]$ cd /etc/init.d/
[dmdba@localhost init.d]$ ./DmServiceDMSERVER stop
Stopping DmServiceDMSERVER: [ OK ]
在bin目录下执行,发现报错
[root@localhost bin]# ./dmrman
dmrman V8
RMAN> backup database ‘/dm8/data/DAMENG/dm.ini’ full backupset ‘/dm8/back/db2.bak’; backup database ‘/dm8/data/DAMENG/dm.ini’ full backupset ‘/dm8/back/db2.bak’; Database mode = 0, oguid = 0
EP[0]'s cur_lsn[62562]
Processing backupset /dm8/back/db2.bak [Percent:0.00%][Speed:0.00M/s][Cost:00:00:00][Remaining:00:00:00]
[-7169]:bakres 与 DMAP 消息通信失败
重新启动 AP 服务后恢复正常
backup database ‘/dm8/data/DAMENG/dm.ini’ full backupset ‘/dm8/back/db2.bak’;
file dm.key not found, use default license!
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[29150], file_lsn[29150]
Processing backupset /dm8/back/db2.bak
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:00][Remaining:00:00:00]
backup successfully!
time used: 00:00:01.065
2、开始dmrman还原
[root@localhost ~]# cd /dm8/bin
[root@localhost bin]# ./dmrman
dmrman V8
RMAN> restore database ‘/dm8/data/DAMENG/dm.ini’ from backupset ‘/dm8/back/db2.bak’;
出现报错
restore database ‘/dm8/data/DAMENG/dm.ini’ from backupset ‘/dm8/backup/db2.bak’;
file dm.key not found, use default license!
[Percent:0.00%][Speed:0.00M/s][Cost:00:00:01][Remaining:00:00:00]
[-10001]:[错误码:-127]无效的备份集目录[/dm8/backup/db2.bak]
RMAN> restore database ‘/dm8/data/DAMENG/dm.ini’ from backupset ‘/dm8/back/db2.bak’;
restore database ‘/dm8/data/DAMENG/dm.ini’ from backupset ‘/dm8/back/db2.bak’;
[Percent:0.00%][Speed:0.00M/s][Cost:00:00:00][Remaining:00:00:00]Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:02][Remaining:00:00:00]
[-8024]:数据文件读写出错
检查数据文件权限后发现是数据文件的用户不对,换为dmdba
[root@localhost DAMENG]# pwd
/dm8/data/DAMENG
[root@localhost DAMENG]# ls -lthr
总用量 2.2G
drwxr-xr-x 2 dmdba dinstall 4.0K 5月 24 22:19 bak
-rw-r–r-- 1 dmdba dinstall 481 5月 24 22:19 sqllog.ini
-rw-r–r-- 1 dmdba dinstall 931 5月 24 22:19 dminit20210524221928.log
drwxr-xr-x 2 dmdba dinstall 4.0K 5月 24 22:19 trace
-rw-r–r-- 1 dmdba dinstall 12 5月 24 22:19 rep_conflict.log
-rw-r–r-- 1 dmdba dinstall 50K 5月 24 23:10 dm.ini
-rw-r–r-- 1 dmdba dinstall 303 5月 24 23:10 dmarch.ini
-rw-r–r-- 1 dmdba dinstall 633 5月 24 23:41 dm_service.prikey
-rw-r–r-- 1 dmdba dinstall 10M 5月 25 00:04 TEMP.DBF
-rw-r–r-- 1 root root 23M 5月 25 00:47 SYSTEM.DBF
-rw-r–r-- 1 root root 128M 5月 25 00:47 ROLL.DBF
-rw-r–r-- 1 root root 128M 5月 25 00:47 MAIN.DBF
-rw-r–r-- 1 root root 128M 5月 25 00:47 TBS01.dbf
-rw-r–r-- 1 root root 128M 5月 25 00:47 TBS02.dbf
-rw-r–r-- 1 root root 128M 5月 25 00:47 HRDB.dbf
drwxr-xr-x 2 root root 4.0K 5月 25 00:47 HMAIN
-rw-r–r-- 1 dmdba dinstall 7.0K 5月 25 00:47 dm.ctl
drwxr-xr-x 2 dmdba dinstall 4.0K 5月 25 00:47 ctl_bak
-rw-r–r-- 1 root root 500M 5月 25 00:47 DAMENG01.log
-rw-r–r-- 1 root root 500M 5月 25 00:47 DAMENG02.log
-rw-r–r-- 1 root root 500M 5月 25 00:47 DAMENG03.log
[root@localhost DAMENG]# chown -R dmdba:dinstall *
再次执行恢复操作发现还是报相同错误,部分文件的用户和用户组又变成了root
然后突然想到自己是通过root用户启动的dmrman,于是换成dmdba用户启动:
[root@localhost bin]# su dmdba
[dmdba@localhost bin]$ ./dmrman
dmrman V8
RMAN> restore database ‘/dm8/data/DAMENG/dm.ini’ from backupset ‘/dm8/back/db2.bak’;
restore database ‘/dm8/data/DAMENG/dm.ini’ from backupset ‘/dm8/back/db2.bak’;
[Percent:0.00%][Speed:0.00M/s][Cost:00:00:00][Remaining:00:00:00]Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:00][Remaining:00:00:00]
restore successfully.
time used: 470.516(ms)
换成dmdba用户后就能成功执行了,继续恢复:
RMAN> recover database ‘/dm8/data/DAMENG/dm.ini’ from backupset ‘/dm8/back/db2.bak’;
recover database ‘/dm8/data/DAMENG/dm.ini’ from backupset ‘/dm8/back/db2.bak’;
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[25375], file_lsn[25375]
EP:0 total 0 pkgs applied, percent: 0%
EP:0 total 16 pkgs applied, percent: 10%
EP:0 total 32 pkgs applied, percent: 21%
EP:0 total 48 pkgs applied, percent: 31%
EP:0 total 64 pkgs applied, percent: 42%
EP:0 total 80 pkgs applied, percent: 52%
EP:0 total 96 pkgs applied, percent: 63%
EP:0 total 112 pkgs applied, percent: 73%
EP:0 total 128 pkgs applied, percent: 84%
EP:0 total 144 pkgs applied, percent: 94%
EP:0 total 152 pkgs applied, percent: 100%
recover successfully!
time used: 406.437(ms)
更新数据库魔数:
RMAN> recover database ‘/dm8/data/DAMENG/dm.ini’ update db_magic;
recover database ‘/dm8/data/DAMENG/dm.ini’ update db_magic;
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[27678], file_lsn[27678]
recover successfully!
time used: 00:00:01.087
RMAN>
3、启动数据库服务,连接数据库
[dmdba@localhost bin]$ cd /etc/init.d/
[dmdba@localhost init.d]$ ./DmServiceDMSERVER start
Starting DmServiceDMSERVER: [ OK ]
[dmdba@localhost init.d]$ cd /dm8/bin
[dmdba@localhost bin]$ ./disql SYSDBA/dameng123
服务器[LOCALHOST:5236]:处于普通打开状态
登录使用时间 : 2.764(ms)
disql V8
SQL>
注:还原时,还有一种情况也会报‘[-8024]:数据文件读写出错’,就是备份文件损坏,这个可以通过查看备份文件的MD5值来查看复制过来的备份文件是否发生改变,若备份文件错误,只能重新备份