达梦归档归档日志丢失不连续的备份处理

环境:
OS:Centos 7
DB:DM8

 

1.归档目录看不出连续性

[dmdba@host01 arch]$ ls -al
total 148
drwxr-xr-x 2 dmdba dinstall    250 Mar 20 14:09 .
drwxr-xr-x 7 dmdba dinstall     67 Mar 15 14:47 ..
-rw-r--r-- 1 dmdba dinstall 118784 Mar 20 14:03 ARCHIVE_LOCAL1_0x61603F60_EP0_2024-03-20_13-50-25.log
-rw-r--r-- 1 dmdba dinstall  16384 Mar 20 14:06 ARCHIVE_LOCAL1_0x61603F60_EP0_2024-03-20_14-04-05.log
-rw-r--r-- 1 dmdba dinstall   8192 Mar 20 14:09 ARCHIVE_LOCAL1_0x61603F60_EP0_2024-03-20_14-07-38.log
-rw-r--r-- 1 dmdba dinstall   8192 Mar 20 14:09 ARCHIVE_LOCAL1_0x61603F60_EP0_2024-03-20_14-09-57.log

若是其中一个归档被删除,只有在联机备份的时候才会有提示,如下:

SQL> backup database full backupset '/dmdbms/bak/fullbak_20240320';
backup database full backupset '/dmdbms/bak/fullbak_20240320';
[-730]:Archive log absent.
used time: 00:00:03.995. Execute id is 0.


这里丢失的是中间的归档,好像丢失第一个归档是可以备份的.

单独备份归档日志是失败的:

SQL> backup archivelog to "archbak_20240320" backupset '/dmdbms/bak/archbak_20240320';
backup archivelog to "archbak_20240320" backupset '/dmdbms/bak/archbak_20240320';
[-718]:Archive log collected not consecutive.
used time: 00:00:02.892. Execute id is 0.

 

2.若要成功备份需要重启下数据库

[root@host01 ~]#systemctl stop DmServiceDMSERVER.service
[root@host01 ~]#systemctl start DmServiceDMSERVER.service

全备可以成功:

SQL> backup database full backupset '/dmdbms/bak/fullbak_20240320';
executed successfully
used time: 00:00:03.051. Execute id is 501

 

但是备份归档还是失败的

SQL> backup archivelog to "archbak_20240320" backupset '/dmdbms/bak/archbak_20240320';
backup archivelog to "archbak_20240320" backupset '/dmdbms/bak/archbak_20240320';
[-718]:Archive log collected not consecutive.
used time: 00:00:02.841. Execute id is 0.

 

3.需要修复归档(针对我这里是某个归档日志丢失的场景不管用)

[dmdba@host01 ~]$ dmrman
dmrman V8

RMAN> repair archivelog database '/dmdbms/data/DAMENG/dm.ini';
repair archivelog database '/dmdbms/data/DAMENG/dm.ini';
file dm.key not found, use default license!
repair archive log failed.error code: -137
[-137]:DM server is running or exist other process which is operating the same database

需要关闭数据库
[root@host01 ~]# systemctl stop DmServiceDMSERVER.service

RMAN> repair archivelog database '/dmdbms/data/DAMENG/dm.ini';
repair archivelog database '/dmdbms/data/DAMENG/dm.ini';
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
Can not open ini file /dmdbms/data/DAMENG/dmmal.ini!
EP[0]'s cur_lsn[44616], file_lsn[44616]
repair archive log successfully.
repair time used: 298.653(ms)
time used: 299.690(ms)

 

4.启动数据库
[root@host01 ~]# systemctl start DmServiceDMSERVER.service

 

5.再次备份归档日志

SQL> backup archivelog to "archbak_20240320" backupset '/dmdbms/bak/archbak_20240320';
backup archivelog to "archbak_20240320" backupset '/dmdbms/bak/archbak_20240320';
[-718]:Archive log collected not consecutive.
used time: 00:00:02.906. Execute id is 0.

解决办法:
重新全备,然后删除备份之前的归档日志

SQL> backup database full backupset '/dmdbms/bak/fullbak_20240320';
executed successfully
used time: 00:00:03.028. Execute id is 506.
SQL> alter system switch logfile;
executed successfully
used time: 48.116(ms). Execute id is 0.

多切换几次,让其生产一个新的归档日志,然后把该归档日志之前的删除掉
删除之后再做归档日志的备份:

SQL> backup archivelog to "archbak_20240320" backupset '/dmdbms/bak/archbak_20240320';
executed successfully
used time: 00:00:02.959. Execute id is 604.

 

 

6.相关查询语句

#能恢复到的最后一个归档,如果显示一条状态为ACTIVE表示不缺归档,如果有其他行表示中间有日志丢失
select ARCH_LSN,status,path from v$arch_file a
where not exists ( select * from v$arch_file b
where b.arch_seq=a.next_seq+1);

SQL> select ARCH_LSN,status,path from v$arch_file a
2   where not exists ( select * from v$arch_file b
3   where b.arch_seq=a.next_seq+1);

LINEID     ARCH_LSN             status   PATH                                                              
---------- -------------------- -------- ------------------------------------------------------------------
1          44001                INACTIVE /dmdbms/arch/ARCHIVE_LOCAL1_0x61603F60_EP0_2024-03-20_14-07-38.log
2          44979                ACTIVE   /dmdbms/arch/ARCHIVE_LOCAL1_0x61603F60_EP0_2024-03-20_14-37-24.log

#显示最近一次备份以来是否缺失归档日志,空行代表不缺失,如果查出一行,代表这行归档日志下面缺失
select path,create_time from v$arch_file a
where not exists ( select * from v$arch_file b
where a.arch_seq=b.next_seq+1)
and arch_lsn >=(select max(begin_lsn) from v$backupset)

SQL> select path,create_time from v$arch_file a
2   where not exists ( select * from v$arch_file b
3   where a.arch_seq=b.next_seq+1)
4   and arch_lsn >=(select max(begin_lsn) from v$backupset);
no rows

 

posted @ 2024-03-20 15:23  slnngk  阅读(355)  评论(0编辑  收藏  举报