DM数据库物理备份还原操作
程序员文章站
2022-06-03 10:06:33
...
文章目录
数据库备份
开启本地归档
在进行联机库级备份、归档备份和表空间备份时,必须保证系统处于归档模式,否则联机备份不能进行。
创建归档目录
mkidr /dm8/arch
数据库在mount状态开启归档
SQL> alter database mount;
SQL> alter database add archivelog 'type=local,dest=/dm8/arch,file_size=64,space_limit=0';
SQL>alter database archivelog;
SQL> alter database open;
查询归档状态
SQL> select name,status$,arch_mode from v$database;
行号 NAME STATUS$ ARCH_MODE
---------- ------ ----------- ---------
1 dameng 4 Y
数据库备份
全备
[[email protected] bak]$ dmrman
dmrman V8
RMAN> backup database backupset '/dm8/backup/bak_1119';
[-8301]:第[1]行,第[16]列[backupset]附近出现错误[-2007]:语法分析出错
报错是因为在dmrman 执行backup 命令和 在disql 中执行不同。
需要在 disql 中备份
SQL> backup database backupset '/dm8/backup/bak_1119';
操作已执行
已用时间: 996.649(毫秒). 执行号:11.
设定备份名称
使用to 设置备份名称,缺省默认名称 DB_库名_备份类型_备份时间
SQL> backup database to full_bak backupset '/dm8/backup/full_1119';
操作已执行
已用时间: 988.841(毫秒). 执行号:13.
压缩备份
指定compressed level ,范围0-9,0不压缩,默认1,9级最高
SQL> backup database to full_compress backupset '/dm8/backup/full_compress_1119' compressed level 9;
操作已执行
已用时间: 00:00:02.572. 执行号:14.
指定备份线程
task thread 参数指定,范围 0-64,默认 4 ,不超过主机核数
SQL> backup database backupset '/dm8/backup/bak_1119_2' task thread 8;
操作已执行
已用时间: 994.965(毫秒). 执行号:15.
查看备份集-----dmrman下查看
RMAN> show backupset '/dm8/backup/bak_1119';
show backupset '/dm8/backup/bak_1119';
<backupset [DEVICE TYPE:DISK, BACKUP_PATH: /dm8/backup/bak_1119] info start ..........>
<DB INFO>
...
...
<backup_piece_list>
$file_seq |$size(KB) |$pos_desc |$content_type
0 |15919 |bak_1119.bak |DATA
1 |7 |bak_1119_1.bak |LOG
<data_file_list>
$file_seq |$group_id |$group_name |$file_id |$file_path |$mirror_path |$file_len
1 |0 |SYSTEM |0 |/dm8/data/dameng/SYSTEM.DBF | |27262976
2 |1 |ROLL |0 |/dm8/data/dameng/ROLL.DBF | |268435456
3 |4 |MAIN |0 |/dm8/data/dameng/MAIN.DBF | |134217728
4 |6 |TEST |0 |/dm8/data/dameng/test01.dbf | |33554432
5 |6 |TEST |1 |/dm8/data/test02.dbf | |33554432
<arch_file_list>
$file_seq |$dsc_seq |$file_len |$begin_seqno |$begin_lsn |$end_seqno |$end_lsn
6 |0 |1536 |4532 |71201 |4534 |71206
<huge_file_list>
$group_id |$schema_id|$table_id |column_id |$file_id |$file_len |$path
<backupset [DEVICE TYPE:DISK, BACKUP_PATH: /dm8/backup/bak_1119] info end .>
show backupsets successfully.
time used: 103.838(ms)
增量备份
SQL> backup database increment backupset '/dm8/backup/bak_inc_1119_1';
操作已执行
已用时间: 967.333(毫秒). 执行号:12.
数据库还原
DMRMAN 是 DM 提供的命令行工具,无需额外地安装。使用 DMRMAN 工具只可对数据库进行脱机备份(联机备份需要通过 DIsql 工具实现)。目前目标库的还原仅支持脱机还原,可通过 DMRMAN 和 CONSOLE 工具实现。
restore 操作
RMAN> restore database '/dm8/data/dameng/dm.ini' from backupset '/dm8/backup/bak_1119';
restore database '/dm8/data/dameng/dm.ini' from backupset '/dm8/backup/bak_1119';
RESTORE DATABASE CHECK......
RESTORE DATABASE,data collect......
RESTORE DATABASE,database refresh ......
RESTORE BACKUPSET [/dm8/backup/bak_1119] START......
total 0 packages processed...
RESTORE DATABASE,UPDATE ctl file......
RESTORE DATABASE,REBUILD key file......
RESTORE DATABASE,CHECK db info......
RESTORE DATABASE,UPDATE db info......
CMD END.CODE:[0]
restore successfully.
time used: 492.609(ms)
recover 操作
RMAN> recover database '/dm8/data/dameng/dm.ini' from backupset '/dm8/backup/bak_1119';
recover database '/dm8/data/dameng/dm.ini' from backupset '/dm8/backup/bak_1119';
Database mode = 0, oguid = 0
EP[0]'s cur_lsn[71201]
RESTORE RLOG CHECK......
RESTORE RLOG, gen tmp file......
RESTORE RLOG FROM BACKUPSET [/dm8/backup/bak_1119] START......
CMD END.CODE:[0]
EP:0 total 1 pkgs applied, percent: 50%
EP:0 total 2 pkgs applied, percent: 100%
Recover from archive log finished, time used:0.004s.
recover successfully!
time used: 299.707(ms)
RMAN>
db_magic 更新
[[email protected] backup]$ /dm8/bin/DmServicedameng start
Starting DmServicedameng: [ FAILED ]
file dm.key not found, use default license!
version info: develop
Use normal os_malloc instead of HugeTLB
Use normal os_malloc instead of HugeTLB
DM Database Server x64 V8 1-1-88-20.06.24-123627-ENT startup...
Database mode = 0, oguid = 0
License will expire on 2021-06-24
Instance DAMENG startup failed, execute 'recover database ... update db_magic' in dmrman.
启动数据库服务
[[email protected] backup]$ /dm8/bin/DmServicedameng start
Starting DmServicedameng: [ OK ]
登录验证
[[email protected] backup]$ disql sysdba/[email protected]:5236
服务器[localhost:5236]:处于普通打开状态
登录使用时间: 5.105(毫秒)
disql V8
SQL> select * from v$instance;
行号 NAME INSTANCE_NAME INSTANCE_NUMBER HOST_NAME SVR_VERSION DB_VERSION
---------- ------ ------------- --------------- --------- -------------------------- -------------------
START_TIME STATUS$ MODE$
---------------------------------------------------------------------------------------------------- ------- ------
OGUID DSC_SEQNO DSC_ROLE
----------- ----------- --------
1 DAMENG DAMENG 1 dm8 DM Database Server x64 V8 DB Version: 0x7000a
2020-11-19 18:40:36 OPEN NORMAL
0 0 NULL
已用时间: 5.247(毫秒). 执行号:4.
上一篇: DM达梦数据库导入导出dexp和dimp命令详细使用方法
下一篇: DM数据库定时作业备份
推荐阅读