注册
达梦数据库dmrman 全备增备归档备份恢复
专栏/培训园地/ 文章详情 /

达梦数据库dmrman 全备增备归档备份恢复

叶坤 2024/05/28 633 0 0
摘要

数据库的备份恢复是数据库管理人员必须掌握的技能。本文介绍达梦数据库全备,增备,归档日志的备份。以及基于全备、增备、归档日志备份的恢复操作。

开启本地归档

vi /dm8/data/testdb/dm.ini

ARCH_INI = 1

vi /dm8/data/testdb/dmarch.ini

[ARCHIVE_LOCAL1]

ARCH_TYPE=LOCAL

ARCH_DEST=/dm8/testdb/arch

ARCH_FILE_SIZE=2048

ARCH_SPACE_LIMIT=10240

重启数据库

systemctl restart DmServiceTESTINSTANCE.service

select para_name,PARA_VALUE from v$dm_ini where para_name like '%ARCH%';

insert into dmtest.test01 values(100);

commit;

关闭数据库并全量脱机备份数据库

systemctl stop DmServiceTESTINSTANCE.service

BACKUP DATABASE '/dm8/data/testdb/dm.ini' FULL TO BACKUP_FILE1 BACKUPSET '/dm8/backup/BACKUP_FILE_01';

启动数据库并插入一笔数据

systemctl start DmServiceTESTINSTANCE.service

insert into dmtest.test01 values(200);

commit;

systemctl stop DmServiceTESTINSTANCE.service

增量数据库备份

backup database '/dm8/data/testdb/dm.ini' increment with backupdir '/dm8/backup/BACKUP_FILE_01/' backupset '/dm8/backup/BACKUP_FILE_01/BACKUP_FILE_02';  --增量备份在全备份下

归档数据库备份

启动数据库并插入一条sql

insert into dmtest.test01 values(300);

commit;

backup archive log all database '/dm8/data/testdb/dm.ini' backupset '/dm8/backup/BACKUP_FILE_02';

--恢复数据库

RESTORE DATABASE '/dm8/data/testdb/dm.ini' FROM BACKUPSET '/dm8/backup/BACKUP_FILE_01/BACKUP_FILE_02';   --此处指定增量备份的目录即可
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:03][Remaining:00:00:00]
restore successfully.
time used: 00:00:04.149

restore archive log from backupset '/dm8/backup/BACKUP_FILE_02' to archivedir '/dm8/arch';  --恢复归档日志

restore archive log from backupset '/dm8/backup/BACKUP_FILE_02' to archivedir '/dm8/arch';
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:00][Remaining:00:00:00]
restore successfully.
time used: 159.983(ms)

recover database '/dm8/data/testdb/dm.ini' with archivedir '/dm8/arch';  --基于归档日志恢复
Database mode = 2, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[446190], file_lsn[446190]
[Percent:100.00%][Speed:0.00PKG/s][Cost:00:00:00][Remaining:00:00:00]
recover successfully!
time used: 459.073(ms)

recover database '/dm8/data/testdb/dm.ini' update db_magic;  --更新数据库魔数

Database mode = 2, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[446660], file_lsn[446660]
recover successfully!
time used: 00:00:01.099

登陆数据库查看数据
SQL> SELECT * FROM DMTEST.TEST01;

LINEID     ID


1          100
2          200
3          300

used time: 2.879(ms). Execute id is 1201.

数据被全部恢复出来。

评论
后发表回复

作者

文章

阅读量

获赞

扫一扫
联系客服