注册
达梦DM8当只有备份集文件时使用dmrman完成异路径恢复操作
专栏/培训园地/ 文章详情 /

达梦DM8当只有备份集文件时使用dmrman完成异路径恢复操作

dmwwei 2024/01/23 920 0 0
摘要

当只有dmrman备份集文件时(也就是无dm.ini和dm.ctl等文件时),如何能快速的在新环境下,且不同数据文件目录下,完成达梦数据库的还原恢复呢?

1. 测试前提

1)安装好DM8数据库软件,无需dminit命令初始化实例
2)dmrman全备的备份集文件

2. 测试目的

当要恢复的路径和原路径不同时,如何能快速的完成恢复操作?例如:
1)源库:dbname: DMSERVER, 实例名:DMSERVER,
数据文件路径:/dm8/dmdbms/data/DAMENG/
2)目标端:恢复至不同路径下,
dbname: DMSERVER, 实例名:DMSERVER,
数据文件路径:/dm8/dmdbms/data/dm02/

3. dmrman恢复命令

3.1 restore还原

RMAN> RESTORE DATABASE TO '/dm8/dmdbms/data/dm02/' OVERWRITE FROM BACKUPSET '/dm8/dmdbms/data/DAMENG/bak/DB_DAMENG_FULL_20221031_232339_978546';

3.2 recover恢复

RMAN> RECOVER DATABASE '/dm8/dmdbms/data/dm02/dm.ini' FROM BACKUPSET '/dm8/dmdbms/data/DAMENG/bak/DB_DAMENG_FULL_20221031_232339_978546'

3.3 更新db_magic值

RMAN> RECOVER DATABASE '/dm8/dmdbms/data/dm02/dm.ini' UPDATE DB_MAGIC

说明:TO指向要恢复的新路径;OVERWRITE指如果文件存在则覆盖(因为是新路径,所以此参数可省略);BACKUPSET备份集路径可以指向任意dmdba用户权限下的路径。

4. 测试过程

4.1 创建dm02新路径,模拟新环境

[dmdba@master data]$ ls -lrt
total 4
drwxr-xr-x 2 dmdba dinstall 4096 Oct 13 18:36 dmfldr
drwxr-xr-x 2 dmdba dinstall 34 Oct 21 12:10 log
drwxr-xr-x 7 dmdba dinstall 321 Oct 31 22:55 DAMENG
[dmdba@master data]$ mkdir -p dm02
[dmdba@master data]$ cd dm02/
[dmdba@master dm02]$ ls -l
total 0
[dmdba@master dm02]$

4.2 Restore还原

---dmrman还原操作:

[dmdba@master dm02]$ /dm8/dmdbms/bin/dmrman CTLSTMT="RESTORE DATABASE TO '/dm8/dmdbms/data/dm02/' OVERWRITE FROM BACKUPSET '/dm8/dmdbms/data/DAMENG/bak/DB_DAMENG_FULL_20221031_232339_978546'"
dmrman V8
RESTORE DATABASE TO '/dm8/dmdbms/data/dm02/' OVERWRITE FROM BACKUPSET '/dm8/dmdbms/data/DAMENG/bak/DB_DAMENG_FULL_20221031_232339_978546'
file dm.key not found, use default license!
chattr: No such file or directory while trying to stat /dm8/dmdbms/data/dm02/dm.ctl
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]
restore successfully.
time used: 00:00:02.781
[dmdba@master dm02]$ ls -l
total 3133524
-rw-r--r-- 1 dmdba dinstall 268435456 Oct 31 23:26 DAMENG01.log
-rw-r--r-- 1 dmdba dinstall 268435456 Oct 31 23:26 DAMENG02.log
-rw-r--r-- 1 dmdba dinstall 5632 Oct 31 23:26 dm.ctl
-rw-r--r-- 1 dmdba dinstall 59755 Oct 31 23:26 dm.ini
-rw-r--r-- 1 dmdba dinstall 633 Oct 31 23:26 dm_service.prikey
drwxr-xr-x 2 dmdba dinstall 6 Oct 31 23:26 HMAIN
-rw-r--r-- 1 dmdba dinstall 236978176 Oct 31 23:26 MAIN.DBF
-rw-r--r-- 1 dmdba dinstall 2241855488 Oct 31 23:26 ROLL.DBF
-rw-r--r-- 1 dmdba dinstall 192937984 Oct 31 23:26 SYSTEM.DBF
[dmdba@master dm02]$

