达梦数据库日志文件被误删除,在没有备份的情况下的恢复

1:创建数据DM01
/dm8/bin/dminit PATH=/dm8/data/ DB_NAME=DM01 INSTANCE_NAME=DMSVR01  PORT_NUM=5236
注册
/dm8/script/root/dm_service_installer.sh -t dmserver -dm_ini /dm8/data/DM01/dm.ini -p DMSVR01
启动
systemctl start DmServiceDMSVR01

2:模拟识删除DM0101.log,DM0101.log
rm -f /dm8/data/DM01/DM0101.log
rm -f /dm8/data/DM01/DM0102.log

3 redo日志损坏
下面是断电后导致redo损坏的一个报错信息;
日志:Read rfil ['/data/dmdbms/data/DAMENG/DAMENG02.log'] from offset[67042304] failed,code [-723]
前台:main rfil [/data/dmdbms/data/DAMENG/DAMENG01.log]'s grp collect 0 invalid recv_pwr record.   最后一般就是段错误。
[dmdba@primary bin]$ ./DmServiceDMSVR01 start
Starting DmServiceDMSVR01:                                 [ FAILED ]
file dm.key not found, use default license!
version info: develop
DM Database Server 64 V8 03134283890-20220525-161267-10045 startup...
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
Database mode = 0, oguid = 0
/dm8/data/DM01/DM0101.log not exist, can not startup

恢复方法:
redo损坏优先选择“备份+归档”恢复,从实例日志获取故障时间;
无备份归档的情况下,可以选择替换redo日志临时启动数据库(危险操作,可能会丢失一部分数据),然后将数据迁移出来。
4:创建数据DM02
/dm8/bin/dminit PATH=/dm8/data/ DB_NAME=DM02 INSTANCE_NAME=DMSVR02  PORT_NUM=5237
注册
/dm8/script/root/dm_service_installer.sh -t dmserver -dm_ini /dm8/data/DM02/dm.ini -p DMSVR02
启动
systemctl start DmServiceDMSVR02
将实例DM02的DM0201.log DM0202.log复制到实例DM01
[dmdba@primary DM02]$ cp DM0201.log DM0202.log   /dm8/data/DM01

无法使用备份归档恢复下,替换redo启动数据库步骤:
5.查看初始化日志,观察初始化参数,重新初始化一个新的实例并前台启动一次

3)查看故障库的db_magic值和pemnt_magic值
/dm8/bin/dmmdf type=1 file=/dm8/data/DM02/SYSTEM.DBF
[dmdba@primary DM02]$ /dm8/bin/dmmdf type=1 file=/dm8/data/DM01/SYSTEM.DBF
dmmdf V8
**********************************************************
1 db_magic=1473764740
2 next_trxid=3007
3 pemnt_magic=1466553014
**********************************************************
Please input which parameter you want to change(1-3), q to quit: 

/dm8/bin/dmmdf type=2 file=/dm8/data/DM01/DM01.01.log
[dmdba@primary DM02]$ /dm8/bin/dmmdf type=2 file=/dm8/data/DM01/DM01.01.log
dmmdf V8
**********************************************************
1 sig = DMRLOG
2 ver = 7007
3 chksum = 942312418
4 sta = 1
5 n_magic = 7
6 db_magic = 884502792
7 len = 268435456
8 free = 4096
9 clsn = 0
10 clsn_fil = 0
11 clsn_off = 4096
12 pemnt_magic = 1021503449
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
**********************************************************
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: 1473764740
**********************************************************
1 sig = DMRLOG
2 ver = 7007
3 chksum = 1531258734
4 sta = 1
5 n_magic = 7
6 db_magic = 1473764740
7 len = 268435456
8 free = 4096
9 clsn = 0
10 clsn_fil = 0
11 clsn_off = 4096
12 pemnt_magic = 1021503449
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
**********************************************************
Do you want to quit and save the change to file (y/n): y
Save to file success!

[dmdba@primary DM02]$ /dm8/bin/dmmdf type=2 file=/dm8/data/DM01/DM0102.log
dmmdf V8
**********************************************************
1 sig = DMRLOG
2 ver = 7007
3 chksum = 673876962
4 sta = 0
5 n_magic = 7
6 db_magic = 884502792
7 len = 268435456
8 free = 4096
9 clsn = 0
10 clsn_fil = 0
11 clsn_off = 0
12 pemnt_magic = 1021503449
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: 1473764740
**********************************************************
1 sig = DMRLOG
2 ver = 7007
3 chksum = 1262823278
4 sta = 0
5 n_magic = 7
6 db_magic = 1473764740
7 len = 268435456
8 free = 4096
9 clsn = 0
10 clsn_fil = 0
11 clsn_off = 0
12 pemnt_magic = 1021503449
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!

[dmdba@primary bin]$ /dm8/bin/dmserver /dm8/data/DM01/dm.ini
file dm.key not found, use default license!
version info: develop
DM Database Server 64 V8 03134283890-20220525-161267-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-05-25
file lsn: 0
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_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!
iid page's trxid[5010]
NEXT TRX ID = 6012.
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
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.


此时已经启动起来的数据库仍然存在隐患,应立即完成数据的迁移工作,防止再次发生宕机事故。

迁移方式采用DTS或逻辑导出导入

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值