DM8表空间备份还原

1、在DMHR表空间创建测试表 
create table dmhr.CITY_TEST tablespace DMHR as select * from dmhr.CITY ; 
SQL> select count(*) from dmhr.CITY_TEST; 
行号 COUNT(*) 
---------- -------------------- 
1 11 
2、表空间级,全备和增备 
表空间全备: 
SQL> BACKUP TABLESPACE DMHR BACKUPSET '/dm/dmback/ts_dmhr_full_bak_01'; 
操作已执行 
已用时间: 00:00:03.497. 执行号:900. 
SQL> insert into dmhr.CITY_TEST select * from dmhr.CITY_TEST;commit; 
DMSQL 过程已成功完成 
已用时间: 6.127(毫秒). 执行号:1000. 
SQL> select count(*) from dmhr.CITY_TEST; 
行号 COUNT(*) 
---------- -------------------- 
1 22 
表空间增备: 
SQL> BACKUP TABLESPACE DMHR INCREMENT BASE ON BACKUPSET '/dm/dmback/ts_dmhr_full_bak_01' BACKUPSET '/dm/dmback/ts_dmhr_increment_bak_02'; 
SQL> alter system switch logfile; 
操作已执行 
已用时间: 11.695(毫秒). 执行号:0. 
SQL> select sysdate from dual; 
行号 SYSDATE 
---------- ------------------- 
1 2023-07-14 14:29:54 
3、模拟删除DMHR表空间的数据文件 
SQL> select t.FILE_NAME from DBA_DATA_FILES t where t.TABLESPACE_NAME='DMHR'; 
行号 FILE_NAME 
---------- ------------------------ 
1 /dm/dmdata/CB/DMHR01.dbf 
[dmdba@Kylin01 CB]$ rm -rf /dm/dmdata/CB/DMHR01.dbf 
[dmdba@Kylin01 CB]$ ls -rlt /dm/dmdata/CB/DMHR01.dbf 
ls: 无法访问 '/dm/dmdata/CB/DMHR01.dbf': 没有那个文件或目录 
4、表空间还原 
注意:表空间不能跨库还原(还原报错:[-8232]:备份集DB_MAGIC与当前库不匹配) 
[dmdba@Kylin01 dmback]$ DmServiceDMSERVER stop 
Stopping DmServiceDMSERVER: [ OK ] 
--还原表空间全量 
RESTORE DATABASE '/dm/dmdata/CB/dm.ini' TABLESPACE DMHR FROM BACKUPSET '/dm/dmback/ts_dmhr_full_bak_01'; 
--还原表空间增量 
RESTORE DATABASE '/dm/dmdata/CB/dm.ini' TABLESPACE DMHR FROM BACKUPSET '/dm/dmback/ts_dmhr_increment_bak_02'; 
--表空间恢复 
RECOVER DATABASE '/dm/dmdata/CB/dm.ini' TABLESPACE DMHR; 
还原过程: 
[dmdba@Kylin01 CB]$ DmServiceDMSERVER stop 
Stopping DmServiceDMSERVER: [ OK ] 
[dmdba@Kylin01 CB]$ dmrman 
dmrman V8 
RMAN> RESTORE DATABASE '/dm/dmdata/CB/dm.ini' TABLESPACE DMHR FROM BACKUPSET '/dm/dmback/ts_dmhr_full_bak_01'; 
RESTORE DATABASE '/dm/dmdata/CB/dm.ini' TABLESPACE DMHR FROM BACKUPSET '/dm/dmback/ts_dmhr_full_bak_01'; 
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[90151], file_lsn[90151] 
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:02][Remaining:00:00:00] 
restore successfully. 
time used: 00:00:02.515 
RMAN> exit 
time used: 0.288(ms) 
[dmdba@Kylin01 CB]$ ls -rlt /dm/dmdata/CB/DMHR01.dbf 
-rw-r--r-- 1 dmdba dinstall 268435456 5月 29 14:31 /dm/dmdata/CB/DMHR01.dbf 
[dmdba@Kylin01 CB]$ dmrman 
dmrman V8 
RMAN> RESTORE DATABASE '/dm/dmdata/CB/dm.ini' TABLESPACE DMHR FROM BACKUPSET '/dm/dmback/ts_dmhr_increment_bak_02'; 
RESTORE DATABASE '/dm/dmdata/CB/dm.ini' TABLESPACE DMHR FROM BACKUPSET '/dm/dmback/ts_dmhr_increment_bak_02'; 
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[90151], file_lsn[90151] 
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:02][Remaining:00:00:00] 
restore successfully. 
time used: 00:00:02.543 
RMAN> RECOVER DATABASE '/dm/dmdata/CB/dm.ini' TABLESPACE DMHR; 
RECOVER DATABASE '/dm/dmdata/CB/dm.ini' TABLESPACE DMHR; 
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[90151], file_lsn[90151] 
dres_backupset_recover_ts bgein. 
[Percent:100.00%][Speed:0.00PKG/s][Cost:00:00:00][Remaining:00:00:00] 
dres_backupset_recover_ts end. 
recover successfully. 
time used: 476.392(ms) 
RMAN> 
验证: 
[dmdba@Kylin01 CB]$ disql sysdba/dameng123 
服务器[LOCALHOST:5236]:处于普通打开状态 
登录使用时间 : 3.009(ms) 
disql V8 
SQL> select count(*) from dmhr.CITY_TEST; 
行号 COUNT(*) 
---------- -------------------- 
1 22 
已用时间: 4.988(毫秒). 执行号:500. 
SQL> 
SQL> select t.FILE_NAME from DBA_DATA_FILES t where t.TABLESPACE_NAME='DMHR'; 
行号 FILE_NAME 
---------- ------------------------ 
1 /dm/dmdata/CB/DMHR01.dbf

达梦在线服务平台:https://eco.dameng.com

你可能感兴趣的:(达梦,达梦,表空间,备份,还原)