4.3 检查dm.ini文件和dm.ctl文件

--检查dm.ini文件中的path路径信息

[dmdba@master dm02]$ more dm.ini
#DaMeng Database Server Configuration file
#this is comments
#file location of dm.ctl
CTL_PATH = /dm8/dmdbms/data/dm02/dm.ctl #ctl file path
CTL_BAK_PATH = /dm8/dmdbms/data/dm02/ctl_bak #dm.ctl backup path
CTL_BAK_NUM = 10 #backup number of dm.ctl, allowed to keep one more backup file besides specified number.
SYSTEM_PATH = /dm8/dmdbms/data/dm02 #system path
CONFIG_PATH = /dm8/dmdbms/data/dm02 #config path
TEMP_PATH = /dm8/dmdbms/data/dm02 #temporary file path
BAK_PATH = /dm8/dmdbms/data/dm02/bak #backup file path
DFS_PATH = $/DAMENG #path of db_file in dfs
#instance name
INSTANCE_NAME = DMSERVER #Instance name

--检查dm.ctl文件中的path路径信息

[dmdba@master dm02]$ /dm8/dmdbms/bin/dmctlcvt TYPE=1 SRC=/dm8/dmdbms/data/dm02/dm.ctl DEST=/dm8/dmdbms/data/dm02/dmctl.txt
DMCTLCVT V8
convert ctl to txt success!
[dmdba@master dm02]$ cat dmctl.txt |grep -i path
#file path
fil_path=/dm8/dmdbms/data/dm02/SYSTEM.DBF
#file path
fil_path=/dm8/dmdbms/data/dm02/ROLL.DBF
#file path
fil_path=/dm8/dmdbms/data/dm02/DAMENG01.log
#file path
fil_path=/dm8/dmdbms/data/dm02/DAMENG02.log
#file path
fil_path=/dm8/dmdbms/data/dm02/MAIN.DBF
#huge path
huge_path=/dm8/dmdbms/data/dm02/HMAIN
#huge path create time
#huge path modify time
[dmdba@master dm02]$

4.4 Recover恢复

[dmdba@master dm02]$ /dm8/dmdbms/bin/dmrman CTLSTMT="RECOVER DATABASE '/dm8/dmdbms/data/dm02/dm.ini' FROM BACKUPSET '/dm8/dmdbms/data/DAMENG/bak/DB_DAMENG_FULL_20221031_232339_978546'"
dmrman V8
RECOVER DATABASE '/dm8/dmdbms/data/dm02/dm.ini' FROM BACKUPSET '/dm8/dmdbms/data/DAMENG/bak/DB_DAMENG_FULL_20221031_232339_978546'
file dm.key not found, use default license!
Read ini warning, default dm.ctl backup path [/dm8/dmdbms/data/dm02/ctl_bak] does not exist.
Read ini warning, default backup path [/dm8/dmdbms/data/dm02/bak] does not exist.
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[3840456], file_lsn[3840456]
[Percent:100.00%][Speed:0.00PKG/s][Cost:00:00:00][Remaining:00:00:00]
recover successfully!
time used: 00:00:02.571
[dmdba@master dm02]$

4.5 更新DB_MAGIC值

[dmdba@master dm02]$ /dm8/dmdbms/bin/dmrman CTLSTMT="RECOVER DATABASE '/dm8/dmdbms/data/dm02/dm.ini' UPDATE DB_MAGIC"
dmrman V8
RECOVER DATABASE '/dm8/dmdbms/data/dm02/dm.ini' UPDATE DB_MAGIC
file dm.key not found, use default license!
Read ini warning, default dm.ctl backup path [/dm8/dmdbms/data/dm02/ctl_bak] does not exist.
Read ini warning, default backup path [/dm8/dmdbms/data/dm02/bak] does not exist.
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[3843562], file_lsn[3843562]
recover successfully!
time used: 00:00:01.035
[dmdba@master dm02]$

4.6 启动数据库

[dmdba@dmdb01 dm02]$ /dm8/dmdbms/bin/dmserver /dm8/dmdbms/data/dm02/dm.ini

image.png
注意:启动完成后,需要手动配置归档模式,指定归档目录为新路径(备份集中是包含dmarch.ini文件的,但是内容为空);并且需要手动创建arch/、bak/和ctl_bak/目录。

评论
后发表回复

作者

文章

阅读量

获赞

扫一扫
联系客服