注册
达梦数据库REDO文件损坏的解决方法
专栏/培训园地/ 文章详情 /

达梦数据库REDO文件损坏的解决方法

LEO(ಡωಡ) 2024/05/30 1991 0 0
摘要

1、处理思路说明

在达梦数据中REDO LOG损坏的情况,处理方法就是新建一个同配置(页大小、大小写敏感、字符集等)的实例,然后把新实例的REDO LOG文件替换掉原实例的所有REDO LOG文件,然后重启数据库。

2、具体操作过程

2.1、创建测试实例

[dmdba@localhost bin]$ dminit path=/opt/dmdbms/data page_size=32 extent_size=32 charset=0 instance_name=cndba
initdb V8
db version: 0x7000c
file dm.key not found, use default license!
License will expire on 2023-12-25
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL

 log file path: /opt/dmdbms/data/DAMENG/DAMENG01.log


 log file path: /opt/dmdbms/data/DAMENG/DAMENG02.log

write to dir [/opt/dmdbms/data/DAMENG].
create dm database success. 2023-08-04 23:07:09

如果忘记旧环境的参数也没有关系,虽然库无法启动,也可以通过数据库日志来查看,日志在DATA目录下以 dminit+日期时间.log 命名。

[dmdba@localhost data]$ cat dminit20230804230707.log
start init database: V8, 2023-08-04 23:07:07
init params:
        db path: /opt/dmdbms/data/DAMENG
        db name: cndba
        auto overwrite: 0
        page size: 32768
        extent size: 32
        char_fix_storage: 0
        sql_log_forbid: 0
        secur_flag: 2
        time zone: +08:00
        string case sensitive: 1
        charset: 0
        length in char: 0
        page check mode: 0
        page check algorithm id: 0
        priv flag: 0
        rlog enc flag: 0
        use new hash: 1
        blank pad mode: 0
        sec priv mode: 0
        huge with delta: 1
        rlog gen for huge: 0
        pseg_mgr_flag: 0

 log file path: /opt/dmdbms/data/DAMENG/DAMENG01.log

 log file path: /opt/dmdbms/data/DAMENG/DAMENG02.log

create ini file /opt/dmdbms/data/DAMENG/dm.ini success.

create rlog file /opt/dmdbms/data/DAMENG/DAMENG01.log success.

create rlog file /opt/dmdbms/data/DAMENG/DAMENG02.log success.

SYSTEM file : /opt/dmdbms/data/DAMENG/SYSTEM.DBF

MAIN file : /opt/dmdbms/data/DAMENG/MAIN.DBF

ROLL file : /opt/dmdbms/data/DAMENG/ROLL.DBF

create dm database success. 2023-08-04 23:07:09

2.2、破坏REDO LOG文件

使用MV命令来模拟:

[dmdba@localhost data]$ mv DAMENG01.log DAMENG01.log.bak 
[dmdba@localhost data]$ mv DAMENG02.log DAMENG02.log.bak 

此时启动直接报错:

[dmdba@localhost bin]$ dmserver dm.ini
file dm.key not found, use default license!
version info: develop
DM Database Server 64 V8 03134283890-20220304-158322-10045 startup...
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
Database mode = 0, oguid = 0
/opt/dmdbms/data/DAMENG/DAMENG01.log not exist, can not startup

2.3、新建临时实例

按照dminit+日期时间.log中的参数创建好实例后,要启动一次实例,在正常关闭后,才能正常使用。

[dmdba@localhost data]$ dminit path=/opt/dmdbms/data page_size=32 extent_size=32 charset=0 
initdb V8
db version: 0x7000c
file dm.key not found, use default license!
License will expire on 2023-03-04
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL

 log file path: /opt/dmdbms/data/DAMENG/DAMENG01.log


 log file path: /opt/dmdbms/data/DAMENG/DAMENG02.log

write to dir [/opt/dmdbms/data/DAMENG].
create dm database success. 2023-08-04 23:17:31

2.4、复制REDO文件

在新环境中将创建好的REDO LOG文件复制到旧环境中。

[dmdba@localhost DAMENG]$ scp DAMENG01.log 旧环境IP地址:/opt/dmdbms/data/DAMENG/DAMENG01.log
[dmdba@localhost DAMENG]$ scp DAMENG02.log 旧环境IP地址:/opt/dmdbms/data/DAMENG/DAMENG02.log

2.5、修改db_magic的值

使用dmmdf工具修改redo日志的db_magic的值,两个文件都要改,保持和源库一样。

