达梦数据库误删redo日志文件故障处理

达梦数据库误删redo日志文件故障处理

1、初始化新数据库

注意事项:保证新初始化数据库和之前故障的库一致。

D:\tools\dmdbms\bin>dminit path=D:\tools\dmdbms\data2
initdb V8
db version: 0x7000c
file dm.key not found, use default license!
License will expire on 2025-03-21
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
 log file path: D:\tools\dmdbms\data2\DAMENG\DAMENG01.log
 log file path: D:\tools\dmdbms\data2\DAMENG\DAMENG02.log
write to dir [D:\tools\dmdbms\data2\DAMENG].
create dm database success. 2024-05-30 11:42:43

2、查找误删redo库的关键信息

dbmagic、pemnt_magic、clsn

D:\tools\dmdbms\bin>dmmdf.exe TYPE=1 FILE=D:\tools\dmdbms\data1\DAMENG\SYSTEM.DBF
dmmdf V8
**********************************************************
1 db_magic=1002709722
2 next_trxid=6008
3 pemnt_magic=882822022
4 enable_page_check=3
**********************************************************
Please input which parameter you want to change(1-4), q to quit: q

lsn 的值可以在数据库日志中查找

2024-05-30 11:42:20.972 [INFO] database P0000021732 T0000000000000002108  ckpt2_log_adjust: ckpt_lsn(44849), ckpt_fil(0), ckpt_off(18022400), cur_lsn(44849), l_next_seq(5051), g_next_seq(5051), cur_free(18022400), total_space(536862720), used_space(0), free_space(536862720), n_ep(1), db_open_id(1)

2.1、ps: dmmdf 工具介绍:

D:\tools\dmdbms\bin>dmmdf.exe help
version: 03134284172-20240321-222308-20093
格式: dmmdf.exe KEYWORD=value
例程: dmmdf.exe TYPE=1 FILE=d:\data\DAMENG\SYSTEM.DBF
关键字              说明
--------------------------------------------------------------------------------
TYPE                类型
                    1表示dbf
                      BP_FLAG=0,表示修改正常节点的数据库控制信息
                      BP_FLAG=1,表示修改DPC的BP节点的数据库控制信息
                    2表示rlog
                    3表示original bak
                    4表示bakset meta
                    5表示bakset bkp
                    6表示bakset
                    7表示数据库降级:
                      SCOPE=1,表示仅支持0x0007000A降级到0x00070009,FILE指定为dm.ctl路径
                      SCOPE=2,表示仅支持0x0007000B降级到0x0007000A,FILE指定为dm.ini路径
                      SCOPE=3,表示仅支持单节点由0x0007000C降级到0x0007000B,FILE指定为dm.ini路径
                    8表示联机日志降级:
                      SCOPE=1, 表示从0x7006降级到0x7005
                      SCOPE=2, 表示从0x7007降级到0x7006
                    9表示特定版本的数据库升级(仅支持执行码版本号在[V8.1.1.88(V7.1.7.88), V8.1.1.100(V7.1.7.100)]范围内的数据库升级)
                    10表示修改数据库的db_magic,FILE指定dm.ini的路径,DB_MAGIC指定修改的目标db_magic
                      BP_FLAG=0,表示修改正常节点
                      BP_FLAG=1,表示修改DPC的BP节点,需要同时指定PAGE_SIZE
FILE                文件路径
PAGE_SIZE           TYPE=10 BP_FLAG=1时使用,数据文件页大小,默认为8192
DCR_INI             dmdcr.ini路径
SCOPE               TYPE=7或8时使用,指定具体的降级范围
BP_FLAG             TYPE=1、10时使用,指定是否是DPC的BP节点,默认为0(否)
DB_MAGIC            TYPE=10时使用,指定目标db_magic
HELP                打印帮助信息

--------------------------------------------------
示例:    dmmdf.exe TYPE=1 FILE=d:\data\DAMENG\SYSTEM.dbf
         dmmdf.exe TYPE=2 FILE=d:\data\DAMENG\DAMENG01.log
         dmmdf.exe TYPE=3 FILE=d:\data\DAMENG\bak\dmdb.bak
         dmmdf.exe TYPE=4 FILE=d:\data\DAMENG\bak\bset\nbak.meta
         dmmdf.exe TYPE=5 FILE=d:\data\DAMENG\bak\bset\nbak.bak
         dmmdf.exe TYPE=6 FILE=d:\data\DAMENG\bak\bset
         dmmdf.exe TYPE=7 SCOPE=1 FILE=d:\data\DAMENG\dm.ctl
         dmmdf.exe TYPE=7 SCOPE=2 FILE=d:\data\DAMENG\dm.ini
         dmmdf.exe TYPE=7 SCOPE=3 FILE=d:\data\DAMENG\dm.ini
         dmmdf.exe TYPE=8 SCOPE=1 FILE=d:\data\DAMENG\dm.ini
         dmmdf.exe TYPE=8 SCOPE=2 FILE=d:\data\DAMENG\dm.ini
         dmmdf.exe TYPE=9 FILE=d:\data\DAMENG\dm.ini
         dmmdf.exe TYPE=10 FILE=d:\data\DAMENG\dm.ini DB_MAGIC=123456

3、将新数据库的redo关键信息修改为查询到故障数据库的信息

1 db_magic=1002709722
2 pemnt_magic=882822022
3 clsn =44849+64 #clsn需要>=查找到的最大的lsn