查看:
[dmdba@localhost data]$ dmmdf type=1 file=SYSTEM.DBF
dmmdf V8
**********************************************************
1 db_magic=1287424634
2 next_trxid=3007
3 pemnt_magic=909598176
**********************************************************
Please input which parameter you want to change(1-3), q to quit: Q

修改:
[dave@www.cndba.cn cndba]$ dmmdf type=2 file=DAMENG02.log
dmmdf V8
**********************************************************
1 sig = DMRLOG
2 ver = 7007
3 chksum = 3739147829
4 sta = 0
5 n_magic = 7
6 db_magic = 881908182
7 len = 268435456
8 free = 4096
9 clsn = 0
10 clsn_fil = 0
11 clsn_off = 0
12 pemnt_magic = 1117177040
13 fil_id = 1
15 next_seq = 0
16 g_next_seq = 0
17 arch_lsn = 0
18 arch_seq = 0
19 dbversion = 0x7000c
20 min_exec_version = V8.1.1.1
21 min_dct_version  = 4
22 p_db_magic = 0
23 n_apply_ep = 0
24 apply_info_lsn = 0
   pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
   apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
25 recv_p_db_magic = 0
26 recv_n_apply_ep = 0
   recv_pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
   recv_apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
27 l_term_id = 0
28 term_id = 0
29 c_seqno = 0
30 c_lsn = 0
**********************************************************
You can only reset sta(4) or db_magic (6) or clsn (9) or clsn_fil(10) or clsn_off(11) or pemnt_magic(12) or fil_id(13) or next_seq(15) or g_next_seq(16) or p_db_magic(22) or n_apply_ep(23).
Please input the num which one you want to change, q to quit: 6
Input the new value: 1287424634
**********************************************************
1 sig = DMRLOG
2 ver = 7007
3 chksum = 2800913817
4 sta = 0
5 n_magic = 7
6 db_magic = 1287424634
7 len = 268435456
8 free = 4096
9 clsn = 0
10 clsn_fil = 0
11 clsn_off = 0
12 pemnt_magic = 1117177040
13 fil_id = 1
15 next_seq = 0
16 g_next_seq = 0
17 arch_lsn = 0
18 arch_seq = 0
19 dbversion = 0x7000c
20 min_exec_version = V8.1.1.1
21 min_dct_version  = 4
22 p_db_magic = 0
23 n_apply_ep = 0
24 apply_info_lsn = 0
   pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
   apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
25 recv_p_db_magic = 0
26 recv_n_apply_ep = 0
   recv_pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
   recv_apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
27 l_term_id = 0
28 term_id = 0
29 c_seqno = 0
30 c_lsn = 0
**********************************************************
Do you want to quit and save the change to file (y/n): y
Save to file success!

2.6、修改PSEG_RECV参数

PSEG_RECV参数控制系统故障重启时,对活动事务和已提交事务的处理方式(默认为3),修改成0,表示跳过回滚活动事务和PURGE已经提交事务的步骤。

[dmdba@localhost DAMENG]$ cat dm.ini|grep PSEG
                PSEG_RECV                       = 0                     #Whether to rollback active transactions and purge committed transactions when system restarts after failure

2.7、启动故障实例

[dmdba@localhost bin]$ dmserver dm.ini
file dm.key not found, use default license!
version info: develop
DM Database Server 64 V8 03134283890-20220304-158322-10045 startup...
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
Database mode = 0, oguid = 0
License will expire on 2023-03-04
file lsn: 35869
ndct db load finished
ndct second level fill fast pool finished
ndct third level fill fast pool finished
ndct second level fill fast pool finished
ndct third level fill fast pool finished
ndct fill fast pool finished
iid page's trxid[4008]
NEXT TRX ID = 4009
pseg recv finished
nsvr_startup end.
aud sys init success.
aud rt sys init success.
systables desc init success.
ndct_db_load_info success.
nsvr_process_before_open begin.
nsvr_process_before_open success.
total 0 active crash trx, pseg_crash_trx_rollback sys_only(0) begin ...
pseg_crash_trx_rollback end, total 0 active crash trx, include 0 empty_trxs, 0 empty_pages which only need to delete mgr recs.
pseg_crash_trx_rollback end
SYSTEM IS READY.

3、相关注意事项

  这种替换的方式可能会存在其他问题,所以等实例启动之后,将数据导出,重新导入到新的实例中。
评论
后发表回复

作者

文章

阅读量

获赞

扫一扫
联系客服