D:\tools\dmdbms\bin>dmmdf.exe TYPE=2 FILE=D:\tools\dmdbms\data2\DAMENG\DAMENG01.log
dmmdf V8
**********************************************************
1 sig = DMRLOG
2 ver = 7007
3 chksum = 3949396612
4 sta = 1
5 n_magic = 7
6 db_magic = 1013147365
7 len = 268435456
8 free = 4096
9 clsn = 0
10 clsn_fil = 0
11 clsn_off = 4096
12 pemnt_magic = 1013159002
13 fil_id = 0
15 next_seq = 2457
16 g_next_seq = 2457
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
31 rpkg_crc_stand = 1
**********************************************************
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: 1002709722
**********************************************************
1 sig = DMRLOG
2 ver = 7007
3 chksum = 3972023995
4 sta = 1
5 n_magic = 7
6 db_magic = 1002709722
7 len = 268435456
8 free = 4096
9 clsn = 0
10 clsn_fil = 0
11 clsn_off = 4096
12 pemnt_magic = 1013159002
13 fil_id = 0
15 next_seq = 2457
16 g_next_seq = 2457
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
31 rpkg_crc_stand = 1
**********************************************************
Do you want to quit and save the change to file (y/n): y
Save to file success!
D:\tools\dmdbms\bin>dmmdf.exe TYPE=2 FILE=D:\tools\dmdbms\data2\DAMENG\DAMENG01.log
dmmdf V8
**********************************************************
1 sig = DMRLOG
2 ver = 7007
3 chksum = 3972023995
4 sta = 1
5 n_magic = 7
6 db_magic = 1002709722
7 len = 268435456
8 free = 4096
9 clsn = 0
10 clsn_fil = 0
11 clsn_off = 4096
12 pemnt_magic = 1013159002
13 fil_id = 0
15 next_seq = 2457
16 g_next_seq = 2457
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
31 rpkg_crc_stand = 1
**********************************************************
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: 12
Input the new value: 882822022
**********************************************************
1 sig = DMRLOG
2 ver = 7007
3 chksum = 3829209447
4 sta = 1
5 n_magic = 7
6 db_magic = 1002709722
7 len = 268435456
8 free = 4096
9 clsn = 0
10 clsn_fil = 0
11 clsn_off = 4096
12 pemnt_magic = 882822022
13 fil_id = 0
15 next_seq = 2457
16 g_next_seq = 2457
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
31 rpkg_crc_stand = 1
**********************************************************
Do you want to quit and save the change to file (y/n): y
Save to file success!
D:\tools\dmdbms\bin>dmmdf.exe TYPE=2 FILE=D:\tools\dmdbms\data2\DAMENG\DAMENG01.log
dmmdf V8
**********************************************************
1 sig = DMRLOG
2 ver = 7007
3 chksum = 3829209447
4 sta = 1
5 n_magic = 7
6 db_magic = 1002709722
7 len = 268435456
8 free = 4096
9 clsn = 0
10 clsn_fil = 0
11 clsn_off = 4096
12 pemnt_magic = 882822022
13 fil_id = 0
15 next_seq = 2457
16 g_next_seq = 2457
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
31 rpkg_crc_stand = 1
**********************************************************
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: 9
Input the new value: 44913
**********************************************************
1 sig = DMRLOG
2 ver = 7007
3 chksum = 3829249558
4 sta = 1
5 n_magic = 7
6 db_magic = 1002709722
7 len = 268435456
8 free = 4096
9 clsn = 44913
10 clsn_fil = 0
11 clsn_off = 4096
12 pemnt_magic = 882822022
13 fil_id = 0
15 next_seq = 2457
16 g_next_seq = 2457
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
31 rpkg_crc_stand = 1
**********************************************************
Do you want to quit and save the change to file (y/n): y
Save to file success!

同理,DAMENG02.log 文件也使用相同步骤修改

4、修复故障数据库

4.1、拷贝 DAMENG01.log、DAMENG01.log 到故障数据库实例目录下。(这里如果初始化实例名不同)

4.2、修改参数文件,添加以下参数到dm.ini中

RLOG_CHECK_SPACE=2

4.3、启动数据库

D:\tools\dmdbms\bin>dmserver ../data1/DAMENG/dm.ini
file dm.key not found, use default license!
version info: develop
csek2_vm_t = 1312
nsql_vm_t = 328
prjt2_vm_t = 176
ltid_vm_t = 216
nins2_vm_t = 1008
nset2_vm_t = 272
ndlck_vm_t = 192
ndel2_vm_t = 768
slct2_vm_t = 208
nli2_vm_t = 192
aagr2_vm_t = 280
pscn_vm_t = 216
dist_vm_t = 896
DM Database Server 64 V8 03134284172-20240321-222308-20093 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 2025-03-21
file lsn: 44913
ndct db load finished, code:0
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
pseg_set_gtv_trxid_low next_trxid in mem:[8009]
pseg_collect_mgr_items, total collect 0 active_trxs, 0 cmt_trxs, 0 pre_cmt_trxs, 0 to_release_trxs, 0 active_pages, 0 cmt_pages, 0 pre_cmt_pages, 0 to_release_pages, 0 mgr pages, 0 mgr recs!
next_trxid in mem:[10011]
next_trxid = 12013.
pseg recv finished
nsvr_startup end.
aud sys init success.
aud rt sys init success.
systables desc init success.
ndct_db_load_info finished, code:0.
nsvr_process_before_open begin.
nsvr_process_before_open success.
SYSTEM IS READY.
  • 7
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值